From 6529e02a7dfd61d28d1d15c541478da1763158d9 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Mon, 18 Jun 2007 16:46:27 +0000 Subject: [PATCH] NotifyBox added. Still needs work. --- eiconman/Jamfile | 2 +- eiconman/NotifyBox.cpp | 102 +++++++++++++++++++++++++++++++++++++++++ eiconman/NotifyBox.h | 46 +++++++++++++++++++ eiconman/eiconman.cpp | 19 +++++++- eiconman/eiconman.h | 4 ++ 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 eiconman/NotifyBox.cpp create mode 100644 eiconman/NotifyBox.h diff --git a/eiconman/Jamfile b/eiconman/Jamfile index 1a04e0b..af1e036 100644 --- a/eiconman/Jamfile +++ b/eiconman/Jamfile @@ -4,4 +4,4 @@ LINKLIBS += -L/opt/ede/lib -ledelib -lao -lvorbis -lvorbisfile -lmad -L/usr/loca C++FLAGS += -Wall -g3 -I/opt/ede/include ; -Main eiconman : eiconman.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp ; +Main eiconman : eiconman.cpp Utils.cpp Wallpaper.cpp DesktopIcon.cpp NotifyBox.cpp ; diff --git a/eiconman/NotifyBox.cpp b/eiconman/NotifyBox.cpp new file mode 100644 index 0000000..1a8533c --- /dev/null +++ b/eiconman/NotifyBox.cpp @@ -0,0 +1,102 @@ +/* + * $Id$ + * + * Eiconman, desktop and icon manager + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2000-2007 EDE Authors. + * + * This program is licensed under terms of the + * GNU General Public License version 2 or newer. + * See COPYING for details. + */ + +#include "NotifyBox.h" +#include "eiconman.h" +#include + +#include +#include +#include + +#define MAX_LABEL_WIDTH 100 + +NotifyBox::NotifyBox() : Fl_Box(0, 0, 0, 0) { + lwidth = lheight = 0; + is_shown = false; + in_animate = false; + box(FL_FLAT_BOX); + color(FL_RED); + align(FL_ALIGN_WRAP); +} + +NotifyBox::~NotifyBox() { + EDEBUG("NotifyBox::~NotifyBox()\n"); +} + +void NotifyBox::update_label_size(void) { + lwidth = MAX_LABEL_WIDTH; + lheight= 0; + fl_font(labelfont(), labelsize()); + + fl_measure(label(), lwidth, lheight, align()); + + lwidth += 10; + lheight += 10; +} + +void NotifyBox::show(void) { + update_label_size(); + resize(x(), y()-lheight, lwidth, lheight); + + EDEBUG("%i %i\n", w(), h()); + + Fl_Box::show(); + + if(!in_animate && !is_shown) + Fl::add_timeout(TIMEOUT, animate_show_cb, this); +} + +void NotifyBox::hide(void) { + if(!in_animate && is_shown) + Fl::add_timeout(TIMEOUT, animate_hide_cb, this); + + Fl_Box::hide(); +} + +void NotifyBox::animate_show(void) { + if(y() < 0) { + position(x(), y() + 1); + EDEBUG("y: %i\n", y()); + redraw(); + Fl::repeat_timeout(TIMEOUT, animate_show_cb, this); + in_animate = true; + } else { + Fl::remove_timeout(animate_show_cb); + in_animate = false; + is_shown = true; + + // add visibility timeout + Fl::add_timeout(TIME_SHOWN, visible_timeout_cb, this); + } +} + +void NotifyBox::animate_hide(void) { + if(y() > -lheight) { + position(x(), y() - 1); + redraw(); + Desktop::instance()->redraw(); + Fl::repeat_timeout(TIMEOUT, animate_hide_cb, this); + in_animate = true; + } else { + Fl::remove_timeout(animate_hide_cb); + Fl::remove_timeout(visible_timeout_cb); + in_animate = false; + is_shown = false; + EDEBUG("!!!!!!!!!!!!!!!!!\n"); + } +} + +void NotifyBox::visible_timeout(void) { + EDEBUG("XXXXXXXXXXXXXXXXX\n"); + animate_hide(); +} diff --git a/eiconman/NotifyBox.h b/eiconman/NotifyBox.h new file mode 100644 index 0000000..84ac059 --- /dev/null +++ b/eiconman/NotifyBox.h @@ -0,0 +1,46 @@ +/* + * $Id$ + * + * Eiconman, desktop and icon manager + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2000-2007 EDE Authors. + * + * This program is licensed under terms of the + * GNU General Public License version 2 or newer. + * See COPYING for details. + */ + +#ifndef __NOTIFYBOX_H__ +#define __NOTIFYBOX_H__ + +#include + +#define TIMEOUT (1.0f/60.0f) +#define TIME_SHOWN 3.0f + +class NotifyBox : public Fl_Box { + private: + bool is_shown; + bool in_animate; + int lwidth, lheight; + void update_label_size(void); + + public: + NotifyBox(); + ~NotifyBox(); + + virtual void show(void); + virtual void hide(void); + bool shown(void) { return is_shown; } + + static void animate_show_cb(void* b) { ((NotifyBox*)b)->animate_show(); } + void animate_show(void); + + static void animate_hide_cb(void* b) { ((NotifyBox*)b)->animate_hide(); } + void animate_hide(void); + + static void visible_timeout_cb(void* b) { ((NotifyBox*)b)->visible_timeout(); } + void visible_timeout(void); +}; + +#endif diff --git a/eiconman/eiconman.cpp b/eiconman/eiconman.cpp index 0e9620a..1df00b9 100644 --- a/eiconman/eiconman.cpp +++ b/eiconman/eiconman.cpp @@ -14,6 +14,7 @@ #include "DesktopIcon.h" #include "Utils.h" #include "Wallpaper.h" +#include "NotifyBox.h" #include #include @@ -90,6 +91,8 @@ Desktop::Desktop() : Fl_Window(0, 0, 100, 100, "") { begin(); wallpaper = new Wallpaper(0, 0, w(), h()); //wallpaper->set_tiled("/home/sanel/wallpapers/katesmall.jpg"); + notify = new NotifyBox(); + notify->hide(); end(); read_config(); @@ -505,6 +508,14 @@ DesktopIcon* Desktop::below_mouse(int px, int py) { } #endif +void Desktop::notify_box(const char* msg) { + if(notify->shown()) + notify->hide(); + + notify->label(msg); + notify->show(); +} + int Desktop::handle(int event) { switch(event) { case FL_FOCUS: @@ -548,10 +559,14 @@ int Desktop::handle(int event) { select(tmp_icon); return 1; } else if(SELECTION_SINGLE) { - if(!in_selection(tmp_icon)) + if(!in_selection(tmp_icon)) { + notify_box(tmp_icon->label()); select_only(tmp_icon); - } else if(Fl::event_button() == 3) + } + } else if(Fl::event_button() == 3) { select_only(tmp_icon); + notify_box(tmp_icon->label()); + } /* * Let child handle the rest. diff --git a/eiconman/eiconman.h b/eiconman/eiconman.h index ca227aa..4ed3a54 100644 --- a/eiconman/eiconman.h +++ b/eiconman/eiconman.h @@ -66,6 +66,7 @@ struct IconSettings { class Wallpaper; class DesktopIcon; +class NotifyBox; typedef edelib::vector DesktopIconList; @@ -80,6 +81,7 @@ class Desktop : public Fl_Window { DesktopSettings* dsett; Wallpaper* wallpaper; + NotifyBox* notify; DesktopIconList icons; DesktopIconList selectionbuff; @@ -116,6 +118,8 @@ class Desktop : public Fl_Window { void update_workarea(void); void set_bg_color(int c, bool do_redraw = true); + void notify_box(const char* msg); + Fl_Window* desktop_window(void) { return this; } };