mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
NotifyBox added. Still needs work.
This commit is contained in:
parent
202b4ffb29
commit
6529e02a7d
@ -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 ;
|
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 ;
|
||||||
|
102
eiconman/NotifyBox.cpp
Normal file
102
eiconman/NotifyBox.cpp
Normal file
@ -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 <edelib/Debug.h>
|
||||||
|
|
||||||
|
#include <FL/Fl.h>
|
||||||
|
#include <FL/fl_draw.h>
|
||||||
|
#include <FL/Fl_Group.h>
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
46
eiconman/NotifyBox.h
Normal file
46
eiconman/NotifyBox.h
Normal file
@ -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 <FL/Fl_Box.h>
|
||||||
|
|
||||||
|
#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
|
@ -14,6 +14,7 @@
|
|||||||
#include "DesktopIcon.h"
|
#include "DesktopIcon.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Wallpaper.h"
|
#include "Wallpaper.h"
|
||||||
|
#include "NotifyBox.h"
|
||||||
|
|
||||||
#include <edelib/Debug.h>
|
#include <edelib/Debug.h>
|
||||||
#include <edelib/File.h>
|
#include <edelib/File.h>
|
||||||
@ -90,6 +91,8 @@ Desktop::Desktop() : Fl_Window(0, 0, 100, 100, "") {
|
|||||||
begin();
|
begin();
|
||||||
wallpaper = new Wallpaper(0, 0, w(), h());
|
wallpaper = new Wallpaper(0, 0, w(), h());
|
||||||
//wallpaper->set_tiled("/home/sanel/wallpapers/katesmall.jpg");
|
//wallpaper->set_tiled("/home/sanel/wallpapers/katesmall.jpg");
|
||||||
|
notify = new NotifyBox();
|
||||||
|
notify->hide();
|
||||||
end();
|
end();
|
||||||
|
|
||||||
read_config();
|
read_config();
|
||||||
@ -505,6 +508,14 @@ DesktopIcon* Desktop::below_mouse(int px, int py) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Desktop::notify_box(const char* msg) {
|
||||||
|
if(notify->shown())
|
||||||
|
notify->hide();
|
||||||
|
|
||||||
|
notify->label(msg);
|
||||||
|
notify->show();
|
||||||
|
}
|
||||||
|
|
||||||
int Desktop::handle(int event) {
|
int Desktop::handle(int event) {
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case FL_FOCUS:
|
case FL_FOCUS:
|
||||||
@ -548,10 +559,14 @@ int Desktop::handle(int event) {
|
|||||||
select(tmp_icon);
|
select(tmp_icon);
|
||||||
return 1;
|
return 1;
|
||||||
} else if(SELECTION_SINGLE) {
|
} else if(SELECTION_SINGLE) {
|
||||||
if(!in_selection(tmp_icon))
|
if(!in_selection(tmp_icon)) {
|
||||||
|
notify_box(tmp_icon->label());
|
||||||
select_only(tmp_icon);
|
select_only(tmp_icon);
|
||||||
} else if(Fl::event_button() == 3)
|
}
|
||||||
|
} else if(Fl::event_button() == 3) {
|
||||||
select_only(tmp_icon);
|
select_only(tmp_icon);
|
||||||
|
notify_box(tmp_icon->label());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let child handle the rest.
|
* Let child handle the rest.
|
||||||
|
@ -66,6 +66,7 @@ struct IconSettings {
|
|||||||
|
|
||||||
class Wallpaper;
|
class Wallpaper;
|
||||||
class DesktopIcon;
|
class DesktopIcon;
|
||||||
|
class NotifyBox;
|
||||||
|
|
||||||
typedef edelib::vector<DesktopIcon*> DesktopIconList;
|
typedef edelib::vector<DesktopIcon*> DesktopIconList;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ class Desktop : public Fl_Window {
|
|||||||
DesktopSettings* dsett;
|
DesktopSettings* dsett;
|
||||||
|
|
||||||
Wallpaper* wallpaper;
|
Wallpaper* wallpaper;
|
||||||
|
NotifyBox* notify;
|
||||||
|
|
||||||
DesktopIconList icons;
|
DesktopIconList icons;
|
||||||
DesktopIconList selectionbuff;
|
DesktopIconList selectionbuff;
|
||||||
@ -116,6 +118,8 @@ class Desktop : public Fl_Window {
|
|||||||
void update_workarea(void);
|
void update_workarea(void);
|
||||||
void set_bg_color(int c, bool do_redraw = true);
|
void set_bg_color(int c, bool do_redraw = true);
|
||||||
|
|
||||||
|
void notify_box(const char* msg);
|
||||||
|
|
||||||
Fl_Window* desktop_window(void) { return this; }
|
Fl_Window* desktop_window(void) { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user