fullscreen test app: prevent combination of fullscreen + maximize
Also, use more explicit button names
This commit is contained in:
parent
94f471b701
commit
af5b2cf464
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Copyright 1998-2024 by Bill Spitzak and others.
|
// Copyright 1998-2025 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@ -121,43 +121,31 @@ void shape_window::draw() {
|
|||||||
|
|
||||||
class fullscreen_window : public Fl_Single_Window {
|
class fullscreen_window : public Fl_Single_Window {
|
||||||
public:
|
public:
|
||||||
fullscreen_window(int W, int H, const char *t=0);
|
fullscreen_window(int W, int H, const char *t=0) : Fl_Single_Window(W, H, t) {}
|
||||||
int handle (int e) FL_OVERRIDE;
|
|
||||||
void resize(int x, int y, int w, int h) FL_OVERRIDE;
|
void resize(int x, int y, int w, int h) FL_OVERRIDE;
|
||||||
Fl_Toggle_Light_Button *b3_maxi;
|
Fl_Toggle_Light_Button *border_button;
|
||||||
Fl_Toggle_Light_Button *b3;
|
Fl_Toggle_Light_Button *maximize_button;
|
||||||
Fl_Toggle_Light_Button *b4;
|
Fl_Toggle_Light_Button *fullscreen_button;
|
||||||
|
Fl_Toggle_Light_Button *allscreens_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
fullscreen_window::fullscreen_window(int W, int H, const char *t) : Fl_Single_Window(W, H, t) {
|
|
||||||
|
|
||||||
|
void after_resize(fullscreen_window *win) {
|
||||||
|
if (win->maximize_active()) win->maximize_button->set();
|
||||||
|
else win->maximize_button->clear();
|
||||||
|
win->maximize_button->redraw();
|
||||||
|
if (win->fullscreen_active()) win->fullscreen_button->set();
|
||||||
|
else win->fullscreen_button->clear();
|
||||||
|
win->fullscreen_button->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void after_resize(void *data) {
|
|
||||||
Fl::remove_check(after_resize, data);
|
|
||||||
fullscreen_window *win = (fullscreen_window*)data;
|
|
||||||
if (win->maximize_active()) win->b3_maxi->set();
|
|
||||||
else win->b3_maxi->clear();
|
|
||||||
win->b3_maxi->redraw();
|
|
||||||
if (win->fullscreen_active()) win->b3->set();
|
|
||||||
else win->b3->clear();
|
|
||||||
win->b3->redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fullscreen_window::resize(int x, int y, int w, int h) {
|
void fullscreen_window::resize(int x, int y, int w, int h) {
|
||||||
Fl_Single_Window::resize(x,y,w,h);
|
Fl_Single_Window::resize(x,y,w,h);
|
||||||
Fl::add_check(after_resize, this);
|
Fl::add_timeout(0, (Fl_Timeout_Handler)after_resize, this);
|
||||||
};
|
|
||||||
|
|
||||||
int fullscreen_window::handle(int e) {
|
|
||||||
if (e == FL_FULLSCREEN) {
|
|
||||||
// fprintf(stderr, "Received FL_FULLSCREEN event\n");
|
|
||||||
b3->value(fullscreen_active());
|
|
||||||
}
|
|
||||||
if (Fl_Single_Window::handle(e)) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sides_cb(Fl_Widget *o, void *p) {
|
void sides_cb(Fl_Widget *o, void *p) {
|
||||||
shape_window *sw = (shape_window *)p;
|
shape_window *sw = (shape_window *)p;
|
||||||
sw->sides = int(((Fl_Slider *)o)->value());
|
sw->sides = int(((Fl_Slider *)o)->value());
|
||||||
@ -184,25 +172,25 @@ void border_cb(Fl_Button *b, Fl_Window *w) {
|
|||||||
|
|
||||||
|
|
||||||
void maximize_cb(Fl_Button *b, Fl_Window *w) {
|
void maximize_cb(Fl_Button *b, Fl_Window *w) {
|
||||||
|
if (w->fullscreen_active()) {
|
||||||
|
b->value(1 - b->value());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (w->maximize_active()) {
|
if (w->maximize_active()) {
|
||||||
w->un_maximize();
|
w->un_maximize();
|
||||||
if (w->maximize_active()) b->set();
|
|
||||||
} else {
|
} else {
|
||||||
w->maximize();
|
w->maximize();
|
||||||
if (!w->maximize_active()) b->clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Fl_Button *border_button;
|
void fullscreen_cb(Fl_Button *b, Fl_Window *w) {
|
||||||
void fullscreen_cb(Fl_Widget *o, void *p) {
|
if (w->maximize_active()) {
|
||||||
Fl_Window *w = (Fl_Window *)p;
|
b->value(1 - b->value());
|
||||||
int d = ((Fl_Button *)o)->value();
|
return;
|
||||||
if (d) {
|
}
|
||||||
|
if (b->value()) {
|
||||||
w->fullscreen();
|
w->fullscreen();
|
||||||
#ifndef _WIN32 // update our border state in case border was turned off
|
|
||||||
border_button->value(w->border());
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
w->fullscreen_off();
|
w->fullscreen_off();
|
||||||
}
|
}
|
||||||
@ -307,7 +295,7 @@ int main(int argc, char **argv) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Fl_Window *w;
|
Fl_Window *w;
|
||||||
if (twowindow) { // make it's own window
|
if (twowindow) { // make its own window
|
||||||
sw.resizable(&sw);
|
sw.resizable(&sw);
|
||||||
w = &sw;
|
w = &sw;
|
||||||
window.set_modal(); // makes controls stay on top when fullscreen pushed
|
window.set_modal(); // makes controls stay on top when fullscreen pushed
|
||||||
@ -337,22 +325,21 @@ int main(int argc, char **argv) {
|
|||||||
Fl_Input i1(50,y,window.w()-60,30, "Input");
|
Fl_Input i1(50,y,window.w()-60,30, "Input");
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
Fl_Toggle_Light_Button b2(50,y,window.w()-60,30,"Border");
|
window.border_button = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"Border");
|
||||||
b2.callback((Fl_Callback*)border_cb,w);
|
window.border_button->callback((Fl_Callback*)border_cb,w);
|
||||||
b2.set();
|
window.border_button->set();
|
||||||
border_button = &b2;
|
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
window.b3 = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"FullScreen");
|
window.fullscreen_button = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"FullScreen");
|
||||||
window.b3->callback(fullscreen_cb,w);
|
window.fullscreen_button->callback((Fl_Callback*)fullscreen_cb,w);
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
window.b3_maxi = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"Maximize");
|
window.maximize_button = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"Maximize");
|
||||||
window.b3_maxi->callback((Fl_Callback*)maximize_cb,w);
|
window.maximize_button->callback((Fl_Callback*)maximize_cb,w);
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
window.b4 = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"All Screens");
|
window.allscreens_button = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"All Screens");
|
||||||
window.b4->callback(allscreens_cb,w);
|
window.allscreens_button->callback(allscreens_cb,w);
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
Fl_Button eb(50,y,window.w()-60,30,"Exit");
|
Fl_Button eb(50,y,window.w()-60,30,"Exit");
|
||||||
@ -367,7 +354,7 @@ int main(int argc, char **argv) {
|
|||||||
update.callback(update_screeninfo, browser);
|
update.callback(update_screeninfo, browser);
|
||||||
y+=30;
|
y+=30;
|
||||||
|
|
||||||
if (initfull) {window.b3->set(); window.b3->do_callback();}
|
if (initfull) {window.fullscreen_button->set(); window.fullscreen_button->do_callback();}
|
||||||
|
|
||||||
window.end();
|
window.end();
|
||||||
window.show(argc,argv);
|
window.show(argc,argv);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user