Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c1
-rw-r--r--source/blender/makesrna/intern/rna_wm.c50
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c124
3 files changed, 106 insertions, 69 deletions
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index a731689082c..12af21e681d 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6060,6 +6060,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
static const EnumPropertyItem preview_type_items[] = {
{USER_FILE_PREVIEW_NONE, "NONE", 0, "None", "Do not create blend previews"},
+ {USER_FILE_PREVIEW_AUTO, "AUTO", 0, "Auto", "Automatically select best preview type"},
{USER_FILE_PREVIEW_SCREENSHOT, "SCREENSHOT", 0, "Screenshot", "Capture the entire window"},
{USER_FILE_PREVIEW_CAMERA, "CAMERA", 0, "Camera View", "Workbench render of scene"},
{0, NULL, 0, NULL, NULL},
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 21a3c087197..c2d1ac67675 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -440,8 +440,7 @@ const EnumPropertyItem rna_enum_event_type_mask_items[] = {
static const EnumPropertyItem keymap_modifiers_items[] = {
{KM_ANY, "ANY", 0, "Any", ""},
{0, "NONE", 0, "None", ""},
- {1, "FIRST", 0, "First", ""},
- {2, "SECOND", 0, "Second", ""},
+ {KM_MOD_HELD, "HELD", 0, "Held", ""},
{0, NULL, 0, NULL, NULL},
};
#endif
@@ -468,6 +467,13 @@ const EnumPropertyItem rna_enum_operator_type_flag_items[] = {
"is enabled"},
{OPTYPE_GRAB_CURSOR_X, "GRAB_CURSOR_X", 0, "Grab Pointer X", "Grab, only warping the X axis"},
{OPTYPE_GRAB_CURSOR_Y, "GRAB_CURSOR_Y", 0, "Grab Pointer Y", "Grab, only warping the Y axis"},
+ {OPTYPE_DEPENDS_ON_CURSOR,
+ "DEPENDS_ON_CURSOR",
+ 0,
+ "Depends on Cursor",
+ "The initial cursor location is used, "
+ "when running from a menus or buttons the user is prompted to place the cursor "
+ "before beginning the operation"},
{OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"},
{OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
{0, NULL, 0, NULL, NULL},
@@ -2725,38 +2731,62 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
- prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "shift", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "shift");
+ RNA_def_property_range(prop, KM_ANY, KM_MOD_HELD);
+ RNA_def_property_ui_text(prop, "Shift", "Shift key pressed, -1 for any state");
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER);
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
+ prop = RNA_def_property(srna, "ctrl", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "ctrl");
+ RNA_def_property_range(prop, KM_ANY, KM_MOD_HELD);
+ RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed, -1 for any state");
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
+ prop = RNA_def_property(srna, "alt", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "alt");
+ RNA_def_property_range(prop, KM_ANY, KM_MOD_HELD);
+ RNA_def_property_ui_text(prop, "Alt", "Alt key pressed, -1 for any state");
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
+ prop = RNA_def_property(srna, "oskey", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "oskey");
+ RNA_def_property_range(prop, KM_ANY, KM_MOD_HELD);
+ RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed, -1 for any state");
+ RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+
+ /* XXX(@campbellbarton): the `*_ui` suffix is only for the UI, may be removed,
+ * since this is only exposed so the UI can show these settings as toggle-buttons. */
+ prop = RNA_def_property(srna, "shift_ui", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_shift_get", NULL);
- /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */
/* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER);
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
- prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "ctrl_ui", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_ctrl_get", NULL);
- /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */
/* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
- prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "alt_ui", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_alt_get", NULL);
- /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */
/* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
- prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "oskey_ui", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_oskey_get", NULL);
- /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */
/* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
+ /* End `_ui` modifiers. */
prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index e123604cbe9..7c3b119abb9 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -39,6 +39,8 @@
#include "wm_cursors.h"
#include "wm_event_types.h"
+#include "WM_types.h"
+
#include "rna_internal.h" /* own include */
/* confusing 2 enums mixed up here */
@@ -216,49 +218,70 @@ static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
return WM_operator_props_popup(C, op, event);
}
+static int keymap_item_modifier_flag_from_args(bool any, int shift, int ctrl, int alt, int oskey)
+{
+ int modifier = 0;
+ if (any) {
+ modifier = KM_ANY;
+ }
+ else {
+ if (shift == KM_MOD_HELD) {
+ modifier |= KM_SHIFT;
+ }
+ else if (shift == KM_ANY) {
+ modifier |= KM_SHIFT_ANY;
+ }
+
+ if (ctrl == KM_MOD_HELD) {
+ modifier |= KM_CTRL;
+ }
+ else if (ctrl == KM_ANY) {
+ modifier |= KM_CTRL_ANY;
+ }
+
+ if (alt == KM_MOD_HELD) {
+ modifier |= KM_ALT;
+ }
+ else if (alt == KM_ANY) {
+ modifier |= KM_ALT_ANY;
+ }
+
+ if (oskey == KM_MOD_HELD) {
+ modifier |= KM_OSKEY;
+ }
+ else if (oskey == KM_ANY) {
+ modifier |= KM_OSKEY_ANY;
+ }
+ }
+ return modifier;
+}
+
static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
ReportList *reports,
const char *idname,
int type,
int value,
bool any,
- bool shift,
- bool ctrl,
- bool alt,
- bool oskey,
+ int shift,
+ int ctrl,
+ int alt,
+ int oskey,
int keymodifier,
bool repeat,
bool head)
{
- // wmWindowManager *wm = CTX_wm_manager(C);
- wmKeyMapItem *kmi = NULL;
- char idname_bl[OP_MAX_TYPENAME];
- int modifier = 0;
-
/* only on non-modal maps */
if (km->flag & KEYMAP_MODAL) {
BKE_report(reports, RPT_ERROR, "Not a non-modal keymap");
return NULL;
}
- WM_operator_bl_idname(idname_bl, idname);
-
- if (shift) {
- modifier |= KM_SHIFT;
- }
- if (ctrl) {
- modifier |= KM_CTRL;
- }
- if (alt) {
- modifier |= KM_ALT;
- }
- if (oskey) {
- modifier |= KM_OSKEY;
- }
+ // wmWindowManager *wm = CTX_wm_manager(C);
+ wmKeyMapItem *kmi = NULL;
+ char idname_bl[OP_MAX_TYPENAME];
+ const int modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey);
- if (any) {
- modifier = KM_ANY;
- }
+ WM_operator_bl_idname(idname_bl, idname);
/* create keymap item */
kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
@@ -305,39 +328,22 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
int type,
int value,
bool any,
- bool shift,
- bool ctrl,
- bool alt,
- bool oskey,
+ int shift,
+ int ctrl,
+ int alt,
+ int oskey,
int keymodifier,
bool repeat)
{
- wmKeyMapItem *kmi = NULL;
- int modifier = 0;
- int propvalue = 0;
-
/* only modal maps */
if ((km->flag & KEYMAP_MODAL) == 0) {
BKE_report(reports, RPT_ERROR, "Not a modal keymap");
return NULL;
}
- if (shift) {
- modifier |= KM_SHIFT;
- }
- if (ctrl) {
- modifier |= KM_CTRL;
- }
- if (alt) {
- modifier |= KM_ALT;
- }
- if (oskey) {
- modifier |= KM_OSKEY;
- }
-
- if (any) {
- modifier = KM_ANY;
- }
+ wmKeyMapItem *kmi = NULL;
+ const int modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey);
+ int propvalue = 0;
/* not initialized yet, do delayed lookup */
if (!km->modal_items) {
@@ -641,7 +647,7 @@ static wmEvent *rna_Window_event_add_simulate(wmWindow *win,
e.is_repeat = false;
e.x = x;
e.y = y;
- /* NOTE: KM_MOD_FIRST, KM_MOD_SECOND aren't used anywhere, set as bools. */
+
e.shift = shift;
e.ctrl = ctrl;
e.alt = alt;
@@ -1131,10 +1137,10 @@ void RNA_api_keymapitems(StructRNA *srna)
parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "any", 0, "Any", "");
- RNA_def_boolean(func, "shift", 0, "Shift", "");
- RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
- RNA_def_boolean(func, "alt", 0, "Alt", "");
- RNA_def_boolean(func, "oskey", 0, "OS Key", "");
+ RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
RNA_def_boolean(func,
@@ -1155,10 +1161,10 @@ void RNA_api_keymapitems(StructRNA *srna)
parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "any", 0, "Any", "");
- RNA_def_boolean(func, "shift", 0, "Shift", "");
- RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
- RNA_def_boolean(func, "alt", 0, "Alt", "");
- RNA_def_boolean(func, "oskey", 0, "OS Key", "");
+ RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
+ RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");