Blender V5.0
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"
32#include "UI_resources.hh"
33
34#include "view3d_intern.hh"
35
36/* -------------------------------------------------------------------- */
39
58
60{
61 /* identifiers */
62 ot->name = "Flip MatCap";
63 ot->description = "Flip MatCap";
64 ot->idname = "VIEW3D_OT_toggle_matcap_flip";
65
66 /* API callbacks. */
68}
69
71
72/* -------------------------------------------------------------------- */
75
77{
78 Object *obedit = CTX_data_edit_object(C);
79 if (!obedit || obedit->type != OB_MESH) {
80 return;
81 }
82
84 uiLayout *row = &layout->row(true);
85
86 PointerRNA op_ptr;
87 wmOperatorType *ot = WM_operatortype_find("MESH_OT_select_mode", true);
88 op_ptr = row->op(ot,
89 "",
90 ICON_VERTEXSEL,
93 RNA_enum_set(&op_ptr, "type", SCE_SELECT_VERTEX);
94 op_ptr = row->op(ot,
95 "",
96 ICON_EDGESEL,
99 RNA_enum_set(&op_ptr, "type", SCE_SELECT_EDGE);
100 op_ptr = row->op(ot,
101 "",
102 ICON_FACESEL,
105 RNA_enum_set(&op_ptr, "type", SCE_SELECT_FACE);
106}
107
109{
110 const Scene *scene = CTX_data_scene(C);
111 ViewLayer *view_layer = CTX_data_view_layer(C);
112 BKE_view_layer_synced_ensure(scene, view_layer);
114
115 /* Gizmos aren't used in paint modes */
117 /* masks aren't used for sculpt and particle painting */
119 static_cast<ID *>(ob->data), &RNA_Mesh, ob->data);
120 if (ob->mode & OB_MODE_TEXTURE_PAINT) {
121 layout->prop(&meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
122 }
123 else {
124 uiLayout *row = &layout->row(true);
125 row->prop(&meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
126 row->prop(&meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
127
128 /* Show the bone selection mode icon only if there is a pose mode armature */
129 Object *ob_armature = BKE_object_pose_armature_get(ob);
130 if (ob_armature) {
131 row->prop(&meshptr, "use_paint_bone_selection", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
132 }
133 }
134 }
135}
136
138{
139 const Scene *scene = CTX_data_scene(C);
140 ViewLayer *view_layer = CTX_data_view_layer(C);
141 BKE_view_layer_synced_ensure(scene, view_layer);
143 Object *obedit = CTX_data_edit_object(C);
144
145 bool is_paint = (ob && ELEM(ob->mode,
150
152 if ((obedit == nullptr) && is_paint) {
154 }
155}
156
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:1118
@ 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:435
#define NC_SCENE
Definition WM_types.hh:378
#define ND_SPACE_VIEW3D
Definition WM_types.hh:528
#define NC_SPACE
Definition WM_types.hh:392
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:414
View3DShading shading
struct SceneDisplay display
View3DShading shading
uiLayout & row(bool align)
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext context, eUI_Item_Flag flag)
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:4237
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)