diff options
| author | Matthias Melcher <git@matthiasm.com> | 2021-12-11 19:43:00 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2021-12-13 18:17:07 +0100 |
| commit | 160832ce04f932fbb3df199aa01d1c93148bb292 (patch) | |
| tree | d1ce303700666997a8608b7a488a25e633f07804 /fluid/Fl_Menu_Type.cxx | |
| parent | a802aaeb170e3c233c5d92ae29d8703a0b9c2768 (diff) | |
STR 3442: copy/paste now inserts widget as expected.
Fluid would add pasted widgets as the last child of the
current group, even if they were cut at the beginning
of the group. This patch adds a 'startegy' to adding
widgets to allow merging closer to the 'current' widget.
Also added d'n'd for the widget bin and some other
UI improvements.
STR 3442: some preparation, variable renaming
STR 3442: unifying functions to add widgets.
Adding widgets interactively is merged into one function,
making undo/redo work as expected and removing
unexpected differences between adding by menu or bin.
STR 3442: adding drag'n'drop for windows from bin.
Just drag the window symbol out of the tree and drop it anywhere
on the desktop.
Visual representation of dragged Window.
STR 3442: insert individual nodes after 'current'
STR 3442: adding new widget at expected positions.
The widget bin can finally do drag'n'drop.
Widgets appear in the tree close to the last selection.
Duplicating now ads right below.
Cut and paste inserts after last selection.
Fluid: replaced #define with strict enum type.
Diffstat (limited to 'fluid/Fl_Menu_Type.cxx')
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 78 |
1 files changed, 28 insertions, 50 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index e3d6fec44..7bd55ce15 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -100,8 +100,12 @@ void Fl_Input_Choice_Type::build_menu() { o->redraw(); } - -Fl_Type *Fl_Menu_Item_Type::make() { +/** + Create and add a new Menu Item node. + \param[in] strategy add after current or as last child + \return new Menu Item node + */ +Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) { // Find the current menu item: Fl_Type* q = Fl_Type::current; Fl_Type* p = q; @@ -122,28 +126,43 @@ Fl_Type *Fl_Menu_Item_Type::make() { t->o = new Fl_Button(0,0,100,20); t->o->type(menuitemtype); t->factory = this; - t->add(p); + t->add(p, strategy); if (!reading_file) t->label(submenuflag ? "submenu" : "item"); return t; } -Fl_Type *Fl_Checkbox_Menu_Item_Type::make() { +/** + Create and add a new Checkbox Menu Item node. + \param[in] strategy add after current or as last child + \return new node + */ +Fl_Type *Fl_Checkbox_Menu_Item_Type::make(Strategy strategy) { menuitemtype = FL_MENU_TOGGLE; - Fl_Type* t = Fl_Menu_Item_Type::make(); + Fl_Type* t = Fl_Menu_Item_Type::make(strategy); menuitemtype = 0; return t; } -Fl_Type *Fl_Radio_Menu_Item_Type::make() { +/** + Create and add a new Radio ButtonMenu Item node. + \param[in] strategy add after current or as last child + \return new node + */ +Fl_Type *Fl_Radio_Menu_Item_Type::make(Strategy strategy) { menuitemtype = FL_MENU_RADIO; - Fl_Type* t = Fl_Menu_Item_Type::make(); + Fl_Type* t = Fl_Menu_Item_Type::make(strategy); menuitemtype = 0; return t; } -Fl_Type *Fl_Submenu_Type::make() { +/** + Create and add a new Submenu Item node. + \param[in] strategy add after current or as last child + \return new node + */ +Fl_Type *Fl_Submenu_Type::make(Strategy strategy) { submenuflag = 1; - Fl_Type* t = Fl_Menu_Item_Type::make(); + Fl_Type* t = Fl_Menu_Item_Type::make(strategy); submenuflag = 0; return t; } @@ -584,47 +603,6 @@ Fl_Menu_Bar_Type Fl_Menu_Bar_type; //////////////////////////////////////////////////////////////// // Shortcut entry item in panel: -void Shortcut_Button::draw() { - if (value()) draw_box(FL_DOWN_BOX, (Fl_Color)9); - else draw_box(FL_UP_BOX, FL_WHITE); - fl_font(FL_HELVETICA,14); fl_color(FL_FOREGROUND_COLOR); - if (use_FL_COMMAND && (svalue & (FL_CTRL|FL_META))) { - char buf[1024]; - fl_snprintf(buf, 1023, "Command+%s", fl_shortcut_label(svalue&~(FL_CTRL|FL_META))); - fl_draw(buf,x()+6,y(),w(),h(),FL_ALIGN_LEFT); - } else { - fl_draw(fl_shortcut_label(svalue),x()+6,y(),w(),h(),FL_ALIGN_LEFT); - } -} - -int Shortcut_Button::handle(int e) { - when(0); type(FL_TOGGLE_BUTTON); - if (e == FL_KEYBOARD) { - if (!value()) return 0; - int v = Fl::event_text()[0]; - if ( (v > 32 && v < 0x7f) || (v > 0xa0 && v <= 0xff) ) { - if (isupper(v)) { - v = tolower(v); - v |= FL_SHIFT; - } - v = v | (Fl::event_state()&(FL_META|FL_ALT|FL_CTRL)); - } else { - v = (Fl::event_state()&(FL_META|FL_ALT|FL_CTRL|FL_SHIFT)) | Fl::event_key(); - if (v == FL_BackSpace && svalue) v = 0; - } - if (v != svalue) {svalue = v; set_changed(); redraw(); do_callback(); } - return 1; - } else if (e == FL_UNFOCUS) { - int c = changed(); value(0); if (c) set_changed(); - return 1; - } else if (e == FL_FOCUS) { - return value(); - } else { - int r = Fl_Button::handle(e); - if (e == FL_RELEASE && value() && Fl::focus() != this) take_focus(); - return r; - } -} void shortcut_in_cb(Shortcut_Button* i, void* v) { if (v == LOAD) { |
