-
Notifications
You must be signed in to change notification settings - Fork 3.2k
context_menu.lua: add this script #16726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| add `--load-context-menu` option |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| CONTEXT MENU SCRIPT | ||
| =================== | ||
|
|
||
| This script provides a context menu for platforms without integration with a | ||
| native context menu. On these platforms, it can be disabled entirely using the | ||
| ``--load-context-menu=no`` option. On platforms where the integration is | ||
| implemented, it is already disabled by default. | ||
|
|
||
| Script messages | ||
| --------------- | ||
|
|
||
| ``open`` | ||
| Show the context menu. | ||
|
|
||
| ``select`` | ||
| Select the focused item when there is one. | ||
|
|
||
| Configuration | ||
| ------------- | ||
|
|
||
| This script can be customized through a config file | ||
| ``script-opts/context_menu.conf`` placed in mpv's user directory and through | ||
| the ``--script-opts`` command-line option. The configuration syntax is | ||
| described in `mp.options functions`_. | ||
|
|
||
| Configurable Options | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| ``font_size`` | ||
| Default: 14 | ||
|
|
||
| The font size. | ||
|
|
||
| ``gap`` | ||
| Default: 3 | ||
|
|
||
| The gap between menu items. | ||
|
|
||
| ``padding_x`` | ||
| Default: 8 | ||
|
|
||
| The horizontal padding of the menu. | ||
|
|
||
| ``padding_y`` | ||
| Default: 4 | ||
|
|
||
| The vertical padding of the menu. | ||
|
|
||
| ``menu_outline_size`` | ||
| Default: 0 | ||
|
|
||
| The size of the menu's border. | ||
|
|
||
| ``menu_outline_color`` | ||
| Default: ``#FFFFFF`` | ||
|
|
||
| The color of the menu's border. | ||
|
|
||
| ``corner_radius`` | ||
| Default: 5 | ||
|
|
||
| The radius of the menu's corners. | ||
|
|
||
| ``scale_with_window`` | ||
| Default: auto | ||
|
|
||
| Whether to scale sizes with the window height. Can be ``yes``, ``no``, or | ||
| ``auto``, which follows the value of ``--osd-scale-by-window``. | ||
|
|
||
| When sizes aren't scaled with the window, they are scaled by | ||
| ``display-hidpi-scale``. | ||
|
|
||
| ``focused_color`` | ||
| Default: ``#222222`` | ||
|
|
||
| The color of the focused item. | ||
|
|
||
| ``focused_back_color`` | ||
| Default: ``#FFFFFF`` | ||
|
|
||
| The background color of the focused item. | ||
|
|
||
| ``disabled_color`` | ||
| Default: ``#555555`` | ||
|
|
||
| The color of disabled items. | ||
|
|
||
| ``seconds_to_open_submenus`` | ||
| Default: 0.2 | ||
|
|
||
| The number of seconds to open submenus after the cursor enters items | ||
| associated with one. | ||
|
|
||
| ``seconds_to_close_submenus`` | ||
| Default: 0.2 | ||
|
|
||
| The number of seconds to close submenus after the cursor enters a parent | ||
| menu. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -565,6 +565,7 @@ static const m_option_t mp_opts[] = { | |
| {"load-select", OPT_BOOL(lua_load_select), .flags = UPDATE_BUILTIN_SCRIPTS}, | ||
| {"load-positioning", OPT_BOOL(lua_load_positioning), .flags = UPDATE_BUILTIN_SCRIPTS}, | ||
| {"load-commands", OPT_BOOL(lua_load_commands), .flags = UPDATE_BUILTIN_SCRIPTS}, | ||
| {"load-context-menu", OPT_BOOL(lua_load_context_menu), .flags = UPDATE_BUILTIN_SCRIPTS}, | ||
| #endif | ||
|
|
||
| // ------------------------- stream options -------------------- | ||
|
|
@@ -1000,6 +1001,9 @@ static const struct MPOpts mp_default_opts = { | |
| .lua_load_select = true, | ||
| .lua_load_positioning = true, | ||
| .lua_load_commands = true, | ||
| #ifndef _WIN32 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks iffy. What about macOS, or other possible implementations of context menu?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is iffy? When the macOS context menu is implemented this needs to be updated to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
macOS has its own context menu implemented already.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementing the macOS context menu is literally listed as a goal in #13608. Only the top bar menu is implemented.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the goal of disabling context menu script anyway? It's not bound to any key, so there is no conflict.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It just reduces the number of threads running. |
||
| .lua_load_context_menu = true, | ||
| #endif | ||
| #endif | ||
| .auto_load_scripts = true, | ||
| .loop_times = 1, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be
autoinstead? I am not sure if some would prefer the OSD menu than GUI menu.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? It already behaves like
autoby changing default value based on the platform.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the explicit value
auto. Is there any reason to make the option special?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that the default value can be determined at compile time unlike every other
autooption, removing the need to implement acontext-menu-loadedproperty.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it wouldn't be conflict with GUI menu. I think I will always set it to
yesto use two menus together in different cases.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what you mean by GUI menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#13700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean Windows users cannot use the ASS menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--load-context-menudefaults tonoon Windows so thatselect.luawill prefer opening the native context menu, but nothing stops you from ignoring this option and opening either menu in a third party script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the only advantage of the native context menu I see is that it can be drawn outside of mpv's window. Whereas the advantage of the ASS menu is that you can customize its appearance.