Keymap: Use 1..4 to change UV select modes
Support for sync selection switching which keys apply.
This commit is contained in:
@@ -112,6 +112,7 @@ void ED_keymap_proportional_obmode(struct wmKeyConfig *keyconf, struct wmKeyMap
|
||||
void ED_keymap_proportional_maskmode(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap);
|
||||
void ED_keymap_proportional_editmode(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap,
|
||||
const bool do_connected);
|
||||
void ED_keymap_editmesh_elem_mode(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap);
|
||||
|
||||
void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode);
|
||||
void ED_object_base_activate(struct bContext *C, struct Base *base);
|
||||
|
||||
@@ -1462,6 +1462,18 @@ static int edbm_select_mode_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
/* Bypass when in UV non sync-select mode, fall through to keymap that edits. */
|
||||
if (CTX_wm_space_image(C)) {
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
if ((ts->uv_flag & UV_SYNC_SELECTION) == 0) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
/* Bypass when no action is needed. */
|
||||
if (!RNA_struct_property_is_set(op->ptr, "type")) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
/* detecting these options based on shift/ctrl here is weak, but it's done
|
||||
* to make this work when clicking buttons or menus */
|
||||
if (!RNA_struct_property_is_set(op->ptr, "use_extend"))
|
||||
|
||||
@@ -335,22 +335,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
|
||||
kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "vertex_only", true);
|
||||
|
||||
/* selecting */
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const bool is_extend = (i & 1);
|
||||
const bool is_expand = (i & 2);
|
||||
const int key_modifier = (is_extend ? KM_SHIFT : 0) | (is_expand ? KM_CTRL : 0);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_mode", ONEKEY + j, KM_PRESS, key_modifier, 0);
|
||||
RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX << j);
|
||||
if (is_extend) {
|
||||
RNA_boolean_set(kmi->ptr, "use_extend", true);
|
||||
}
|
||||
if (is_expand) {
|
||||
RNA_boolean_set(kmi->ptr, "use_expand", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Selec Vert/Edge/Face. */
|
||||
ED_keymap_editmesh_elem_mode(keyconf, keymap);
|
||||
|
||||
/* standard mouse selection goes via space_view3d */
|
||||
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -490,3 +491,26 @@ void ED_keymap_proportional_editmode(struct wmKeyConfig *UNUSED(keyconf), struct
|
||||
RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map 1..3 to Vert/Edge/Face.
|
||||
*/
|
||||
void ED_keymap_editmesh_elem_mode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const bool is_extend = (i & 1);
|
||||
const bool is_expand = (i & 2);
|
||||
const int key_modifier = (is_extend ? KM_SHIFT : 0) | (is_expand ? KM_CTRL : 0);
|
||||
for (int j = 0; j < 3; j++) {
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(
|
||||
keymap, "MESH_OT_select_mode", ONEKEY + j, KM_PRESS, key_modifier, 0);
|
||||
RNA_enum_set(kmi->ptr, "type", SCE_SELECT_VERTEX << j);
|
||||
if (is_extend) {
|
||||
RNA_boolean_set(kmi->ptr, "use_extend", true);
|
||||
}
|
||||
if (is_expand) {
|
||||
RNA_boolean_set(kmi->ptr, "use_expand", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -4404,6 +4405,15 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
|
||||
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_uv_sculpt");
|
||||
#endif
|
||||
|
||||
/* Select Element (Sync Select: on) */
|
||||
ED_keymap_editmesh_elem_mode(keyconf, keymap);
|
||||
/* Hack to prevent fall-through, when the button isn't visible. */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_select_mode", FOURKEY, KM_PRESS, 0, 0);
|
||||
/* Select Element (Sync Select: off) */
|
||||
WM_keymap_add_context_enum_set_items(
|
||||
keymap, rna_enum_mesh_select_mode_uv_items, "tool_settings.uv_select_mode",
|
||||
ONEKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* Mark edge seam */
|
||||
WM_keymap_add_item(keymap, "UV_OT_mark_seam", EKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ extern const EnumPropertyItem rna_enum_snap_element_items[];
|
||||
extern const EnumPropertyItem rna_enum_snap_node_element_items[];
|
||||
extern const EnumPropertyItem rna_enum_curve_fit_method_items[];
|
||||
extern const EnumPropertyItem rna_enum_mesh_select_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_mesh_select_mode_uv_items[];
|
||||
extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_space_graph_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_space_type_items[];
|
||||
|
||||
@@ -165,6 +165,14 @@ const EnumPropertyItem rna_enum_mesh_select_mode_items[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_mesh_select_mode_uv_items[] = {
|
||||
{UV_SELECT_VERTEX, "VERTEX", ICON_UV_VERTEXSEL, "Vertex", "Vertex selection mode"},
|
||||
{UV_SELECT_EDGE, "EDGE", ICON_UV_EDGESEL, "Edge", "Edge selection mode"},
|
||||
{UV_SELECT_FACE, "FACE", ICON_UV_FACESEL, "Face", "Face selection mode"},
|
||||
{UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_snap_element_items[] = {
|
||||
{SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"},
|
||||
{SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"},
|
||||
@@ -2404,14 +2412,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem uv_select_mode_items[] = {
|
||||
{UV_SELECT_VERTEX, "VERTEX", ICON_UV_VERTEXSEL, "Vertex", "Vertex selection mode"},
|
||||
{UV_SELECT_EDGE, "EDGE", ICON_UV_EDGESEL, "Edge", "Edge selection mode"},
|
||||
{UV_SELECT_FACE, "FACE", ICON_UV_FACESEL, "Face", "Face selection mode"},
|
||||
{UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* the construction of this enum is quite special - everything is stored as bitflags,
|
||||
* with 1st position only for for on/off (and exposed as boolean), while others are mutually
|
||||
* exclusive options but which will only have any effect when autokey is enabled
|
||||
@@ -2806,7 +2806,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
/* UV */
|
||||
prop = RNA_def_property(srna, "uv_select_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "uv_selectmode");
|
||||
RNA_def_property_enum_items(prop, uv_select_mode_items);
|
||||
RNA_def_property_enum_items(prop, rna_enum_mesh_select_mode_uv_items);
|
||||
RNA_def_property_ui_text(prop, "UV Selection Mode", "UV selection and display mode");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user