From 97fcaa47455240d4ae2c6b4a254e4d3cbccd110e Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 5 Aug 2011 09:28:26 -0400 Subject: Fix resize for the corner case of starting dillo in a tiny window FLTK has no problem in resizing from a "fitting" size into a "compressed" one, but if it starts compressed, things go wild. --- src/ui.hh | 5 +++++ src/uicmd.cc | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.hh b/src/ui.hh index 68b7a972..57611f86 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -31,6 +31,11 @@ typedef enum { UI_HIDDEN = 1 } UIPanelmode; + +// Min size to fit the full UI +#define UI_MIN_W 600 +#define UI_MIN_H 200 + // Private classes class CustProgressBox; class CustTabs; diff --git a/src/uicmd.cc b/src/uicmd.cc index 864113d6..c7bb5a8a 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -210,12 +210,16 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus) Wizard->resize(0,ctab_h,Wizard->w(),window()->h()-ctab_h); resize(0,0,window()->w(),ctab_h); // tabbar CloseBtn->show(); + child(0)->size(tab_w,ctab_h); child(0)->show(); // first tab button window()->init_sizes(); } + /* The UI is constructed in a comfortable fitting size, and then resized + * so FLTK doesn't get confused later with even smaller dimensions! */ current(0); - UI *new_ui = new UI(0,ctab_h,Wizard->w(),Wizard->h(),0,old_ui); + UI *new_ui = new UI(0,0,UI_MIN_W,UI_MIN_H,0,old_ui); + new_ui->resize(0,ctab_h,Wizard->w(),Wizard->h()); new_ui->tabs(this); Wizard->add(new_ui); new_ui->show(); @@ -276,6 +280,7 @@ void CustTabs::remove_tab(UI *ui) // hide tabbar ctab_h = 1; CloseBtn->hide(); + child(0)->size(0,0); child(0)->hide(); // first tab button resize(0,0,window()->w(),ctab_h); // tabbar Wizard->resize(0,ctab_h,Wizard->w(),window()->h()-ctab_h); -- cgit v1.2.3 From 4a021ae7d68a7b1701a6567ad14feea90b6a833f Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 5 Aug 2011 09:28:29 -0400 Subject: Fix: Don't confuse FLTK when tabs overflow. When tabs overflow width, FLTK starts resizing the last tab label. This patch handles the case more gracefully. --- src/ui.hh | 16 ++++++++++++++-- src/uicmd.cc | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.hh b/src/ui.hh index 57611f86..3b61f69b 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -48,6 +48,7 @@ class CustTabs; * The resizable child get's the remaining space. */ class CustGroupHorizontal : public Fl_Group { + Fl_Widget *rsz; public: CustGroupHorizontal(int x,int y,int w ,int h,const char *l = 0) : Fl_Group(x,y,w,h,l) { }; @@ -57,13 +58,24 @@ public: int sum = 0, _x = x(); int children_ = children(); + if (resizable()) + rsz = resizable(); + for (int i=0; i < children_; i++) if (a[i] != resizable() && a[i]->visible()) sum += a[i]->w(); for (int i=0; i < children_; i++) { - if (a[i] == resizable()) { - a[i]->resize(_x, y(), w() - sum, h()); + if (a[i] == rsz) { + if (w() > sum) { + a[i]->resize(_x, y(), w()-sum, h()); + if (!resizable()) + resizable(rsz); + } else { + /* widgets overflow width */ + a[i]->resize(_x, y(), 0, h()); + resizable(NULL); + } } else { a[i]->resize(_x, y(), a[i]->w(), h()); } diff --git a/src/uicmd.cc b/src/uicmd.cc index c7bb5a8a..88dedd96 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -194,6 +194,11 @@ int CustTabs::handle(int e) a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL); ret = 1; } + } else if (e == FL_ENTER) { + /* WORKAROUND: when tabs overflow width, the resizable is set to NULL, + * and the close button loses its position. This call fixes it. */ + if (!resizable()) + rearrange(); } return (ret) ? ret : CustGroupHorizontal::handle(e); -- cgit v1.2.3 From dd05e2dddec41cefb3869749e6729f565fb3e821 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 5 Aug 2011 09:38:26 -0400 Subject: merge --- src/uicmd.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 88dedd96..32b5e8bb 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -276,12 +276,7 @@ void CustTabs::remove_tab(UI *ui) Wizard->remove(ui); delete(ui); - if (num_tabs() == 0) { - window()->hide(); - // TODO: free memory - //delete window(); - - } else if (num_tabs() == 1) { + if (num_tabs() == 1) { // hide tabbar ctab_h = 1; CloseBtn->hide(); @@ -378,14 +373,14 @@ void CustTabs::set_tab_label(UI *ui, const char *label) //---------------------------------------------------------------------------- static void win_cb (Fl_Widget *w, void *cb_data) { - int choice = 1; CustTabs *tabs = (CustTabs*) cb_data; + int choice = 1, ntabs = tabs->num_tabs(); - if (tabs->num_tabs() > 1) + if (ntabs > 1) choice = a_Dialog_choice5("Window contains more than one tab.", "Close", "Cancel", NULL, NULL, NULL); if (choice == 1) - while (tabs->num_tabs()) + while (ntabs-- > 0) a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->wizard()->value())); } @@ -495,13 +490,16 @@ void a_UIcmd_close_bw(void *vbw) { BrowserWindow *bw = (BrowserWindow *)vbw; UI *ui = BW2UI(bw); + CustTabs *tabs = ui->tabs(); Layout *layout = (Layout*)bw->render_layout; _MSG("a_UIcmd_close_bw\n"); a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force); delete(layout); - if (ui->tabs()) { - ui->tabs()->remove_tab(ui); + if (tabs) { + tabs->remove_tab(ui); + if (tabs->num_tabs() == 0) + delete tabs->window(); } a_Bw_free(bw); } -- cgit v1.2.3