Add the possibility to turn off click animation on Fbutton

This commit is contained in:
Markus Gans 2015-06-15 22:04:27 +02:00
parent e87e0ceb94
commit 749e8914c2
2 changed files with 38 additions and 7 deletions

View File

@ -37,6 +37,7 @@ void FButton::init()
{ {
flags = 0; flags = 0;
button_down = false; button_down = false;
click_animation = true;
this->text = ""; this->text = "";
if ( hasFocus() ) if ( hasFocus() )
@ -492,9 +493,12 @@ void FButton::onKeyPress (FKeyEvent* event)
case fc::Fkey_return: case fc::Fkey_return:
case fc::Fkey_enter: case fc::Fkey_enter:
case fc::Fkey_space: case fc::Fkey_space:
if ( click_animation )
{
setDown(); setDown();
usleep(150000); usleep(150000);
setUp(); setUp();
}
processClick(); processClick();
event->accept(); event->accept();
break; break;
@ -566,14 +570,20 @@ void FButton::onAccel (FAccelEvent* event)
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( click_animation )
setDown(); setDown();
else
redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
else else if ( click_animation )
setDown(); setDown();
if ( click_animation )
{
usleep(150000); usleep(150000);
setUp(); setUp();
}
processClick(); processClick();
event->accept(); event->accept();
} }

View File

@ -19,6 +19,7 @@ class FButton : public FWidget
private: private:
FString text; FString text;
bool button_down; bool button_down;
bool click_animation;
private: private:
FButton (const FButton&); FButton (const FButton&);
@ -70,6 +71,10 @@ class FButton : public FWidget
bool setDown(); bool setDown();
bool setUp(); bool setUp();
bool isDown() const; bool isDown() const;
bool setClickAnimation(bool);
bool setClickAnimation();
bool unsetClickAnimation();
bool hasClickAnimation();
void setText (const FString&); void setText (const FString&);
FString& getText(); FString& getText();
@ -146,6 +151,22 @@ inline bool FButton::setUp()
inline bool FButton::isDown() const inline bool FButton::isDown() const
{ return button_down; } { return button_down; }
//----------------------------------------------------------------------
inline bool FButton::setClickAnimation(bool on)
{ return click_animation = on; }
//----------------------------------------------------------------------
inline bool FButton::setClickAnimation()
{ return setClickAnimation(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetClickAnimation()
{ return setClickAnimation(false); }
//----------------------------------------------------------------------
inline bool FButton::hasClickAnimation()
{ return click_animation; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString& FButton::getText() inline FString& FButton::getText()
{ return this->text; } { return this->text; }