diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-10-25 15:49:42 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-10-25 15:49:42 +0100 |
commit | 8d930afb3d6ba353149c31a3520352502eab6c0c (patch) | |
tree | bd874a771951aa0ffa70ac871dff98aa5bdbe3cf /amiga/gui.c | |
parent | 088c03a9b76211b3be39b54c2be9a08089290946 (diff) | |
download | netsurf-8d930afb3d6ba353149c31a3520352502eab6c0c.tar.gz netsurf-8d930afb3d6ba353149c31a3520352502eab6c0c.tar.bz2 |
Reduce code duplication
Diffstat (limited to 'amiga/gui.c')
-rw-r--r-- | amiga/gui.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/amiga/gui.c b/amiga/gui.c index 214adc94d..77b64a6b5 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2511,12 +2511,13 @@ void ami_get_msg(void) ami_quit_netsurf_delayed(); } -/* Add a vertical scroller, if not already present */ -static void ami_gui_vscroll_add(struct gui_window_2 *gwin) +/* Add a vertical scroller, if not already present + * Returns true if changed, false otherwise */ +static bool ami_gui_vscroll_add(struct gui_window_2 *gwin) { struct TagItem attrs[2]; - if(gwin->objects[GID_VSCROLL] != NULL) return; + if(gwin->objects[GID_VSCROLL] != NULL) return false; attrs[0].ti_Tag = CHILD_MinWidth; attrs[0].ti_Data = 0; @@ -2532,32 +2533,20 @@ static void ami_gui_vscroll_add(struct gui_window_2 *gwin) IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_ADDCHILD, gwin->win, gwin->objects[GID_VSCROLL], attrs); - FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]); - - RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], - gwin->win, NULL, TRUE); - - browser_window_schedule_reformat(gwin->bw); - ami_schedule_redraw(gwin, true); + return true; } /* Remove the vertical scroller, if present */ static void ami_gui_vscroll_remove(struct gui_window_2 *gwin) { - if(gwin->objects[GID_VSCROLL] == NULL) return; + if(gwin->objects[GID_VSCROLL] == NULL) return false; IDoMethod(gwin->objects[GID_VSCROLLLAYOUT], LM_REMOVECHILD, gwin->win, gwin->objects[GID_VSCROLL]); - FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]); - - RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], - gwin->win, NULL, TRUE); - - browser_window_schedule_reformat(gwin->bw); - ami_schedule_redraw(gwin, true); - gwin->objects[GID_VSCROLL] = NULL; + + return true; } /** @@ -2569,6 +2558,7 @@ static void ami_gui_vscroll_remove(struct gui_window_2 *gwin) */ static void ami_gui_vscroll_update(struct gui_window_2 *gwin) { + bool rethink = false; browser_scrolling hscroll = BW_SCROLLING_YES; browser_scrolling vscroll = BW_SCROLLING_YES; @@ -2578,9 +2568,17 @@ static void ami_gui_vscroll_update(struct gui_window_2 *gwin) bottom window border with the status bar, so toggling it is pointless */ if((vscroll == BW_SCROLLING_NO) || browser_window_is_frameset(gwin->bw) == true) { - ami_gui_vscroll_remove(gwin); + rethink = ami_gui_vscroll_remove(gwin); } else { - ami_gui_vscroll_add(gwin); + rethink = ami_gui_vscroll_add(gwin); + } + + if(rethink) { + FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]); + RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], + gwin->win, NULL, TRUE); + browser_window_schedule_reformat(gwin->bw); + ami_schedule_redraw(gwin, true); } } |