Fix: GPv3: Radial controls not working in some modes
The radial controls to set the brush size were not working in sculpt and vertex paint mode. This was because of a collision with the `cyclical_set` operator in edit mode. The issue was that the poll function for the edit mode keymaps also passed in sculpt and vertex paint mode. To solve this, add a keymap for these common selection operators and separate them from the general edit mode keymap. Pull Request: https://projects.blender.org/blender/blender/pulls/128542
This commit is contained in:
@@ -3707,6 +3707,28 @@ def km_annotate(params):
|
||||
|
||||
|
||||
# Grease Pencil
|
||||
def km_grease_pencil_selection(params):
|
||||
items = []
|
||||
keymap = (
|
||||
"Grease Pencil Selection",
|
||||
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
|
||||
{"items": items},
|
||||
)
|
||||
|
||||
items.extend([
|
||||
# Select All
|
||||
*_template_items_select_actions(params, "grease_pencil.select_all"),
|
||||
# Select linked
|
||||
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS'}, None),
|
||||
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
|
||||
# Select more/less
|
||||
("grease_pencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
|
||||
("grease_pencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
|
||||
])
|
||||
|
||||
return keymap
|
||||
|
||||
|
||||
def km_grease_pencil_paint_mode(params):
|
||||
items = []
|
||||
keymap = (
|
||||
@@ -3788,12 +3810,6 @@ def km_grease_pencil_edit_mode(params):
|
||||
)
|
||||
|
||||
items.extend([
|
||||
*_template_items_select_actions(params, "grease_pencil.select_all"),
|
||||
# Select linked
|
||||
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS'}, None),
|
||||
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
|
||||
("grease_pencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
|
||||
("grease_pencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
|
||||
# Delete menu
|
||||
op_menu("VIEW3D_MT_edit_greasepencil_delete", {"type": 'X', "value": 'PRESS'}),
|
||||
op_menu("VIEW3D_MT_edit_greasepencil_delete", {"type": 'DEL', "value": 'PRESS'}),
|
||||
@@ -8042,6 +8058,7 @@ def generate_keymaps(params=None):
|
||||
# Annotations
|
||||
km_annotate(params),
|
||||
# Grease Pencil
|
||||
km_grease_pencil_selection(params),
|
||||
km_grease_pencil_paint_mode(params),
|
||||
km_grease_pencil_edit_mode(params),
|
||||
km_grease_pencil_sculpt_mode(params),
|
||||
|
||||
@@ -42,13 +42,6 @@ bool editable_grease_pencil_poll(bContext *C)
|
||||
if (!ED_operator_object_active_editable_ex(C, object)) {
|
||||
return false;
|
||||
}
|
||||
if (!ELEM(object->mode,
|
||||
OB_MODE_EDIT,
|
||||
OB_MODE_SCULPT_GPENCIL_LEGACY,
|
||||
OB_MODE_VERTEX_GPENCIL_LEGACY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -73,6 +66,24 @@ bool editable_grease_pencil_point_selection_poll(bContext *C)
|
||||
return (ts->gpencil_selectmode_edit != GP_SELECTMODE_STROKE);
|
||||
}
|
||||
|
||||
bool grease_pencil_selection_poll(bContext *C)
|
||||
{
|
||||
if (!active_grease_pencil_poll(C)) {
|
||||
return false;
|
||||
}
|
||||
Object *object = CTX_data_active_object(C);
|
||||
/* Selection operators are available in multiple modes, e.g. for masking in sculpt and vertex
|
||||
* paint mode. */
|
||||
if (!ELEM(object->mode,
|
||||
OB_MODE_EDIT_GPENCIL_LEGACY,
|
||||
OB_MODE_SCULPT_GPENCIL_LEGACY,
|
||||
OB_MODE_VERTEX_GPENCIL_LEGACY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool grease_pencil_painting_poll(bContext *C)
|
||||
{
|
||||
if (!active_grease_pencil_poll(C)) {
|
||||
@@ -89,6 +100,18 @@ bool grease_pencil_painting_poll(bContext *C)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool grease_pencil_edit_poll(bContext *C)
|
||||
{
|
||||
if (!active_grease_pencil_poll(C)) {
|
||||
return false;
|
||||
}
|
||||
Object *object = CTX_data_active_object(C);
|
||||
if ((object->mode & OB_MODE_EDIT) == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool grease_pencil_sculpting_poll(bContext *C)
|
||||
{
|
||||
if (!active_grease_pencil_poll(C)) {
|
||||
@@ -137,11 +160,18 @@ bool grease_pencil_vertex_painting_poll(bContext *C)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void keymap_grease_pencil_selection(wmKeyConfig *keyconf)
|
||||
{
|
||||
wmKeyMap *keymap = WM_keymap_ensure(
|
||||
keyconf, "Grease Pencil Selection", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
||||
keymap->poll = grease_pencil_selection_poll;
|
||||
}
|
||||
|
||||
static void keymap_grease_pencil_edit_mode(wmKeyConfig *keyconf)
|
||||
{
|
||||
wmKeyMap *keymap = WM_keymap_ensure(
|
||||
keyconf, "Grease Pencil Edit Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
||||
keymap->poll = editable_grease_pencil_poll;
|
||||
keymap->poll = grease_pencil_edit_poll;
|
||||
}
|
||||
|
||||
static void keymap_grease_pencil_paint_mode(wmKeyConfig *keyconf)
|
||||
@@ -291,6 +321,7 @@ void ED_operatormacros_grease_pencil()
|
||||
void ED_keymap_grease_pencil(wmKeyConfig *keyconf)
|
||||
{
|
||||
using namespace blender::ed::greasepencil;
|
||||
keymap_grease_pencil_selection(keyconf);
|
||||
keymap_grease_pencil_edit_mode(keyconf);
|
||||
keymap_grease_pencil_paint_mode(keyconf);
|
||||
keymap_grease_pencil_sculpt_mode(keyconf);
|
||||
@@ -298,6 +329,7 @@ void ED_keymap_grease_pencil(wmKeyConfig *keyconf)
|
||||
keymap_grease_pencil_vertex_paint_mode(keyconf);
|
||||
keymap_grease_pencil_brush_stroke(keyconf);
|
||||
keymap_grease_pencil_fill_tool(keyconf);
|
||||
|
||||
ED_primitivetool_modal_keymap(keyconf);
|
||||
ED_filltool_modal_keymap(keyconf);
|
||||
ED_interpolatetool_modal_keymap(keyconf);
|
||||
|
||||
@@ -402,6 +402,10 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *region)
|
||||
* `ed_default_handlers` because it needed to be added to multiple editors (as other editors use
|
||||
* annotations.). But for OB_GREASE_PENCIL, we only need it to register the keymaps for the
|
||||
* 3D View. */
|
||||
keymap = WM_keymap_ensure(
|
||||
wm->defaultconf, "Grease Pencil Selection", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler(®ion->handlers, keymap);
|
||||
|
||||
keymap = WM_keymap_ensure(
|
||||
wm->defaultconf, "Grease Pencil Edit Mode", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
||||
WM_event_add_keymap_handler(®ion->handlers, keymap);
|
||||
|
||||
Reference in New Issue
Block a user