From d1342e1d461b0001f5154c3c95fcc116a2451f50 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Mon, 1 Aug 2011 11:30:28 -0400 Subject: Re-enabled the temoporary panels feature for Ctrl+l It has lots of code cleanups and a simpler/more-uniform way of handling it all. --- src/findbar.cc | 28 ++++------------------------ src/findbar.hh | 1 - src/ui.cc | 53 ++++++++++++++--------------------------------------- src/ui.hh | 8 ++++---- src/uicmd.cc | 11 +---------- 5 files changed, 23 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index 4c881755..dcb9db53 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -97,7 +97,7 @@ void Findbar::searchBackwards_cb(Fl_Widget *, void *vfb) */ void Findbar::hide_cb(Fl_Widget *, void *vfb) { - ((Findbar *)vfb)->hide(); + a_UIcmd_findbar_toggle(a_UIcmd_get_bw_by_widget(vfb), 0); } /* @@ -175,19 +175,15 @@ Findbar::~Findbar() */ int Findbar::handle(int event) { - int ret = 0; int k = Fl::event_key(); unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META); if (event == FL_KEYBOARD && modifier == 0 && k == FL_Escape) { - hide(); - ret = 1; + /* let the UI handle it */ + return 0; } - if (ret == 0) - ret = Fl_Group::handle(event); - - return ret; + return Fl_Group::handle(event); } /* @@ -199,7 +195,6 @@ void Findbar::show() dReturn_if (bw == NULL); // It takes more than just calling show() to do the trick - //a_UIcmd_findbar_toggle(bw, 1); Fl_Group::show(); /* select text even if already focused */ @@ -207,18 +202,3 @@ void Findbar::show() i->position(i->size(), 0); } -/* - * Hide the findbar and reset the search state - */ -void Findbar::hide() -{ - BrowserWindow *bw = a_UIcmd_get_bw_by_widget(this); - dReturn_if (bw == NULL); - - // It takes more than just calling hide() to do the trick - Fl_Group::hide(); - a_UIcmd_findbar_toggle(bw, 0); - - a_UIcmd_findtext_reset(bw); - a_UIcmd_focus_main_area(bw); -} diff --git a/src/findbar.hh b/src/findbar.hh index 11986407..72d24c44 100644 --- a/src/findbar.hh +++ b/src/findbar.hh @@ -27,7 +27,6 @@ public: ~Findbar(); int handle(int event); void show(); - void hide(); }; #endif // __FINDBAR_HH__ diff --git a/src/ui.cc b/src/ui.cc index bbcf7b20..fc8624c6 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -313,9 +313,8 @@ static void location_cb(Fl_Widget *wid, void *data) _MSG("location_cb()\n"); a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value()); - if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) { - ui->set_panelmode(UI_HIDDEN); - } + if (ui->temporaryPanels()) + ui->panels_toggle(); } @@ -668,15 +667,12 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : TopGroup->box(FL_NO_BOX); clear_flag(SHORTCUT_LABEL); + PanelTemporary = false; if (cur_ui) { PanelSize = cur_ui->PanelSize; CuteColor = cur_ui->CuteColor; Small_Icons = cur_ui->Small_Icons; - if (cur_ui->Panelmode == UI_HIDDEN || - cur_ui->Panelmode == UI_TEMPORARILY_SHOW_PANELS) - Panelmode = UI_HIDDEN; - else - Panelmode = UI_NORMAL; + Panelmode = cur_ui->Panelmode; } else { // Set some default values PanelSize = prefs.panel_size; @@ -784,14 +780,17 @@ int UI::handle(int event) a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this)); ret = 1; } else if (cmd == KEYS_GOTO) { + if (Panelmode == UI_HIDDEN) { + panels_toggle(); + temporaryPanels(true); + } focus_location(); ret = 1; } else if (cmd == KEYS_HIDE_PANELS) { /* Hide findbar if present, hide panels if not */ (FindBarSpace) ? findbar_toggle(0) : panels_toggle(); + temporaryPanels(false); ret = 1; - //if (get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) - // set_panelmode(UI_HIDDEN); } else if (cmd == KEYS_OPEN) { a_UIcmd_open_file(a_UIcmd_get_bw_by_widget(this)); ret = 1; @@ -861,10 +860,6 @@ void UI::set_location(const char *str) */ void UI::focus_location() { - if (get_panelmode() == UI_HIDDEN) { - // Temporary panel handling is disabled now. - //set_panelmode(UI_TEMPORARILY_SHOW_PANELS); - } Location->take_focus(); // Make text selected when already focused. Location->position(Location->size(), 0); @@ -1037,31 +1032,6 @@ void UI::color_change_cb_i() Location->redraw(); } -/* - * Set or remove the Panelmode flag and update the UI accordingly - */ -void UI::set_panelmode(UIPanelmode mode) -{ - if (mode == UI_HIDDEN) { - //Panel->hide(); - StatusBar->hide(); - } else { - /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */ - //Panel->show(); - StatusBar->show(); - } - Panelmode = mode; - TopGroup->rearrange(); -} - -/* - * Get the value of the panelmode flag - */ -UIPanelmode UI::get_panelmode() -{ - return Panelmode; -} - /* * Set 'nw' as the main render area widget */ @@ -1136,6 +1106,10 @@ void UI::findbar_toggle(bool add) Main->size(Main->w(), Main->h()+FindBar->h()); remove(FindBar); FindBarSpace = 0; + // reset state + a_UIcmd_findtext_reset(a_UIcmd_get_bw_by_widget(this)); + // focus main area + focus_main(); } TopGroup->rearrange(); } @@ -1171,4 +1145,5 @@ void UI::panels_toggle() } TopGroup->rearrange(); + Panelmode = (hide) ? UI_HIDDEN : UI_NORMAL; } diff --git a/src/ui.hh b/src/ui.hh index 97f786d8..6fd09b10 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -28,8 +28,7 @@ typedef enum { typedef enum { UI_NORMAL = 0, /* make sure it's compatible with bool */ - UI_HIDDEN = 1, - UI_TEMPORARILY_SHOW_PANELS + UI_HIDDEN = 1 } UIPanelmode; // Private classes @@ -121,6 +120,7 @@ class UI : public CustGroupVertical { // Panel customization variables int PanelSize, CuteColor, Small_Icons; int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl; + bool PanelTemporary; UIPanelmode Panelmode; Fl_Button *make_button(const char *label, Fl_Image *img, @@ -153,8 +153,6 @@ public: void customize(int flags); void button_set_sens(UIButton btn, int sens); void paste_url(); - void set_panelmode(UIPanelmode mode); - UIPanelmode get_panelmode(); int get_panelsize() { return PanelSize; } int get_smallicons() { return Small_Icons; } void change_panel(int new_size, int small_icons); @@ -163,6 +161,8 @@ public: CustTabs *tabs() { return Tabs; } void tabs(CustTabs *tabs) { Tabs = tabs; } + bool temporaryPanels() { return PanelTemporary; } + void temporaryPanels(bool val) { PanelTemporary = val; } // Hooks to method callbacks void color_change_cb_i(); diff --git a/src/uicmd.cc b/src/uicmd.cc index 0889fd41..12aaca06 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -144,11 +144,7 @@ int CustTabs::handle(int e) UI *ui = (UI*)wizard()->value(); BrowserWindow *bw = a_UIcmd_get_bw_by_widget(ui); KeysCommand_t cmd = Keys::getKeyCmd(); - if (Fl::event_key() == FL_Escape) { - // Hide findbar if present - ui->findbar_toggle(0); - ret = 1; - } else if (cmd == KEYS_NOP) { + if (cmd == KEYS_NOP) { // Do nothing _MSG("CustTabs::handle KEYS_NOP\n"); } else if (cmd == KEYS_NEW_TAB) { @@ -541,11 +537,6 @@ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url) BW2UI(bw)->focus_location(); a_UIcmd_set_buttons_sens(bw); } -#if 0 - if (BW2UI(bw)->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) - BW2UI(bw)->set_panelmode(UI_HIDDEN); - a_UIcmd_focus_main_area(bw); -#endif } static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url) -- cgit v1.2.3