GUI: Remove 'sticky button' feature
This feature made pressed buttons wait a few moments before returning to an unpressed state. It was half-implemented, and caused several visual bugs. Fixes #7083.
This commit is contained in:
parent
5e49800901
commit
e30a94e6ff
4 changed files with 5 additions and 46 deletions
|
@ -190,7 +190,7 @@ void PredictiveDialog::saveUserDictToFile() {
|
||||||
|
|
||||||
void PredictiveDialog::handleKeyUp(Common::KeyState state) {
|
void PredictiveDialog::handleKeyUp(Common::KeyState state) {
|
||||||
if (_curPressedButton != kNoAct && !_needRefresh) {
|
if (_curPressedButton != kNoAct && !_needRefresh) {
|
||||||
_button[_curPressedButton]->startAnimatePressedState();
|
_button[_curPressedButton]->setUnpressedState();
|
||||||
processButton(_curPressedButton);
|
processButton(_curPressedButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastButton != _curPressedButton)
|
if (_lastButton != _curPressedButton)
|
||||||
_button[_lastButton]->stopAnimatePressedState();
|
_button[_lastButton]->setUnpressedState();
|
||||||
|
|
||||||
if (_curPressedButton != kNoAct && !_needRefresh)
|
if (_curPressedButton != kNoAct && !_needRefresh)
|
||||||
_button[_curPressedButton]->setPressedState();
|
_button[_curPressedButton]->setPressedState();
|
||||||
|
@ -604,18 +604,6 @@ void PredictiveDialog::processButton(ButtonId button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PredictiveDialog::handleTickle() {
|
|
||||||
if (_lastTime) {
|
|
||||||
if ((_curTime - _lastTime) > kRepeatDelay) {
|
|
||||||
_lastTime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getTickleWidget()) {
|
|
||||||
getTickleWidget()->handleTickle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PredictiveDialog::mergeDicts() {
|
void PredictiveDialog::mergeDicts() {
|
||||||
_unitedDict.dictLineCount = _predictiveDict.dictLineCount + _userDict.dictLineCount;
|
_unitedDict.dictLineCount = _predictiveDict.dictLineCount + _userDict.dictLineCount;
|
||||||
_unitedDict.dictLine = (char **)calloc(_unitedDict.dictLineCount, sizeof(char *));
|
_unitedDict.dictLine = (char **)calloc(_unitedDict.dictLineCount, sizeof(char *));
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
virtual void handleKeyUp(Common::KeyState state);
|
virtual void handleKeyUp(Common::KeyState state);
|
||||||
virtual void handleKeyDown(Common::KeyState state);
|
virtual void handleKeyDown(Common::KeyState state);
|
||||||
virtual void handleTickle();
|
|
||||||
|
|
||||||
const char *getResult() const { return _predictiveResult; }
|
const char *getResult() const { return _predictiveResult; }
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Co
|
||||||
|
|
||||||
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
if (isEnabled() && _duringPress && x >= 0 && x < _w && y >= 0 && y < _h) {
|
if (isEnabled() && _duringPress && x >= 0 && x < _w && y >= 0 && y < _h) {
|
||||||
startAnimatePressedState();
|
setUnpressedState();
|
||||||
sendCommand(_cmd, 0);
|
sendCommand(_cmd, 0);
|
||||||
}
|
}
|
||||||
_duringPress = false;
|
_duringPress = false;
|
||||||
|
@ -344,40 +344,17 @@ void ButtonWidget::setHighLighted(bool enable) {
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::handleTickle() {
|
|
||||||
if (_lastTime) {
|
|
||||||
uint32 curTime = g_system->getMillis();
|
|
||||||
if (curTime - _lastTime > kPressedButtonTime) {
|
|
||||||
stopAnimatePressedState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonWidget::setPressedState() {
|
void ButtonWidget::setPressedState() {
|
||||||
wantTickle(true);
|
|
||||||
setFlags(WIDGET_PRESSED);
|
setFlags(WIDGET_PRESSED);
|
||||||
clearFlags(WIDGET_HILITED);
|
clearFlags(WIDGET_HILITED);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::stopAnimatePressedState() {
|
void ButtonWidget::setUnpressedState() {
|
||||||
wantTickle(false);
|
|
||||||
_lastTime = 0;
|
|
||||||
clearFlags(WIDGET_PRESSED);
|
clearFlags(WIDGET_PRESSED);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::startAnimatePressedState() {
|
|
||||||
_lastTime = g_system->getMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonWidget::wantTickle(bool tickled) {
|
|
||||||
if (tickled)
|
|
||||||
((GUI::Dialog *)_boss)->setTickleWidget(this);
|
|
||||||
else
|
|
||||||
((GUI::Dialog *)_boss)->unSetTickleWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
|
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
|
||||||
|
|
|
@ -201,17 +201,12 @@ public:
|
||||||
void handleMouseDown(int x, int y, int button, int clickCount);
|
void handleMouseDown(int x, int y, int button, int clickCount);
|
||||||
void handleMouseEntered(int button) { if (_duringPress) { setFlags(WIDGET_PRESSED); } else { setFlags(WIDGET_HILITED); } draw(); }
|
void handleMouseEntered(int button) { if (_duringPress) { setFlags(WIDGET_PRESSED); } else { setFlags(WIDGET_HILITED); } draw(); }
|
||||||
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED | WIDGET_PRESSED); draw(); }
|
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED | WIDGET_PRESSED); draw(); }
|
||||||
void handleTickle();
|
|
||||||
|
|
||||||
void setHighLighted(bool enable);
|
void setHighLighted(bool enable);
|
||||||
void setPressedState();
|
void setPressedState();
|
||||||
void startAnimatePressedState();
|
void setUnpressedState();
|
||||||
void stopAnimatePressedState();
|
|
||||||
|
|
||||||
void lostFocusWidget() { stopAnimatePressedState(); }
|
|
||||||
protected:
|
protected:
|
||||||
void drawWidget();
|
void drawWidget();
|
||||||
void wantTickle(bool tickled);
|
|
||||||
bool _duringPress;
|
bool _duringPress;
|
||||||
private:
|
private:
|
||||||
uint32 _lastTime;
|
uint32 _lastTime;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue