comparison src/ui.cc @ 2052:89af8495455f

remove use of Fl_Pack to avoid resizing issues CustGroup is split into CustGroupHorizontal and CustGroupVertical. CustGroupVertical is then used to replace Fl_Pack for TopGroup.
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 26 May 2011 21:12:33 +0200
parents 8f021c978252
children d8eaa1203895
comparison
equal deleted inserted replaced
2051:e1c1d44e56c4 2052:89af8495455f
533 Fl_Widget *UI::make_filemenu_button() 533 Fl_Widget *UI::make_filemenu_button()
534 { 534 {
535 Fl_Button *btn; 535 Fl_Button *btn;
536 int w = 0, h = 0, padding; 536 int w = 0, h = 0, padding;
537 537
538 FileButton = btn = new Fl_Button(p_xpos,0,0,0,"W"); 538 FileButton = btn = new Fl_Button(p_xpos,0,bw,bh,"W");
539 btn->labeltype(FL_FREE_LABELTYPE); 539 btn->labeltype(FL_FREE_LABELTYPE);
540 btn->measure_label(w, h); 540 btn->measure_label(w, h);
541 padding = w; 541 padding = w;
542 btn->copy_label(PanelSize == P_tiny ? "&F" : "&File"); 542 btn->copy_label(PanelSize == P_tiny ? "&F" : "&File");
543 btn->measure_label(w,h); 543 btn->measure_label(w,h);
593 } 593 }
594 nh = bh, fh = 28; sh = 20; 594 nh = bh, fh = 28; sh = 20;
595 595
596 current(0); 596 current(0);
597 if (PanelSize == P_tiny) { 597 if (PanelSize == P_tiny) {
598 NavBar = new CustGroup(0,0,ww,nh); 598 NavBar = new CustGroupHorizontal(0,0,ww,nh);
599 NavBar->begin(); 599 NavBar->begin();
600 make_toolbar(ww,bh); 600 make_toolbar(ww,bh);
601 make_filemenu_button(); 601 make_filemenu_button();
602 make_location(ww); 602 make_location(ww);
603 NavBar->resizable(Location); 603 NavBar->resizable(Location);
604 make_progress_bars(0,1); 604 make_progress_bars(0,1);
605 NavBar->box(FL_THIN_UP_FRAME); 605 NavBar->box(FL_THIN_UP_FRAME);
606 NavBar->end(); 606 NavBar->end();
607 NavBar->rearrange();
607 TopGroup->insert(*NavBar,0); 608 TopGroup->insert(*NavBar,0);
608 } else { 609 } else {
609 if (PanelSize == P_large) { 610 if (PanelSize == P_large) {
610 MenuBar = new CustGroup(0,0,ww,mh); 611 MenuBar = new CustGroupHorizontal(0,0,ww,mh);
611 MenuBar->begin(); 612 MenuBar->begin();
612 MenuBar->box(FL_THIN_UP_BOX); 613 MenuBar->box(FL_THIN_UP_BOX);
613 Fl_Widget *bn = make_filemenu_button(); 614 Fl_Widget *bn = make_filemenu_button();
614 MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh)); 615 MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh));
615 MenuBar->end(); 616 MenuBar->end();
617 MenuBar->rearrange();
616 TopGroup->insert(*MenuBar,0); 618 TopGroup->insert(*MenuBar,0);
617 619
618 p_xpos = 0; 620 p_xpos = 0;
619 LocBar = new CustGroup(0,0,ww,lh); 621 LocBar = new CustGroupHorizontal(0,0,ww,lh);
620 LocBar->begin(); 622 LocBar->begin();
621 make_location(ww); 623 make_location(ww);
622 LocBar->resizable(Location); 624 LocBar->resizable(Location);
623 LocBar->end(); 625 LocBar->end();
626 LocBar->rearrange();
624 TopGroup->insert(*LocBar,1); 627 TopGroup->insert(*LocBar,1);
625 } else { 628 } else {
626 LocBar = new CustGroup(0,0,ww,lh); 629 LocBar = new CustGroupHorizontal(0,0,ww,lh);
627 LocBar->begin(); 630 LocBar->begin();
628 p_xpos = 0; 631 p_xpos = 0;
629 make_filemenu_button(); 632 make_filemenu_button();
630 make_location(ww); 633 make_location(ww);
631 LocBar->resizable(Location); 634 LocBar->resizable(Location);
632 LocBar->end(); 635 LocBar->end();
636 LocBar->rearrange();
633 TopGroup->insert(*LocBar,0); 637 TopGroup->insert(*LocBar,0);
634 } 638 }
635 639
636 // Toolbar 640 // Toolbar
637 p_ypos = 0; 641 p_ypos = 0;
638 NavBar = new CustGroup(0,0,ww,bh); 642 NavBar = new CustGroupHorizontal(0,0,ww,bh);
639 NavBar->begin(); 643 NavBar->begin();
640 make_toolbar(ww,bh); 644 make_toolbar(ww,bh);
641 w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh); 645 w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh);
642 w->box(FL_FLAT_BOX); 646 w->box(FL_FLAT_BOX);
643 NavBar->resizable(w); 647 NavBar->resizable(w);
646 make_progress_bars(0,0); 650 make_progress_bars(0,0);
647 } else { 651 } else {
648 make_progress_bars(1,0); 652 make_progress_bars(1,0);
649 } 653 }
650 NavBar->end(); 654 NavBar->end();
655 NavBar->rearrange();
651 TopGroup->insert(*NavBar,(MenuBar ? 2 : 1)); 656 TopGroup->insert(*NavBar,(MenuBar ? 2 : 1));
652 } 657 }
653 } 658 }
654 659
655 /* 660 /*
656 * Create the status panel 661 * Create the status panel
657 */ 662 */
658 void UI::make_status_bar(int ww, int wh) 663 void UI::make_status_bar(int ww, int wh)
659 { 664 {
660 const int bm_w = 20; 665 const int bm_w = 20;
661 StatusBar = new CustGroup(0, wh-sh, ww, sh); 666 StatusBar = new CustGroupHorizontal(0, wh-sh, ww, sh);
662 667
663 // Status box 668 // Status box
664 StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); 669 StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh);
665 StatusOutput->value("http://www.dillo.org"); 670 StatusOutput->value("http://www.dillo.org");
666 StatusOutput->labelsize(8); 671 StatusOutput->labelsize(8);
678 BugMeter->callback(bugmeter_cb, this); 683 BugMeter->callback(bugmeter_cb, this);
679 BugMeter->clear_visible_focus(); 684 BugMeter->clear_visible_focus();
680 685
681 StatusBar->end(); 686 StatusBar->end();
682 StatusBar->resizable(StatusOutput); 687 StatusBar->resizable(StatusOutput);
688 StatusBar->rearrange();
683 } 689 }
684 690
685 /* 691 /*
686 * User Interface constructor 692 * User Interface constructor
687 */ 693 */
688 UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : 694 UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) :
689 Fl_Pack(x, y, ui_w, ui_h, label) 695 CustGroupVertical(x, y, ui_w, ui_h, label)
690 { 696 {
691 PointerOnLink = FALSE; 697 PointerOnLink = FALSE;
692 698
693 MenuBar = LocBar = NavBar = StatusBar = NULL; 699 MenuBar = LocBar = NavBar = StatusBar = NULL;
694 700
695 Tabs = NULL; 701 Tabs = NULL;
696 TabTooltip = NULL; 702 TabTooltip = NULL;
697 TopGroup = this; 703 TopGroup = this;
698 TopGroup->type(VERTICAL);
699 TopGroup->box(FL_NO_BOX); 704 TopGroup->box(FL_NO_BOX);
700 clear_flag(SHORTCUT_LABEL); 705 clear_flag(SHORTCUT_LABEL);
701 706
702 if (cur_ui) { 707 if (cur_ui) {
703 PanelSize = cur_ui->PanelSize; 708 PanelSize = cur_ui->PanelSize;
720 // Control panel 725 // Control panel
721 TopGroup->begin(); 726 TopGroup->begin();
722 make_panel(ui_w); 727 make_panel(ui_w);
723 728
724 // Render area 729 // Render area
725 int main_h = ui_h - (mh+(LocBar?lh:0)+nh+fh+sh); 730 Main = new Fl_Group(0,0,0,0,"Welcome..."); // size is set by rearrange()
726 Main = new Fl_Group(0,0,0,main_h,"Welcome...");
727 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); 731 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
728 Main->box(FL_FLAT_BOX); 732 Main->box(FL_FLAT_BOX);
729 Main->color(FL_GRAY_RAMP + 3); 733 Main->color(FL_GRAY_RAMP + 3);
730 Main->labelfont(FL_HELVETICA_BOLD_ITALIC); 734 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
731 Main->labelsize(36); 735 Main->labelsize(36);
741 TopGroup->add(FindBar); 745 TopGroup->add(FindBar);
742 746
743 // Status Panel 747 // Status Panel
744 make_status_bar(ui_w, ui_h); 748 make_status_bar(ui_w, ui_h);
745 TopGroup->add(StatusBar); 749 TopGroup->add(StatusBar);
746
747 TopGroup->end(); 750 TopGroup->end();
751 TopGroup->rearrange();
748 752
749 // Make the full screen button (to be attached to the viewport later) 753 // Make the full screen button (to be attached to the viewport later)
750 // TODO: attach to the viewport 754 // TODO: attach to the viewport
751 //FullScreen = new Fl_Button(0,0,15,15); 755 //FullScreen = new Fl_Button(0,0,15,15);
752 //FullScreen->image(ImgFullScreenOn); 756 //FullScreen->image(ImgFullScreenOn);
1047 // make a new panel 1051 // make a new panel
1048 make_panel(TopGroup->w()); 1052 make_panel(TopGroup->w());
1049 customize(0); 1053 customize(0);
1050 a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this)); 1054 a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this));
1051 1055
1052 // adjust Main's height 1056 TopGroup->rearrange();
1053 int main_h = h() - (mh+(LocBar?lh:0)+nh+(FindBarSpace?fh:0)+sh);
1054 Main->size(Main->w(), main_h);
1055 redraw();
1056
1057 Location->take_focus(); 1057 Location->take_focus();
1058 } 1058 }
1059 1059
1060 /* 1060 /*
1061 * On-the-fly color style change 1061 * On-the-fly color style change
1084 /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */ 1084 /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */
1085 //Panel->show(); 1085 //Panel->show();
1086 StatusBar->show(); 1086 StatusBar->show();
1087 } 1087 }
1088 Panelmode = mode; 1088 Panelmode = mode;
1089 TopGroup->rearrange();
1089 } 1090 }
1090 1091
1091 /* 1092 /*
1092 * Get the value of the panelmode flag 1093 * Get the value of the panelmode flag
1093 */ 1094 */
1108 * Set 'nw' as the main render area widget 1109 * Set 'nw' as the main render area widget
1109 */ 1110 */
1110 void UI::set_render_layout(Fl_Group *nw) 1111 void UI::set_render_layout(Fl_Group *nw)
1111 { 1112 {
1112 // Resize layout widget to current height 1113 // Resize layout widget to current height
1113 nw->resize(0,0,0,Main->h()); 1114 nw->resize(0,Main->y(),Main->w(),Main->h());
1114 1115
1115 TopGroup->insert(*nw, Main); 1116 TopGroup->insert(*nw, Main);
1116 remove(Main); 1117 remove(Main);
1117 delete(Main); 1118 delete(Main);
1118 Main = nw; 1119 Main = nw;
1167 // show 1168 // show
1168 Main->size(Main->w(), Main->h()-FindBar->h()); 1169 Main->size(Main->w(), Main->h()-FindBar->h());
1169 insert(*FindBar, StatusBar); 1170 insert(*FindBar, StatusBar);
1170 FindBar->show(); 1171 FindBar->show();
1171 FindBarSpace = 1; 1172 FindBarSpace = 1;
1172 redraw();
1173 } else { 1173 } else {
1174 // select text 1174 // select text
1175 FindBar->show(); 1175 FindBar->show();
1176 } 1176 }
1177 } else if (!add && FindBarSpace) { 1177 } else if (!add && FindBarSpace) {
1178 // hide 1178 // hide
1179 Main->size(Main->w(), Main->h()+FindBar->h()); 1179 Main->size(Main->w(), Main->h()+FindBar->h());
1180 remove(FindBar); 1180 remove(FindBar);
1181 FindBarSpace = 0; 1181 FindBarSpace = 0;
1182 redraw(); /* Main->redraw(); is not enough */ 1182 }
1183 } 1183 TopGroup->rearrange();
1184 } 1184 }
1185 1185
1186 /* 1186 /*
1187 * Make panels disappear growing the render area. 1187 * Make panels disappear growing the render area.
1188 * WORKAROUND: here we avoid hidden widgets resize by setting their 1188 * WORKAROUND: here we avoid hidden widgets resize by setting their
1215 dh += sh; 1215 dh += sh;
1216 hide ? StatusBar->size(0,0) : StatusBar->size(w(),sh);; 1216 hide ? StatusBar->size(0,0) : StatusBar->size(w(),sh);;
1217 hide ? StatusBar->hide() : StatusBar->show();; 1217 hide ? StatusBar->hide() : StatusBar->show();;
1218 } 1218 }
1219 1219
1220 Main->size(Main->w(), Main->h() + (hide ? dh : -dh)); 1220 TopGroup->rearrange();
1221 redraw(); 1221 }
1222 }