diff --git a/ede-panel/applets/hider/Hider.cpp b/ede-panel/Hider.cpp similarity index 61% rename from ede-panel/applets/hider/Hider.cpp rename to ede-panel/Hider.cpp index 5caa4e7..349ead9 100644 --- a/ede-panel/applets/hider/Hider.cpp +++ b/ede-panel/Hider.cpp @@ -1,49 +1,41 @@ -#include "Applet.h" -#include "Panel.h" +/* + * $Id: ede-panel.cpp 3463 2012-12-17 15:49:33Z karijes $ + * + * Copyright (C) 2012 Sanel Zukan + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ #include -#include #include #include +#include #include #include -#include +#include "Hider.h" +#include "Panel.h" /* delay in secs */ #define PANEL_MOVE_DELAY 0.0015 /* how fast we will move X axis */ #define PANEL_ANIM_SPEED 50 -static void hide_cb(Fl_Widget*, void *h); - -class Hider : public Fl_Button { -private: - int old_x, old_y, is_hidden, old_px, stop_x; -public: - Hider() : Fl_Button(0, 0, 10, 25, "@>"), old_x(0), old_y(0), is_hidden(0), old_px(0), stop_x(0) { - labelsize(8); - box(FL_FLAT_BOX); - tooltip(_("Hide panel")); - callback(hide_cb, this); - } - - int panel_hidden(void) { return is_hidden; } - void panel_hidden(int s) { is_hidden = s; } - - void panel_show(void); - void panel_hide(void); - void post_show(void); - void post_hide(void); - void animate(void); -}; - static void hide_cb(Fl_Widget*, void *h) { Hider *hh = (Hider*)h; - if(hh->panel_hidden()) - hh->panel_show(); - else - hh->panel_hide(); + hh->panel_hidden() ? hh->panel_show() : hh->panel_hide(); } static void animate_cb(void *h) { @@ -51,8 +43,15 @@ static void animate_cb(void *h) { hh->animate(); } +Hider::Hider() : Fl_Button(0, 0, 10, 25, "@>"), old_x(0), old_y(0), is_hidden(0), old_px(0), stop_x(0) { + labelsize(8); + box(FL_FLAT_BOX); + tooltip(_("Hide panel")); + callback(hide_cb, this); +} + void Hider::animate(void) { - Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this); + Panel *p = (Panel*)parent(); if(!panel_hidden()) { /* hide */ @@ -76,7 +75,8 @@ void Hider::animate(void) { } void Hider::panel_hide(void) { - Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this); + Panel *p = (Panel*)parent(); + int X, Y, W, H; p->screen_size(X, Y, W, H); @@ -87,7 +87,7 @@ void Hider::panel_hide(void) { } void Hider::post_hide(void) { - Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this); + Panel *p = (Panel*)parent(); /* align to bounds */ p->position(stop_x, p->y()); @@ -116,7 +116,7 @@ void Hider::panel_show(void) { } void Hider::post_show(void) { - Panel *p = EDE_PANEL_GET_PANEL_OBJECT(this); + Panel *p = (Panel*)parent(); /* align to bounds */ p->position(old_px, p->y()); @@ -136,12 +136,3 @@ void Hider::post_show(void) { panel_hidden(0); tooltip(_("Hide panel")); } - -EDE_PANEL_APPLET_EXPORT ( - Hider, - EDE_PANEL_APPLET_OPTION_ALIGN_RIGHT, - "Hide-panel applet", - "0.1", - "empty", - "Sanel Zukan" -) diff --git a/ede-panel/Hider.h b/ede-panel/Hider.h new file mode 100644 index 0000000..082dbf6 --- /dev/null +++ b/ede-panel/Hider.h @@ -0,0 +1,41 @@ +/* + * $Id: ede-panel.cpp 3463 2012-12-17 15:49:33Z karijes $ + * + * Copyright (C) 2012 Sanel Zukan + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#ifndef __HIDER_H__ +#define __HIDER_H__ + +class Hider : public Fl_Button { +private: + int old_x, old_y, is_hidden, old_px, stop_x; +public: + Hider(); + int panel_hidden(void) { return is_hidden; } + void panel_hidden(int s) { is_hidden = s; } + + void panel_show(void); + void panel_hide(void); + void post_show(void); + void post_hide(void); + void animate(void); +}; + +#endif diff --git a/ede-panel/Jamfile b/ede-panel/Jamfile index faa4a9b..d528c5c 100644 --- a/ede-panel/Jamfile +++ b/ede-panel/Jamfile @@ -10,8 +10,8 @@ SubDir TOP ede-panel ; -EdeProgram ede-panel : Panel.cpp AppletManager.cpp ede-panel.cpp ; -#ObjectC++Flags Panel.cpp : -DEDE_PANEL_LOCAL_APPLETS ; +EdeProgram ede-panel : Hider.cpp Panel.cpp AppletManager.cpp ede-panel.cpp ; +ObjectC++Flags Panel.cpp : -DEDE_PANEL_LOCAL_APPLETS ; if $(OS) != "SOLARIS" { # also must use this flag (on anything but Solaris) or program will crash diff --git a/ede-panel/Panel.cpp b/ede-panel/Panel.cpp index 06ab6c2..420d3ea 100644 --- a/ede-panel/Panel.cpp +++ b/ede-panel/Panel.cpp @@ -32,6 +32,7 @@ #include #include "Panel.h" +#include "Hider.h" /* empty space from left and right panel border */ #define INITIAL_SPACING 5 @@ -218,6 +219,7 @@ static void move_widget(Panel *self, Fl_Widget *o, int &sx, int &sy) { Panel::Panel() : PanelWindow(300, 30, "ede-panel") { gpanel = this; + hider = NULL; clicked = 0; sx = sy = 0; @@ -229,6 +231,9 @@ Panel::Panel() : PanelWindow(300, 30, "ede-panel") { box(FL_UP_BOX); read_config(); + + hider = new Hider(); + add(hider); } void Panel::read_config(void) { @@ -261,7 +266,7 @@ void Panel::save_config(void) { } void Panel::do_layout(void) { - E_RETURN_IF_FAIL(mgr.napplets() > 0); + E_RETURN_IF_FAIL(children() > 0); Fl_Widget *o; unsigned long opts; @@ -276,6 +281,12 @@ void Panel::do_layout(void) { /* first center it vertically */ center_widget_h(o, this); + /* manage hider specifically */ + if(hider && o == hider) { + right.push_back(o); + continue; + } + /* could be slow, but I'm relaying how number of loaded applets will not be that large */ if(!mgr.get_applet_options(o, opts)) { /* here are put widgets not loaded as applets */ @@ -500,7 +511,6 @@ void Panel::load_applets(void) { "start_menu.so", "quick_launch.so", "pager.so", - "hider.so", "clock.so", "taskbar.so", "keyboard_layout.so", @@ -524,10 +534,9 @@ void Panel::load_applets(void) { mgr.fill_group(this); #else - mgr.load("./applets/start-menu/start_menu.so"); mgr.load("./applets/quick-launch/quick_launch.so"); + mgr.load("./applets/start-menu/start_menu.so"); mgr.load("./applets/pager/pager.so"); - mgr.load("./applets/hider/hider.so"); mgr.load("./applets/clock/clock.so"); mgr.load("./applets/taskbar/taskbar.so"); mgr.load("./applets/keyboard-layout/keyboard_layout.so"); diff --git a/ede-panel/Panel.h b/ede-panel/Panel.h index 994efd5..04aaec0 100644 --- a/ede-panel/Panel.h +++ b/ede-panel/Panel.h @@ -34,9 +34,13 @@ enum { PANEL_POSITION_BOTTOM }; +class Hider; + class Panel : public PanelWindow { private: Fl_Widget *clicked; + Hider *hider; + int vpos; int sx, sy; int screen_x, screen_y, screen_w, screen_h, screen_h_half; diff --git a/ede-panel/applets/Jamfile b/ede-panel/applets/Jamfile index 6d8dbe2..07cdb8f 100644 --- a/ede-panel/applets/Jamfile +++ b/ede-panel/applets/Jamfile @@ -13,7 +13,6 @@ SubDir TOP ede-panel applets ; # SubInclude TOP ede-panel applets demo ; SubInclude TOP ede-panel applets clock ; SubInclude TOP ede-panel applets cpu-monitor ; -SubInclude TOP ede-panel applets hider ; SubInclude TOP ede-panel applets mem-monitor ; SubInclude TOP ede-panel applets keyboard-layout ; SubInclude TOP ede-panel applets pager ; diff --git a/ede-panel/applets/hider/Jamfile b/ede-panel/applets/hider/Jamfile deleted file mode 100644 index 258fbc1..0000000 --- a/ede-panel/applets/hider/Jamfile +++ /dev/null @@ -1,13 +0,0 @@ -# -# $Id: Jamfile 2864 2009-10-03 07:49:30Z karijes $ -# -# Part of Equinox Desktop Environment (EDE). -# Copyright (c) 2012 EDE Authors. -# -# This program is licensed under terms of the -# GNU General Public License version 2 or newer. -# See COPYING for details. - -SubDir TOP ede-panel applets hider ; - -PanelApplet hider : Hider.cpp ; diff --git a/ede-panel/applets/system-tray/Tray.cpp b/ede-panel/applets/system-tray/Tray.cpp index 1fbe885..f80ebf6 100644 --- a/ede-panel/applets/system-tray/Tray.cpp +++ b/ede-panel/applets/system-tray/Tray.cpp @@ -68,7 +68,6 @@ static int validate_drawable(Display *d, Window xid) { } Tray::Tray() : Fl_Group(0, 0, 1, 25), opcode(0) { - //color(FL_RED); box(FL_FLAT_BOX); register_notification_area(); } diff --git a/ede-panel/applets/taskbar/Taskbar.cpp b/ede-panel/applets/taskbar/Taskbar.cpp index 5e3e073..163c669 100644 --- a/ede-panel/applets/taskbar/Taskbar.cpp +++ b/ede-panel/applets/taskbar/Taskbar.cpp @@ -103,6 +103,9 @@ static void net_event_cb(int action, Window xid, void *data) { Taskbar::Taskbar() : Fl_Group(0, 0, 40, 25), curr_active(NULL), prev_active(NULL) { end(); + //box(FL_FLAT_BOX); + //color(FL_RED); + fixed_layout = false; ignore_workspace_value = false; @@ -227,8 +230,7 @@ void Taskbar::resize(int X, int Y, int W, int H) { } void Taskbar::layout_children(void) { - if(!children()) - return; + if(!children()) return; Fl_Widget *o; int X, Y, W, reduce = 0, sz = 0, all_buttons_w = 0; @@ -252,11 +254,7 @@ void Taskbar::layout_children(void) { all_buttons_w += DEFAULT_SPACING; } - /* - * find reduction size - * TODO: due large number of childs, 'reduce' could be bigger than child - * width, yielding drawing issues on borders - */ + /* find reduction size */ if(all_buttons_w > W) reduce = (all_buttons_w - W) / sz; @@ -265,11 +263,12 @@ void Taskbar::layout_children(void) { o = child(i); if(!o->visible()) continue; - o->resize(X, Y, o->w() - reduce, o->h()); - X += o->w(); - - if(i != children() - 1) - X += DEFAULT_SPACING; + /* + * 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()); + X += o->w() + DEFAULT_SPACING; } }