From e7f1247552fbb9d056d4c68eb51564a504df3161 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 14 Sep 2024 01:10:35 +0200 Subject: 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 --- fluid/Fl_Menu_Type.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'fluid/Fl_Menu_Type.cxx') 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"); -- cgit v1.2.3