summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-11-02 17:45:30 +0100
committerMatthias Melcher <github@matthiasm.com>2023-11-02 17:45:36 +0100
commit7c6266f67ef12f24e165fcb975b134dd867b2d45 (patch)
tree69109d9737cd62550b2dc9f10074604d62695344
parent9ca4aed1fa13df227ddebe4fed4353d9156ab414 (diff)
FLUID: Simplifies and improves Ghosted Outlines
-rw-r--r--fluid/Fl_Grid_Type.cxx15
-rw-r--r--fluid/Fl_Group_Type.cxx65
-rw-r--r--fluid/Fl_Window_Type.cxx18
-rw-r--r--fluid/alignment_panel.cxx2
-rw-r--r--fluid/alignment_panel.fl6
5 files changed, 35 insertions, 71 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx
index aca608aa5..dca886153 100644
--- a/fluid/Fl_Grid_Type.cxx
+++ b/fluid/Fl_Grid_Type.cxx
@@ -53,19 +53,10 @@ void Fl_Grid_Proxy::resize(int X, int Y, int W, int H) {
Override draw() to make groups with no box or flat box background visible.
*/
void Fl_Grid_Proxy::draw() {
- if (show_ghosted_outline) {
- if (!box()) {
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- Fl_Grid::draw();
- } else if (box() == FL_FLAT_BOX && parent() && parent()->color() == color()) {
- Fl_Grid::draw();
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- } else {
- Fl_Grid::draw();
- }
- } else {
- Fl_Grid::draw();
+ if (show_ghosted_outline && (box() == FL_NO_BOX)) {
+ fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
}
+ Fl_Grid::draw();
}
/**
diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx
index d42965554..5651aac86 100644
--- a/fluid/Fl_Group_Type.cxx
+++ b/fluid/Fl_Group_Type.cxx
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
+
// ---- Fl_Group_Type -------------------------------------------------- MARK: -
Fl_Group_Type Fl_Group_type; // the "factory"
@@ -59,23 +60,10 @@ void Fl_Group_Proxy::resize(int X, int Y, int W, int H) {
Override draw() to make groups with no box or flat box background visible.
*/
void Fl_Group_Proxy::draw() {
- if (show_ghosted_outline) {
- // it would be nice to check if the parent is Fl_Tabs, because the parent
- // would then draw the outline... .
- if (!box()) {
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- Fl_Group::draw();
- } else if (box() == FL_FLAT_BOX && parent() && parent()->color() == color()) {
- // FIXME: the rect will be drawn over the children. Instead, change the
- // draw function for the FL_FLAT_BOX boxtype only while the group is drawn.
- Fl_Group::draw();
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- } else {
- Fl_Group::draw();
- }
- } else {
- Fl_Group::draw();
+ if (show_ghosted_outline && (box() == FL_NO_BOX)) {
+ fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
}
+ Fl_Group::draw();
}
@@ -279,19 +267,10 @@ void Fl_Flex_Proxy::resize(int X, int Y, int W, int H) {
Override draw() to make groups with no box or flat box background visible.
*/
void Fl_Flex_Proxy::draw() {
- if (show_ghosted_outline) {
- if (!box()) {
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- Fl_Flex::draw();
- } else if (box() == FL_FLAT_BOX && parent() && parent()->color() == color()) {
- Fl_Flex::draw();
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- } else {
- Fl_Flex::draw();
- }
- } else {
- Fl_Flex::draw();
+ if (show_ghosted_outline && (box() == FL_NO_BOX)) {
+ fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
}
+ Fl_Flex::draw();
}
Fl_Widget *Fl_Flex_Type::enter_live_mode(int) {
@@ -704,19 +683,10 @@ void Fl_Tabs_Proxy::resize(int X, int Y, int W, int H) {
Override draw() to make groups with no box or flat box background visible.
*/
void Fl_Tabs_Proxy::draw() {
- if (show_ghosted_outline) {
- if (!box()) {
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- Fl_Tabs::draw();
- } else if (box() == FL_FLAT_BOX && parent() && parent()->color() == color()) {
- Fl_Tabs::draw();
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- } else {
- Fl_Tabs::draw();
- }
- } else {
- Fl_Tabs::draw();
+ if (show_ghosted_outline && (box() == FL_NO_BOX)) {
+ fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
}
+ Fl_Tabs::draw();
}
// This is called when user clicks on a widget in the window. See
@@ -817,18 +787,9 @@ void Fl_Wizard_Proxy::resize(int X, int Y, int W, int H) {
Override draw() to make groups with no box or flat box background visible.
*/
void Fl_Wizard_Proxy::draw() {
- if (show_ghosted_outline) {
- if (!box()) {
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- Fl_Wizard::draw();
- } else if (box() == FL_FLAT_BOX && parent() && parent()->color() == color()) {
- Fl_Wizard::draw();
- fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
- } else {
- Fl_Wizard::draw();
- }
- } else {
- Fl_Wizard::draw();
+ if (show_ghosted_outline && (box() == FL_NO_BOX)) {
+ fl_rect(x(), y(), w(), h(), Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, color(), .1f)));
}
+ Fl_Wizard::draw();
}
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index 451f4dbea..b20a3bf7e 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -141,6 +141,13 @@ void Overlay_Window::close_cb(Overlay_Window *self, void*) {
self->hide();
}
+// Use this when drawing flat boxes while editing, so users can see the outline,
+// even if the group and its parent have the same color.
+static void fd_flat_box_ghosted(int x, int y, int w, int h, Fl_Color c) {
+ fl_rectf(x, y, w, h, Fl::box_color(c));
+ fl_rect(x, y, w, h, Fl::box_color(fl_color_average(FL_FOREGROUND_COLOR, c, .1f)));
+}
+
void Overlay_Window::draw() {
const int CHECKSIZE = 8;
// see if box is clear or a frame or rounded:
@@ -154,7 +161,14 @@ void Overlay_Window::draw() {
fl_rectf(X,Y,CHECKSIZE,CHECKSIZE);
}
}
- Fl_Overlay_Window::draw();
+ if (show_ghosted_outline) {
+ Fl_Box_Draw_F *old_flat_box = Fl::get_boxtype(FL_FLAT_BOX);
+ Fl::set_boxtype(FL_FLAT_BOX, fd_flat_box_ghosted, 0, 0, 0, 0);
+ Fl_Overlay_Window::draw();
+ Fl::set_boxtype(FL_FLAT_BOX, old_flat_box, 0, 0, 0, 0);
+ } else {
+ Fl_Overlay_Window::draw();
+ }
}
extern Fl_Window *main_window;
@@ -684,8 +698,6 @@ void Fl_Window_Type::draw_overlay() {
Fd_Snap_Data data = { dx, dy, sx, sy, sr, st, drag, 4, 4, dx, dy, (Fl_Widget_Type*)selection, this};
Fd_Snap_Action::draw_all(data);
}
-
- // TODO: for invisible boxes (NONE, FLAT, etc.) draw a faint outline when dragging
}
extern Fl_Menu_Item Main_Menu[];
diff --git a/fluid/alignment_panel.cxx b/fluid/alignment_panel.cxx
index 160e39a0a..a46ed57cb 100644
--- a/fluid/alignment_panel.cxx
+++ b/fluid/alignment_panel.cxx
@@ -2265,7 +2265,7 @@ ps");
restricted_button->callback((Fl_Callback*)toggle_restricted_cb);
o->value(show_restricted);
} // Fl_Check_Button* restricted_button
- { Fl_Check_Button* o = ghosted_outline_button = new Fl_Check_Button(120, 340, 200, 20, "Show Low Contrast Groups Ghosted");
+ { Fl_Check_Button* o = ghosted_outline_button = new Fl_Check_Button(120, 340, 200, 20, "Show Ghosted Group Outlines");
ghosted_outline_button->tooltip("groups with no box type or flat boxtypes without contrast will be rendered wi\
th a dim outline in the editing window only");
ghosted_outline_button->down_box(FL_DOWN_BOX);
diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl
index 3ddf7b4fb..464970348 100644
--- a/fluid/alignment_panel.fl
+++ b/fluid/alignment_panel.fl
@@ -110,7 +110,7 @@ decl {void scheme_cb(Fl_Scheme_Choice *, void *);} {public local
decl {int w_settings_shell_list_selected;} {public local
}
-Function {make_script_panel()} {open selected
+Function {make_script_panel()} {open
} {
Fl_Window script_panel {
label {Shell Script Editor}
@@ -281,8 +281,8 @@ Examples:
code0 {o->value(show_restricted);}
}
Fl_Check_Button ghosted_outline_button {
- label {Show Low Contrast Groups Ghosted}
- callback toggle_ghosted_outline_cb
+ label {Show Ghosted Group Outlines}
+ callback toggle_ghosted_outline_cb selected
tooltip {groups with no box type or flat boxtypes without contrast will be rendered with a dim outline in the editing window only} xywh {120 340 200 20} down_box DOWN_BOX labelsize 11
code0 {o->value(show_ghosted_outline);}
}