Blender V4.3
view3d_header.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004-2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12
14#include "DNA_object_types.h"
15#include "DNA_scene_types.h"
16
17#include "BLI_utildefines.h"
18
19#include "BKE_context.hh"
20#include "BKE_editmesh.hh"
21#include "BKE_layer.hh"
22#include "BKE_object.hh"
23
24#include "DEG_depsgraph.hh"
25
26#include "RNA_access.hh"
27#include "RNA_prototypes.hh"
28
29#include "WM_api.hh"
30#include "WM_types.hh"
31
32#include "UI_interface.hh"
33#include "UI_resources.hh"
34
35#include "view3d_intern.hh"
36
37/* -------------------------------------------------------------------- */
42{
43 View3D *v3d = CTX_wm_view3d(C);
44
45 if (v3d) {
49 }
50 else {
51 Scene *scene = CTX_data_scene(C);
52 scene->display.shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
55 }
56
57 return OPERATOR_FINISHED;
58}
59
61{
62 /* identifiers */
63 ot->name = "Flip MatCap";
64 ot->description = "Flip MatCap";
65 ot->idname = "VIEW3D_OT_toggle_matcap_flip";
66
67 /* api callbacks */
69}
70
73/* -------------------------------------------------------------------- */
78{
79 Object *obedit = CTX_data_edit_object(C);
80 if (!obedit || obedit->type != OB_MESH) {
81 return;
82 }
83
85 uiLayout *row = uiLayoutRow(layout, true);
86
87 PointerRNA op_ptr;
88 wmOperatorType *ot = WM_operatortype_find("MESH_OT_select_mode", true);
90 ot,
91 "",
92 ICON_VERTEXSEL,
93 nullptr,
96 &op_ptr);
97 RNA_enum_set(&op_ptr, "type", SCE_SELECT_VERTEX);
99 ot,
100 "",
101 ICON_EDGESEL,
102 nullptr,
105 &op_ptr);
106 RNA_enum_set(&op_ptr, "type", SCE_SELECT_EDGE);
107 uiItemFullO_ptr(row,
108 ot,
109 "",
110 ICON_FACESEL,
111 nullptr,
114 &op_ptr);
115 RNA_enum_set(&op_ptr, "type", SCE_SELECT_FACE);
116}
117
119{
120 const Scene *scene = CTX_data_scene(C);
121 ViewLayer *view_layer = CTX_data_view_layer(C);
122 BKE_view_layer_synced_ensure(scene, view_layer);
124
125 /* Gizmos aren't used in paint modes */
127 /* masks aren't used for sculpt and particle painting */
128 PointerRNA meshptr = RNA_pointer_create(static_cast<ID *>(ob->data), &RNA_Mesh, ob->data);
129 if (ob->mode & OB_MODE_TEXTURE_PAINT) {
130 uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
131 }
132 else {
133 uiLayout *row = uiLayoutRow(layout, true);
134 uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
135 uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
136
137 /* Show the bone selection mode icon only if there is a pose mode armature */
138 Object *ob_armature = BKE_object_pose_armature_get(ob);
139 if (ob_armature) {
140 uiItemR(row, &meshptr, "use_paint_bone_selection", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
141 }
142 }
143 }
144}
145
147{
148 const Scene *scene = CTX_data_scene(C);
149 ViewLayer *view_layer = CTX_data_view_layer(C);
150 BKE_view_layer_synced_ensure(scene, view_layer);
152 Object *obedit = CTX_data_edit_object(C);
153
154 bool is_paint = (ob && ELEM(ob->mode,
159
161 if ((obedit == nullptr) && is_paint) {
163 }
164}
165
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
Definition editmesh.cc:63
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
General operations, lookup, etc. for blender objects.
Object * BKE_object_pose_armature_get(Object *ob)
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1085
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_SCULPT
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_VERTEX_PAINT
Object is a sort of wrapper for general info.
@ OB_MESH
@ SCE_SELECT_FACE
@ SCE_SELECT_VERTEX
@ SCE_SELECT_EDGE
@ V3D_SHADING_MATCAP_FLIP_X
void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, wmOperatorCallContext context, eUI_Item_Flag flag, PointerRNA *r_opptr)
#define UI_ITEM_NONE
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_O_DEPRESS
@ UI_ITEM_R_ICON_ONLY
#define ND_RENDER_OPTIONS
Definition WM_types.hh:402
#define NC_SCENE
Definition WM_types.hh:345
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:218
#define ND_SPACE_VIEW3D
Definition WM_types.hh:494
#define NC_SPACE
Definition WM_types.hh:359
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
short selectmode
Definition DNA_ID.h:413
View3DShading shading
const char * name
Definition WM_types.hh:990
const char * idname
Definition WM_types.hh:992
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
static void uiTemplatePaintModeSelection(uiLayout *layout, bContext *C)
static int toggle_matcap_flip_exec(bContext *C, wmOperator *)
void uiTemplateHeader3D_mode(uiLayout *layout, bContext *C)
void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
void uiTemplateEditModeSelection(uiLayout *layout, bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)