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

View File

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