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_Widget_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_Widget_Type.cxx')
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index da80add7e..44b470102 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -87,19 +87,20 @@ Fl_Widget_Type::ideal_size(int &w, int &h) { \return new node */ Fl_Type *Fl_Widget_Type::make(Strategy strategy) { - // Find the current widget, or widget to copy: - Fl_Type *qq = Fl_Type::current; - while (qq && (!qq->is_true_widget() || !qq->can_have_children())) qq = qq->parent; - if (!qq) { + Fl_Type *anchor = Fl_Type::current, *pp = anchor; + if (pp && (strategy == kAddAfterCurrent)) pp = pp->parent; + while (pp && !pp->is_a(ID_Group)) { + anchor = pp; + strategy = kAddAfterCurrent; + pp = pp->parent; + } + if (!pp || !pp->is_true_widget() || !anchor->is_true_widget()) { fl_message("Please select a group widget or window"); return 0; } - Fl_Widget_Type* q = (Fl_Widget_Type*)qq; - // find the parent widget: - Fl_Widget_Type* p = q; - if ((force_parent || !p->is_a(ID_Group)) && p->parent && p->parent->is_widget()) - p = (Fl_Widget_Type*)(p->parent); - force_parent = 0; + + Fl_Widget_Type* p = (Fl_Widget_Type*)pp; + Fl_Widget_Type* q = (Fl_Widget_Type*)anchor; // Figure out a border between widget and window: int B = p->o->w()/2; if (p->o->h()/2 < B) B = p->o->h()/2; if (B>25) B = 25; @@ -146,7 +147,7 @@ Fl_Type *Fl_Widget_Type::make(Strategy strategy) { // Put it in the parent: // ((Fl_Group *)(p->o))->add(t->o); (done by Fl_Type::add()) // add to browser: - t->add(p, strategy); + t->add(anchor, strategy); t->redraw(); return t; } |
