Fix enabling experimental gpencil-v3 failing to refresh the keymap

Add an update function that ensures the key-configuration is reloaded.

Also prefer passing individual options instead of passing in
PreferencesExperimental to the key-map since it's no longer clear
which options impact shortcuts.
This commit is contained in:
Campbell Barton
2023-09-01 14:31:06 +10:00
parent 618f39fca2
commit 523700030f
3 changed files with 18 additions and 7 deletions
+2 -1
View File
@@ -366,8 +366,9 @@ def load():
use_alt_click_leader=kc_prefs.use_alt_click_leader,
use_pie_click_drag=kc_prefs.use_pie_click_drag,
use_file_single_click=kc_prefs.use_file_single_click,
experimental=prefs.experimental,
use_alt_navigation=kc_prefs.use_alt_navigation,
# Experimental features.
use_experimental_grease_pencil_version3=prefs.experimental.use_grease_pencil_version3,
),
)
@@ -77,6 +77,14 @@ class Params:
# File selector actions on single click.
"use_file_single_click",
# Experimental variables:
# Options for experimental features.
#
# NOTE: don't pass the experimental struct directly as this makes it less
# clear which experimental options impact shortcuts. Further, any experimental option
# that adjust shortcuts need to reload the key-configuration (see: `rna_userdef.cc`).
"use_experimental_grease_pencil_version3",
# Convenience variables:
# (derived from other settings).
#
@@ -98,8 +106,6 @@ class Params:
# Since this means with RMB select enabled in edit-mode for e.g.
# `Ctrl-LMB` would be caught by box-select instead of add/extrude.
"tool_maybe_tweak_event",
# Access to bpy.context.preferences.experimental
"experimental",
# Changes some transformers modal key-map items to avoid conflicts with navigation operations
"use_alt_navigation",
)
@@ -128,8 +134,8 @@ class Params:
use_file_single_click=False,
v3d_tilde_action='VIEW',
v3d_alt_mmb_drag_action='RELATIVE',
experimental=None,
use_alt_navigation=True,
use_experimental_grease_pencil_version3=False,
):
from sys import platform
self.apple = platform == 'darwin'
@@ -209,6 +215,9 @@ class Params:
self.use_fallback_tool = use_fallback_tool
# Experimental variables:
self.use_experimental_grease_pencil_version3 = use_experimental_grease_pencil_version3
# Convenience variables:
self.use_fallback_tool_select_handled = (
True if (select_mouse == 'LEFT') else
@@ -228,8 +237,6 @@ class Params:
self.tool_maybe_tweak_event = {"type": self.tool_mouse, "value": self.tool_maybe_tweak_value}
self.use_alt_navigation = use_alt_navigation
self.experimental = experimental
# ------------------------------------------------------------------------------
# Constants
@@ -3878,7 +3885,7 @@ def km_grease_pencil_stroke_paint_draw_brush(params):
)
# Draw
if params.experimental and params.experimental.use_grease_pencil_version3:
if params.use_experimental_grease_pencil_version3:
items.extend([
("grease_pencil.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
("grease_pencil.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
@@ -6983,6 +6983,9 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_grease_pencil_version3", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "use_grease_pencil_version3", 1);
RNA_def_property_ui_text(prop, "Grease Pencil 3.0", "Enable the new grease pencil 3.0 codebase");
/* The key-map depends on this setting, it needs to be reloaded. */
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update");
prop = RNA_def_property(srna, "use_viewport_debug", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "use_viewport_debug", 1);