#862: Removes default shortcut from Fl_Shortcut_Button

- the current UI for fallback/default/original shortcut was
confusing, so I remove it until we find something better. I
kept the values so we can reinstate a better interface without
changing the API.
This commit is contained in:
Matthias Melcher 2023-12-13 16:55:10 +01:00
parent 3c6fed2dd7
commit 41dd84016d
5 changed files with 26 additions and 8 deletions

View File

@ -33,9 +33,12 @@ public:
Fl_Shortcut_Button(int X,int Y,int W,int H, const char* l = 0);
void value(Fl_Shortcut shortcut);
Fl_Shortcut value();
#if 0
// Default shortcut settings are disabled until successful review of the UI
void default_value(Fl_Shortcut shortcut);
Fl_Shortcut default_value();
void default_clear();
#endif
};
#endif // Fl_Shortcut_Button_H

View File

@ -711,7 +711,7 @@ void shortcut_in_cb(Fl_Shortcut_Button* i, void* v) {
i->parent()->hide();
return;
}
i->default_value( i->value() ); // enable the "undo" capability of the shortcut button
//i->default_value( i->value() ); // enable the "undo" capability of the shortcut button
i->show();
i->parent()->show();
i->redraw();

View File

@ -1041,7 +1041,7 @@ static void cb_Shortcut(Fl_Shortcut_Button* o, void* v) {
if (v == LOAD) {
if (selected) {
o->value(g_shell_config->list[selected-1]->shortcut);
o->default_value(o->value());
//o->default_value(o->value());
} else {
o->value(0);
}

View File

@ -156,7 +156,7 @@ Function {make_settings_window()} {open
xywh {10 10 320 530} selection_color 12 labelsize 11 labelcolor 255 resizable
} {
Fl_Group {} {
label General open
label General open selected
image {icons/general_64.png} compress_image 1 xywh {10 60 320 480} labelsize 11 resizable
code0 {o->image()->scale(36, 24);}
} {
@ -1092,7 +1092,7 @@ if (v == LOAD) {
if (v == LOAD) {
if (selected) {
o->value(g_shell_config->list[selected-1]->shortcut);
o->default_value(o->value());
//o->default_value(o->value());
} else {
o->value(0);
}
@ -1574,7 +1574,7 @@ Function {make_shell_window()} {open
label {Shell Command Output} open
xywh {769 585 555 430} type Double align 80 resizable visible
} {
Fl_Terminal shell_run_terminal {selected
Fl_Terminal shell_run_terminal {
xywh {10 10 535 375} resizable
code0 {shell_run_terminal->ansi(1);}
code1 {shell_run_terminal->history_lines(1000);}

View File

@ -75,7 +75,9 @@ Fl_Shortcut Fl_Shortcut_Button::value() {
return shortcut_value;
}
/**
#if 0
// Default shortcut settings are disabled until successful review of the UI
/* *
Set the default shortcut.
If set, and additional 'reverse' button apears that the user can click to
reset the shortcut to some default value (including 0).
@ -86,22 +88,29 @@ void Fl_Shortcut_Button::default_value(Fl_Shortcut shortcut) {
default_set_ = true;
redraw();
}
#endif
/**
#if 0
// Default shortcut settings are disabled until successful review of the UI
/* *
Return the default shortcut.
\return shortcut encoded as key and modifier
*/
Fl_Shortcut Fl_Shortcut_Button::default_value() {
return default_shortcut_;
}
#endif
/**
#if 0
// Default shortcut settings are disabled until successful review of the UI
/* *
No longer show the button to reverse to a default shortcut.
*/
void Fl_Shortcut_Button::default_clear() {
default_set_ = false;
redraw();
}
#endif
/**
Draw the textual representation of the shortcut button.
@ -134,12 +143,16 @@ void Fl_Shortcut_Button::draw() {
const char *text = label();
if (shortcut_value)
text = fl_shortcut_label(shortcut_value);
#if 0
if (default_set_) {
fl_draw(text, X, Y, W-H, H, align() | FL_ALIGN_INSIDE);
fl_draw_symbol("@-29undo", X+W-H, Y, H, H, textcol);
} else {
fl_draw(text, X, Y, W, H, align() | FL_ALIGN_INSIDE);
}
#else
fl_draw(text, X, Y, W, H, align() | FL_ALIGN_INSIDE);
#endif
if (Fl::focus() == this) draw_focus();
}
@ -156,6 +169,7 @@ void Fl_Shortcut_Button::do_end_hot_callback() {
Handle keystrokes to catch the user's shortcut.
*/
int Fl_Shortcut_Button::handle(int e) {
#if 0
bool inside_default_button = false;
if (default_set_ && ( (e == FL_PUSH) || (e == FL_DRAG) || (e == FL_RELEASE) ) ) {
int X = x() + Fl::box_dx(box());
@ -184,6 +198,7 @@ int Fl_Shortcut_Button::handle(int e) {
return 1;
}
}
#endif
switch (e) {
case FL_PUSH:
if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);