UI: expose tool settings in the 3D view side-bar

Internally tool settings have been moved to the 3D view.
Added the ability for to draw panels from another space/region
so they can be mirrored in the properties editor.
This commit is contained in:
Campbell Barton 2019-05-10 13:43:07 +10:00
parent a287153ee4
commit 6b082278d1
Notes: blender-bot 2023-02-14 08:42:53 +01:00
Referenced by commit 6eacb626e0, Fix top-bar showing paint popover panels
Referenced by issue #64418, UI: In Preferences, Invisible Execute Region in Nav_bar, blocks resize of area.
Referenced by issue #64421, Redraw Timer crashes Blender
Referenced by issue #64408, Playback shortcut doesn't fully work
Referenced by issue #64284, Mirroed Collection Intances have flipped normals/face orientation.
10 changed files with 211 additions and 154 deletions

View File

@ -24,11 +24,15 @@ from bpy.types import (
from rna_prop_ui import PropertyPanel
class WorkSpaceButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = ".workspace"
# bl_space_type = 'PROPERTIES'
# bl_region_type = 'WINDOW'
# bl_context = ".workspace"
# Developer note: this is displayed in tool settings as well as the 3D view.
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Tool"
class WORKSPACE_PT_main(WorkSpaceButtonsPanel, Panel):

View File

@ -4717,6 +4717,7 @@ class VIEW3D_PT_active_tool(Panel):
def draw(self, context):
layout = self.layout
tool_mode = context.mode
# Panel display of topbar tool settings.
# currently displays in tool settings, keep here since the same functionality is used for the topbar.
@ -4725,7 +4726,12 @@ class VIEW3D_PT_active_tool(Panel):
layout.use_property_decorate = False
from .space_toolsystem_common import ToolSelectPanelHelper
ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
ToolSelectPanelHelper.draw_active_tool_header(
context,
layout,
show_tool_name=True,
tool_key=('VIEW_3D', tool_mode),
)
class VIEW3D_PT_view3d_properties(Panel):

View File

@ -38,8 +38,8 @@ from bl_ui.utils import PresetPanel
class View3DPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
# **************** standard tool clusters ******************
@ -82,7 +82,6 @@ class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
bl_category = "Options"
bl_context = ".mesh_edit" # dot on purpose (access from topbar)
bl_label = "Options"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
@ -204,8 +203,9 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
class View3DPaintPanel(UnifiedPaintPanel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Tool"
class VIEW3D_PT_tools_particlemode(Panel, View3DPaintPanel):
@ -576,6 +576,7 @@ class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
bl_category = "Tool"
bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Texture Slots"
@ -650,6 +651,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
bl_category = "Tool"
bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Mask"
bl_options = {'DEFAULT_CLOSED'}
@ -789,6 +791,7 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
# TODO, move to space_view3d.py
class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
bl_category = "Tool"
bl_context = ".imagepaint" # dot on purpose (access from topbar)
bl_label = "Texture Mask"
bl_options = {'DEFAULT_CLOSED'}
@ -1523,6 +1526,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu):
# TODO, move to space_view3d.py
class VIEW3D_PT_tools_particlemode_options(View3DPanel, Panel):
"""Default tools for particle mode"""
bl_category = "Options"
bl_context = ".particlemode"
bl_label = "Options"
bl_options = {'DEFAULT_CLOSED'}
@ -1572,6 +1576,7 @@ class VIEW3D_PT_tools_particlemode_options(View3DPanel, Panel):
class VIEW3D_PT_tools_particlemode_options_shapecut(View3DPanel, Panel):
"""Default tools for particle mode"""
bl_category = "Options"
bl_parent_id = "VIEW3D_PT_tools_particlemode_options"
bl_label = "Cut Particles to Shape"
bl_options = {'DEFAULT_CLOSED'}
@ -1590,6 +1595,7 @@ class VIEW3D_PT_tools_particlemode_options_shapecut(View3DPanel, Panel):
class VIEW3D_PT_tools_particlemode_options_display(View3DPanel, Panel):
"""Default tools for particle mode"""
bl_category = "Options"
bl_parent_id = "VIEW3D_PT_tools_particlemode_options"
bl_label = "Viewport Display"
@ -1616,7 +1622,7 @@ class VIEW3D_PT_tools_particlemode_options_display(View3DPanel, Panel):
class VIEW3D_PT_tools_meshedit_normal(View3DPanel, Panel):
bl_category = ""
bl_category = "Options"
bl_context = ".mesh_edit"
bl_label = "Normals"
bl_options = {'DEFAULT_CLOSED'}
@ -1639,6 +1645,7 @@ class VIEW3D_PT_tools_meshedit_normal(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Brush"
bl_category = "Tool"
@classmethod
def poll(cls, context):
@ -1695,6 +1702,7 @@ class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brush_option(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Options"
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -1744,6 +1752,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_stabilizer(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
bl_label = "Stabilize"
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -1773,6 +1782,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_settings(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
bl_label = "Post-Processing"
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -1814,6 +1824,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
bl_label = "Randomize"
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -1848,6 +1859,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Curves"
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -1862,6 +1874,7 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Sensitivity"
bl_category = "Tool"
bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
def draw(self, context):
@ -1878,6 +1891,7 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Strength"
bl_category = "Tool"
bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
def draw(self, context):
@ -1894,6 +1908,7 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Jitter"
bl_category = "Tool"
bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
def draw(self, context):
@ -1910,6 +1925,7 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
# Grease Pencil stroke editing tools
class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
bl_space_type = 'VIEW_3D'
bl_category = "Tool"
# Grease Pencil stroke interpolation tools
@ -1964,6 +1980,7 @@ class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, View3D
bl_context = ".greasepencil_sculpt"
bl_category = "Tools"
bl_label = "Brush"
bl_category = "Tool"
# Grease Pencil weight painting tools
@ -1971,6 +1988,7 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint(View3DPanel, Panel):
bl_context = ".greasepencil_weight"
bl_category = "Tools"
bl_label = "Brush"
bl_category = "Tool"
def draw(self, context):
layout = self.layout
@ -1995,22 +2013,26 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint(View3DPanel, Panel):
class VIEW3D_PT_tools_grease_pencil_paint_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
bl_context = ".greasepencil_paint"
bl_label = "Display"
bl_category = "Tool"
class VIEW3D_PT_tools_grease_pencil_sculpt_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
bl_context = ".greasepencil_sculpt"
bl_label = "Display"
bl_category = "Tool"
class VIEW3D_PT_tools_grease_pencil_sculpt_options(GreasePencilSculptOptionsPanel, View3DPanel, Panel):
bl_context = ".greasepencil_sculpt"
bl_label = "Sculpt Strokes"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_sculpt'
bl_category = "Tool"
class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
bl_context = ".greasepencil_weight"
bl_label = "Display"
bl_category = "Tool"
class VIEW3D_PT_gpencil_brush_presets(PresetPanel, Panel):

View File

@ -87,9 +87,12 @@ void ED_region_panels_ex(const struct bContext *C,
void ED_region_panels(const struct bContext *C, struct ARegion *ar);
void ED_region_panels_layout_ex(const struct bContext *C,
struct ARegion *ar,
struct ListBase *paneltypes,
const char *contexts[],
int contextnr,
const bool vertical);
const bool vertical,
const char *category_override);
void ED_region_panels_layout(const struct bContext *C, struct ARegion *ar);
void ED_region_panels_draw(const struct bContext *C, struct ARegion *ar);

View File

@ -730,4 +730,9 @@ void ED_view3d_gizmo_mesh_preselect_get_active(struct bContext *C,
struct Base **r_base,
struct BMElem **r_ele);
/* space_view3d.c */
void ED_view3d_buttons_region_layout_ex(const struct bContext *C,
struct ARegion *ar,
const char *category_override);
#endif /* __ED_VIEW3D_H__ */

View File

@ -2069,7 +2069,11 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f));
BLF_size(fontid, fstyle_points, U.dpi);
BLI_assert(UI_panel_category_is_visible(ar));
/* Check the region type supports categories to avoid an assert
* for showing 3D view panels in the properties space. */
if ((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) {
BLI_assert(UI_panel_category_is_visible(ar));
}
/* calculate tab rect's and check if we need to scale down */
for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) {

View File

@ -2300,14 +2300,48 @@ static void ed_panel_draw(const bContext *C,
* Matching against any of these strings will draw the panel.
* Can be NULL to skip context checks.
*/
void ED_region_panels_layout_ex(
const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical)
void ED_region_panels_layout_ex(const bContext *C,
ARegion *ar,
ListBase *paneltypes,
const char *contexts[],
int contextnr,
const bool vertical,
const char *category_override)
{
/* collect panels to draw */
LinkNode *panel_types_stack = NULL;
for (PanelType *pt = paneltypes->last; pt; pt = pt->prev) {
WorkSpace *workspace = CTX_wm_workspace(C);
/* Only draw top level panels. */
if (pt->parent) {
continue;
}
if (category_override) {
if (!STREQ(pt->category, category_override)) {
continue;
}
}
/* verify context */
if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) {
continue;
}
/* If we're tagged, only use compatible. */
if (pt->owner_id[0] && BKE_workspace_owner_id_check(workspace, pt->owner_id) == false) {
continue;
}
/* draw panel */
if (pt->draw && (!pt->poll || pt->poll(C, pt))) {
BLI_linklist_prepend_alloca(&panel_types_stack, pt);
}
}
ar->runtime.category = NULL;
const WorkSpace *workspace = CTX_wm_workspace(C);
ScrArea *sa = CTX_wm_area(C);
PanelType *pt;
View2D *v2d = &ar->v2d;
int x, y, w, em;
bool is_context_new = 0;
@ -2315,16 +2349,15 @@ void ED_region_panels_layout_ex(
/* XXX, should use some better check? */
/* For now also has hardcoded check for clip editor until it supports actual toolbar. */
bool use_category_tabs = ((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) ||
(ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP);
bool use_category_tabs = (category_override == NULL) &&
((((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) ||
(ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP)));
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
int margin_x = 0;
const bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *);
if (contextnr != -1) {
is_context_new = UI_view2d_tab_set(v2d, contextnr);
}
@ -2348,42 +2381,19 @@ void ED_region_panels_layout_ex(
scroll = v2d->scroll;
/* collect panels to draw */
for (pt = ar->type->paneltypes.last; pt; pt = pt->prev) {
/* Only draw top level panels. */
if (pt->parent) {
continue;
}
/* verify context */
if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) {
continue;
}
/* If we're tagged, only use compatible. */
if (pt->owner_id[0] && BKE_workspace_owner_id_check(workspace, pt->owner_id) == false) {
continue;
}
/* draw panel */
if (pt->draw && (!pt->poll || pt->poll(C, pt))) {
BLI_SMALLSTACK_PUSH(pt_stack, pt);
}
}
/* collect categories */
if (use_category_tabs) {
UI_panel_category_clear_all(ar);
/* gather unique categories */
BLI_SMALLSTACK_ITER_BEGIN (pt_stack, pt) {
for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) {
PanelType *pt = pt_link->link;
if (pt->category[0]) {
if (!UI_panel_category_find(ar, pt->category)) {
UI_panel_category_add(ar, pt->category);
}
}
}
BLI_SMALLSTACK_ITER_END;
if (!UI_panel_category_is_visible(ar)) {
use_category_tabs = false;
@ -2411,7 +2421,8 @@ void ED_region_panels_layout_ex(
/* set view2d view matrix - UI_block_begin() stores it */
UI_view2d_view_ortho(v2d);
BLI_SMALLSTACK_ITER_BEGIN (pt_stack, pt) {
for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) {
PanelType *pt = pt_link->link;
Panel *panel = UI_panel_find_by_type(&ar->panels, pt);
if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) {
@ -2422,7 +2433,6 @@ void ED_region_panels_layout_ex(
ed_panel_draw(C, sa, ar, &ar->panels, pt, panel, w, em, vertical);
}
BLI_SMALLSTACK_ITER_END;
/* align panels and return size */
UI_panels_end(C, ar, &x, &y);
@ -2493,9 +2503,11 @@ void ED_region_panels_layout_ex(
ar->runtime.category = category;
}
}
void ED_region_panels_layout(const bContext *C, ARegion *ar)
{
ED_region_panels_layout_ex(C, ar, NULL, -1, true);
bool vertical = true;
ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, NULL, -1, vertical, NULL);
}
void ED_region_panels_draw(const bContext *C, ARegion *ar)
@ -2544,7 +2556,7 @@ void ED_region_panels_ex(
const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical)
{
/* TODO: remove? */
ED_region_panels_layout_ex(C, ar, contexts, contextnr, vertical);
ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, contexts, contextnr, vertical, NULL);
ED_region_panels_draw(C, ar);
}

View File

@ -34,6 +34,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_view3d.h" /* To draw toolbar UI. */
#include "WM_api.h"
#include "WM_types.h"
@ -198,105 +199,7 @@ static void buttons_main_region_layout_properties(const bContext *C,
}
const bool vertical = true;
ED_region_panels_layout_ex(C, ar, contexts, sbuts->mainb, vertical);
}
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[5] = {NULL};
contexts_base[0] = ".active_tool";
const char **contexts = &contexts_base[1];
/* Hard coded to 3D view. */
{
switch (mode) {
case CTX_MODE_EDIT_MESH:
ARRAY_SET_ITEMS(contexts, ".mesh_edit");
break;
case CTX_MODE_EDIT_CURVE:
ARRAY_SET_ITEMS(contexts, ".curve_edit");
break;
case CTX_MODE_EDIT_SURFACE:
ARRAY_SET_ITEMS(contexts, ".curve_edit");
break;
case CTX_MODE_EDIT_TEXT:
ARRAY_SET_ITEMS(contexts, ".text_edit");
break;
case CTX_MODE_EDIT_ARMATURE:
ARRAY_SET_ITEMS(contexts, ".armature_edit");
break;
case CTX_MODE_EDIT_METABALL:
ARRAY_SET_ITEMS(contexts, ".mball_edit");
break;
case CTX_MODE_EDIT_LATTICE:
ARRAY_SET_ITEMS(contexts, ".lattice_edit");
break;
case CTX_MODE_POSE:
ARRAY_SET_ITEMS(contexts, ".posemode");
break;
case CTX_MODE_SCULPT:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".sculpt_mode");
break;
case CTX_MODE_PAINT_WEIGHT:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".weightpaint");
break;
case CTX_MODE_PAINT_VERTEX:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".vertexpaint");
break;
case CTX_MODE_PAINT_TEXTURE:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".imagepaint");
break;
case CTX_MODE_PARTICLE:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".particlemode");
break;
case CTX_MODE_OBJECT:
ARRAY_SET_ITEMS(contexts, ".objectmode");
break;
case CTX_MODE_PAINT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_paint");
break;
case CTX_MODE_SCULPT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
break;
case CTX_MODE_WEIGHT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
break;
default:
break;
}
}
/* for grease pencil we don't use tool system yet, so we need check outside
* workspace->tools_space_type because this value is not available
*/
switch (mode) {
case CTX_MODE_PAINT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_paint");
break;
case CTX_MODE_SCULPT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
break;
case CTX_MODE_WEIGHT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
break;
case CTX_MODE_EDIT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_edit");
break;
default:
break;
}
int i = 0;
while (contexts_base[i]) {
i++;
}
BLI_assert(i < ARRAY_SIZE(contexts_base));
contexts_base[i] = ".workspace";
const bool vertical = true;
ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, contexts, sbuts->mainb, vertical, NULL);
}
static void buttons_main_region_layout(const bContext *C, ARegion *ar)
@ -305,7 +208,7 @@ static void buttons_main_region_layout(const bContext *C, ARegion *ar)
SpaceProperties *sbuts = CTX_wm_space_properties(C);
if (sbuts->mainb == BCONTEXT_TOOL) {
buttons_main_region_layout_tool(C, ar);
ED_view3d_buttons_region_layout_ex(C, ar, "Tool");
}
else {
buttons_main_region_layout_properties(C, sbuts, ar);

View File

@ -762,7 +762,7 @@ static void image_buttons_region_layout(const bContext *C, ARegion *ar)
}
const bool vertical = true;
ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, contexts_base, -1, vertical, NULL);
}
static void image_buttons_region_draw(const bContext *C, ARegion *ar)

