fix window button image updates
This commit is contained in:
parent
33079d2593
commit
0780952b10
5 changed files with 35 additions and 18 deletions
|
@ -1,5 +1,9 @@
|
||||||
(Format: Year/Month/Day)
|
(Format: Year/Month/Day)
|
||||||
Changes for 0.9.16:
|
Changes for 0.9.16:
|
||||||
|
*06/04/14:
|
||||||
|
* Fix updating of button state (esp stick/shade) (Simon)
|
||||||
|
(sf.net #1281724, #1213257)
|
||||||
|
FbTk/Button.hh/cc WinButton.cc Window.cc
|
||||||
*06/04/13:
|
*06/04/13:
|
||||||
* Provide "Key Modes" (Thanks Mark Tiefenbruck, mark at tiefenbruck dot org)
|
* Provide "Key Modes" (Thanks Mark Tiefenbruck, mark at tiefenbruck dot org)
|
||||||
- New action in keys file:
|
- New action in keys file:
|
||||||
|
|
|
@ -37,7 +37,8 @@ Button::Button(int screen_num, int x, int y,
|
||||||
m_pressed_pm(0),
|
m_pressed_pm(0),
|
||||||
m_pressed_color(),
|
m_pressed_color(),
|
||||||
m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)),
|
m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)),
|
||||||
m_pressed(false) {
|
m_pressed(false),
|
||||||
|
mark_if_deleted(0) {
|
||||||
|
|
||||||
// add this to eventmanager
|
// add this to eventmanager
|
||||||
FbTk::EventManager::instance()->add(*this, *this);
|
FbTk::EventManager::instance()->add(*this, *this);
|
||||||
|
@ -51,13 +52,16 @@ Button::Button(const FbWindow &parent, int x, int y,
|
||||||
m_pressed_pm(0),
|
m_pressed_pm(0),
|
||||||
m_pressed_color(),
|
m_pressed_color(),
|
||||||
m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())),
|
m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())),
|
||||||
m_pressed(false) {
|
m_pressed(false),
|
||||||
|
mark_if_deleted(0) {
|
||||||
// add this to eventmanager
|
// add this to eventmanager
|
||||||
FbTk::EventManager::instance()->add(*this, *this);
|
FbTk::EventManager::instance()->add(*this, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::~Button() {
|
Button::~Button() {
|
||||||
|
if (mark_if_deleted) {
|
||||||
|
*mark_if_deleted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setOnClick(RefCount<Command> &cmd, int button) {
|
void Button::setOnClick(RefCount<Command> &cmd, int button) {
|
||||||
|
@ -107,26 +111,33 @@ void Button::buttonPressEvent(XButtonEvent &event) {
|
||||||
void Button::buttonReleaseEvent(XButtonEvent &event) {
|
void Button::buttonReleaseEvent(XButtonEvent &event) {
|
||||||
m_pressed = false;
|
m_pressed = false;
|
||||||
bool update = false;
|
bool update = false;
|
||||||
if (m_background_pm) {
|
bool been_deleted = false;
|
||||||
if (m_pressed_pm != 0) {
|
mark_if_deleted = &been_deleted;
|
||||||
update = true;
|
|
||||||
setBackgroundPixmap(m_background_pm);
|
|
||||||
}
|
|
||||||
} else if (m_pressed_color.isAllocated()) {
|
|
||||||
update = true;
|
|
||||||
setBackgroundColor(m_background_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update)
|
// This command may result in this object being deleted
|
||||||
clear(); // clear background
|
// hence the mark_if_deleted mechanism so that we can
|
||||||
|
// update our state after the command
|
||||||
// finaly, execute command (this must be done last since this object might be deleted by the command)
|
|
||||||
if (event.button > 0 && event.button <= 5 &&
|
if (event.button > 0 && event.button <= 5 &&
|
||||||
event.x > 0 && event.x < static_cast<signed>(width()) &&
|
event.x > 0 && event.x < static_cast<signed>(width()) &&
|
||||||
event.y > 0 && event.y < static_cast<signed>(height()) &&
|
event.y > 0 && event.y < static_cast<signed>(height()) &&
|
||||||
m_onclick[event.button -1].get() != 0)
|
m_onclick[event.button -1].get() != 0)
|
||||||
m_onclick[event.button - 1]->execute();
|
m_onclick[event.button - 1]->execute();
|
||||||
|
|
||||||
|
if (!been_deleted) {
|
||||||
|
mark_if_deleted = 0;
|
||||||
|
if (m_background_pm) {
|
||||||
|
if (m_pressed_pm != 0) {
|
||||||
|
update = true;
|
||||||
|
setBackgroundPixmap(m_background_pm);
|
||||||
|
}
|
||||||
|
} else if (m_pressed_color.isAllocated()) {
|
||||||
|
update = true;
|
||||||
|
setBackgroundColor(m_background_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update)
|
||||||
|
clear(); // clear background
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ private:
|
||||||
Color m_pressed_color;
|
Color m_pressed_color;
|
||||||
GC m_gc; ///< graphic context for button
|
GC m_gc; ///< graphic context for button
|
||||||
bool m_pressed; ///< if the button is pressed
|
bool m_pressed; ///< if the button is pressed
|
||||||
|
bool *mark_if_deleted; ///< if the button is deleted and this is set, make it true
|
||||||
RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num
|
RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -187,9 +187,9 @@ Pixmap WinButton::getPressedPixmap() const {
|
||||||
return m_theme.closePressedPixmap().pixmap().drawable();
|
return m_theme.closePressedPixmap().pixmap().drawable();
|
||||||
case SHADE:
|
case SHADE:
|
||||||
if (m_listen_to.isShaded())
|
if (m_listen_to.isShaded())
|
||||||
return m_theme.unshadePressedPixmap().pixmap().drawable();
|
|
||||||
else
|
|
||||||
return m_theme.shadePressedPixmap().pixmap().drawable();
|
return m_theme.shadePressedPixmap().pixmap().drawable();
|
||||||
|
else
|
||||||
|
return m_theme.unshadePressedPixmap().pixmap().drawable();
|
||||||
case MENUICON:
|
case MENUICON:
|
||||||
if (m_icon_pixmap.drawable())
|
if (m_icon_pixmap.drawable())
|
||||||
if (m_listen_to.isFocused())
|
if (m_listen_to.isFocused())
|
||||||
|
|
|
@ -4008,6 +4008,7 @@ void FluxboxWindow::setupWindow() {
|
||||||
frame().titlebar(),
|
frame().titlebar(),
|
||||||
0, 0, 10, 10);
|
0, 0, 10, 10);
|
||||||
|
|
||||||
|
stateSig().attach(winbtn);
|
||||||
winbtn->setOnClick(stick_cmd);
|
winbtn->setOnClick(stick_cmd);
|
||||||
break;
|
break;
|
||||||
case WinButton::SHADE:
|
case WinButton::SHADE:
|
||||||
|
|
Loading…
Reference in a new issue