Blender V5.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
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.hh"
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
36namespace blender {
37
38/* -------------------------------------------------------------------- */
41
60
62{
63 /* identifiers */
64 ot->name = "Flip MatCap";
65 ot->description = "Flip MatCap";
66 ot->idname = "VIEW3D_OT_toggle_matcap_flip";
67
68 /* API callbacks. */
70}
71
73
74/* -------------------------------------------------------------------- */
77
79{
80 Object *obedit = CTX_data_edit_object(C);
81 if (!obedit || obedit->type != OB_MESH) {
82 return;
83 }
84
86 ui::Layout &row = layout->row(true);
87
88 wmOperatorType *ot = WM_operatortype_find("MESH_OT_select_mode", true);
89 PointerRNA op_ptr = row.op(ot,
90 "",
91 ICON_VERTEXSEL,
95 RNA_enum_set(&op_ptr, "type", SCE_SELECT_VERTEX);
96 op_ptr = row.op(ot,
97 "",
98 ICON_EDGESEL,
101 RNA_enum_set(&op_ptr, "type", SCE_SELECT_EDGE);
102 op_ptr = row.op(ot,
103 "",
104 ICON_FACESEL,
107 RNA_enum_set(&op_ptr, "type", SCE_SELECT_FACE);
108}
109
111{
112 const Main *bmain = CTX_data_main(C);
113 const Scene *scene = CTX_data_scene(C);
114 ViewLayer *view_layer = CTX_data_view_layer(C);
115 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
117
118 /* Gizmos aren't used in paint modes */
120 /* masks aren't used for sculpt and particle painting */
121 PointerRNA meshptr = RNA_pointer_create_discrete(ob->data, RNA_Mesh, ob->data);
122 if (ob->mode & OB_MODE_TEXTURE_PAINT) {
123 layout->prop(&meshptr, "use_paint_mask", ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
124 }
125 else {
126 ui::Layout &row = layout->row(true);
127 row.prop(&meshptr, "use_paint_mask", ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
128 row.prop(&meshptr, "use_paint_mask_vertex", ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
129
130 /* Show the bone selection mode icon only if there is a pose mode armature */
131 Object *ob_armature = BKE_object_pose_armature_get(ob);
132 if (ob_armature) {
133 row.prop(&meshptr, "use_paint_bone_selection", ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
134 }
135 }
136 }
137}
138
140{
141 const Main *bmain = CTX_data_main(C);
142 const Scene *scene = CTX_data_scene(C);
143 ViewLayer *view_layer = CTX_data_view_layer(C);
144 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
146 Object *obedit = CTX_data_edit_object(C);
147
148 bool is_paint = (ob && ELEM(ob->mode,
153
155 if ((obedit == nullptr) && is_paint) {
157 }
158}
159
161
162} // namespace blender
General operations, lookup, etc. for blender objects.
Object is a sort of wrapper for general info.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define ND_RENDER_OPTIONS
Definition WM_types.hh:454
#define NC_SCENE
Definition WM_types.hh:391
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NC_SPACE
Definition WM_types.hh:405
#define ELEM(...)
BMesh Iterators.
ScrArea * CTX_wm_area(const bContext *C)
static void uiTemplatePaintModeSelection(ui::Layout *layout, bContext *C)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@ V3D_SHADING_MATCAP_FLIP_X
ViewLayer * CTX_data_view_layer(const bContext *C)
void DEG_id_tag_update(ID *id, unsigned int flags)
void uiTemplateEditModeSelection(ui::Layout *layout, bContext *C)
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_PARTICLE_EDIT
Object * BKE_object_pose_armature_get(Object *ob)
Definition object.cc:2507
Object * CTX_data_edit_object(const bContext *C)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
Definition editmesh.cc:59
static wmOperatorStatus toggle_matcap_flip_exec(bContext *C, wmOperator *)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void template_header3D_mode(ui::Layout *layout, bContext *C)
Main * CTX_data_main(const bContext *C)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
Scene * CTX_data_scene(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
struct SceneDisplay display
eView3DShading_Flag flag
View3DShading shading
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & row(bool align)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115