Class FButton: use the object timer for the click animation
This commit is contained in:
parent
65626b98a2
commit
f4f1629809
|
@ -28,6 +28,7 @@ FButton::FButton (const FString& txt, FWidget* parent) : FWidget(parent)
|
||||||
FButton::~FButton() // destructor
|
FButton::~FButton() // destructor
|
||||||
{
|
{
|
||||||
delAccelerator (this);
|
delAccelerator (this);
|
||||||
|
delAllTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ void FButton::init()
|
||||||
flags = 0;
|
flags = 0;
|
||||||
button_down = false;
|
button_down = false;
|
||||||
click_animation = true;
|
click_animation = true;
|
||||||
|
click_time = 150;
|
||||||
this->text = "";
|
this->text = "";
|
||||||
|
|
||||||
setForegroundColor (wc.button_active_fg);
|
setForegroundColor (wc.button_active_fg);
|
||||||
|
@ -545,8 +547,7 @@ void FButton::onKeyPress (FKeyEvent* event)
|
||||||
if ( click_animation )
|
if ( click_animation )
|
||||||
{
|
{
|
||||||
setDown();
|
setDown();
|
||||||
usleep(150000);
|
addTimer(click_time);
|
||||||
setUp();
|
|
||||||
}
|
}
|
||||||
processClick();
|
processClick();
|
||||||
event->accept();
|
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)
|
void FButton::onAccel (FAccelEvent* event)
|
||||||
{
|
{
|
||||||
|
@ -632,10 +641,8 @@ void FButton::onAccel (FAccelEvent* event)
|
||||||
else if ( click_animation )
|
else if ( click_animation )
|
||||||
setDown();
|
setDown();
|
||||||
if ( click_animation )
|
if ( click_animation )
|
||||||
{
|
addTimer(click_time);
|
||||||
usleep(150000);
|
|
||||||
setUp();
|
|
||||||
}
|
|
||||||
processClick();
|
processClick();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ class FButton : public FWidget
|
||||||
FString text;
|
FString text;
|
||||||
bool button_down;
|
bool button_down;
|
||||||
bool click_animation;
|
bool click_animation;
|
||||||
|
int click_time;
|
||||||
int button_fg;
|
int button_fg;
|
||||||
int button_bg;
|
int button_bg;
|
||||||
int button_hotkey_fg;
|
int button_hotkey_fg;
|
||||||
|
@ -58,6 +59,7 @@ class FButton : public FWidget
|
||||||
void onMouseDown (FMouseEvent*);
|
void onMouseDown (FMouseEvent*);
|
||||||
void onMouseUp (FMouseEvent*);
|
void onMouseUp (FMouseEvent*);
|
||||||
void onMouseMove (FMouseEvent*);
|
void onMouseMove (FMouseEvent*);
|
||||||
|
void onTimer (FTimerEvent*);
|
||||||
void onAccel (FAccelEvent*);
|
void onAccel (FAccelEvent*);
|
||||||
void onFocusIn (FFocusEvent*);
|
void onFocusIn (FFocusEvent*);
|
||||||
void onFocusOut (FFocusEvent*);
|
void onFocusOut (FFocusEvent*);
|
||||||
|
|
|
@ -244,9 +244,10 @@ Calc::Calc (FWidget* parent) : FDialog(parent)
|
||||||
}
|
}
|
||||||
btn->setFlat();
|
btn->setFlat();
|
||||||
btn->setNoUnderline();
|
btn->setNoUnderline();
|
||||||
btn->unsetClickAnimation();
|
|
||||||
btn->setText(button_text[key]);
|
btn->setText(button_text[key]);
|
||||||
btn->setDoubleFlatLine(fc::top);
|
btn->setDoubleFlatLine(fc::top);
|
||||||
|
if ( isNewFont() )
|
||||||
|
btn->unsetClickAnimation();
|
||||||
if ( key <= Three )
|
if ( key <= Three )
|
||||||
btn->setDoubleFlatLine(fc::bottom);
|
btn->setDoubleFlatLine(fc::bottom);
|
||||||
|
|
||||||
|
@ -273,7 +274,6 @@ Calc::Calc (FWidget* parent) : FDialog(parent)
|
||||||
calculator_buttons[Change_sign]->addAccelerator('#');
|
calculator_buttons[Change_sign]->addAccelerator('#');
|
||||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
|
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
|
||||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
|
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue