summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-04-07 00:59:54 +0000
committerDarkvater <darkvater@openttd.org>2005-04-07 00:59:54 +0000
commit081ff2428202ae8c184e9cb25bafdb1bf6a214a6 (patch)
treee0db387aa35ff5dee722b1621502fa8ed7b85a00
parent5a78c32a23c02df5fb4d3d5d0ee6b88bde13e83a (diff)
downloadopenttd-081ff2428202ae8c184e9cb25bafdb1bf6a214a6.tar.xz
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
- CodeChange: Use images as arrows in the scenario-date scroller, looks better - Feature: Clicked buttons with images/text now visibly depress their contents when pressed (eg it really seems like the button is moving) - Fix: Fix sprite offsets of the arrow sprites in openttd.grf
-rw-r--r--data/openttd.grfbin22917 -> 22917 bytes
-rw-r--r--main_gui.c4
-rw-r--r--widget.c71
-rw-r--r--window.c2
4 files changed, 42 insertions, 35 deletions
diff --git a/data/openttd.grf b/data/openttd.grf
index 6145941ab..3754fb50c 100644
--- a/data/openttd.grf
+++ b/data/openttd.grf
Binary files differ
diff --git a/main_gui.c b/main_gui.c
index e85f10600..2808a6312 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2008,8 +2008,8 @@ static const Widget _toolb_scen_widgets[] = {
{ WWT_PANEL, RESIZE_NONE, 14, 96, 225, 0, 21, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, 14, 233, 362, 0, 21, 0x0, STR_NULL},
-{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 246, 5, 16, STR_0225, STR_029E_MOVE_THE_STARTING_DATE},
-{ WWT_CLOSEBOX, RESIZE_NONE, 14, 347, 357, 5, 16, STR_0224, STR_029F_MOVE_THE_STARTING_DATE},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 236, 247, 5, 16, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 347, 358, 5, 16, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE},
{ WWT_PANEL, RESIZE_NONE, 14, 371, 392, 0, 21, 0x2C4, STR_0175_DISPLAY_MAP_TOWN_DIRECTORY},
diff --git a/widget.c b/widget.c
index 6add3e7ff..001c70668 100644
--- a/widget.c
+++ b/widget.c
@@ -175,6 +175,8 @@ void DrawWindowWidgets(Window *w)
cur_hidden = w->hidden_state;
do {
+ bool clicked = (cur_click & 1);
+
if (dpi->left > (r.right=/*w->left + */wi->right) ||
dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) ||
dpi->top > (r.bottom=/*w->top +*/ wi->bottom) ||
@@ -182,34 +184,34 @@ void DrawWindowWidgets(Window *w)
(cur_hidden&1))
continue;
- switch(wi->type&WWT_MASK) {
- case WWT_PANEL:
+ switch (wi->type & WWT_MASK) {
+ case WWT_PANEL: /* WWT_IMGBTN */
case WWT_PANEL_2: {
int img;
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color,
- (cur_click & 1) ? 0x20 : 0);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+
+ if ((img = wi->unkA) != 0) { // has an image
+ if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++; // show diff image when clicked
- if ((img=wi->unkA) != 0) {
- if ((wi->type&WWT_MASK) == WWT_PANEL_2 && (cur_click&1)) img++;
- DrawSprite(img, r.left+1, r.top+1);
+ DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked);
}
goto draw_default;
}
- case WWT_CLOSEBOX:
+ case WWT_CLOSEBOX: /* WWT_TEXTBTN */
case WWT_4: {
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color,
- (cur_click & 1) ? 0x20 : 0);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
}
/* fall through */
case WWT_5: {
StringID str = wi->unkA;
- if ((wi->type&WWT_MASK) == WWT_4 && (cur_click&1)) str++;
+ if ((wi->type&WWT_MASK) == WWT_4 && clicked) str++;
- DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0);
+ DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, 0);
+ //DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0);
goto restore_dparam;
}
@@ -229,8 +231,7 @@ void DrawWindowWidgets(Window *w)
int x, amt1, amt2;
int color;
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color,
- (cur_click & 1) ? 0x20 : 0);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
c = (wi->unkA&0xFF);
amt1 = (wi->right - wi->left + 1) / c;
@@ -277,12 +278,13 @@ void DrawWindowWidgets(Window *w)
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
// draw up/down buttons
- DrawFrameRect(r.left, r.top, r.right, r.top+9, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP ? 0x20 : 0);
- DrawFrameRect(r.left, r.bottom-9, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN ? 0x20 : 0);
+ clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
+ DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? 0x20 : 0);
+ DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10);
- // draw icons in up/down buttons
- DoDrawString("\xA0", r.left+2, r.top, 0x10);
- DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10);
+ clicked = !!(((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN));
+ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10);
c1 = _color_list[wi->color&0xF].window_color_1a;
c2 = _color_list[wi->color&0xF].window_color_2;
@@ -308,12 +310,13 @@ void DrawWindowWidgets(Window *w)
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
// draw up/down buttons
- DrawFrameRect(r.left, r.top, r.right, r.top+9, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2) ? 0x20 : 0);
- DrawFrameRect(r.left, r.bottom-9, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2) ? 0x20 : 0);
+ clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
+ DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? 0x20 : 0);
+ DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10);
- // draw icons in up/down buttons
- DoDrawString("\xA0", r.left+2, r.top, 0x10);
- DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10);
+ clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2));
+ DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10);
c1 = _color_list[wi->color&0xF].window_color_1a;
c2 = _color_list[wi->color&0xF].window_color_2;
@@ -340,12 +343,13 @@ void DrawWindowWidgets(Window *w)
assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere!
- DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL) ? 0x20 : 0);
- DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL) ? 0x20 : 0);
+ clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL));
+ DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked);
- // draw icons in up/down buttons
- DrawSprite(SPR_ARROW_LEFT, r.left + 3, r.top + 2);
- DrawSprite(SPR_ARROW_RIGHT, r.right - 6, r.top + 2);
+ clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL));
+ DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked);
c1 = _color_list[wi->color&0xF].window_color_1a;
c2 = _color_list[wi->color&0xF].window_color_2;
@@ -402,16 +406,17 @@ void DrawWindowWidgets(Window *w)
case WWT_STICKYBOX: {
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0);
- DrawSprite((cur_click & 1) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2, r.top + 3);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked);
break;
}
case WWT_RESIZEBOX: {
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
- DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0);
- DrawSprite(SPR_WINDOW_RESIZE, r.left + 3, r.top + 3);
+ clicked = !!(w->flags4 & WF_SIZING);
+ DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? 0x20 : 0);
+ DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked);
break;
}
diff --git a/window.c b/window.c
index 2bf8a154a..c5bc834ba 100644
--- a/window.c
+++ b/window.c
@@ -1005,6 +1005,7 @@ static bool HandleWindowDragging(void)
/* Stop the sizing if the left mouse button was released */
if (!_left_button_down) {
w->flags4 &= ~WF_SIZING;
+ SetWindowDirty(w);
break;
}
@@ -1111,6 +1112,7 @@ Window *StartWindowSizing(Window *w)
w = BringWindowToFront(w);
DeleteWindowById(WC_DROPDOWN_MENU, 0);
+ SetWindowDirty(w);
return w;
}