Skip to content

Commit

Permalink
(svn r2161) - Fix: When resizing a window, the button is also visibly…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Darkvater committed Apr 7, 2005
1 parent 5a78c32 commit 081ff24
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
Binary file modified data/openttd.grf
Binary file not shown.
4 changes: 2 additions & 2 deletions main_gui.c
Expand Up @@ -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},

Expand Down
71 changes: 38 additions & 33 deletions widget.c
Expand Up @@ -175,41 +175,43 @@ 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) ||
dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) ||
(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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions window.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -1111,6 +1112,7 @@ Window *StartWindowSizing(Window *w)

w = BringWindowToFront(w);
DeleteWindowById(WC_DROPDOWN_MENU, 0);
SetWindowDirty(w);
return w;
}

Expand Down

0 comments on commit 081ff24

Please sign in to comment.