(svn r3247) - Fix: "[ 1335580 ] sticky windows not sticky anymore"

Determine clicked status of sticky icon from window flags rather than the widget click state. This keeps the status in one place where it can't get out of sync.
This commit is contained in:
peter1138 2005-11-29 22:04:02 +00:00
parent 708c135ff7
commit 627dd10451
4 changed files with 2 additions and 7 deletions

View File

@ -735,12 +735,7 @@ void UnclickSomeWindowButtons(Window *w, uint32 mask)
void UnclickWindowButtons(Window *w) void UnclickWindowButtons(Window *w)
{ {
bool sticky = false;
if (w->desc_flags & WDF_STICKY_BUTTON && HASBIT(w->click_state, 2)) sticky = true;
UnclickSomeWindowButtons(w, (uint32)-1); UnclickSomeWindowButtons(w, (uint32)-1);
if (sticky) SETBIT(w->click_state, 2);
} }

View File

@ -235,7 +235,6 @@ static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_sti
WP(w,def_d).data_1 = mode; WP(w,def_d).data_1 = mode;
if (show_stickied) { if (show_stickied) {
w->flags4 |= WF_STICKY; w->flags4 |= WF_STICKY;
w->click_state ^= (1 << 3);
} }
} }
} }

View File

@ -394,6 +394,8 @@ void DrawWindowWidgets(const Window *w)
case WWT_STICKYBOX: { case WWT_STICKYBOX: {
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
clicked = !!(w->flags4 & WF_STICKY);
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0);
DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked);
break; break;

View File

@ -74,7 +74,6 @@ static void DispatchLeftClickEvent(Window* w, int x, int y)
} }
if (w->desc_flags & WDF_STICKY_BUTTON && wi->type == WWT_STICKYBOX) { if (w->desc_flags & WDF_STICKY_BUTTON && wi->type == WWT_STICKYBOX) {
TOGGLEBIT(w->click_state, e.click.widget);
w->flags4 ^= WF_STICKY; w->flags4 ^= WF_STICKY;
InvalidateWidget(w, e.click.widget); InvalidateWidget(w, e.click.widget);
return; return;