aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>1970-01-01 01:05:39 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>1970-01-01 01:05:39 +0100
commit5d52cee064372bb7400e4fe537b9bab8d1502a3d (patch)
tree01a5a25a65fe80ce8b32e778b9c97a4561dc2f47 /src
parente2fe24b904895dca8245ea5bac9c43abe7dc2012 (diff)
parent037c25162ba7a36e600f4e1366a206e4abf05020 (diff)
merge
Diffstat (limited to 'src')
-rw-r--r--src/ui.cc13
-rw-r--r--src/uicmd.cc73
2 files changed, 54 insertions, 32 deletions
diff --git a/src/ui.cc b/src/ui.cc
index 1004bfdc..6fc769c8 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -320,13 +320,8 @@ static void location_cb(Fl_Widget *wid, void *data)
UI *ui = (UI*)data;
_MSG("location_cb()\n");
- /* This test is necessary because WHEN_ENTER_KEY also includes
- * other events we're not interested in. For instance pressing
- * The Back or Forward, buttons, or the first click on a rendered
- * page. BUG: this must be investigated and reported to FLTK2 team */
- if (Fl::event_key() == FL_Enter) {
- a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
- }
+ 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);
}
@@ -596,6 +591,7 @@ void UI::make_panel(int ww)
current(0);
if (PanelSize == P_tiny) {
NavBar = new CustGroupHorizontal(0,0,ww,nh);
+ NavBar->box(FL_NO_BOX);
NavBar->begin();
make_toolbar(ww,bh);
make_filemenu_button();
@@ -627,6 +623,7 @@ void UI::make_panel(int ww)
TopGroup->insert(*LocBar,1);
} else {
LocBar = new CustGroupHorizontal(0,0,ww,lh);
+ LocBar->box(FL_NO_BOX);
LocBar->begin();
p_xpos = 0;
make_filemenu_button();
@@ -640,6 +637,7 @@ void UI::make_panel(int ww)
// Toolbar
p_ypos = 0;
NavBar = new CustGroupHorizontal(0,0,ww,bh);
+ NavBar->box(FL_NO_BOX);
NavBar->begin();
make_toolbar(ww,bh);
w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh);
@@ -664,6 +662,7 @@ void UI::make_status_bar(int ww, int wh)
{
const int bm_w = 20;
StatusBar = new CustGroupHorizontal(0, wh-sh, ww, sh);
+ StatusBar->box(FL_NO_BOX);
// Status box
StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh);
diff --git a/src/uicmd.cc b/src/uicmd.cc
index a28128c8..68550e41 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -84,21 +84,21 @@ public:
* Allows fine control of the tabbed interface
*/
class CustTabs : public CustGroupHorizontal {
- int tab_w, tab_h, tab_n;
+ int tab_w, tab_h, ctab_h, tab_n;
Fl_Wizard *Wizard;
int tabcolor_inactive, tabcolor_active, curtab_idx;
public:
CustTabs (int ww, int wh, int th, const char *lbl=0) :
CustGroupHorizontal(0,0,ww,th,lbl) {
- tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1;
+ tab_w = 80, tab_h = th, ctab_h = 1, tab_n = 0, curtab_idx = -1;
tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206;
- Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e");
- w->box(FL_NO_BOX);
- resizable(0);
+ resize(0,0,ww,ctab_h);
+ resizable(NULL);
box(FL_FLAT_BOX);
end();
- Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h);
+ Wizard = new Fl_Wizard(0,ctab_h,ww,wh-ctab_h);
+ Wizard->box(FL_NO_BOX);
Wizard->end();
};
int handle(int e);
@@ -106,7 +106,7 @@ public:
void remove_tab(UI *ui);
Fl_Wizard *wizard(void) { return Wizard; }
int get_btn_idx(UI *ui);
- int num_tabs() { return (children() - 1); } // substract invisible box
+ int num_tabs() { return children(); }
void switch_tab(CustTabButton *cbtn);
void prev_tab(void);
void next_tab(void);
@@ -184,14 +184,23 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus)
{
char tab_label[64];
+ if (num_tabs() == 1) {
+ // Show tabbar
+ ctab_h = tab_h;
+ Wizard->resize(0,ctab_h,Wizard->w(),window()->h()-ctab_h);
+ resize(0,0,window()->w(),ctab_h); // tabbar
+ child(0)->show(); // first tab button
+ window()->init_sizes();
+ }
+
current(0);
- UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h(),0,old_ui);
+ UI *new_ui = new UI(0,ctab_h,Wizard->w(),Wizard->h(),0,old_ui);
new_ui->tabs(this);
Wizard->add(new_ui);
new_ui->show();
snprintf(tab_label, 64,"ctab%d", ++tab_n);
- CustTabButton *btn = new CustTabButton(num_tabs()*tab_w,0,tab_w,tab_h);
+ CustTabButton *btn = new CustTabButton(num_tabs()*tab_w,0,tab_w,ctab_h);
btn->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
btn->copy_label(tab_label);
btn->clear_visible_focus();
@@ -199,11 +208,12 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus)
btn->color(focus ? tabcolor_active : tabcolor_inactive);
btn->ui(new_ui);
add(btn);
- btn->redraw();
btn->callback(tab_btn_cb, this);
if (focus)
switch_tab(btn);
+ if (num_tabs() == 1)
+ btn->hide();
rearrange();
return new_ui;
@@ -216,19 +226,19 @@ void CustTabs::remove_tab(UI *ui)
{
CustTabButton *btn;
- // remove label button
- int idx = get_btn_idx(ui);
- btn = (CustTabButton*)child(idx);
- idx > 1 ? prev_tab() : next_tab();
-
- // WORKAROUND: with two tabs, closing the non-focused one, doesn't
- // delete it from screen. This hide() call makes it work. --Jcid
- btn->hide();
+ // get active tab idx
+ int act_idx = get_btn_idx((UI*)Wizard->value());
+ // get to-be-removed tab idx
+ int rm_idx = get_btn_idx(ui);
+ btn = (CustTabButton*)child(rm_idx);
- remove(idx);
+ if (act_idx == rm_idx) {
+ // Active tab is being closed, switch to another one
+ rm_idx > 0 ? prev_tab() : next_tab();
+ }
+ remove(rm_idx);
delete btn;
rearrange();
- redraw();
Wizard->remove(ui);
delete(ui);
@@ -237,12 +247,21 @@ void CustTabs::remove_tab(UI *ui)
window()->hide();
// TODO: free memory
//delete window();
+
+ } else if (num_tabs() == 1) {
+ // hide tabbar
+ ctab_h = 1;
+ 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);
+ window()->init_sizes();
+ window()->redraw();
}
}
int CustTabs::get_btn_idx(UI *ui)
{
- for (int i = 1; i <= num_tabs(); ++i) {
+ for (int i = 0; i < num_tabs(); ++i) {
CustTabButton *btn = (CustTabButton*)child(i);
if (btn->ui() == ui)
return i;
@@ -250,6 +269,9 @@ int CustTabs::get_btn_idx(UI *ui)
return -1;
}
+/*
+ * Make cbtn's tab the active one
+ */
void CustTabs::switch_tab(CustTabButton *cbtn)
{
int idx;
@@ -259,7 +281,7 @@ void CustTabs::switch_tab(CustTabButton *cbtn)
if (cbtn->ui() != old_ui) {
// Set old tab label to normal color
- if ((idx = get_btn_idx(old_ui)) > 0) {
+ if ((idx = get_btn_idx(old_ui)) != -1) {
btn = (CustTabButton*)child(idx);
btn->color(tabcolor_inactive);
btn->redraw();
@@ -281,7 +303,7 @@ void CustTabs::prev_tab()
int idx;
if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
- switch_tab( (CustTabButton*)child(idx > 1 ? idx-1 : num_tabs()) );
+ switch_tab( (CustTabButton*)child(idx > 0 ? idx-1 : num_tabs()-1) );
}
void CustTabs::next_tab()
@@ -289,7 +311,7 @@ void CustTabs::next_tab()
int idx;
if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
- switch_tab( (CustTabButton*)child(idx < num_tabs() ? idx+1 : 1) );
+ switch_tab( (CustTabButton*)child((idx+1 < num_tabs()) ? idx+1 : 0) );
}
/*
@@ -300,7 +322,7 @@ void CustTabs::set_tab_label(UI *ui, const char *label)
char title[128];
int idx = get_btn_idx(ui);
- if (idx > 0) {
+ if (idx != -1) {
// Make a label for this tab
size_t tab_chars = 7, label_len = strlen(label);
@@ -410,6 +432,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus)
// set_render_layout() sets the proper viewport size
FltkViewport *viewport = new FltkViewport (0, 0, 0, 1);
+ viewport->box(FL_NO_BOX);
viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false);
layout->attachView (viewport);
new_ui->set_render_layout(viewport);