From: Christian Heller Date: Thu, 27 Jun 2013 23:01:19 +0000 (+0200) Subject: Make resize_active_win use yx_uint16 for coordinates instead of two separate ints. X-Git-Tag: tce~1188 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/static/%7B%7Bprefix%7D%7D/processes?a=commitdiff_plain;h=d7c46fb1de25edd8782fbc7642be71e5e54deab2;p=plomrogue Make resize_active_win use yx_uint16 for coordinates instead of two separate ints. --- diff --git a/src/roguelike.c b/src/roguelike.c index 7bcaf92..0d1e96b 100644 --- a/src/roguelike.c +++ b/src/roguelike.c @@ -110,17 +110,12 @@ void scroll_pad (struct WinMeta * win_meta, char dir) { void growshrink_active_window (struct WinMeta * win_meta, char change) { // Grow or shrink active window horizontally or vertically by one cell size. if (0 != win_meta->active) { - uint16_t height = win_meta->active->frame.size.y; - uint16_t width = win_meta->active->frame.size.x; - if (change == '-') - height--; - else if (change == '+') - height++; - else if (change == '_') - width--; - else if (change == '*') - width++; - resize_active_win (win_meta, height, width); } } + struct yx_uint16 size = win_meta->active->frame.size; + if (change == '-') size.y--; + else if (change == '+') size.y++; + else if (change == '_') size.x--; + else if (change == '*') size.x++; + resize_active_win (win_meta, size); } } unsigned char meta_keys(int key, struct World * world, struct WinMeta * win_meta, struct Win * win_keys, struct Win * win_map, struct Win * win_info, struct Win * win_log) { diff --git a/src/windows.c b/src/windows.c index 6089781..181247c 100644 --- a/src/windows.c +++ b/src/windows.c @@ -237,11 +237,10 @@ extern void draw_all_wins (struct WinMeta * wmeta) { pnoutrefresh(wmeta->pad.curses_win, 0, wmeta->pad_offset, 0, 0, wmeta->pad.size.y, wmeta->pad.size.x-1); } doupdate(); } -extern void resize_active_win (struct WinMeta * wmeta, uint16_t height, uint16_t width) { +extern void resize_active_win (struct WinMeta * wmeta, struct yx_uint16 size) { // Grow or shrink currently active window. Correct its geometry and that of its followers. - if (0 != wmeta->active && width > 0 && height > 0 && height < wmeta->pad.size.y) { - wmeta->active->frame.size.y = height; - wmeta->active->frame.size.x = width; + if (0 != wmeta->active && size.x > 0 && size.y > 0 && size.y < wmeta->pad.size.y) { + wmeta->active->frame.size = size; update_wins(wmeta, wmeta->chain_start); } } extern void cycle_active_win (struct WinMeta * wmeta, char dir) { diff --git a/src/windows.h b/src/windows.h index 9391233..7714c6c 100644 --- a/src/windows.h +++ b/src/windows.h @@ -32,7 +32,7 @@ extern void append_win (struct WinMeta *, struct Win *); extern void suspend_win (struct WinMeta *, struct Win *); extern void draw_scroll_hint (struct Frame *, uint16_t, uint32_t, char); extern void draw_all_wins (struct WinMeta *); -extern void resize_active_win (struct WinMeta *, uint16_t, uint16_t); +extern void resize_active_win (struct WinMeta *, struct yx_uint16); extern void cycle_active_win (struct WinMeta *, char); extern void shift_active_win (struct WinMeta *, char); extern void reset_pad_offset (struct WinMeta *, uint16_t);