mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
NotifyBox is now window... to simplify a bunch of things.
This commit is contained in:
parent
2bb9e5dc4c
commit
cbc6571b77
@ -23,20 +23,21 @@
|
|||||||
#define TIMEOUT (1.0f/60.0f)
|
#define TIMEOUT (1.0f/60.0f)
|
||||||
#define TIME_SHOWN 3.0f
|
#define TIME_SHOWN 3.0f
|
||||||
|
|
||||||
#define STATE_SHOWING 1
|
NotifyBox::NotifyBox(int aw, int ah) : Fl_Window(0, 0, 10, 10) {
|
||||||
#define STATE_HIDING 2
|
|
||||||
#define STATE_DONE 3
|
|
||||||
|
|
||||||
NotifyBox::NotifyBox(int aw, int ah) : Fl_Box(0, 0, 0, 0) {
|
|
||||||
area_w = aw;
|
area_w = aw;
|
||||||
area_h = ah;
|
area_h = ah;
|
||||||
lwidth = lheight = 0;
|
lwidth = lheight = 0;
|
||||||
is_shown = false;
|
is_shown = false;
|
||||||
state = 0;
|
|
||||||
|
|
||||||
box(FL_BORDER_BOX);
|
clear_border();
|
||||||
color(FL_WHITE);
|
set_non_modal();
|
||||||
align(FL_ALIGN_WRAP);
|
|
||||||
|
begin();
|
||||||
|
txt_box = new Fl_Box(0, 0, w(), h());
|
||||||
|
txt_box->box(FL_BORDER_BOX);
|
||||||
|
txt_box->color(FL_WHITE);
|
||||||
|
txt_box->align(FL_ALIGN_WRAP);
|
||||||
|
end();
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyBox::~NotifyBox() {
|
NotifyBox::~NotifyBox() {
|
||||||
@ -47,89 +48,67 @@ void NotifyBox::update_label_size(void) {
|
|||||||
lwidth = MAX_LABEL_WIDTH;
|
lwidth = MAX_LABEL_WIDTH;
|
||||||
lheight= 0;
|
lheight= 0;
|
||||||
|
|
||||||
fl_font(labelfont(), labelsize());
|
fl_font(txt_box->labelfont(), txt_box->labelsize());
|
||||||
fl_measure(label(), lwidth, lheight, align());
|
fl_measure(txt_box->label(), lwidth, lheight, txt_box->align());
|
||||||
|
|
||||||
lwidth += 10;
|
lwidth += 10;
|
||||||
lheight += 10;
|
lheight += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyBox::resize_all(void) {
|
||||||
|
update_label_size();
|
||||||
|
|
||||||
|
// center box
|
||||||
|
int x_pos = (area_w/2) - (lwidth/2);
|
||||||
|
resize(x_pos, 0, lwidth, lheight);
|
||||||
|
txt_box->resize(0, 0, w(), h());
|
||||||
|
}
|
||||||
|
|
||||||
void NotifyBox::show(void) {
|
void NotifyBox::show(void) {
|
||||||
if(shown())
|
if(shown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(state == STATE_HIDING)
|
EDEBUG(ESTRLOC ": %i %i\n", x(), y());
|
||||||
return;
|
resize_all();
|
||||||
|
|
||||||
update_label_size();
|
Fl_Window::show();
|
||||||
|
is_shown = true;
|
||||||
// center box
|
Fl::add_timeout(TIME_SHOWN, visible_timeout_cb, this);
|
||||||
int x_pos = (area_w/2) - (lwidth/2);
|
|
||||||
resize(x_pos, y() - lheight, lwidth, lheight);
|
|
||||||
|
|
||||||
Fl_Box::show();
|
|
||||||
|
|
||||||
state = STATE_SHOWING;
|
|
||||||
Fl::add_timeout(TIMEOUT, animate_cb, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBox::hide(void) {
|
void NotifyBox::hide(void) {
|
||||||
if(!shown())
|
if(!shown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// explicitely remove timer when hide() is called
|
Fl_Window::hide();
|
||||||
Fl::remove_timeout(animate_cb);
|
|
||||||
|
|
||||||
Fl_Box::hide();
|
|
||||||
is_shown = false;
|
is_shown = false;
|
||||||
state = 0;
|
Fl::remove_timeout(visible_timeout_cb);
|
||||||
|
Fl::remove_timeout(animate_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBox::label(const char* l) {
|
void NotifyBox::label(const char* l) {
|
||||||
Fl_Box::label(l);
|
txt_box->label(l);
|
||||||
|
resize_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBox::copy_label(const char* l) {
|
void NotifyBox::copy_label(const char* l) {
|
||||||
Fl_Box::copy_label(l);
|
txt_box->copy_label(l);
|
||||||
|
resize_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* NotifyBox::label(void) {
|
const char* NotifyBox::label(void) {
|
||||||
return Fl_Box::label();
|
return txt_box->label();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBox::animate(void) {
|
void NotifyBox::animate(void) {
|
||||||
if(state == STATE_SHOWING) {
|
if(y() > -lheight) {
|
||||||
if(y() < 0) {
|
position(x(), y() - 1);
|
||||||
position(x(), y() + 1);
|
Fl::repeat_timeout(TIMEOUT, animate_cb, this);
|
||||||
redraw();
|
} else
|
||||||
//EDEBUG("SHOWING...\n");
|
hide();
|
||||||
Fl::repeat_timeout(TIMEOUT, animate_cb, this);
|
|
||||||
state = STATE_SHOWING;
|
|
||||||
} else {
|
|
||||||
state = STATE_DONE;
|
|
||||||
is_shown = true;
|
|
||||||
|
|
||||||
// now set visible timeout, which will procede to hiding()
|
|
||||||
visible_timeout();
|
|
||||||
}
|
|
||||||
} else if(state == STATE_HIDING) {
|
|
||||||
if(y() > -lheight) {
|
|
||||||
position(x(), y() - 1);
|
|
||||||
//redraw();
|
|
||||||
//EDEBUG("%i %i\n", x(), y());
|
|
||||||
// this will prevent redrawing whole screen
|
|
||||||
Desktop::instance()->damage(FL_DAMAGE_ALL, x(), 0, w(), h());
|
|
||||||
|
|
||||||
//EDEBUG("HIDING...\n");
|
|
||||||
Fl::repeat_timeout(TIMEOUT, animate_cb, this);
|
|
||||||
} else {
|
|
||||||
state = STATE_DONE;
|
|
||||||
is_shown = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyBox::visible_timeout(void) {
|
void NotifyBox::visible_timeout(void) {
|
||||||
state = STATE_HIDING;
|
Fl::remove_timeout(visible_timeout_cb);
|
||||||
Fl::repeat_timeout(TIME_SHOWN, animate_cb, this);
|
Fl::add_timeout(TIMEOUT, animate_cb, this);
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,16 @@
|
|||||||
#define __NOTIFYBOX_H__
|
#define __NOTIFYBOX_H__
|
||||||
|
|
||||||
#include <FL/Fl_Box.h>
|
#include <FL/Fl_Box.h>
|
||||||
|
#include <FL/Fl_Window.h>
|
||||||
|
|
||||||
class NotifyBox : public Fl_Box {
|
class NotifyBox : public Fl_Window {
|
||||||
private:
|
private:
|
||||||
bool is_shown;
|
bool is_shown;
|
||||||
int state;
|
|
||||||
int lwidth, lheight;
|
int lwidth, lheight;
|
||||||
int area_w, area_h;
|
int area_w, area_h;
|
||||||
|
Fl_Box* txt_box;
|
||||||
void update_label_size(void);
|
void update_label_size(void);
|
||||||
|
void resize_all(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NotifyBox(int aw, int ah);
|
NotifyBox(int aw, int ah);
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
* Which widgets Fl::belowmouse() should skip. This should be updated
|
* Which widgets Fl::belowmouse() should skip. This should be updated
|
||||||
* when new non-icon child is added to Desktop window.
|
* when new non-icon child is added to Desktop window.
|
||||||
*/
|
*/
|
||||||
#define NOT_SELECTABLE(widget) ((widget == this) || (widget == wallpaper) || (widget == notify))
|
#define NOT_SELECTABLE(widget) ((widget == this) || (widget == wallpaper))
|
||||||
|
|
||||||
Desktop* Desktop::pinstance = NULL;
|
Desktop* Desktop::pinstance = NULL;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
@ -134,10 +134,10 @@ Desktop::Desktop() : DESKTOP_WINDOW(0, 0, 100, 100, "") {
|
|||||||
//wallpaper->hide();
|
//wallpaper->hide();
|
||||||
wallpaper->set("/home/sanelz/walls/nin/1024x768-04.jpg");
|
wallpaper->set("/home/sanelz/walls/nin/1024x768-04.jpg");
|
||||||
//wallpaper->set("/home/sanelz/walls/nin/1024x768-02.jpg");
|
//wallpaper->set("/home/sanelz/walls/nin/1024x768-02.jpg");
|
||||||
notify = new NotifyBox(w(), h());
|
|
||||||
notify->hide();
|
|
||||||
end();
|
end();
|
||||||
|
|
||||||
|
notify = new NotifyBox(w(), h());
|
||||||
|
|
||||||
read_config();
|
read_config();
|
||||||
|
|
||||||
set_bg_color(dsett->color, false);
|
set_bg_color(dsett->color, false);
|
||||||
@ -149,6 +149,7 @@ Desktop::~Desktop() {
|
|||||||
|
|
||||||
delete dsett;
|
delete dsett;
|
||||||
delete selbox;
|
delete selbox;
|
||||||
|
delete notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Desktop::init(void) {
|
void Desktop::init(void) {
|
||||||
@ -414,7 +415,6 @@ void Desktop::add_icon(DesktopIcon* ic) {
|
|||||||
EASSERT(ic != NULL);
|
EASSERT(ic != NULL);
|
||||||
|
|
||||||
icons.push_back(ic);
|
icons.push_back(ic);
|
||||||
// FIXME: validate this
|
|
||||||
add((Fl_Widget*)ic);
|
add((Fl_Widget*)ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +587,8 @@ void Desktop::notify_box(const char* msg, bool copy) {
|
|||||||
else
|
else
|
||||||
notify->label(msg);
|
notify->label(msg);
|
||||||
|
|
||||||
notify->show();
|
if(!notify->shown())
|
||||||
|
notify->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Desktop::notify_box_color(Fl_Color col) {
|
void Desktop::notify_box_color(Fl_Color col) {
|
||||||
|
Loading…
Reference in New Issue
Block a user