From a1194cd03ffca1ebe29275bdab7c03a441d554e1 Mon Sep 17 00:00:00 2001 From: Steve Fryatt Date: Sun, 24 Oct 2010 21:52:16 +0000 Subject: Re-enable toolbar editing and button selection in RO treeview windows. svn path=/trunk/netsurf/; revision=10907 --- riscos/cookies.c | 28 ++++++++++++++++++++++++---- riscos/cookies.h | 2 +- riscos/global_history.c | 28 ++++++++++++++++++++++++---- riscos/global_history.h | 2 +- riscos/hotlist.c | 30 ++++++++++++++++++++++++------ riscos/hotlist.h | 2 +- riscos/menus.c | 47 ++++------------------------------------------- riscos/theme.c | 30 +++++++++++++++++++++++++++--- riscos/theme.h | 1 + riscos/treeview.c | 17 ++++++++++++++--- riscos/treeview.h | 1 + 11 files changed, 122 insertions(+), 66 deletions(-) (limited to 'riscos') diff --git a/riscos/cookies.c b/riscos/cookies.c index e19a1a2fa..d73e8b5fe 100644 --- a/riscos/cookies.c +++ b/riscos/cookies.c @@ -160,6 +160,12 @@ void ro_gui_cookies_open(void) bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer) { + if (cookies_window.toolbar->editor != NULL) { + ro_gui_theme_toolbar_editor_click(cookies_window.toolbar, + pointer); + return true; + } + switch (pointer->i) { case ICON_TOOLBAR_DELETE: if (pointer->buttons == wimp_CLICK_SELECT) { @@ -286,6 +292,14 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu, case TREE_CLEAR_SELECTION: cookies_clear_selection(); return true; + case TOOLBAR_BUTTONS: + cookies_window.toolbar->display_buttons = + !cookies_window.toolbar->display_buttons; + ro_gui_theme_refresh_toolbar(cookies_window.toolbar); + return true; + case TOOLBAR_EDIT: + ro_gui_theme_toggle_edit(cookies_window.toolbar); + return true; default: return false; } @@ -295,11 +309,17 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu, /** * Update the theme details of the cookies window. + * + * \param full_update true to force a full theme change; false to + * refresh the toolbar size. */ -void ro_gui_cookies_update_theme(void) +void ro_gui_cookies_update_theme(bool full_update) { - ro_treeview_update_theme(cookies_window.tv); + if (full_update) + ro_treeview_update_theme(cookies_window.tv); + else + ro_treeview_update_toolbar(cookies_window.tv); } /** @@ -311,9 +331,9 @@ void ro_gui_cookies_update_theme(void) bool ro_gui_cookies_check_window(wimp_w window) { -/* SF if (cookies_window.w == window) + if (cookies_window.window == window) return true; - else*/ + else return false; } diff --git a/riscos/cookies.h b/riscos/cookies.h index 8c9c14925..3ab1a3bad 100644 --- a/riscos/cookies.h +++ b/riscos/cookies.h @@ -31,7 +31,7 @@ bool ro_gui_cookies_check_menu(wimp_menu *menu); bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer); void ro_gui_cookies_open(void); -void ro_gui_cookies_update_theme(void); +void ro_gui_cookies_update_theme(bool full_update); #endif diff --git a/riscos/global_history.c b/riscos/global_history.c index 44d39b93a..4b2352289 100644 --- a/riscos/global_history.c +++ b/riscos/global_history.c @@ -167,6 +167,12 @@ void ro_gui_global_history_open(void) bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer) { + if (global_history_window.toolbar->editor != NULL) { + ro_gui_theme_toolbar_editor_click(global_history_window.toolbar, + pointer); + return true; + } + switch (pointer->i) { case ICON_TOOLBAR_DELETE: if (pointer->buttons == wimp_CLICK_SELECT) { @@ -311,6 +317,14 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu, case TREE_CLEAR_SELECTION: history_global_clear_selection(); return true; + case TOOLBAR_BUTTONS: + global_history_window.toolbar->display_buttons = + !global_history_window.toolbar->display_buttons; + ro_gui_theme_refresh_toolbar(global_history_window.toolbar); + return true; + case TOOLBAR_EDIT: + ro_gui_theme_toggle_edit(global_history_window.toolbar); + return true; default: return false; } @@ -320,11 +334,17 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu, /** * Update the theme details of the global history window. + * + * \param full_update true to force a full theme change; false to + * refresh the toolbar size. */ -void ro_gui_global_history_update_theme(void) +void ro_gui_global_history_update_theme(bool full_update) { - ro_treeview_update_theme(global_history_window.tv); + if (full_update) + ro_treeview_update_theme(global_history_window.tv); + else + ro_treeview_update_toolbar(global_history_window.tv); } /** @@ -336,9 +356,9 @@ void ro_gui_global_history_update_theme(void) bool ro_gui_global_history_check_window(wimp_w window) { -/* if (global_history_window.w == window) + if (global_history_window.window == window) return true; - else*/ + else return false; } diff --git a/riscos/global_history.h b/riscos/global_history.h index 7ca2ed9da..7618aa438 100644 --- a/riscos/global_history.h +++ b/riscos/global_history.h @@ -28,7 +28,7 @@ void ro_gui_global_history_preinitialise(void); void ro_gui_global_history_postinitialise(void); void ro_gui_global_history_open(void); void ro_gui_global_history_save(void); -void ro_gui_global_history_update_theme(void); +void ro_gui_global_history_update_theme(bool full_update); bool ro_gui_global_history_check_window(wimp_w window); bool ro_gui_global_history_check_menu(wimp_menu *menu); bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer); diff --git a/riscos/hotlist.c b/riscos/hotlist.c index aed66532a..61202eaa2 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -181,7 +181,11 @@ void ro_gui_hotlist_open(void) bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer) { - LOG(("Entering hotlist toolbar handler: b=%d, i=%d", pointer->buttons, pointer->i)); + if (hotlist_window.toolbar->editor != NULL) { + ro_gui_theme_toolbar_editor_click(hotlist_window.toolbar, + pointer); + return true; + } switch (pointer->i) { case ICON_TOOLBAR_DELETE: @@ -254,17 +258,17 @@ void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu) ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_BUTTONS, (hotlist_window.toolbar == NULL || - hotlist_window.toolbar->editor)); + hotlist_window.toolbar->editor != NULL)); ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_BUTTONS, (hotlist_window.toolbar != NULL && (hotlist_window.toolbar->display_buttons || - hotlist_window.toolbar->editor))); + (hotlist_window.toolbar->editor != NULL)))); ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_EDIT, hotlist_window.toolbar == NULL); ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_EDIT, (hotlist_window.toolbar != NULL && - hotlist_window.toolbar->editor)); + hotlist_window.toolbar->editor != NULL)); ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML, NULL, NULL, NULL, NULL); @@ -341,6 +345,14 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu, case TREE_CLEAR_SELECTION: hotlist_clear_selection(); return true; + case TOOLBAR_BUTTONS: + hotlist_window.toolbar->display_buttons = + !hotlist_window.toolbar->display_buttons; + ro_gui_theme_refresh_toolbar(hotlist_window.toolbar); + return true; + case TOOLBAR_EDIT: + ro_gui_theme_toggle_edit(hotlist_window.toolbar); + return true; default: return false; } @@ -350,11 +362,17 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu, /** * Update the theme details of the hotlist window. + * + * \param full_update true to force a full theme change; false to + * refresh the toolbar size. */ -void ro_gui_hotlist_update_theme(void) +void ro_gui_hotlist_update_theme(bool full_update) { - ro_treeview_update_theme(hotlist_window.tv); + if (full_update) + ro_treeview_update_theme(hotlist_window.tv); + else + ro_treeview_update_toolbar(hotlist_window.tv); } /** diff --git a/riscos/hotlist.h b/riscos/hotlist.h index 346f14fe9..84fcca9c2 100644 --- a/riscos/hotlist.h +++ b/riscos/hotlist.h @@ -28,7 +28,7 @@ void ro_gui_hotlist_preinitialise(void); void ro_gui_hotlist_postinitialise(void); void ro_gui_hotlist_open(void); void ro_gui_hotlist_save(void); -void ro_gui_hotlist_update_theme(void); +void ro_gui_hotlist_update_theme(bool full_update); bool ro_gui_hotlist_check_window(wimp_w window); bool ro_gui_hotlist_check_menu(wimp_menu *menu); bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer); diff --git a/riscos/menus.c b/riscos/menus.c index 39e1a4c03..9bffbd582 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -101,7 +101,6 @@ static int ro_gui_menu_get_checksum(void); static void ro_gui_menu_prepare_pageinfo(struct gui_window *g); static void ro_gui_menu_prepare_objectinfo(hlcache_handle *object, const char *href); -static void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar); static bool ro_gui_menu_translate(struct menu_definition *menu); @@ -755,44 +754,6 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning) } -/** - * Refresh a toolbar after it has been updated - * - * \param toolbar the toolbar to update - */ -void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar) -{ -// struct treeview_window *treeview_window; - - assert(toolbar); - - toolbar->reformat_buttons = true; - ro_gui_theme_process_toolbar(toolbar, -1); - if (toolbar->type == THEME_BROWSER_TOOLBAR) { - gui_window_update_extent(ro_gui_window_lookup( - current_menu_window)); -// } else if (toolbar->type == THEME_HOTLIST_TOOLBAR) { -// treeview_window = ro_gui_hotlist_get(); -// /* TODO: FIX THIS */ -// /* tree_resized(treeview_window->tree); */ -// xwimp_force_redraw(treeview_window->window, -// 0,-16384, 16384, 16384); -// } else if (toolbar->type == THEME_HISTORY_TOOLBAR) { -// treeview_window = ro_gui_global_history_get(); -// /* TODO: FIX THIS */ -// /* tree_resized(treeview_window->tree); */ -// xwimp_force_redraw(treeview_window->window, -// 0,-16384, 16384, 16384); -// } else if (toolbar->type == THEME_COOKIES_TOOLBAR) { -// treeview_window = ro_gui_cookies_get(); -// /* TODO: FIX THIS */ -// /* tree_resized(treeview_window->tree); */ -// xwimp_force_redraw(treeview_window->window, -// 0,-16384, 16384, 16384); - } -} - - /** * Update navigate menu status and toolbar icons. * @@ -896,7 +857,7 @@ void ro_gui_menu_prepare_objectinfo(hlcache_handle *object, const char *href) mime = content_get_mime_type(object); if (mime == NULL) mime = "-"; - + if (href) target = href; @@ -1688,19 +1649,19 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action, case TOOLBAR_BUTTONS: assert(t); t->display_buttons = !t->display_buttons; - ro_gui_menu_refresh_toolbar(t); + ro_gui_theme_refresh_toolbar(t); return true; case TOOLBAR_ADDRESS_BAR: assert(t); t->display_url = !t->display_url; - ro_gui_menu_refresh_toolbar(t); + ro_gui_theme_refresh_toolbar(t); if (t->display_url) ro_gui_set_caret_first(t->toolbar_handle); return true; case TOOLBAR_THROBBER: assert(t); t->display_throbber = !t->display_throbber; - ro_gui_menu_refresh_toolbar(t); + ro_gui_theme_refresh_toolbar(t); return true; case TOOLBAR_EDIT: assert(t); diff --git a/riscos/theme.c b/riscos/theme.c index b5c5d8eb5..a2b893266 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -588,9 +588,9 @@ bool ro_gui_theme_apply(struct theme_descriptor *descriptor) /* apply the theme to all the current windows */ ro_gui_window_update_theme(); - ro_gui_cookies_update_theme(); - ro_gui_global_history_update_theme(); - ro_gui_hotlist_update_theme(); + ro_gui_cookies_update_theme(true); + ro_gui_global_history_update_theme(true); + ro_gui_hotlist_update_theme(true); ro_gui_theme_close(theme_previous, false); return true; } @@ -1599,6 +1599,30 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar) } +/** + * Refresh a toolbar after it has been updated + * + * \param toolbar the toolbar to update + */ +void ro_gui_theme_refresh_toolbar(struct toolbar *toolbar) +{ + assert(toolbar); + + toolbar->reformat_buttons = true; + ro_gui_theme_process_toolbar(toolbar, -1); + if (toolbar->type == THEME_BROWSER_TOOLBAR) { + gui_window_update_extent(ro_gui_window_lookup( + current_menu_window)); + } else if (toolbar->type == THEME_HOTLIST_TOOLBAR) { + ro_gui_hotlist_update_theme(false); + } else if (toolbar->type == THEME_HISTORY_TOOLBAR) { + ro_gui_global_history_update_theme(false); + } else if (toolbar->type == THEME_COOKIES_TOOLBAR) { + ro_gui_cookies_update_theme(false); + } +} + + /** * Toggles the toolbar editing mode * diff --git a/riscos/theme.h b/riscos/theme.h index a7cc2b97b..1bc9de07c 100644 --- a/riscos/theme.h +++ b/riscos/theme.h @@ -163,6 +163,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct too bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent); bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width); void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar); +void ro_gui_theme_refresh_toolbar(struct toolbar *toolbar); void ro_gui_theme_toggle_edit(struct toolbar *toolbar); void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar); diff --git a/riscos/treeview.c b/riscos/treeview.c index 27e014cac..e67fc3ad8 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -933,14 +933,25 @@ void ro_treeview_update_theme(ro_treeview *tv) /* \todo -- Check for toolbar editing here. */ ro_gui_theme_attach_toolbar(tv->tb, tv->w); + ro_treeview_update_toolbar(tv); + } +} + + +/** + * Change the size of a treeview's toolbar and redraw the window. + * + * \param *tv The treeview to update. + */ + +void ro_treeview_update_toolbar(ro_treeview *tv) +{ ro_treeview_set_origin(tv, 0, -(ro_gui_theme_toolbar_height(tv->tb))); xwimp_force_redraw(tv->w, 0, tv->extent.y, tv->extent.x, 0); - } -} - +} #if 0 if ((tree) && (tree->toolbar)) { diff --git a/riscos/treeview.h b/riscos/treeview.h index be0a3478e..2b87d57e8 100644 --- a/riscos/treeview.h +++ b/riscos/treeview.h @@ -47,6 +47,7 @@ bool ro_treeview_has_selection(ro_treeview *tv); void ro_treeview_set_origin(ro_treeview *tv, int x, int y); void ro_treeview_mouse_at(wimp_w w, wimp_pointer *pointer); void ro_treeview_update_theme(ro_treeview *tv); +void ro_treeview_update_toolbar(ro_treeview *tv); int ro_treeview_get_help(help_full_message_request *message_data); #endif -- cgit v1.2.3