From 229914358a0e0b97c30f4e2210b95770f7c41b62 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Thu, 17 Jan 2013 23:53:11 +0000 Subject: [PATCH] Support for panel height resize. Now, when panel height get resized, children will update their height's too. Children height is always calculated in form (parent()->h() - 10). --- ede-panel/Panel.cpp | 15 +++++++-------- ede-panel/applets/start-menu/StartMenu.cpp | 6 +++--- ede-panel/applets/taskbar/Taskbar.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ede-panel/Panel.cpp b/ede-panel/Panel.cpp index ad76baf..ff4e112 100644 --- a/ede-panel/Panel.cpp +++ b/ede-panel/Panel.cpp @@ -80,8 +80,7 @@ static int xerror_handler(Display *d, XErrorEvent *e) { * construct the similar message format like X11 is using by default, but again, little * bit different so we knows it comes from here */ - - sprintf(buf, "%d", e->request_code); + snprintf(buf, sizeof(buf), "%d", e->request_code); XGetErrorDatabaseText(d, "XRequest", buf, "%d", buf, sizeof(buf)); fprintf(stderr, "%s: ", buf); @@ -121,12 +120,12 @@ static int x_events(int ev) { } /* horizontaly centers widget in the panel */ -static void center_widget_h(Fl_Widget *o, Panel *self) { - int ph, wy; +static void fix_widget_h(Fl_Widget *o, Panel *self) { + int ph, wy, H = self->h() - 10; ph = self->panel_h() / 2; - wy = ph - (o->h() / 2); - o->position(o->x(), wy); + wy = ph - (H / 2); + o->resize(o->x(), wy, o->w(), H); } static void add_from_list(WidgetList &lst, Panel *self, int &X, bool inc) { @@ -278,8 +277,8 @@ void Panel::do_layout(void) { for(int i = 0; i < children(); i++) { o = child(i); - /* first center it vertically */ - center_widget_h(o, this); + /* first resize it to some reasonable height and center it vertically */ + fix_widget_h(o, this); /* manage hider specifically */ if(hider && o == hider) { diff --git a/ede-panel/applets/start-menu/StartMenu.cpp b/ede-panel/applets/start-menu/StartMenu.cpp index 10405a9..8fbf26f 100644 --- a/ede-panel/applets/start-menu/StartMenu.cpp +++ b/ede-panel/applets/start-menu/StartMenu.cpp @@ -36,15 +36,15 @@ #define EDE_PANEL_MENU_AUTOUPDATE 1 #ifdef EDE_PANEL_MENU_AUTOUPDATE - #include +# include EDELIB_NS_USING(DirWatch) EDELIB_NS_USING_LIST(4, (DW_CREATE, DW_MODIFY, DW_DELETE, DW_REPORT_RENAME)) /* when menu needs to be update, after how long to do real update */ - #define MENU_UPDATE_TIMEOUT 5.0 +# define MENU_UPDATE_TIMEOUT 5.0 /* elapsed seconds between changes reports from DirWatch; to prevent event throttling */ - #define MENU_UPDATE_DIFF 5 +# define MENU_UPDATE_DIFF 5 #endif EDELIB_NS_USING(MenuBase) diff --git a/ede-panel/applets/taskbar/Taskbar.cpp b/ede-panel/applets/taskbar/Taskbar.cpp index 87ebcd4..7b95953 100644 --- a/ede-panel/applets/taskbar/Taskbar.cpp +++ b/ede-panel/applets/taskbar/Taskbar.cpp @@ -233,11 +233,12 @@ void Taskbar::layout_children(void) { if(!children()) return; Fl_Widget *o; - int X, Y, W, reduce = 0, sz = 0, all_buttons_w = 0; + int X, Y, W, child_h, reduce = 0, sz = 0, all_buttons_w = 0; X = x() + Fl::box_dx(box()); Y = y() + Fl::box_dy(box()); W = w() - Fl::box_dw(box()); + child_h = parent()->h() - 10; /* same sizes as in panel */ for(int i = 0; i < children(); i++) { o = child(i); @@ -246,7 +247,7 @@ void Taskbar::layout_children(void) { sz++; /* resize every child to default size so we can calculate total length */ - o->resize(o->x(), o->y(), (fixed_layout ? DEFAULT_CHILD_W : W), o->h()); + o->resize(o->x(), o->y(), (fixed_layout ? DEFAULT_CHILD_W : W), child_h); all_buttons_w += o->w(); /* do not include ending spaces */ @@ -267,7 +268,7 @@ void Taskbar::layout_children(void) { * I'm putting -1 here to leave a small space at the end of group; this will also * make children adaptive to not overflow group in case too many of them was created */ - o->resize(X, Y, o->w() - reduce - 1, o->h()); + o->resize(X, Y, o->w() - reduce - 1, child_h); X += o->w() + DEFAULT_SPACING; } }