Add OPTION_SIMPLE_ZOOM_SHORTCUT to fine tune zoom-in shortcut
This commit is contained in:
parent
a76229972e
commit
b74099c5fd
7
FL/Fl.H
7
FL/Fl.H
@ -277,6 +277,12 @@ public:
|
||||
/// Meaningful for the Wayland/X11 platform only. When switched on (default), the library uses a Zenity-based file dialog.
|
||||
/// When switched off, the GTK file dialog is used instead.
|
||||
OPTION_FNFC_USES_ZENITY,
|
||||
/// When switched on and when the keyboard in use has '+' in the shifted position of its key,
|
||||
/// pressing that key and ctrl triggers the zoom-in operation.
|
||||
/// When switched off (default), the zoom-in operation requires that also the shift key is pressed.
|
||||
/// Under macOS, this option has no effect because the OS itself generates ⌘= followed
|
||||
/// by ⌘+ when pressing ⌘ and the '=|+' key without pressing shift.
|
||||
OPTION_SIMPLE_ZOOM_SHORTCUT,
|
||||
// don't change this, leave it always as the last element
|
||||
/// For internal use only.
|
||||
OPTION_LAST
|
||||
@ -1085,6 +1091,7 @@ public:
|
||||
callback can be associated with Fl::add_handler().
|
||||
By default, FLTK displays the new scaling factor value in a yellow, transient window.
|
||||
This can be changed with option Fl::OPTION_SHOW_SCALING.
|
||||
See also Fl::OPTION_SIMPLE_ZOOM_SHORTCUT.
|
||||
@{ */
|
||||
static int x(); // via screen driver
|
||||
static int y(); // via screen driver
|
||||
|
@ -156,6 +156,13 @@ Fo_Option_Descr g_option_list[] = {
|
||||
"If 'Transiently show scaling factor' is enabled, the library shows in a "
|
||||
"transient popup window the display scaling factor value when it is "
|
||||
"changed. If disabled, no such transient window is used." },
|
||||
{ FO_OPTION_BOOL, "Allow simple zoom-in shortcut:",
|
||||
Fl::OPTION_SIMPLE_ZOOM_SHORTCUT, "OPTION_SIMPLE_ZOOM_SHORTCUT", "SimpleZoomShortcut", false,
|
||||
"Fine tune the shortcut that triggers the zoom-in operation.",
|
||||
"When the keyboard in use has '+' in the shifted position of its key, "
|
||||
"pressing that key and ctrl triggers the zoom-in operation. "
|
||||
"If disabled, the zoom-in operation requires the shift key to be pressed also "
|
||||
"with such a keyboard." },
|
||||
// -- When adding new options here, please make sure that you also update
|
||||
// -- documentation.src/fltk-options.dox
|
||||
// -- and
|
||||
|
@ -2010,6 +2010,8 @@ bool Fl::option(Fl_Option opt)
|
||||
options_[OPTION_SHOW_SCALING] = tmp;
|
||||
opt_prefs.get("UseZenity", tmp, 1); // default: on
|
||||
options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
||||
opt_prefs.get("SimpleZoomShortcut", tmp, 0); // default: off
|
||||
options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
|
||||
}
|
||||
{ // next, check the user preferences
|
||||
// override system options only, if the option is set ( >= 0 )
|
||||
@ -2036,6 +2038,8 @@ bool Fl::option(Fl_Option opt)
|
||||
if (tmp >= 0) options_[OPTION_SHOW_SCALING] = tmp;
|
||||
opt_prefs.get("UseZenity", tmp, -1);
|
||||
if (tmp >= 0) options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
||||
opt_prefs.get("SimpleZoomShortcut", tmp, -1);
|
||||
if (tmp >= 0) options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
|
||||
}
|
||||
{ // now, if the developer has registered this app, we could ask for per-application preferences
|
||||
}
|
||||
|
@ -483,9 +483,11 @@ int Fl_Screen_Driver::scale_handler(int event)
|
||||
if (Fl::test_shortcut(FL_COMMAND+'+')) zoom = zoom_in;
|
||||
else if (Fl::test_shortcut(FL_COMMAND+'-')) zoom = zoom_out;
|
||||
else if (Fl::test_shortcut(FL_COMMAND+'0')) zoom = zoom_reset;
|
||||
// kludge to recognize shortcut FL_COMMAND+'+' without pressing SHIFT
|
||||
else if ((Fl::event_state()&(FL_META|FL_ALT|FL_CTRL|FL_SHIFT)) == FL_COMMAND &&
|
||||
if (Fl::option(Fl::OPTION_SIMPLE_ZOOM_SHORTCUT)) {
|
||||
// kludge to recognize shortcut FL_COMMAND+'+' without pressing SHIFT
|
||||
if ((Fl::event_state()&(FL_META|FL_ALT|FL_CTRL|FL_SHIFT)) == FL_COMMAND &&
|
||||
Fl::event_key() == '=') zoom = zoom_in;
|
||||
}
|
||||
if (zoom != none) {
|
||||
int i, count;
|
||||
if (Fl::grab()) return 0; // don't rescale when menu windows are on
|
||||
|
Loading…
Reference in New Issue
Block a user