raw();
init_keybindings(&world);
struct WinMeta win_meta = init_win_meta(screen);
- struct Win win_keys = init_win(&win_meta, "Keys", &world, draw_keys_win);
- struct Win win_map = init_win(&win_meta, "Map", &world, draw_map_win);
- struct Win win_info = init_win(&win_meta, "Info", &world, draw_info_win);
- struct Win win_log = init_win(&win_meta, "Log", &world, draw_log_win);
- win_keys.frame.size.x = 29;
- win_map.frame.size.x = win_meta.padframe.size.x - win_keys.frame.size.x
- - win_log.frame.size.x - 2;
- win_info.frame.size.y = 2;
- win_log.frame.size.y = win_meta.padframe.size.y
- - (2 + win_info.frame.size.y);
+ struct Win win_keys = init_win(&win_meta, "Keys", 0, 29, &world, draw_keys_win);
+ struct Win win_info = init_win(&win_meta, "Info", 2, 20, &world, draw_info_win);
+ uint16_t height_logwin = win_meta.padframe.size.y - (2 + win_info.frame.size.y);
+ struct Win win_log = init_win(&win_meta, "Log",
+ height_logwin, 20, &world, draw_log_win);
+ uint16_t width_mapwin = win_meta.padframe.size.x - win_keys.frame.size.x
+ - win_log.frame.size.x - 2;
+ struct Win win_map = init_win(&win_meta, "Map",
+ 0, width_mapwin, &world, draw_map_win);
toggle_window(&win_meta, &win_keys);
toggle_window(&win_meta, &win_map);
toggle_window(&win_meta, &win_info);
extern struct Win init_win(struct WinMeta * wmeta, char * title,
+ uint16_t height, uint16_t width,
void * data, void * func)
{
struct Win w;
w.next = 0;
w.frame.curses_win = 0;
w.title = title;
- w.frame.size.x = 20;
- w.frame.size.y = wmeta->padframe.size.y - 1;
w.data = data;
w.draw = func;
+ if (width > 0)
+ {
+ w.frame.size.x = width;
+ }
+ else
+ {
+ w.frame.size.x = 1;
+ }
+ if (height > 0 && height <= wmeta->padframe.size.y - 1)
+ {
+ w.frame.size.y = height;
+ }
+ else
+ {
+ w.frame.size.y = wmeta->padframe.size.y - 1;
+ }
return w;
}
-/* Create a window below inside "wmeta" titled "title" and appointing "func"()
- * to interpret and draw the content stored at "data" if the window is visible.
+/* Create a window below inside "wmeta" titled "title" of "height" and "width"
+ * and appointing "func"() to interpret and draw the content stored at "data"
+ * if the window is visible.
*
- * The start size for the Frame will be a width of 20 cells and a height one
- * less than the height of the virtual screen (so as to fit the title bar on top
- * of the window). Other values will be initialized to 0. The window will stay
- * invisible until appended to the chain of visible windows via append_win().
+ * A value for "width" <1 will trigger a fallback to width=1. A "height" <1 or
+ * larger than the maximum window height possible within the virtual screen will
+ * trigger a fallback to the maximum height possible (i.e. pass a "height" of 0
+ * to initialize the window to its largest possible height).
*
- * TODO: Why default start widths/heights instead of passing start values?
+ * Other values of the Win struct will be initialized to 0. The window will stay
+ * invisible until appended to the chain of visible windows via append_win().
*/
extern struct Win init_win(struct WinMeta * wmeta, char * title,
+ uint16_t height, uint16_t widtht,
void * data, void * func);