Blender V5.0
view3d_navigate_view_pan.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "WM_api.hh"
10
11#include "RNA_access.hh"
12#include "RNA_define.hh"
13
14#include "view3d_intern.hh"
15
16#include "view3d_navigate.hh" /* own include */
17
18/* -------------------------------------------------------------------- */
23
24enum {
29};
30
32 {V3D_VIEW_PANLEFT, "PANLEFT", 0, "Pan Left", "Pan the view to the left"},
33 {V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the right"},
34 {V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view up"},
35 {V3D_VIEW_PANDOWN, "PANDOWN", 0, "Pan Down", "Pan the view down"},
36 {0, nullptr, 0, nullptr, nullptr},
37};
38
40 ViewOpsData *vod,
41 const wmEvent * /*event*/,
43{
44 int x = 0, y = 0;
45 int pandir = RNA_enum_get(ptr, "type");
46
47 if (pandir == V3D_VIEW_PANRIGHT) {
48 x = -32;
49 }
50 else if (pandir == V3D_VIEW_PANLEFT) {
51 x = 32;
52 }
53 else if (pandir == V3D_VIEW_PANUP) {
54 y = -25;
55 }
56 else if (pandir == V3D_VIEW_PANDOWN) {
57 y = 25;
58 }
59
60 viewmove_apply(vod, vod->prev.event_xy[0] + x, vod->prev.event_xy[1] + y);
61
62 return OPERATOR_FINISHED;
63}
64
66{
68}
69
71{
72 /* identifiers */
73 ot->name = "Pan View Direction";
74 ot->description = "Pan the view in a given direction";
75 ot->idname = ViewOpsType_pan.idname;
76
77 /* API callbacks. */
78 ot->invoke = viewpan_invoke;
80
81 /* flags */
82 ot->flag = 0;
83
84 /* Properties */
85 ot->prop = RNA_def_enum(
86 ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
87}
88
90
93 /*idname*/ "VIEW3D_OT_view_pan",
94 /*poll_fn*/ view3d_location_poll,
95 /*init_fn*/ viewpan_invoke_impl,
96 /*apply_fn*/ nullptr,
97};
@ OPERATOR_FINISHED
#define C
Definition RandGen.cpp:29
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
blender::int2 event_xy
struct ViewOpsData::@244345216304223004112237167211144027240265370072 prev
wmOperatorStatus view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
bool view3d_location_poll(bContext *C)
void viewmove_apply(ViewOpsData *vod, int x, int y)
const ViewOpsType ViewOpsType_pan
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_INIT_ZFAC
static wmOperatorStatus viewpan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus viewpan_invoke_impl(bContext *, ViewOpsData *vod, const wmEvent *, PointerRNA *ptr)
void VIEW3D_OT_view_pan(wmOperatorType *ot)
static const EnumPropertyItem prop_view_pan_items[]
PointerRNA * ptr
Definition wm_files.cc:4238
wmOperatorType * ot
Definition wm_files.cc:4237