From 97763814b874f3347e107a5013a529e571a23525 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 4 Aug 2011 13:48:47 -0400 Subject: FindBar cleanup: use the same size(0,0) trick we use for Panels --- src/ui.cc | 28 ++++++++-------------------- src/ui.hh | 2 +- 2 files changed, 9 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index b81146d2..8c75002a 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -670,7 +670,6 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : MainIdx = TopGroup->find(Main); // Find text bar - FindBarSpace = 1; FindBar = new Findbar(ui_w, fh); TopGroup->add(FindBar); @@ -694,9 +693,6 @@ UI::~UI() { _MSG("UI::~UI()\n"); dFree(TabTooltip); - - if (!FindBarSpace) - delete FindBar; } /* @@ -752,7 +748,7 @@ int UI::handle(int event) ret = 1; } else if (cmd == KEYS_HIDE_PANELS) { /* Hide findbar if present, hide panels if not */ - (FindBarSpace) ? findbar_toggle(0) : panels_toggle(); + (FindBar->visible()) ? findbar_toggle(0) : panels_toggle(); temporaryPanels(false); ret = 1; } else if (cmd == KEYS_OPEN) { @@ -1046,27 +1042,19 @@ void UI::findbar_toggle(bool add) { /* WORKAROUND: * This is tricky: As fltk-1.3 resizes hidden widgets (which it - * doesn't resize when visible!). We need to go through hoops to + * doesn't resize when visible!). We need to set the size to (0,0) to * get the desired behaviour. * (STR#2639 in FLTK bug tracker). */ if (add) { - if (!FindBarSpace) { - // show - Main->size(Main->w(), Main->h()-FindBar->h()); - insert(*FindBar, StatusBar); - FindBar->show(); - FindBarSpace = 1; - } else { - // select text - FindBar->show(); - } - } else if (!add && FindBarSpace) { + if (!FindBar->visible()) + FindBar->size(w(), fh); + FindBar->show(); + } else { // hide - Main->size(Main->w(), Main->h()+FindBar->h()); - remove(FindBar); - FindBarSpace = 0; + FindBar->size(0,0); + FindBar->hide(); // reset state a_UIcmd_findtext_reset(a_UIcmd_get_bw_by_widget(this)); // focus main area diff --git a/src/ui.hh b/src/ui.hh index 47297f51..aa21f1ed 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -139,7 +139,7 @@ class UI : public CustGroupVertical { Fl_Output *StatusOutput; Findbar *FindBar; - int FindBarSpace, MainIdx; + int MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl; -- cgit v1.2.3