diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-09-14 01:10:35 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-09-14 01:10:41 +0200 |
| commit | e7f1247552fbb9d056d4c68eb51564a504df3161 (patch) | |
| tree | cbaa15d7d58359d0fd59e86711881179ad34e134 /fluid/Fl_Menu_Type.cxx | |
| parent | bb917628ffa8ffc6cafc79da80344c8c9c653969 (diff) | |
FLUID: type node placement in scene graph revised
- fixes copy/paste operation that would place pasted types wrong
- improves paste into folded and unfolded groups
- improves duplication of multiple types
- much improved placement of types that don;t fit at the
requested position
- some more testing will follow in the next days
Diffstat (limited to 'fluid/Fl_Menu_Type.cxx')
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index c03516bb8..23a7868fb 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -160,15 +160,16 @@ Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) { \return new Menu Item node */ Fl_Type* Fl_Menu_Item_Type::make(int flags, Strategy strategy) { - // Find the current menu item: - Fl_Type* q = Fl_Type::current; - Fl_Type* p = q; - if (p) { - if ( (force_parent && q->is_a(ID_Menu_Item)) || !q->can_have_children()) p = p->parent; - } - force_parent = 0; - if (!p || !(p->is_a(ID_Menu_Manager_) || p->is_a(ID_Submenu))) { - fl_message("Please select a menu to add to"); + // Find a good insert position based on the current marked node + Fl_Type *anchor = Fl_Type::current, *p = anchor; + if (p && (strategy == kAddAfterCurrent)) p = p->parent; + while (p && !(p->is_a(ID_Menu_Manager_) || p->is_a(ID_Submenu))) { + anchor = p; + strategy = kAddAfterCurrent; + p = p->parent; + } + if (!p) { + fl_message("Please select a menu widget or a menu item"); return 0; } if (!o) { @@ -184,7 +185,7 @@ Fl_Type* Fl_Menu_Item_Type::make(int flags, Strategy strategy) { t->o = new Fl_Button(0,0,100,20); t->o->type(flags); t->factory = this; - t->add(p, strategy); + t->add(anchor, strategy); if (!reading_file) { if (flags==FL_SUBMENU) { t->label("submenu"); |
