diff options
| author | Matthias Melcher <git@matthiasm.com> | 2021-12-05 00:40:08 +0100 |
|---|---|---|
| committer | Matthias Melcher <git@matthiasm.com> | 2021-12-05 00:40:08 +0100 |
| commit | 30371740acf46d77dd1933e206109aa73ae781bd (patch) | |
| tree | 88ed41f7fdacabb8d8c49601ae0e431ca096c32d | |
| parent | 204ac3dfdfd519607e2f392fa83c12fad9e73fde (diff) | |
STR #2842: new widgets will be created where the user clicked the RMB
If a user adds a new widget using the right mouse button in any of the
design's windows, the new widget will be located with its top left corner
at the selected position.
| -rw-r--r-- | fluid/Fl_Type.h | 2 | ||||
| -rw-r--r-- | fluid/Fl_Window_Type.cxx | 5 | ||||
| -rw-r--r-- | fluid/factory.cxx | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 2ba7e3047..4dedece5e 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -643,6 +643,8 @@ public: void copy_properties(); int sr_min_w, sr_min_h, sr_max_w, sr_max_h; + + static int popupx, popupy; }; class Fl_Widget_Class_Type : private Fl_Window_Type { diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx index 62ed479f8..ff196d2e1 100644 --- a/fluid/Fl_Window_Type.cxx +++ b/fluid/Fl_Window_Type.cxx @@ -1176,6 +1176,9 @@ void Fl_Window_Type::moveallchildren() update_xywh(); } +int Fl_Window_Type::popupx = 0x7FFFFFFF; // mark as invalid (MAXINT) +int Fl_Window_Type::popupy = 0x7FFFFFFF; + int Fl_Window_Type::handle(int event) { static Fl_Type* selection; switch (event) { @@ -1187,8 +1190,10 @@ int Fl_Window_Type::handle(int event) { if (Fl::event_button() >= 3) { in_this_only = this; // modifies how some menu items work. static const Fl_Menu_Item* myprev; + popupx = mx; popupy = my; const Fl_Menu_Item* m = New_Menu->popup(mx,my,"New",myprev); if (m && m->callback()) {myprev = m; m->do_callback(this->o);} + popupx = 0x7FFFFFFF; popupy = 0x7FFFFFFF; // mark as invalid (MAXINT) in_this_only = 0; return 1; } diff --git a/fluid/factory.cxx b/fluid/factory.cxx index ecbecef90..803411d3a 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -979,8 +979,15 @@ static void cb(Fl_Widget *, void *v) { // Move and resize the menubar across the top of the window... wt->o->resize(0, 0, w, h); } else { - // Just resize to the ideal size... - wt->o->size(w, h); + if (Fl_Window_Type::popupx != 0x7FFFFFFF) { + // If this callback was called from the RMB popup menu in a window, + // popupx and popupy will contain the mouse coordinates at RMB event. + wt->o->resize(Fl_Window_Type::popupx, Fl_Window_Type::popupy, w, h); + } else { + // If popupx is invalid, use the default position and find a good + // size for the widget. + wt->o->size(w, h); + } } } select_only(t); |