View File

@ -1200,9 +1200,106 @@ static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
static void view3d_buttons_region_draw(const bContext *C, ARegion *ar)
void ED_view3d_buttons_region_layout_ex(const bContext *C,
ARegion *ar,
const char *category_override)
{
ED_region_panels_ex(C, ar, (const char *[]){CTX_data_mode_string(C), NULL}, -1, true);
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[4] = {NULL};
contexts_base[0] = CTX_data_mode_string(C);
const char **contexts = &contexts_base[1];
switch (mode) {
case CTX_MODE_EDIT_MESH:
ARRAY_SET_ITEMS(contexts, ".mesh_edit");
break;
case CTX_MODE_EDIT_CURVE:
ARRAY_SET_ITEMS(contexts, ".curve_edit");
break;
case CTX_MODE_EDIT_SURFACE:
ARRAY_SET_ITEMS(contexts, ".curve_edit");
break;
case CTX_MODE_EDIT_TEXT:
ARRAY_SET_ITEMS(contexts, ".text_edit");
break;
case CTX_MODE_EDIT_ARMATURE:
ARRAY_SET_ITEMS(contexts, ".armature_edit");
break;
case CTX_MODE_EDIT_METABALL:
ARRAY_SET_ITEMS(contexts, ".mball_edit");
break;
case CTX_MODE_EDIT_LATTICE:
ARRAY_SET_ITEMS(contexts, ".lattice_edit");
break;
case CTX_MODE_POSE:
ARRAY_SET_ITEMS(contexts, ".posemode");
break;
case CTX_MODE_SCULPT:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".sculpt_mode");
break;
case CTX_MODE_PAINT_WEIGHT:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".weightpaint");
break;
case CTX_MODE_PAINT_VERTEX:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".vertexpaint");
break;
case CTX_MODE_PAINT_TEXTURE:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".imagepaint");
break;
case CTX_MODE_PARTICLE:
ARRAY_SET_ITEMS(contexts, ".paint_common", ".particlemode");
break;
case CTX_MODE_OBJECT:
ARRAY_SET_ITEMS(contexts, ".objectmode");
break;
case CTX_MODE_PAINT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_paint");
break;
case CTX_MODE_SCULPT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
break;
case CTX_MODE_WEIGHT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
break;
default:
break;
}
switch (mode) {
case CTX_MODE_PAINT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_paint");
break;
case CTX_MODE_SCULPT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
break;
case CTX_MODE_WEIGHT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
break;
case CTX_MODE_EDIT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_edit");
break;
default:
break;
}
ListBase *paneltypes = &ar->type->paneltypes;
/* Allow drawing 3D view toolbar from non 3D view space type. */
if (category_override != NULL) {
SpaceType *st = BKE_spacetype_from_id(SPACE_VIEW3D);
ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI);
paneltypes = &art->paneltypes;
}
const bool vertical = true;
ED_region_panels_layout_ex(C, ar, paneltypes, contexts_base, -1, vertical, category_override);
}
static void view3d_buttons_region_layout(const bContext *C, ARegion *ar)
{
ED_view3d_buttons_region_layout_ex(C, ar, NULL);
}
static void view3d_buttons_region_listener(wmWindow *UNUSED(win),
@ -1512,7 +1609,8 @@ void ED_spacetype_view3d(void)
art->listener = view3d_buttons_region_listener;
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui;
art->init = view3d_buttons_region_init;
art->draw = view3d_buttons_region_draw;
art->layout = view3d_buttons_region_layout;
art->draw = ED_region_panels_draw;
BLI_addhead(&st->regiontypes, art);
view3d_buttons_register(art);