Class FButton: use the object timer for the click animation

This commit is contained in:
Markus Gans 2015-07-01 22:34:40 +02:00
parent 65626b98a2
commit f4f1629809
3 changed files with 17 additions and 8 deletions

View File

@ -28,6 +28,7 @@ FButton::FButton (const FString& txt, FWidget* parent) : FWidget(parent)
FButton::~FButton() // destructor
{
delAccelerator (this);
delAllTimer();
}
@ -38,6 +39,7 @@ void FButton::init()
flags = 0;
button_down = false;
click_animation = true;
click_time = 150;
this->text = "";
setForegroundColor (wc.button_active_fg);
@ -545,8 +547,7 @@ void FButton::onKeyPress (FKeyEvent* event)
if ( click_animation )
{
setDown();
usleep(150000);
setUp();
addTimer(click_time);
}
processClick();
event->accept();
@ -609,6 +610,14 @@ void FButton::onMouseMove (FMouseEvent* event)
}
}
//----------------------------------------------------------------------
void FButton::onTimer (FTimerEvent* ev)
{
//delAllTimer();
delTimer(ev->timerId());
setUp();
}
//----------------------------------------------------------------------
void FButton::onAccel (FAccelEvent* event)
{
@ -632,10 +641,8 @@ void FButton::onAccel (FAccelEvent* event)
else if ( click_animation )
setDown();
if ( click_animation )
{
usleep(150000);
setUp();
}
addTimer(click_time);
processClick();
event->accept();
}

View File

@ -20,6 +20,7 @@ class FButton : public FWidget
FString text;
bool button_down;
bool click_animation;
int click_time;
int button_fg;
int button_bg;
int button_hotkey_fg;
@ -58,6 +59,7 @@ class FButton : public FWidget
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);

View File

@ -244,9 +244,10 @@ Calc::Calc (FWidget* parent) : FDialog(parent)
}
btn->setFlat();
btn->setNoUnderline();
btn->unsetClickAnimation();
btn->setText(button_text[key]);
btn->setDoubleFlatLine(fc::top);
if ( isNewFont() )
btn->unsetClickAnimation();
if ( key <= Three )
btn->setDoubleFlatLine(fc::bottom);
@ -273,7 +274,6 @@ Calc::Calc (FWidget* parent) : FDialog(parent)
calculator_buttons[Change_sign]->addAccelerator('#');
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
}
//----------------------------------------------------------------------