changeset 1977:e816e06ee901

Added a submenu to control the panel size (Tools)
author Jorge Arellano Cid <jcid@dillo.org>
date Thu, 21 Apr 2011 13:15:51 -0300
parents 041d4979092f
children 3172b6199fd1
files src/menu.cc src/ui.cc src/ui.hh
diffstat 3 files changed, 36 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/menu.cc	Thu Apr 21 13:14:44 2011 -0300
+++ b/src/menu.cc	Thu Apr 21 13:15:51 2011 -0300
@@ -645,16 +645,26 @@
 {
    const Fl_Menu_Item *item;
    Fl_Widget *wid = (Fl_Widget*)v_wid;
+   UI *ui = (UI*)bw->ui;
 
    static Fl_Menu_Item pm[] = {
       {"Use remote CSS", 0, Menu_remote_css_cb, 0, FL_MENU_TOGGLE,0,0,0,0},
       {"Use embedded CSS", 0, Menu_embedded_css_cb, 0,
        FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
-      {"Load images", 0, Menu_imgload_toggle_cb, 0, FL_MENU_TOGGLE,0,0,0,0},
+      {"Load images", 0, Menu_imgload_toggle_cb, 0, 
+       FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
+      {"Panel size", 0, 0, (void*)"Submenu1", FL_SUBMENU,0,0,0,0},
+         {"tiny",  0,0,(void*)P_tiny,FL_MENU_RADIO,0,0,0,0},
+         {"small", 0,0,(void*)P_small,FL_MENU_RADIO,0,0,0,0},
+         {"medium",0,0,(void*)P_medium,FL_MENU_RADIO,0,0,0,0},
+         {"large", 0,0,(void*)P_large,FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0},
+         {"small icons", 0,0,(void*)10,FL_MENU_TOGGLE,0,0,0,0},
       {0,0,0,0,0,0,0,0,0}
    };
 
    popup_bw = bw;
+   int cur_panelsize = ui->get_panelsize();
+   int cur_smallicons = ui->get_smallicons();
 
    if (prefs.load_stylesheets)
       pm[0].set();
@@ -662,9 +672,15 @@
       pm[1].set();
    if (prefs.load_images)
       pm[2].set();
+   pm[4+cur_panelsize].setonly();
+   cur_smallicons ? pm[8].set() : pm[8].clear();
 
    item = pm->popup(wid->x(), wid->y() + wid->h());
-   if (item)
-      ((Fl_Widget *)item)->do_callback();
+   if (item) {
+      if (VOIDP2INT(item->user_data_) == 10)
+         ui->change_panel(cur_panelsize, !cur_smallicons);
+      else
+         ui->change_panel(VOIDP2INT(item->user_data_), cur_smallicons);
+   }
 }
 
--- a/src/ui.cc	Thu Apr 21 13:14:44 2011 -0300
+++ b/src/ui.cc	Thu Apr 21 13:15:51 2011 -0300
@@ -238,7 +238,7 @@
    } else if (b == FL_MIDDLE_MOUSE) {
       ((UI*)data)->color_change_cb_i();
    } else if (b == FL_RIGHT_MOUSE) {
-      ((UI*)data)->panel_cb_i();
+      ((UI*)data)->change_panel(-1,-1);
    }
 }
 
@@ -551,11 +551,6 @@
 {
    Fl_Widget *w;
 
-   if (PanelSize > P_large) {
-      PanelSize = P_tiny;
-      Small_Icons = !Small_Icons;
-   }
-
    if (Small_Icons)
       icons = &small_icons;
    else
@@ -1015,7 +1010,7 @@
 /*
  * On-the-fly panel style change
  */
-void UI::panel_cb_i()
+void UI::change_panel(int new_size, int small_icons)
 {
    // Remove current panel's bars
    init_sizes();
@@ -1027,10 +1022,21 @@
    Fl::delete_widget(NavBar);
    MenuBar = LocBar = NavBar = NULL;
 
+   // Set panel and icons size
+   if (new_size < 0 || small_icons < 0) {
+      if (++PanelSize > P_large) {
+         PanelSize = P_tiny;
+         Small_Icons = !Small_Icons;
+      }
+   } else {
+      PanelSize = new_size;
+      Small_Icons = small_icons;
+   }
+
    // make a new panel
-   ++PanelSize;
    make_panel(TopGroup->w());
    customize(0);
+   a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this));
 
    // adjust Main's height
    int main_h = h() - (mh+(LocBar?lh:0)+nh+(FindBarSpace?fh:0)+sh);
--- a/src/ui.hh	Thu Apr 21 13:14:44 2011 -0300
+++ b/src/ui.hh	Thu Apr 21 13:15:51 2011 -0300
@@ -168,6 +168,9 @@
    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);
    void findbar_toggle(bool add);
    void fullscreen_toggle();
 
@@ -177,7 +180,6 @@
    void pointerOnLink(int flag) { PointerOnLink = flag; }
 
    // Hooks to method callbacks
-   void panel_cb_i();
    void color_change_cb_i();
    void toggle_cb_i();
    void panelmode_cb_i();