GPencil: Move New Layer option to menu top

The new layer option must be the first in the menu.

Differential Revision: https://developer.blender.org/D15255
This commit is contained in:
Antonio Vazquez 2022-06-21 16:38:58 +02:00
parent d2f47017b9
commit 7140016838
2 changed files with 20 additions and 20 deletions

View File

@ -234,6 +234,11 @@ class GPENCIL_MT_move_to_layer(Menu):
layout = self.layout
gpd = context.gpencil_data
if gpd:
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("gpencil.move_to_layer", text="New Layer", icon='ADD').layer = -1
layout.separator()
gpl_active = context.active_gpencil_layer
tot_layers = len(gpd.layers)
i = tot_layers - 1
@ -246,11 +251,6 @@ class GPENCIL_MT_move_to_layer(Menu):
layout.operator("gpencil.move_to_layer", text=gpl.info, icon=icon, translate=False).layer = i
i -= 1
layout.separator()
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("gpencil.move_to_layer", text="New Layer", icon='ADD').layer = -1
class GPENCIL_MT_layer_active(Menu):
bl_label = "Change Active Layer"
@ -261,6 +261,10 @@ class GPENCIL_MT_layer_active(Menu):
gpd = context.gpencil_data
if gpd:
layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
layout.separator()
gpl_active = context.active_gpencil_layer
tot_layers = len(gpd.layers)
i = tot_layers - 1
@ -273,10 +277,6 @@ class GPENCIL_MT_layer_active(Menu):
layout.operator("gpencil.layer_active", text=gpl.info, icon=icon).layer = i
i -= 1
layout.separator()
layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
class GPENCIL_MT_material_active(Menu):
bl_label = "Change Active Material"

View File

@ -388,6 +388,17 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C,
/* Create new layer */
/* TODO: have some way of specifying that we don't want this? */
{
/* "New Layer" entry */
item_tmp.identifier = "__CREATE__";
item_tmp.name = "New Layer";
item_tmp.value = -1;
item_tmp.icon = ICON_ADD;
RNA_enum_item_add(&item, &totitem, &item_tmp);
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
}
const int tot = BLI_listbase_count(&gpd->layers);
/* Existing layers */
@ -405,17 +416,6 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C,
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
{
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
/* "New Layer" entry */
item_tmp.identifier = "__CREATE__";
item_tmp.name = "New Layer";
item_tmp.value = -1;
item_tmp.icon = ICON_ADD;
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
RNA_enum_item_end(&item, &totitem);
*r_free = true;