Blender V4.5
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
8
9#include <cstdlib>
10#include <cstring>
11
12#include "DNA_object_types.h"
13#include "DNA_scene_types.h"
14
15#include "BLI_utildefines.h"
16
17#include "BKE_context.hh"
18#include "BKE_editmesh.hh"
19#include "BKE_layer.hh"
20#include "BKE_object.hh"
21
22#include "DEG_depsgraph.hh"
23
24#include "RNA_access.hh"
25#include "RNA_prototypes.hh"
26
27#include "WM_api.hh"
28#include "WM_types.hh"
29
30#include "UI_interface.hh"
31#include "UI_resources.hh"
32
33#include "view3d_intern.hh"
34
35/* -------------------------------------------------------------------- */
38
57
59{
60 /* identifiers */
61 ot->name = "Flip MatCap";
62 ot->description = "Flip MatCap";
63 ot->idname = "VIEW3D_OT_toggle_matcap_flip";
64
65 /* API callbacks. */
67}
68
70
71/* -------------------------------------------------------------------- */
74
76{
77 Object *obedit = CTX_data_edit_object(C);
78 if (!obedit || obedit->type != OB_MESH) {
79 return;
80 }
81
83 uiLayout *row = &layout->row(true);
84
85 PointerRNA op_ptr;
86 wmOperatorType *ot = WM_operatortype_find("MESH_OT_select_mode", true);
87 op_ptr = row->op(ot,
88 "",
89 ICON_VERTEXSEL,
92 RNA_enum_set(&op_ptr, "type", SCE_SELECT_VERTEX);
93 op_ptr = row->op(ot,
94 "",
95 ICON_EDGESEL,
98 RNA_enum_set(&op_ptr, "type", SCE_SELECT_EDGE);
99 op_ptr = row->op(ot,
100 "",
101 ICON_FACESEL,
104 RNA_enum_set(&op_ptr, "type", SCE_SELECT_FACE);
105}
106
108{
109 const Scene *scene = CTX_data_scene(C);
110 ViewLayer *view_layer = CTX_data_view_layer(C);
111 BKE_view_layer_synced_ensure(scene, view_layer);
113
114 /* Gizmos aren't used in paint modes */
116 /* masks aren't used for sculpt and particle painting */
118 static_cast<ID *>(ob->data), &RNA_Mesh, ob->data);
119 if (ob->mode & OB_MODE_TEXTURE_PAINT) {
120 layout->prop(&meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
121 }
122 else {
123 uiLayout *row = &layout->row(true);
124 row->prop(&meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
125 row->prop(&meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
126
127 /* Show the bone selection mode icon only if there is a pose mode armature */
128 Object *ob_armature = BKE_object_pose_armature_get(ob);
129 if (ob_armature) {
130 row->prop(&meshptr, "use_paint_bone_selection", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
131 }
132 }
133 }
134}
135
137{
138 const Scene *scene = CTX_data_scene(C);
139 ViewLayer *view_layer = CTX_data_view_layer(C);
140 BKE_view_layer_synced_ensure(scene, view_layer);
142 Object *obedit = CTX_data_edit_object(C);
143
144 bool is_paint = (ob && ELEM(ob->mode,
149
151 if ((obedit == nullptr) && is_paint) {
153 }
154}
155
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:61
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:1026
@ 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
@ OPERATOR_FINISHED
void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
#define C
Definition RandGen.cpp:29
@ UI_ITEM_O_DEPRESS
@ UI_ITEM_R_ICON_ONLY
#define UI_ITEM_NONE
#define ND_RENDER_OPTIONS
Definition WM_types.hh:432
#define NC_SCENE
Definition WM_types.hh:375
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:238
#define ND_SPACE_VIEW3D
Definition WM_types.hh:525
#define NC_SPACE
Definition WM_types.hh:389
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
short selectmode
Definition DNA_ID.h:404
View3DShading shading
struct SceneDisplay display
View3DShading shading
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
uiLayout & row(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
static void uiTemplatePaintModeSelection(uiLayout *layout, bContext *C)
void uiTemplateHeader3D_mode(uiLayout *layout, bContext *C)
void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
void uiTemplateEditModeSelection(uiLayout *layout, bContext *C)
static wmOperatorStatus toggle_matcap_flip_exec(bContext *C, wmOperator *)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4226
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)