blob: fdda8e636f7ba346d41b66d0284bcb4e729c680c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup edcurves
*/
#include "BLI_utildefines.h"
#include "ED_curves.h"
#include "ED_object.h"
#include "WM_api.h"
#include "WM_types.h"
#include "BKE_context.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_types.h"
static bool curves_sculptmode_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if (ob == nullptr) {
return false;
}
if (ob->type != OB_CURVES) {
return false;
}
return true;
}
static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES;
if (is_mode_set) {
if (!ED_object_mode_compat_set(C, ob, OB_MODE_SCULPT_CURVES, op->reports)) {
return OPERATOR_CANCELLED;
}
}
if (is_mode_set) {
ob->mode = OB_MODE_OBJECT;
}
else {
ob->mode = OB_MODE_SCULPT_CURVES;
}
WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr);
return OPERATOR_CANCELLED;
}
static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot)
{
ot->name = "Curve Sculpt Mode Toggle";
ot->idname = "CURVES_OT_sculptmode_toggle";
ot->description = "Enter/Exit sculpt mode for curves";
ot->exec = curves_sculptmode_toggle_exec;
ot->poll = curves_sculptmode_toggle_poll;
ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
}
void ED_operatortypes_curves()
{
WM_operatortype_append(CURVES_OT_sculptmode_toggle);
}
|