summaryrefslogtreecommitdiff
path: root/fluid/nodes
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-11-19 16:57:02 +0100
committerMatthias Melcher <github@matthiasm.com>2025-11-19 16:58:08 +0100
commit94008f57c30eadff13217e3de733cb9895ee41e8 (patch)
tree905b8557229266ea825ae4959a96ed04ecfeecf1 /fluid/nodes
parent2182bd60c0cabbb6cf65ca953d4643ec03006725 (diff)
Add headline menu item style (#1059)
A menu item can be designated as a headline. Fully integrated and used in Fluid.
Diffstat (limited to 'fluid/nodes')
-rw-r--r--fluid/nodes/Menu_Node.cxx5
-rw-r--r--fluid/nodes/Widget_Node.cxx3
-rw-r--r--fluid/nodes/Widget_Node.h6
3 files changed, 12 insertions, 2 deletions
diff --git a/fluid/nodes/Menu_Node.cxx b/fluid/nodes/Menu_Node.cxx
index f5555644c..342fcf014 100644
--- a/fluid/nodes/Menu_Node.cxx
+++ b/fluid/nodes/Menu_Node.cxx
@@ -128,7 +128,7 @@ void Input_Choice_Node::build_menu() {
}
m->shortcut(((Fl_Button*)(i->o))->shortcut());
m->callback(nullptr,(void*)i);
- m->flags = i->flags();
+ m->flags = i->flags() & ~FL_MENU_HEADLINE;
m->labelfont(i->o->labelfont());
m->labelsize(i->o->labelsize());
m->labelcolor(i->o->labelcolor());
@@ -467,6 +467,7 @@ int Menu_Item_Node::flags() {
else i |= FL_SUBMENU_POINTER;
}
if (hotspot()) i |= FL_MENU_DIVIDER;
+ if (menu_headline()) i |= FL_MENU_HEADLINE;
return i;
}
@@ -697,7 +698,7 @@ void Menu_Base_Node::build_menu() {
}
m->shortcut(((Fl_Button*)(i->o))->shortcut());
m->callback(nullptr,(void*)i);
- m->flags = i->flags() | i->o->type();
+ m->flags = (i->flags() | i->o->type()) & ~FL_MENU_HEADLINE;
m->labelfont(i->o->labelfont());
m->labelsize(i->o->labelsize());
m->labelcolor(i->o->labelcolor());
diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx
index 2082941ce..3d076b29b 100644
--- a/fluid/nodes/Widget_Node.cxx
+++ b/fluid/nodes/Widget_Node.cxx
@@ -2007,6 +2007,7 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) {
if (!o->active()) f.write_string("deactivate");
if (resizable()) f.write_string("resizable");
if (hotspot()) f.write_string(is_a(Type::Menu_Item) ? "divider" : "hotspot");
+ if (menu_headline()) f.write_string("headline");
for (int n=0; n < NUM_EXTRA_CODE; n++) if (extra_code(n)) {
f.write_indent(level+1);
f.write_string("code%d",n);
@@ -2179,6 +2180,8 @@ void Widget_Node::read_property(fld::io::Project_Reader &f, const char *c) {
resizable(1);
} else if (!strcmp(c,"hotspot") || !strcmp(c, "divider")) {
hotspot(1);
+ } else if (!strcmp(c,"headline")) {
+ menu_headline(true);
} else if (!strcmp(c,"class")) {
subclass(f.read_word());
} else if (!strcmp(c,"shortcut")) {
diff --git a/fluid/nodes/Widget_Node.h b/fluid/nodes/Widget_Node.h
index 261005590..fd0b7ddbe 100644
--- a/fluid/nodes/Widget_Node.h
+++ b/fluid/nodes/Widget_Node.h
@@ -51,6 +51,8 @@ class Widget_Node : public Node
const char *inactive_name_;
uchar hotspot_;
+ bool menu_headline_ { false };
+
protected:
/// This variable is set for visible windows in batch mode.
@@ -97,11 +99,15 @@ public:
void image_name(const char *);
const char *inactive_name() const {return inactive_name_;}
void inactive_name(const char *);
+ // Note: hotspot is misused by menu items to indicate a divider
uchar hotspot() const {return hotspot_;}
void hotspot(uchar v) {hotspot_ = v;}
uchar resizable() const;
void resizable(uchar v);
+ bool menu_headline() const { return menu_headline_; }
+ void menu_headline(bool v) { menu_headline_ = v; }
+
virtual int textstuff(int what, Fl_Font &, int &, Fl_Color &);
virtual Fl_Menu_Item *subtypes();