Updates to manipulator API
While this is work-in-progress from custom-manipulators branch its stable so adding into 2.8 so we don't get too much out of sync. - ManipulatorGroupType's are moved out of the manipulator-map and are now global (like operators, panels etc) and added into spaces as needed. Without this all operators that might ever use a manipulator in the 3D view would be polling the viewport. - Add optional get/set callbacks for non-RNA properties Needed so re-usable manipulators can control values that don't correspond to a single properly or need conversion. - Fix divide by zero bug in arrow manipulator (when moving zero pixels).
This commit is contained in:
@@ -58,7 +58,6 @@ set(SRC_DNA_INC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_manipulator_types.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h
|
||||||
|
@@ -161,10 +161,10 @@ void TRANSFORM_WGT_manipulator(struct wmManipulatorGroupType *wgt);
|
|||||||
|
|
||||||
void TRANSFORM_WGT_object(struct wmManipulatorGroupType *wgt);
|
void TRANSFORM_WGT_object(struct wmManipulatorGroupType *wgt);
|
||||||
|
|
||||||
bool WIDGETGROUP_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgrouptype);
|
bool ED_widgetgroup_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt);
|
||||||
void WIDGETGROUP_manipulator2d_init(const struct bContext *C, struct wmManipulatorGroup *wgroup);
|
void ED_widgetgroup_manipulator2d_setup(const struct bContext *C, struct wmManipulatorGroup *mgroup);
|
||||||
void WIDGETGROUP_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *wgroup);
|
void ED_widgetgroup_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *mgroup);
|
||||||
void WIDGETGROUP_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *wgroup);
|
void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *mgroup);
|
||||||
|
|
||||||
|
|
||||||
/* Snapping */
|
/* Snapping */
|
||||||
|
@@ -43,6 +43,7 @@ set(SRC
|
|||||||
dial3d_manipulator.c
|
dial3d_manipulator.c
|
||||||
geom_arrow_manipulator.c
|
geom_arrow_manipulator.c
|
||||||
geom_cube_manipulator.c
|
geom_cube_manipulator.c
|
||||||
|
geom_dial_manipulator.c
|
||||||
manipulator_draw_utils.c
|
manipulator_draw_utils.c
|
||||||
manipulator_library_presets.c
|
manipulator_library_presets.c
|
||||||
manipulator_library_utils.c
|
manipulator_library_utils.c
|
||||||
|
@@ -39,7 +39,6 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_rect.h"
|
#include "BLI_rect.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_windowmanager_types.h"
|
#include "DNA_windowmanager_types.h"
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
@@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
|
|
||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
@@ -90,7 +89,7 @@ typedef struct ArrowManipulator3D {
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void manipulator_arrow_get_final_pos(wmManipulator *mpr, float r_pos[3])
|
static void manipulator_arrow_position_get(wmManipulator *mpr, float r_pos[3])
|
||||||
{
|
{
|
||||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||||
|
|
||||||
@@ -194,7 +193,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
|
|||||||
float final_pos[3];
|
float final_pos[3];
|
||||||
|
|
||||||
manipulator_color_get(&arrow->manipulator, highlight, col);
|
manipulator_color_get(&arrow->manipulator, highlight, col);
|
||||||
manipulator_arrow_get_final_pos(&arrow->manipulator, final_pos);
|
manipulator_arrow_position_get(&arrow->manipulator, final_pos);
|
||||||
|
|
||||||
if (arrow->flag & ARROW_UP_VECTOR_SET) {
|
if (arrow->flag & ARROW_UP_VECTOR_SET) {
|
||||||
copy_v3_v3(rot[2], arrow->direction);
|
copy_v3_v3(rot[2], arrow->direction);
|
||||||
@@ -238,7 +237,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_arrow_render_3d_intersect(
|
static void manipulator_arrow_draw_select(
|
||||||
const bContext *UNUSED(C), wmManipulator *mpr,
|
const bContext *UNUSED(C), wmManipulator *mpr,
|
||||||
int selectionbase)
|
int selectionbase)
|
||||||
{
|
{
|
||||||
@@ -327,14 +326,17 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
|
|||||||
|
|
||||||
normalize_v3(viewvec);
|
normalize_v3(viewvec);
|
||||||
if (!use_vertical) {
|
if (!use_vertical) {
|
||||||
float fac;
|
|
||||||
/* now find a plane parallel to the view vector so we can intersect with the arrow direction */
|
/* now find a plane parallel to the view vector so we can intersect with the arrow direction */
|
||||||
cross_v3_v3v3(tangent, viewvec, offset);
|
cross_v3_v3v3(tangent, viewvec, offset);
|
||||||
cross_v3_v3v3(plane, tangent, viewvec);
|
cross_v3_v3v3(plane, tangent, viewvec);
|
||||||
fac = dot_v3v3(plane, offset) / dot_v3v3(arrow->direction, plane);
|
|
||||||
|
|
||||||
|
const float plane_offset = dot_v3v3(plane, offset);
|
||||||
|
const float plane_dir = dot_v3v3(plane, arrow->direction);
|
||||||
|
const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
|
||||||
facdir = (fac < 0.0) ? -1.0 : 1.0;
|
facdir = (fac < 0.0) ? -1.0 : 1.0;
|
||||||
mul_v3_v3fl(offset, arrow->direction, fac);
|
if (isfinite(fac)) {
|
||||||
|
mul_v3_v3fl(offset, arrow->direction, fac);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0;
|
facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0;
|
||||||
@@ -344,18 +346,18 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
|
|||||||
ManipulatorCommonData *data = &arrow->data;
|
ManipulatorCommonData *data = &arrow->data;
|
||||||
const float ofs_new = facdir * len_v3(offset);
|
const float ofs_new = facdir * len_v3(offset);
|
||||||
|
|
||||||
wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
|
wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
|
||||||
|
|
||||||
/* set the property for the operator and call its modal function */
|
/* set the property for the operator and call its modal function */
|
||||||
if (mpr_prop->prop != NULL) {
|
if (WM_manipulator_property_is_valid(mpr_prop)) {
|
||||||
const bool constrained = arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED;
|
const bool constrained = arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED;
|
||||||
const bool inverted = arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED;
|
const bool inverted = arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED;
|
||||||
const bool use_precision = flag & WM_MANIPULATOR_TWEAK_PRECISE;
|
const bool use_precision = flag & WM_MANIPULATOR_TWEAK_PRECISE;
|
||||||
float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
|
float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
|
||||||
|
|
||||||
manipulator_property_value_set(C, mpr, mpr_prop, value);
|
WM_manipulator_property_value_set(C, mpr, mpr_prop, value);
|
||||||
/* get clamped value */
|
/* get clamped value */
|
||||||
value = manipulator_property_value_get(mpr, mpr_prop);
|
value = WM_manipulator_property_value_get(mpr, mpr_prop);
|
||||||
|
|
||||||
data->offset = manipulator_offset_from_value(data, value, constrained, inverted);
|
data->offset = manipulator_offset_from_value(data, value, constrained, inverted);
|
||||||
}
|
}
|
||||||
@@ -374,11 +376,11 @@ static void manipulator_arrow_invoke(
|
|||||||
{
|
{
|
||||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||||
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
|
ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__);
|
||||||
wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
|
wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
|
||||||
|
|
||||||
/* Some manipulators don't use properties. */
|
/* Some manipulators don't use properties. */
|
||||||
if (mpr_prop && mpr_prop->prop) {
|
if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) {
|
||||||
inter->init_value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
|
inter->init_value = WM_manipulator_property_value_get(mpr, mpr_prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
inter->init_offset = arrow->data.offset;
|
inter->init_offset = arrow->data.offset;
|
||||||
@@ -388,16 +390,16 @@ static void manipulator_arrow_invoke(
|
|||||||
|
|
||||||
inter->init_scale = mpr->scale;
|
inter->init_scale = mpr->scale;
|
||||||
|
|
||||||
manipulator_arrow_get_final_pos(mpr, inter->init_origin);
|
manipulator_arrow_position_get(mpr, inter->init_origin);
|
||||||
|
|
||||||
mpr->interaction_data = inter;
|
mpr->interaction_data = inter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_arrow_property_update(wmManipulator *mnp, wmManipulatorProperty *mpr_prop)
|
static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
|
||||||
{
|
{
|
||||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mnp;
|
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||||
manipulator_property_data_update(
|
manipulator_property_data_update(
|
||||||
mnp, &arrow->data, mpr_prop,
|
mpr, &arrow->data, mpr_prop,
|
||||||
(arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0,
|
(arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0,
|
||||||
(arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0);
|
(arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0);
|
||||||
}
|
}
|
||||||
@@ -411,7 +413,7 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c
|
|||||||
ManipulatorCommonData *data = &arrow->data;
|
ManipulatorCommonData *data = &arrow->data;
|
||||||
ManipulatorInteraction *inter = mpr->interaction_data;
|
ManipulatorInteraction *inter = mpr->interaction_data;
|
||||||
|
|
||||||
wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset");
|
wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset");
|
||||||
manipulator_property_value_reset(C, mpr, inter, mpr_prop);
|
manipulator_property_value_reset(C, mpr, inter, mpr_prop);
|
||||||
data->offset = inter->init_offset;
|
data->offset = inter->init_offset;
|
||||||
}
|
}
|
||||||
@@ -486,15 +488,15 @@ void ED_manipulator_arrow3d_set_line_len(wmManipulator *mpr, const float len)
|
|||||||
/**
|
/**
|
||||||
* Define a custom property UI range
|
* Define a custom property UI range
|
||||||
*
|
*
|
||||||
* \note Needs to be called before WM_manipulator_def_property!
|
* \note Needs to be called before WM_manipulator_property_def_rna!
|
||||||
*/
|
*/
|
||||||
void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max)
|
void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max)
|
||||||
{
|
{
|
||||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||||
|
|
||||||
BLI_assert(min < max);
|
BLI_assert(min < max);
|
||||||
BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function "
|
BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function "
|
||||||
"is called before WM_manipulator_def_property"));
|
"is called before WM_manipulator_property_def_rna"));
|
||||||
|
|
||||||
arrow->data.range = max - min;
|
arrow->data.range = max - min;
|
||||||
arrow->data.min = min;
|
arrow->data.min = min;
|
||||||
@@ -504,13 +506,13 @@ void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, co
|
|||||||
/**
|
/**
|
||||||
* Define a custom factor for arrow min/max distance
|
* Define a custom factor for arrow min/max distance
|
||||||
*
|
*
|
||||||
* \note Needs to be called before WM_manipulator_def_property!
|
* \note Needs to be called before WM_manipulator_property_def_rna!
|
||||||
*/
|
*/
|
||||||
void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac)
|
void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac)
|
||||||
{
|
{
|
||||||
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
|
||||||
BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function "
|
BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function "
|
||||||
"is called before WM_manipulator_def_property"));
|
"is called before WM_manipulator_property_def_rna"));
|
||||||
|
|
||||||
arrow->data.range_fac = range_fac;
|
arrow->data.range_fac = range_fac;
|
||||||
}
|
}
|
||||||
@@ -532,8 +534,8 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
|
|||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
wt->draw = manipulator_arrow_draw;
|
wt->draw = manipulator_arrow_draw;
|
||||||
wt->draw_select = manipulator_arrow_render_3d_intersect;
|
wt->draw_select = manipulator_arrow_draw_select;
|
||||||
wt->position_get = manipulator_arrow_get_final_pos;
|
wt->position_get = manipulator_arrow_position_get;
|
||||||
wt->modal = manipulator_arrow_modal;
|
wt->modal = manipulator_arrow_modal;
|
||||||
wt->invoke = manipulator_arrow_invoke;
|
wt->invoke = manipulator_arrow_invoke;
|
||||||
wt->property_update = manipulator_arrow_property_update;
|
wt->property_update = manipulator_arrow_property_update;
|
||||||
|
@@ -41,8 +41,6 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_rect.h"
|
#include "BLI_rect.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_manipulator_library.h"
|
#include "ED_manipulator_library.h"
|
||||||
|
|
||||||
@@ -367,7 +365,7 @@ typedef struct RectTransformInteraction {
|
|||||||
} RectTransformInteraction;
|
} RectTransformInteraction;
|
||||||
|
|
||||||
static bool manipulator_rect_transform_get_prop_value(
|
static bool manipulator_rect_transform_get_prop_value(
|
||||||
wmManipulator *mnp, wmManipulatorProperty *mpr_prop, float *value)
|
wmManipulator *mpr, wmManipulatorProperty *mpr_prop, float *value)
|
||||||
{
|
{
|
||||||
PropertyType type = RNA_property_type(mpr_prop->prop);
|
PropertyType type = RNA_property_type(mpr_prop->prop);
|
||||||
|
|
||||||
@@ -384,7 +382,7 @@ static bool manipulator_rect_transform_get_prop_value(
|
|||||||
RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
|
RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
|
||||||
}
|
}
|
||||||
else if (STREQ(mpr_prop->idname, "scale")) {
|
else if (STREQ(mpr_prop->idname, "scale")) {
|
||||||
RectTransformManipulator *cage = (RectTransformManipulator *)mnp;
|
RectTransformManipulator *cage = (RectTransformManipulator *)mpr;
|
||||||
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
||||||
*value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
|
*value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
|
||||||
}
|
}
|
||||||
@@ -488,13 +486,13 @@ static void manipulator_rect_transform_modal(
|
|||||||
|
|
||||||
wmManipulatorProperty *mpr_prop;
|
wmManipulatorProperty *mpr_prop;
|
||||||
|
|
||||||
mpr_prop = WM_manipulator_get_property(mpr, "offset");
|
mpr_prop = WM_manipulator_property_find(mpr, "offset");
|
||||||
if (mpr_prop->prop != NULL) {
|
if (mpr_prop->prop != NULL) {
|
||||||
RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->offset);
|
RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->offset);
|
||||||
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpr_prop = WM_manipulator_get_property(mpr, "scale");
|
mpr_prop = WM_manipulator_property_find(mpr, "scale");
|
||||||
if (mpr_prop->prop != NULL) {
|
if (mpr_prop->prop != NULL) {
|
||||||
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
||||||
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, cage->scale[0]);
|
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, cage->scale[0]);
|
||||||
@@ -509,15 +507,15 @@ static void manipulator_rect_transform_modal(
|
|||||||
ED_region_tag_redraw(CTX_wm_region(C));
|
ED_region_tag_redraw(CTX_wm_region(C));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_rect_transform_property_update(wmManipulator *mnp, wmManipulatorProperty *mpr_prop)
|
static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
|
||||||
{
|
{
|
||||||
RectTransformManipulator *cage = (RectTransformManipulator *)mnp;
|
RectTransformManipulator *cage = (RectTransformManipulator *)mpr;
|
||||||
|
|
||||||
if (STREQ(mpr_prop->idname, "offset")) {
|
if (STREQ(mpr_prop->idname, "offset")) {
|
||||||
manipulator_rect_transform_get_prop_value(mnp, mpr_prop, mnp->offset);
|
manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->offset);
|
||||||
}
|
}
|
||||||
else if (STREQ(mpr_prop->idname, "scale")) {
|
else if (STREQ(mpr_prop->idname, "scale")) {
|
||||||
manipulator_rect_transform_get_prop_value(mnp, mpr_prop, cage->scale);
|
manipulator_rect_transform_get_prop_value(mpr, mpr_prop, cage->scale);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_assert(0);
|
BLI_assert(0);
|
||||||
@@ -535,13 +533,13 @@ static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, con
|
|||||||
wmManipulatorProperty *mpr_prop;
|
wmManipulatorProperty *mpr_prop;
|
||||||
|
|
||||||
/* reset properties */
|
/* reset properties */
|
||||||
mpr_prop = WM_manipulator_get_property(mpr, "offset");
|
mpr_prop = WM_manipulator_property_find(mpr, "offset");
|
||||||
if (mpr_prop->prop != NULL) {
|
if (mpr_prop->prop != NULL) {
|
||||||
RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, data->orig_offset);
|
RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, data->orig_offset);
|
||||||
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpr_prop = WM_manipulator_get_property(mpr, "scale");
|
mpr_prop = WM_manipulator_property_find(mpr, "scale");
|
||||||
if (mpr_prop->prop != NULL) {
|
if (mpr_prop->prop != NULL) {
|
||||||
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) {
|
||||||
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, data->orig_scale[0]);
|
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, data->orig_scale[0]);
|
||||||
|
@@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
#include "ED_manipulator_library.h"
|
#include "ED_manipulator_library.h"
|
||||||
@@ -66,6 +64,8 @@
|
|||||||
/* to use custom dials exported to geom_dial_manipulator.c */
|
/* to use custom dials exported to geom_dial_manipulator.c */
|
||||||
// #define USE_MANIPULATOR_CUSTOM_DIAL
|
// #define USE_MANIPULATOR_CUSTOM_DIAL
|
||||||
|
|
||||||
|
static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag);
|
||||||
|
|
||||||
typedef struct DialManipulator {
|
typedef struct DialManipulator {
|
||||||
wmManipulator manipulator;
|
wmManipulator manipulator;
|
||||||
int style;
|
int style;
|
||||||
@@ -79,11 +79,29 @@ typedef struct DialInteraction {
|
|||||||
float last_angle;
|
float last_angle;
|
||||||
/* number of full rotations */
|
/* number of full rotations */
|
||||||
int rotations;
|
int rotations;
|
||||||
|
|
||||||
|
/* final output values, used for drawing */
|
||||||
|
struct {
|
||||||
|
float angle_ofs;
|
||||||
|
float angle_delta;
|
||||||
|
} output;
|
||||||
} DialInteraction;
|
} DialInteraction;
|
||||||
|
|
||||||
#define DIAL_WIDTH 1.0f
|
#define DIAL_WIDTH 1.0f
|
||||||
#define DIAL_RESOLUTION 32
|
#define DIAL_RESOLUTION 32
|
||||||
|
|
||||||
|
|
||||||
|
static void dial_calc_matrix(const DialManipulator *dial, float mat[4][4])
|
||||||
|
{
|
||||||
|
float rot[3][3];
|
||||||
|
const float up[3] = {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
rotation_between_vecs_to_mat3(rot, up, dial->direction);
|
||||||
|
copy_m4_m3(mat, rot);
|
||||||
|
copy_v3_v3(mat[3], dial->manipulator.origin);
|
||||||
|
mul_mat3_m4_fl(mat, dial->manipulator.scale);
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void dial_geom_draw(
|
static void dial_geom_draw(
|
||||||
@@ -221,31 +239,36 @@ static void dial_draw_intern(
|
|||||||
const bContext *C, DialManipulator *dial,
|
const bContext *C, DialManipulator *dial,
|
||||||
const bool select, const bool highlight, float clip_plane[4])
|
const bool select, const bool highlight, float clip_plane[4])
|
||||||
{
|
{
|
||||||
float rot[3][3];
|
|
||||||
float mat[4][4];
|
float mat[4][4];
|
||||||
const float up[3] = {0.0f, 0.0f, 1.0f};
|
|
||||||
float col[4];
|
float col[4];
|
||||||
|
|
||||||
BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
|
BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
|
||||||
|
|
||||||
manipulator_color_get(&dial->manipulator, highlight, col);
|
manipulator_color_get(&dial->manipulator, highlight, col);
|
||||||
|
|
||||||
rotation_between_vecs_to_mat3(rot, up, dial->direction);
|
dial_calc_matrix(dial, mat);
|
||||||
copy_m4_m3(mat, rot);
|
|
||||||
copy_v3_v3(mat[3], dial->manipulator.origin);
|
|
||||||
mul_mat3_m4_fl(mat, dial->manipulator.scale);
|
|
||||||
|
|
||||||
gpuPushMatrix();
|
gpuPushMatrix();
|
||||||
gpuMultMatrix(mat);
|
gpuMultMatrix(mat);
|
||||||
gpuTranslate3fv(dial->manipulator.offset);
|
gpuTranslate3fv(dial->manipulator.offset);
|
||||||
|
|
||||||
/* draw rotation indicator arc first */
|
/* draw rotation indicator arc first */
|
||||||
if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) && (dial->manipulator.state & WM_MANIPULATOR_STATE_ACTIVE)) {
|
if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) &&
|
||||||
wmWindow *win = CTX_wm_window(C);
|
(dial->manipulator.state & WM_MANIPULATOR_STATE_ACTIVE))
|
||||||
|
{
|
||||||
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
|
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
|
||||||
float angle_ofs, angle_delta;
|
|
||||||
|
|
||||||
dial_ghostarc_get_angles(dial, win->eventstate, CTX_wm_region(C), mat, co_outer, &angle_ofs, &angle_delta);
|
DialInteraction *inter = dial->manipulator.interaction_data;
|
||||||
|
|
||||||
|
/* XXX, View3D rotation manipulator doesn't call modal. */
|
||||||
|
if (dial->manipulator.properties.first == NULL) {
|
||||||
|
wmWindow *win = CTX_wm_window(C);
|
||||||
|
manipulator_dial_modal((bContext *)C, &dial->manipulator, win->eventstate, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float angle_ofs = inter->output.angle_ofs;
|
||||||
|
const float angle_delta = inter->output.angle_delta;
|
||||||
|
|
||||||
/* draw! */
|
/* draw! */
|
||||||
dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f});
|
dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f});
|
||||||
|
|
||||||
@@ -259,7 +282,7 @@ static void dial_draw_intern(
|
|||||||
gpuPopMatrix();
|
gpuPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_dial_render_3d_intersect(const bContext *C, wmManipulator *mpr, int selectionbase)
|
static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase)
|
||||||
{
|
{
|
||||||
DialManipulator *dial = (DialManipulator *)mpr;
|
DialManipulator *dial = (DialManipulator *)mpr;
|
||||||
float clip_plane_buf[4];
|
float clip_plane_buf[4];
|
||||||
@@ -312,6 +335,23 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag))
|
||||||
|
{
|
||||||
|
DialManipulator *dial = (DialManipulator *)mpr;
|
||||||
|
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
|
||||||
|
float angle_ofs, angle_delta;
|
||||||
|
|
||||||
|
float mat[4][4];
|
||||||
|
|
||||||
|
dial_calc_matrix(dial, mat);
|
||||||
|
|
||||||
|
dial_ghostarc_get_angles(dial, event, CTX_wm_region(C), mat, co_outer, &angle_ofs, &angle_delta);
|
||||||
|
|
||||||
|
DialInteraction *inter = dial->manipulator.interaction_data;
|
||||||
|
inter->output.angle_delta = angle_delta;
|
||||||
|
inter->output.angle_ofs = angle_ofs;
|
||||||
|
}
|
||||||
|
|
||||||
static void manipulator_dial_invoke(
|
static void manipulator_dial_invoke(
|
||||||
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
|
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
|
||||||
{
|
{
|
||||||
@@ -362,8 +402,9 @@ static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
|
|||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
wt->draw = manipulator_dial_draw;
|
wt->draw = manipulator_dial_draw;
|
||||||
wt->draw_select = manipulator_dial_render_3d_intersect;
|
wt->draw_select = manipulator_dial_draw_select;
|
||||||
wt->invoke = manipulator_dial_invoke;
|
wt->invoke = manipulator_dial_invoke;
|
||||||
|
wt->modal = manipulator_dial_modal;
|
||||||
|
|
||||||
wt->struct_size = sizeof(DialManipulator);
|
wt->struct_size = sizeof(DialManipulator);
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,6 @@
|
|||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_string_utils.h"
|
#include "BLI_string_utils.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
|
|
||||||
|
@@ -76,15 +76,11 @@ float manipulator_value_from_offset(
|
|||||||
const bool constrained, const bool inverted, const bool use_precision);
|
const bool constrained, const bool inverted, const bool use_precision);
|
||||||
|
|
||||||
void manipulator_property_data_update(
|
void manipulator_property_data_update(
|
||||||
struct wmManipulator *mnp, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
|
struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
|
||||||
const bool constrained, const bool inverted);
|
const bool constrained, const bool inverted);
|
||||||
|
|
||||||
void manipulator_property_value_set(
|
|
||||||
bContext *C, const struct wmManipulator *mnp, wmManipulatorProperty *mpr_prop, const float value);
|
|
||||||
float manipulator_property_value_get(
|
|
||||||
const struct wmManipulator *mnp, wmManipulatorProperty *mpr_prop);
|
|
||||||
void manipulator_property_value_reset(
|
void manipulator_property_value_reset(
|
||||||
bContext *C, const struct wmManipulator *mnp, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop);
|
bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop);
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
|
|
||||||
|
@@ -105,20 +105,25 @@ void manipulator_property_data_update(
|
|||||||
wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
|
wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop,
|
||||||
const bool constrained, const bool inverted)
|
const bool constrained, const bool inverted)
|
||||||
{
|
{
|
||||||
if (mpr_prop->prop == NULL) {
|
if (mpr_prop->custom_func.value_get_fn != NULL) {
|
||||||
|
/* pass */
|
||||||
|
}
|
||||||
|
else if (mpr_prop->prop != NULL) {
|
||||||
|
/* pass */
|
||||||
|
}
|
||||||
|
else {
|
||||||
data->offset = 0.0f;
|
data->offset = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float value = manipulator_property_value_get(mpr, mpr_prop);
|
float value = WM_manipulator_property_value_get(mpr, mpr_prop);
|
||||||
|
|
||||||
if (constrained) {
|
if (constrained) {
|
||||||
if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) {
|
if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) {
|
||||||
float step, precision;
|
float range[2];
|
||||||
float min, max;
|
WM_manipulator_property_range_get(mpr, mpr_prop, range);
|
||||||
RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &min, &max, &step, &precision);
|
data->range = range[1] - range[0];
|
||||||
data->range = max - min;
|
data->min = range[0];
|
||||||
data->min = min;
|
|
||||||
}
|
}
|
||||||
data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
|
data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted);
|
||||||
}
|
}
|
||||||
@@ -127,40 +132,13 @@ void manipulator_property_data_update(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void manipulator_property_value_set(
|
|
||||||
bContext *C, const wmManipulator *UNUSED(mnp),
|
|
||||||
wmManipulatorProperty *mpr_prop, const float value)
|
|
||||||
{
|
|
||||||
/* reset property */
|
|
||||||
if (mpr_prop->index == -1) {
|
|
||||||
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value);
|
|
||||||
}
|
|
||||||
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
float manipulator_property_value_get(
|
|
||||||
const wmManipulator *UNUSED(mnp),
|
|
||||||
wmManipulatorProperty *mpr_prop)
|
|
||||||
{
|
|
||||||
if (mpr_prop->index == -1) {
|
|
||||||
return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void manipulator_property_value_reset(
|
void manipulator_property_value_reset(
|
||||||
bContext *C, const wmManipulator *mnp, ManipulatorInteraction *inter,
|
bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter,
|
||||||
wmManipulatorProperty *mpr_prop)
|
wmManipulatorProperty *mpr_prop)
|
||||||
{
|
{
|
||||||
manipulator_property_value_set(C, mnp, mpr_prop, inter->init_value);
|
WM_manipulator_property_value_set(C, mpr, mpr_prop, inter->init_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void manipulator_color_get(
|
void manipulator_color_get(
|
||||||
|
@@ -36,7 +36,6 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
|
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "GPU_immediate.h"
|
#include "GPU_immediate.h"
|
||||||
#include "GPU_matrix.h"
|
#include "GPU_matrix.h"
|
||||||
@@ -157,7 +156,7 @@ static void manipulator_primitive_draw_intern(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manipulator_primitive_render_3d_intersect(
|
static void manipulator_primitive_draw_select(
|
||||||
const bContext *UNUSED(C), wmManipulator *mpr,
|
const bContext *UNUSED(C), wmManipulator *mpr,
|
||||||
int selectionbase)
|
int selectionbase)
|
||||||
{
|
{
|
||||||
@@ -238,7 +237,7 @@ static void MANIPULATOR_WT_primitive3d(wmManipulatorType *wt)
|
|||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
wt->draw = manipulator_primitive_draw;
|
wt->draw = manipulator_primitive_draw;
|
||||||
wt->draw_select = manipulator_primitive_render_3d_intersect;
|
wt->draw_select = manipulator_primitive_draw_select;
|
||||||
wt->invoke = manipulator_primitive_invoke;
|
wt->invoke = manipulator_primitive_invoke;
|
||||||
|
|
||||||
wt->struct_size = sizeof(PrimitiveManipulator);
|
wt->struct_size = sizeof(PrimitiveManipulator);
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
#include "BKE_image.h"
|
#include "BKE_image.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_manipulator_library.h"
|
#include "ED_manipulator_library.h"
|
||||||
|
|
||||||
@@ -95,8 +93,8 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG
|
|||||||
SpaceNode *snode = CTX_wm_space_node(C);
|
SpaceNode *snode = CTX_wm_space_node(C);
|
||||||
PointerRNA nodeptr;
|
PointerRNA nodeptr;
|
||||||
RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr);
|
RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr);
|
||||||
WM_manipulator_def_property(cage, "offset", &nodeptr, "backdrop_offset", -1);
|
WM_manipulator_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1);
|
||||||
WM_manipulator_def_property(cage, "scale", &nodeptr, "backdrop_zoom", -1);
|
WM_manipulator_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true);
|
WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true);
|
||||||
@@ -110,6 +108,8 @@ void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt)
|
|||||||
wgt->name = "Backdrop Transform Widgets";
|
wgt->name = "Backdrop Transform Widgets";
|
||||||
wgt->idname = "NODE_WGT_backdrop_transform";
|
wgt->idname = "NODE_WGT_backdrop_transform";
|
||||||
|
|
||||||
|
wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT;
|
||||||
|
|
||||||
wgt->poll = WIDGETGROUP_node_transform_poll;
|
wgt->poll = WIDGETGROUP_node_transform_poll;
|
||||||
wgt->setup = WIDGETGROUP_node_transform_setup;
|
wgt->setup = WIDGETGROUP_node_transform_setup;
|
||||||
wgt->refresh = WIDGETGROUP_node_transform_refresh;
|
wgt->refresh = WIDGETGROUP_node_transform_refresh;
|
||||||
|
@@ -646,9 +646,9 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar)
|
|||||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
||||||
|
|
||||||
/* manipulators stay in the background for now - quick patchjob to make sure nodes themselves work */
|
/* manipulators stay in the background for now - quick patchjob to make sure nodes themselves work */
|
||||||
if (!ar->manipulator_map) {
|
if (ar->manipulator_map == NULL) {
|
||||||
ar->manipulator_map = WM_manipulatormap_new_from_type(&(const struct wmManipulatorMapType_Params) {
|
ar->manipulator_map = WM_manipulatormap_new_from_type(
|
||||||
"Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW});
|
&(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
|
||||||
}
|
}
|
||||||
|
|
||||||
WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
|
WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
|
||||||
@@ -859,9 +859,9 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
|
|||||||
static void node_widgets(void)
|
static void node_widgets(void)
|
||||||
{
|
{
|
||||||
/* create the widgetmap for the area here */
|
/* create the widgetmap for the area here */
|
||||||
wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&(const struct wmManipulatorMapType_Params) {
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
|
||||||
"Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW});
|
&(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW});
|
||||||
WM_manipulatorgrouptype_append(wmaptype, NODE_WGT_backdrop_transform);
|
WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
|
static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
|
||||||
|
@@ -491,9 +491,9 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
|
|||||||
ListBase *lb;
|
ListBase *lb;
|
||||||
wmKeyMap *keymap;
|
wmKeyMap *keymap;
|
||||||
|
|
||||||
if (!ar->manipulator_map) {
|
if (ar->manipulator_map == NULL) {
|
||||||
ar->manipulator_map = WM_manipulatormap_new_from_type(&(const struct wmManipulatorMapType_Params) {
|
ar->manipulator_map = WM_manipulatormap_new_from_type(
|
||||||
"View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW});
|
&(const struct wmManipulatorMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW});
|
||||||
}
|
}
|
||||||
|
|
||||||
WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
|
WM_manipulatormap_add_handlers(ar, ar->manipulator_map);
|
||||||
@@ -731,16 +731,13 @@ static void view3d_dropboxes(void)
|
|||||||
|
|
||||||
static void view3d_widgets(void)
|
static void view3d_widgets(void)
|
||||||
{
|
{
|
||||||
const struct wmManipulatorMapType_Params wmap_params = {
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(
|
||||||
.idname = "View3D",
|
&(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
|
||||||
.spaceid = SPACE_VIEW3D, .regionid = RGN_TYPE_WINDOW,
|
|
||||||
};
|
|
||||||
wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&wmap_params);
|
|
||||||
|
|
||||||
WM_manipulatorgrouptype_append(wmaptype, TRANSFORM_WGT_manipulator);
|
WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator);
|
||||||
WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_lamp);
|
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp);
|
||||||
WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_force_field);
|
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field);
|
||||||
WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_camera);
|
WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -39,7 +39,6 @@
|
|||||||
#include "DNA_lamp_types.h"
|
#include "DNA_lamp_types.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_object_force.h"
|
#include "DNA_object_force.h"
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_armature.h"
|
#include "ED_armature.h"
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
@@ -103,7 +102,7 @@ static void WIDGETGROUP_lamp_refresh(const bContext *C, wmManipulatorGroup *mgro
|
|||||||
PointerRNA lamp_ptr;
|
PointerRNA lamp_ptr;
|
||||||
const char *propname = "spot_size";
|
const char *propname = "spot_size";
|
||||||
RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr);
|
RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr);
|
||||||
WM_manipulator_def_property(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1);
|
WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt)
|
void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt)
|
||||||
@@ -111,11 +110,13 @@ void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt)
|
|||||||
wgt->name = "Lamp Widgets";
|
wgt->name = "Lamp Widgets";
|
||||||
wgt->idname = "VIEW3D_WGT_lamp";
|
wgt->idname = "VIEW3D_WGT_lamp";
|
||||||
|
|
||||||
|
wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
|
||||||
|
WM_MANIPULATORGROUPTYPE_3D |
|
||||||
|
WM_MANIPULATORGROUPTYPE_SCALE_3D);
|
||||||
|
|
||||||
wgt->poll = WIDGETGROUP_lamp_poll;
|
wgt->poll = WIDGETGROUP_lamp_poll;
|
||||||
wgt->setup = WIDGETGROUP_lamp_setup;
|
wgt->setup = WIDGETGROUP_lamp_setup;
|
||||||
wgt->refresh = WIDGETGROUP_lamp_refresh;
|
wgt->refresh = WIDGETGROUP_lamp_refresh;
|
||||||
|
|
||||||
wgt->flag |= (WM_MANIPULATORGROUPTYPE_3D | WM_MANIPULATORGROUPTYPE_SCALE_3D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
@@ -230,7 +231,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
|
|||||||
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false);
|
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false);
|
||||||
|
|
||||||
/* need to set property here for undo. TODO would prefer to do this in _init */
|
/* need to set property here for undo. TODO would prefer to do this in _init */
|
||||||
WM_manipulator_def_property(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1);
|
WM_manipulator_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true);
|
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true);
|
||||||
@@ -273,8 +274,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
|
|||||||
WM_manipulator_set_scale(widget, drawsize);
|
WM_manipulator_set_scale(widget, drawsize);
|
||||||
|
|
||||||
/* need to set property here for undo. TODO would prefer to do this in _init */
|
/* need to set property here for undo. TODO would prefer to do this in _init */
|
||||||
WM_manipulator_def_property(camgroup->focal_len, "offset", &camera_ptr, "lens", -1);
|
WM_manipulator_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1);
|
||||||
WM_manipulator_def_property(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1);
|
WM_manipulator_property_def_rna(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,11 +284,12 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt)
|
|||||||
wgt->name = "Camera Widgets";
|
wgt->name = "Camera Widgets";
|
||||||
wgt->idname = "VIEW3D_WGT_camera";
|
wgt->idname = "VIEW3D_WGT_camera";
|
||||||
|
|
||||||
|
wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
|
||||||
|
WM_MANIPULATORGROUPTYPE_3D);
|
||||||
|
|
||||||
wgt->poll = WIDGETGROUP_camera_poll;
|
wgt->poll = WIDGETGROUP_camera_poll;
|
||||||
wgt->setup = WIDGETGROUP_camera_setup;
|
wgt->setup = WIDGETGROUP_camera_setup;
|
||||||
wgt->refresh = WIDGETGROUP_camera_refresh;
|
wgt->refresh = WIDGETGROUP_camera_refresh;
|
||||||
|
|
||||||
wgt->flag |= WM_MANIPULATORGROUPTYPE_3D;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
@@ -305,7 +307,7 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupTyp
|
|||||||
return (ob && ob->pd && ob->pd->forcefield);
|
return (ob && ob->pd && ob->pd->forcefield);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WIDGETGROUP_forcefield_init(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
|
static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
|
||||||
{
|
{
|
||||||
const float col[4] = {0.8f, 0.8f, 0.45f, 0.5f};
|
const float col[4] = {0.8f, 0.8f, 0.45f, 0.5f};
|
||||||
const float col_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f};
|
const float col_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f};
|
||||||
@@ -339,7 +341,7 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup
|
|||||||
WM_manipulator_set_origin(wwrapper->manipulator, ob->obmat[3]);
|
WM_manipulator_set_origin(wwrapper->manipulator, ob->obmat[3]);
|
||||||
WM_manipulator_set_offset(wwrapper->manipulator, ofs);
|
WM_manipulator_set_offset(wwrapper->manipulator, ofs);
|
||||||
WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false);
|
WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false);
|
||||||
WM_manipulator_def_property(wwrapper->manipulator, "offset", &field_ptr, "strength", -1);
|
WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, true);
|
WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, true);
|
||||||
@@ -351,11 +353,12 @@ void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt)
|
|||||||
wgt->name = "Force Field Widgets";
|
wgt->name = "Force Field Widgets";
|
||||||
wgt->idname = "VIEW3D_WGT_force_field";
|
wgt->idname = "VIEW3D_WGT_force_field";
|
||||||
|
|
||||||
wgt->poll = WIDGETGROUP_forcefield_poll;
|
wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
|
||||||
wgt->setup = WIDGETGROUP_forcefield_init;
|
WM_MANIPULATORGROUPTYPE_3D);
|
||||||
wgt->refresh = WIDGETGROUP_forcefield_refresh;
|
|
||||||
|
|
||||||
wgt->flag |= WM_MANIPULATORGROUPTYPE_3D;
|
wgt->poll = WIDGETGROUP_forcefield_poll;
|
||||||
|
wgt->setup = WIDGETGROUP_forcefield_setup;
|
||||||
|
wgt->refresh = WIDGETGROUP_forcefield_refresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@@ -39,7 +39,6 @@
|
|||||||
#include "DNA_curve_types.h"
|
#include "DNA_curve_types.h"
|
||||||
#include "DNA_gpencil_types.h"
|
#include "DNA_gpencil_types.h"
|
||||||
#include "DNA_lattice_types.h"
|
#include "DNA_lattice_types.h"
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_meta_types.h"
|
#include "DNA_meta_types.h"
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
@@ -1134,7 +1133,7 @@ static void manipulator_modal(
|
|||||||
ED_region_tag_redraw(ar);
|
ED_region_tag_redraw(ar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WIDGETGROUP_manipulator_init(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
|
static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
|
||||||
{
|
{
|
||||||
ManipulatorGroup *man = manipulatorgroup_init(mgroup);
|
ManipulatorGroup *man = manipulatorgroup_init(mgroup);
|
||||||
mgroup->customdata = man;
|
mgroup->customdata = man;
|
||||||
@@ -1345,12 +1344,14 @@ void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt)
|
|||||||
wgt->name = "Transform Manipulator";
|
wgt->name = "Transform Manipulator";
|
||||||
wgt->idname = "TRANSFORM_WGT_manipulator";
|
wgt->idname = "TRANSFORM_WGT_manipulator";
|
||||||
|
|
||||||
|
wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT |
|
||||||
|
WM_MANIPULATORGROUPTYPE_3D |
|
||||||
|
WM_MANIPULATORGROUPTYPE_SCALE_3D);
|
||||||
|
|
||||||
wgt->poll = WIDGETGROUP_manipulator_poll;
|
wgt->poll = WIDGETGROUP_manipulator_poll;
|
||||||
wgt->setup = WIDGETGROUP_manipulator_init;
|
wgt->setup = WIDGETGROUP_manipulator_setup;
|
||||||
wgt->refresh = WIDGETGROUP_manipulator_refresh;
|
wgt->refresh = WIDGETGROUP_manipulator_refresh;
|
||||||
wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare;
|
wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare;
|
||||||
|
|
||||||
wgt->flag |= (WM_MANIPULATORGROUPTYPE_3D | WM_MANIPULATORGROUPTYPE_SCALE_3D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1365,7 +1366,7 @@ static void WIDGETGROUP_object_manipulator_init(const bContext *C, wmManipulator
|
|||||||
ob->mgroup = mgroup;
|
ob->mgroup = mgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
WIDGETGROUP_manipulator_init(C, mgroup);
|
WIDGETGROUP_manipulator_setup(C, mgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool WIDGETGROUP_object_manipulator_poll(const bContext *C, wmManipulatorGroupType *wgt)
|
static bool WIDGETGROUP_object_manipulator_poll(const bContext *C, wmManipulatorGroupType *wgt)
|
||||||
|
@@ -104,12 +104,15 @@ void ED_editors_init(bContext *C)
|
|||||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||||
int mode = ob->mode;
|
int mode = ob->mode;
|
||||||
|
|
||||||
if (!ELEM(mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
|
if (mode == OB_MODE_OBJECT) {
|
||||||
ob->mode = OB_MODE_OBJECT;
|
/* pass */
|
||||||
|
}
|
||||||
|
else {
|
||||||
data = ob->data;
|
data = ob->data;
|
||||||
|
ob->mode = OB_MODE_OBJECT;
|
||||||
if (ob == obact && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data)))
|
if ((ob == obact) && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data))) {
|
||||||
ED_object_toggle_modes(C, mode);
|
ED_object_toggle_modes(C, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* ***** END GPL LICENSE BLOCK *****
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file DNA_manipulator_types.h
|
|
||||||
* \ingroup DNA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __DNA_MANIPULATOR_TYPES_H__
|
|
||||||
#define __DNA_MANIPULATOR_TYPES_H__
|
|
||||||
|
|
||||||
typedef struct wmManipulatorGroup {
|
|
||||||
struct wmManipulatorGroup *next, *prev;
|
|
||||||
|
|
||||||
struct wmManipulatorGroupType *type;
|
|
||||||
ListBase manipulators;
|
|
||||||
|
|
||||||
struct wmManipulatorMap *parent_mmap;
|
|
||||||
|
|
||||||
void *py_instance; /* python stores the class instance here */
|
|
||||||
struct ReportList *reports; /* errors and warnings storage */
|
|
||||||
|
|
||||||
void *customdata;
|
|
||||||
void (*customdata_free)(void *); /* for freeing customdata from above */
|
|
||||||
int flag; /* private */
|
|
||||||
int pad;
|
|
||||||
} wmManipulatorGroup;
|
|
||||||
|
|
||||||
#endif /* __DNA_MANIPULATOR_TYPES_H__ */
|
|
@@ -80,7 +80,6 @@ static const char *includefiles[] = {
|
|||||||
"DNA_image_types.h",
|
"DNA_image_types.h",
|
||||||
"DNA_texture_types.h",
|
"DNA_texture_types.h",
|
||||||
"DNA_lamp_types.h",
|
"DNA_lamp_types.h",
|
||||||
"DNA_manipulator_types.h",
|
|
||||||
"DNA_material_types.h",
|
"DNA_material_types.h",
|
||||||
"DNA_vfont_types.h",
|
"DNA_vfont_types.h",
|
||||||
"DNA_meta_types.h",
|
"DNA_meta_types.h",
|
||||||
@@ -1308,7 +1307,6 @@ int main(int argc, char **argv)
|
|||||||
#include "DNA_image_types.h"
|
#include "DNA_image_types.h"
|
||||||
#include "DNA_texture_types.h"
|
#include "DNA_texture_types.h"
|
||||||
#include "DNA_lamp_types.h"
|
#include "DNA_lamp_types.h"
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_material_types.h"
|
#include "DNA_material_types.h"
|
||||||
#include "DNA_vfont_types.h"
|
#include "DNA_vfont_types.h"
|
||||||
#include "DNA_meta_types.h"
|
#include "DNA_meta_types.h"
|
||||||
|
@@ -72,7 +72,10 @@ set(SRC
|
|||||||
intern/wm_window.c
|
intern/wm_window.c
|
||||||
intern/wm_stereo.c
|
intern/wm_stereo.c
|
||||||
manipulators/intern/wm_manipulator.c
|
manipulators/intern/wm_manipulator.c
|
||||||
|
manipulators/intern/wm_manipulator_property.c
|
||||||
|
manipulators/intern/wm_manipulator_type.c
|
||||||
manipulators/intern/wm_manipulatorgroup.c
|
manipulators/intern/wm_manipulatorgroup.c
|
||||||
|
manipulators/intern/wm_manipulatorgroup_type.c
|
||||||
manipulators/intern/wm_manipulatormap.c
|
manipulators/intern/wm_manipulatormap.c
|
||||||
|
|
||||||
WM_api.h
|
WM_api.h
|
||||||
|
@@ -36,7 +36,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "DNA_listBase.h"
|
#include "DNA_listBase.h"
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_windowmanager_types.h"
|
#include "DNA_windowmanager_types.h"
|
||||||
@@ -2165,7 +2164,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
|
|||||||
/* handle user configurable manipulator-map keymap */
|
/* handle user configurable manipulator-map keymap */
|
||||||
else if (mpr) {
|
else if (mpr) {
|
||||||
/* get user customized keymap from default one */
|
/* get user customized keymap from default one */
|
||||||
const wmManipulatorGroup *highlightgroup = wm_manipulator_get_parent_group(mpr);
|
const wmManipulatorGroup *highlightgroup = mpr->parent_mgroup;
|
||||||
const wmKeyMap *keymap = WM_keymap_active(wm, highlightgroup->type->keymap);
|
const wmKeyMap *keymap = WM_keymap_active(wm, highlightgroup->type->keymap);
|
||||||
wmKeyMapItem *kmi;
|
wmKeyMapItem *kmi;
|
||||||
|
|
||||||
@@ -2452,6 +2451,7 @@ void wm_event_do_handlers(bContext *C)
|
|||||||
|
|
||||||
/* update key configuration before handling events */
|
/* update key configuration before handling events */
|
||||||
WM_keyconfig_update(wm);
|
WM_keyconfig_update(wm);
|
||||||
|
WM_manipulatorconfig_update(CTX_data_main(C));
|
||||||
|
|
||||||
for (win = wm->windows.first; win; win = win->next) {
|
for (win = wm->windows.first; win; win = win->next) {
|
||||||
bScreen *screen = WM_window_get_active_screen(win);
|
bScreen *screen = WM_window_get_active_screen(win);
|
||||||
@@ -2664,6 +2664,7 @@ void wm_event_do_handlers(bContext *C)
|
|||||||
|
|
||||||
/* update key configuration after handling events */
|
/* update key configuration after handling events */
|
||||||
WM_keyconfig_update(wm);
|
WM_keyconfig_update(wm);
|
||||||
|
WM_manipulatorconfig_update(CTX_data_main(C));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********** filesector handling ************ */
|
/* ********** filesector handling ************ */
|
||||||
|
@@ -166,6 +166,7 @@ void WM_init(bContext *C, int argc, const char **argv)
|
|||||||
WM_menutype_init();
|
WM_menutype_init();
|
||||||
WM_uilisttype_init();
|
WM_uilisttype_init();
|
||||||
wm_manipulatortype_init();
|
wm_manipulatortype_init();
|
||||||
|
wm_manipulatorgrouptype_init();
|
||||||
|
|
||||||
BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback);
|
BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback);
|
||||||
|
|
||||||
@@ -488,6 +489,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
|
|||||||
wm_dropbox_free();
|
wm_dropbox_free();
|
||||||
WM_menutype_free();
|
WM_menutype_free();
|
||||||
WM_uilisttype_free();
|
WM_uilisttype_free();
|
||||||
|
wm_manipulatorgrouptype_free();
|
||||||
wm_manipulatortype_free();
|
wm_manipulatortype_free();
|
||||||
|
|
||||||
/* all non-screen and non-space stuff editors did, like editmode */
|
/* all non-screen and non-space stuff editors did, like editmode */
|
||||||
|
@@ -63,13 +63,6 @@ struct wmManipulator *WM_manipulator_new(
|
|||||||
void WM_manipulator_free(
|
void WM_manipulator_free(
|
||||||
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
|
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
|
||||||
struct bContext *C);
|
struct bContext *C);
|
||||||
struct wmManipulatorGroup *WM_manipulator_get_parent_group(struct wmManipulator *mpr);
|
|
||||||
|
|
||||||
struct wmManipulatorProperty *WM_manipulator_get_property(
|
|
||||||
struct wmManipulator *mpr, const char *idname);
|
|
||||||
void WM_manipulator_def_property(
|
|
||||||
struct wmManipulator *mpr, const char *idname,
|
|
||||||
struct PointerRNA *ptr, const char *propname, int index);
|
|
||||||
|
|
||||||
struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname);
|
struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname);
|
||||||
|
|
||||||
@@ -87,7 +80,7 @@ void WM_manipulator_set_color(struct wmManipulator *mpr, const float col[4]);
|
|||||||
void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float col_hi[4]);
|
void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float col_hi[4]);
|
||||||
void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float col[4]);
|
void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float col[4]);
|
||||||
|
|
||||||
/* wm_manipulator.c */
|
/* wm_manipulator_type.c */
|
||||||
const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet);
|
const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet);
|
||||||
void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *));
|
void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *));
|
||||||
void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata);
|
void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata);
|
||||||
@@ -95,48 +88,59 @@ bool WM_manipulatortype_remove(const char *idname);
|
|||||||
void WM_manipulatortype_remove_ptr(struct wmManipulatorType *wt);
|
void WM_manipulatortype_remove_ptr(struct wmManipulatorType *wt);
|
||||||
void WM_manipulatortype_iter(struct GHashIterator *ghi);
|
void WM_manipulatortype_iter(struct GHashIterator *ghi);
|
||||||
|
|
||||||
|
/* wm_manipulatorgroup_type.c */
|
||||||
|
struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet);
|
||||||
|
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *));
|
||||||
|
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata);
|
||||||
|
bool WM_manipulatorgrouptype_remove(const char *idname);
|
||||||
|
void WM_manipulatorgrouptype_remove_ptr(struct wmManipulatorGroupType *wt);
|
||||||
|
void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi);
|
||||||
|
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
|
||||||
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
void (*wtfunc)(struct wmManipulatorGroupType *));
|
||||||
|
|
||||||
|
/* wm_manipulatormap.c */
|
||||||
|
|
||||||
|
/* Dynamic Updates (for RNA runtime registration) */
|
||||||
|
void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt);
|
||||||
|
void WM_manipulatorconfig_update(const struct Main *bmain);
|
||||||
|
|
||||||
|
|
||||||
|
/* wm_maniulator_property.c */
|
||||||
|
struct wmManipulatorProperty *WM_manipulator_property_find(
|
||||||
|
struct wmManipulator *mpr, const char *idname);
|
||||||
|
|
||||||
|
void WM_manipulator_property_def_rna(
|
||||||
|
struct wmManipulator *mpr, const char *idname,
|
||||||
|
struct PointerRNA *ptr, const char *propname, int index);
|
||||||
|
void WM_manipulator_property_def_func(
|
||||||
|
struct wmManipulator *mpr, const char *idname,
|
||||||
|
const struct wmManipulatorPropertyFnParams *params);
|
||||||
|
|
||||||
|
bool WM_manipulator_property_is_valid(
|
||||||
|
const struct wmManipulatorProperty *mpr_prop);
|
||||||
|
void WM_manipulator_property_value_set(
|
||||||
|
struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float value);
|
||||||
|
float WM_manipulator_property_value_get(
|
||||||
|
const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
|
||||||
|
void WM_manipulator_property_range_get(
|
||||||
|
const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
|
||||||
|
float range[2]);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* wmManipulatorGroup */
|
/* wmManipulatorGroup */
|
||||||
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(
|
/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */
|
||||||
struct wmManipulatorMapType *mmaptype,
|
|
||||||
const char *idname);
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(
|
|
||||||
struct wmManipulatorMapType *mmaptype,
|
|
||||||
void (*mgrouptype_func)(struct wmManipulatorGroupType *));
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(
|
|
||||||
struct wmManipulatorMapType *mmaptype,
|
|
||||||
void (*mgrouptype_func)(struct wmManipulatorGroupType *, void *),
|
|
||||||
void *userdata);
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_runtime(
|
|
||||||
const struct Main *main, struct wmManipulatorMapType *mmaptype,
|
|
||||||
void (*mgrouptype_func)(struct wmManipulatorGroupType *));
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr_runtime(
|
|
||||||
const struct Main *main, struct wmManipulatorMapType *mmaptype,
|
|
||||||
void (*mgrouptype_func)(struct wmManipulatorGroupType *, void *),
|
|
||||||
void *userdata);
|
|
||||||
|
|
||||||
void WM_manipulatorgrouptype_init_runtime(
|
|
||||||
const struct Main *bmain, struct wmManipulatorMapType *mmaptype,
|
|
||||||
struct wmManipulatorGroupType *wgt);
|
|
||||||
void WM_manipulatorgrouptype_free(struct wmManipulatorGroupType *wgt);
|
|
||||||
void WM_manipulatorgrouptype_remove_ptr(
|
|
||||||
struct bContext *C, struct Main *bmain, struct wmManipulatorGroupType *mgroup);
|
|
||||||
|
|
||||||
struct wmKeyMap *WM_manipulatorgroup_keymap_common(
|
struct wmKeyMap *WM_manipulatorgroup_keymap_common(
|
||||||
const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
|
const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
|
||||||
struct wmKeyMap *WM_manipulatorgroup_keymap_common_sel(
|
struct wmKeyMap *WM_manipulatorgroup_keymap_common_select(
|
||||||
const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
|
const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config);
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* wmManipulatorMap */
|
/* wmManipulatorMap */
|
||||||
|
|
||||||
struct wmManipulatorMapType *WM_manipulatormaptype_find(
|
|
||||||
const struct wmManipulatorMapType_Params *mmap_params);
|
|
||||||
struct wmManipulatorMapType *WM_manipulatormaptype_ensure(
|
|
||||||
const struct wmManipulatorMapType_Params *mmap_params);
|
|
||||||
|
|
||||||
struct wmManipulatorMap *WM_manipulatormap_new_from_type(
|
struct wmManipulatorMap *WM_manipulatormap_new_from_type(
|
||||||
const struct wmManipulatorMapType_Params *mmap_params);
|
const struct wmManipulatorMapType_Params *mmap_params);
|
||||||
void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap);
|
void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap);
|
||||||
@@ -145,5 +149,51 @@ void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap
|
|||||||
bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action);
|
bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action);
|
||||||
bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win);
|
bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win);
|
||||||
|
|
||||||
#endif /* __WM_MANIPULATOR_API_H__ */
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* wmManipulatorMapType */
|
||||||
|
|
||||||
|
struct wmManipulatorMapType *WM_manipulatormaptype_find(
|
||||||
|
const struct wmManipulatorMapType_Params *mmap_params);
|
||||||
|
struct wmManipulatorMapType *WM_manipulatormaptype_ensure(
|
||||||
|
const struct wmManipulatorMapType_Params *mmap_params);
|
||||||
|
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find(
|
||||||
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
const char *idname);
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr(
|
||||||
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
const struct wmManipulatorGroupType *wgt);
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link(
|
||||||
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
const char *idname);
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
|
||||||
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
struct wmManipulatorGroupType *wgt);
|
||||||
|
|
||||||
|
void WM_manipulatormaptype_group_init_runtime(
|
||||||
|
const struct Main *bmain, struct wmManipulatorMapType *mmap_type,
|
||||||
|
struct wmManipulatorGroupType *wgt);
|
||||||
|
void WM_manipulatormaptype_group_unlink(
|
||||||
|
struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type,
|
||||||
|
const struct wmManipulatorGroupType *wgt);
|
||||||
|
|
||||||
|
void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* Manipulator Add/Remove (High level API) */
|
||||||
|
|
||||||
|
void WM_manipulator_group_add_ptr_ex(
|
||||||
|
struct wmManipulatorGroupType *wgt,
|
||||||
|
struct wmManipulatorMapType *mmap_type);
|
||||||
|
void WM_manipulator_group_add_ptr(
|
||||||
|
struct wmManipulatorGroupType *wgt);
|
||||||
|
void WM_manipulator_group_add(const char *idname);
|
||||||
|
|
||||||
|
void WM_manipulator_group_remove_ptr_ex(
|
||||||
|
struct Main *bmain, struct wmManipulatorGroupType *wgt,
|
||||||
|
struct wmManipulatorMapType *mmap_type);
|
||||||
|
void WM_manipulator_group_remove_ptr(
|
||||||
|
struct Main *bmain, struct wmManipulatorGroupType *wgt);
|
||||||
|
void WM_manipulator_group_remove(struct Main *bmain, const char *idname);
|
||||||
|
|
||||||
|
#endif /* __WM_MANIPULATOR_API_H__ */
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "BLI_compiler_attrs.h"
|
#include "BLI_compiler_attrs.h"
|
||||||
|
|
||||||
|
struct wmManipulatorMapType;
|
||||||
struct wmManipulatorGroupType;
|
struct wmManipulatorGroupType;
|
||||||
struct wmManipulatorGroup;
|
struct wmManipulatorGroup;
|
||||||
struct wmManipulator;
|
struct wmManipulator;
|
||||||
@@ -104,12 +105,25 @@ struct wmManipulator {
|
|||||||
ListBase properties;
|
ListBase properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*wmManipulatorGroupFnInit)(
|
||||||
|
const struct bContext *, struct wmManipulatorGroup *);
|
||||||
|
|
||||||
/* Similar to PropertyElemRNA, but has an identifier. */
|
/* Similar to PropertyElemRNA, but has an identifier. */
|
||||||
typedef struct wmManipulatorProperty {
|
typedef struct wmManipulatorProperty {
|
||||||
struct wmManipulatorProperty *next, *prev;
|
struct wmManipulatorProperty *next, *prev;
|
||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
/* Optional functions for converting to/from RNA */
|
||||||
|
struct {
|
||||||
|
wmManipulatorPropertyFnGet value_get_fn;
|
||||||
|
wmManipulatorPropertyFnSet value_set_fn;
|
||||||
|
wmManipulatorPropertyFnRangeGet range_get_fn;
|
||||||
|
const struct bContext *context;
|
||||||
|
void *user_data;
|
||||||
|
} custom_func;
|
||||||
|
|
||||||
/* over alloc */
|
/* over alloc */
|
||||||
char idname[0];
|
char idname[0];
|
||||||
} wmManipulatorProperty;
|
} wmManipulatorProperty;
|
||||||
@@ -121,6 +135,12 @@ typedef struct wmManipulatorWrapper {
|
|||||||
struct wmManipulator *manipulator;
|
struct wmManipulator *manipulator;
|
||||||
} wmManipulatorWrapper;
|
} wmManipulatorWrapper;
|
||||||
|
|
||||||
|
struct wmManipulatorMapType_Params {
|
||||||
|
short spaceid;
|
||||||
|
short regionid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* wmManipulator.flag
|
/* wmManipulator.flag
|
||||||
* Flags for individual manipulators. */
|
* Flags for individual manipulators. */
|
||||||
enum {
|
enum {
|
||||||
@@ -194,9 +214,13 @@ typedef struct wmManipulatorType {
|
|||||||
/* wmManipulatorGroup */
|
/* wmManipulatorGroup */
|
||||||
|
|
||||||
/* factory class for a manipulator-group type, gets called every time a new area is spawned */
|
/* factory class for a manipulator-group type, gets called every time a new area is spawned */
|
||||||
typedef struct wmManipulatorGroupType {
|
typedef struct wmManipulatorGroupTypeRef {
|
||||||
struct wmManipulatorGroupType *next, *prev;
|
struct wmManipulatorGroupTypeRef *next, *prev;
|
||||||
|
struct wmManipulatorGroupType *type;
|
||||||
|
} wmManipulatorGroupTypeRef;
|
||||||
|
|
||||||
|
/* factory class for a manipulator-group type, gets called every time a new area is spawned */
|
||||||
|
typedef struct wmManipulatorGroupType {
|
||||||
const char *idname; /* MAX_NAME */
|
const char *idname; /* MAX_NAME */
|
||||||
const char *name; /* manipulator-group name - displayed in UI (keymap editor) */
|
const char *name; /* manipulator-group name - displayed in UI (keymap editor) */
|
||||||
|
|
||||||
@@ -211,7 +235,8 @@ typedef struct wmManipulatorGroupType {
|
|||||||
|
|
||||||
/* Keymap init callback for this manipulator-group (optional),
|
/* Keymap init callback for this manipulator-group (optional),
|
||||||
* will fall back to default tweak keymap when left NULL. */
|
* will fall back to default tweak keymap when left NULL. */
|
||||||
struct wmKeyMap *(*setup_keymap)(const struct wmManipulatorGroupType *, struct wmKeyConfig *);
|
wmManipulatorGroupFnSetupKeymap setup_keymap;
|
||||||
|
|
||||||
/* keymap created with callback from above */
|
/* keymap created with callback from above */
|
||||||
struct wmKeyMap *keymap;
|
struct wmKeyMap *keymap;
|
||||||
|
|
||||||
@@ -226,11 +251,39 @@ typedef struct wmManipulatorGroupType {
|
|||||||
|
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
|
/* eManipulatorMapTypeUpdateFlags (so we know which group type to update) */
|
||||||
|
uchar type_update_flag;
|
||||||
|
|
||||||
/* same as manipulator-maps, so registering/unregistering goes to the correct region */
|
/* same as manipulator-maps, so registering/unregistering goes to the correct region */
|
||||||
short spaceid, regionid;
|
struct wmManipulatorMapType_Params mmap_params;
|
||||||
char mapidname[64];
|
|
||||||
} wmManipulatorGroupType;
|
} wmManipulatorGroupType;
|
||||||
|
|
||||||
|
typedef struct wmManipulatorGroup {
|
||||||
|
struct wmManipulatorGroup *next, *prev;
|
||||||
|
|
||||||
|
struct wmManipulatorGroupType *type;
|
||||||
|
ListBase manipulators;
|
||||||
|
|
||||||
|
struct wmManipulatorMap *parent_mmap;
|
||||||
|
|
||||||
|
void *py_instance; /* python stores the class instance here */
|
||||||
|
struct ReportList *reports; /* errors and warnings storage */
|
||||||
|
|
||||||
|
void *customdata;
|
||||||
|
void (*customdata_free)(void *); /* for freeing customdata from above */
|
||||||
|
int flag; /* private */
|
||||||
|
int pad;
|
||||||
|
} wmManipulatorGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manipulator-map type update flag: `wmManipulatorMapType.type_update_flag`
|
||||||
|
*/
|
||||||
|
enum eManipulatorMapTypeUpdateFlags {
|
||||||
|
/* A new type has been added, needs to be initialized for all views. */
|
||||||
|
WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wmManipulatorGroupType.flag
|
* wmManipulatorGroupType.flag
|
||||||
* Flags that influence the behavior of all manipulators in the group.
|
* Flags that influence the behavior of all manipulators in the group.
|
||||||
@@ -244,18 +297,14 @@ enum {
|
|||||||
WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2),
|
WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2),
|
||||||
/* Manipulators can be selected */
|
/* Manipulators can be selected */
|
||||||
WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3),
|
WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3),
|
||||||
|
/* The manipulator group is to be kept (not removed on loading a new file for eg). */
|
||||||
|
WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* wmManipulatorMap */
|
/* wmManipulatorMap */
|
||||||
|
|
||||||
struct wmManipulatorMapType_Params {
|
|
||||||
const char *idname;
|
|
||||||
const int spaceid;
|
|
||||||
const int regionid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw.
|
* Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw.
|
||||||
*/
|
*/
|
||||||
|
@@ -30,13 +30,10 @@
|
|||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
|
|
||||||
#include "BLI_listbase.h"
|
#include "BLI_listbase.h"
|
||||||
#include "BLI_ghash.h"
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_string_utils.h"
|
#include "BLI_string_utils.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
|
|
||||||
@@ -65,118 +62,6 @@
|
|||||||
static void wm_manipulator_register(
|
static void wm_manipulator_register(
|
||||||
wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name);
|
wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name);
|
||||||
|
|
||||||
/** \name Manipulator Type Append
|
|
||||||
*
|
|
||||||
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
|
|
||||||
* \{ */
|
|
||||||
|
|
||||||
static GHash *global_manipulatortype_hash = NULL;
|
|
||||||
|
|
||||||
const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet)
|
|
||||||
{
|
|
||||||
if (idname[0]) {
|
|
||||||
wmManipulatorType *wt;
|
|
||||||
|
|
||||||
wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
|
|
||||||
if (wt) {
|
|
||||||
return wt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!quiet) {
|
|
||||||
printf("search for unknown manipulator '%s'\n", idname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!quiet) {
|
|
||||||
printf("search for empty manipulator\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* caller must free */
|
|
||||||
void WM_manipulatortype_iter(GHashIterator *ghi)
|
|
||||||
{
|
|
||||||
BLI_ghashIterator_init(ghi, global_manipulatortype_hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
static wmManipulatorType *wm_manipulatortype_append__begin(void)
|
|
||||||
{
|
|
||||||
wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype");
|
|
||||||
return wt;
|
|
||||||
}
|
|
||||||
static void wm_manipulatortype_append__end(wmManipulatorType *wt)
|
|
||||||
{
|
|
||||||
BLI_assert(wt->struct_size >= sizeof(wmManipulator));
|
|
||||||
|
|
||||||
BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *))
|
|
||||||
{
|
|
||||||
wmManipulatorType *wt = wm_manipulatortype_append__begin();
|
|
||||||
wtfunc(wt);
|
|
||||||
wm_manipulatortype_append__end(wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata)
|
|
||||||
{
|
|
||||||
wmManipulatorType *mt = wm_manipulatortype_append__begin();
|
|
||||||
wtfunc(mt, userdata);
|
|
||||||
wm_manipulatortype_append__end(mt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free but don't remove from ghash.
|
|
||||||
*/
|
|
||||||
static void manipulatortype_free(wmManipulatorType *wt)
|
|
||||||
{
|
|
||||||
MEM_freeN(wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WM_manipulatortype_remove_ptr(wmManipulatorType *wt)
|
|
||||||
{
|
|
||||||
BLI_assert(wt == WM_manipulatortype_find(wt->idname, false));
|
|
||||||
|
|
||||||
BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL);
|
|
||||||
|
|
||||||
manipulatortype_free(wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WM_manipulatortype_remove(const char *idname)
|
|
||||||
{
|
|
||||||
wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
|
|
||||||
|
|
||||||
if (wt == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WM_manipulatortype_remove_ptr(wt);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt)
|
|
||||||
{
|
|
||||||
manipulatortype_free(mt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wm_manipulatortype_free(void)
|
|
||||||
{
|
|
||||||
BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb);
|
|
||||||
global_manipulatortype_hash = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* called on initialize WM_init() */
|
|
||||||
void wm_manipulatortype_init(void)
|
|
||||||
{
|
|
||||||
/* reserve size is set based on blender default setup */
|
|
||||||
global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \note Follow #wm_operator_create convention.
|
* \note Follow #wm_operator_create convention.
|
||||||
*/
|
*/
|
||||||
@@ -215,11 +100,6 @@ wmManipulator *WM_manipulator_new(const char *idname, wmManipulatorGroup *mgroup
|
|||||||
return mpr;
|
return mpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wmManipulatorGroup *WM_manipulator_get_parent_group(wmManipulator *mpr)
|
|
||||||
{
|
|
||||||
return mpr->parent_mgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign an idname that is unique in \a mgroup to \a manipulator.
|
* Assign an idname that is unique in \a mgroup to \a manipulator.
|
||||||
*
|
*
|
||||||
@@ -297,12 +177,6 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
|
|||||||
MEM_freeN(mpr);
|
MEM_freeN(mpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
wmManipulatorGroup *wm_manipulator_get_parent_group(const wmManipulator *mpr)
|
|
||||||
{
|
|
||||||
return mpr->parent_mgroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Manipulator Creation API
|
/** \name Manipulator Creation API
|
||||||
*
|
*
|
||||||
@@ -310,34 +184,6 @@ wmManipulatorGroup *wm_manipulator_get_parent_group(const wmManipulator *mpr)
|
|||||||
*
|
*
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
struct wmManipulatorProperty *WM_manipulator_get_property(wmManipulator *mpr, const char *idname)
|
|
||||||
{
|
|
||||||
return BLI_findstring(&mpr->properties, idname, offsetof(wmManipulatorProperty, idname));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WM_manipulator_def_property(
|
|
||||||
wmManipulator *mpr, const char *idname,
|
|
||||||
PointerRNA *ptr, const char *propname, int index)
|
|
||||||
{
|
|
||||||
wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, idname);
|
|
||||||
|
|
||||||
if (mpr_prop == NULL) {
|
|
||||||
const uint idname_size = strlen(idname) + 1;
|
|
||||||
mpr_prop = MEM_callocN(sizeof(wmManipulatorProperty) + idname_size, __func__);
|
|
||||||
memcpy(mpr_prop->idname, idname, idname_size);
|
|
||||||
BLI_addtail(&mpr->properties, mpr_prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if manipulator evokes an operator we cannot use it for property manipulation */
|
|
||||||
mpr->opname = NULL;
|
|
||||||
mpr_prop->ptr = *ptr;
|
|
||||||
mpr_prop->prop = RNA_struct_find_property(ptr, propname);
|
|
||||||
mpr_prop->index = index;
|
|
||||||
|
|
||||||
if (mpr->type->property_update) {
|
|
||||||
mpr->type->property_update(mpr, mpr_prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname)
|
PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname)
|
||||||
{
|
{
|
||||||
@@ -533,7 +379,7 @@ static void manipulator_update_prop_data(wmManipulator *mpr)
|
|||||||
/* manipulator property might have been changed, so update manipulator */
|
/* manipulator property might have been changed, so update manipulator */
|
||||||
if (mpr->type->property_update && !BLI_listbase_is_empty(&mpr->properties)) {
|
if (mpr->type->property_update && !BLI_listbase_is_empty(&mpr->properties)) {
|
||||||
for (wmManipulatorProperty *mpr_prop = mpr->properties.first; mpr_prop; mpr_prop = mpr_prop->next) {
|
for (wmManipulatorProperty *mpr_prop = mpr->properties.first; mpr_prop; mpr_prop = mpr_prop->next) {
|
||||||
if (mpr_prop->prop != NULL) {
|
if (WM_manipulator_property_is_valid(mpr_prop)) {
|
||||||
mpr->type->property_update(mpr, mpr_prop);
|
mpr->type->property_update(mpr, mpr_prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
|
struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
|
||||||
struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *mgroup_type);
|
struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt);
|
||||||
void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup);
|
void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup);
|
||||||
void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr);
|
void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr);
|
||||||
struct wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator(
|
struct wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator(
|
||||||
@@ -68,7 +68,8 @@ void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, c
|
|||||||
bool wm_manipulatorgroup_is_visible(const struct wmManipulatorGroup *mgroup, const struct bContext *C);
|
bool wm_manipulatorgroup_is_visible(const struct wmManipulatorGroup *mgroup, const struct bContext *C);
|
||||||
bool wm_manipulatorgroup_is_visible_in_drawstep(const struct wmManipulatorGroup *mgroup, const int drawstep);
|
bool wm_manipulatorgroup_is_visible_in_drawstep(const struct wmManipulatorGroup *mgroup, const int drawstep);
|
||||||
|
|
||||||
void wm_manipulatorgrouptype_setup_keymap(struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf);
|
void wm_manipulatorgrouptype_setup_keymap(
|
||||||
|
struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf);
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
@@ -78,7 +79,7 @@ struct wmManipulatorMap {
|
|||||||
struct wmManipulatorMap *next, *prev;
|
struct wmManipulatorMap *next, *prev;
|
||||||
|
|
||||||
struct wmManipulatorMapType *type;
|
struct wmManipulatorMapType *type;
|
||||||
ListBase manipulator_groups;
|
ListBase groups; /* wmManipulatorGroup */
|
||||||
|
|
||||||
char update_flag; /* private, update tagging */
|
char update_flag; /* private, update tagging */
|
||||||
|
|
||||||
@@ -108,10 +109,12 @@ struct wmManipulatorMap {
|
|||||||
*/
|
*/
|
||||||
struct wmManipulatorMapType {
|
struct wmManipulatorMapType {
|
||||||
struct wmManipulatorMapType *next, *prev;
|
struct wmManipulatorMapType *next, *prev;
|
||||||
char idname[64];
|
|
||||||
short spaceid, regionid;
|
short spaceid, regionid;
|
||||||
/* types of manipulator-groups for this manipulator-map type */
|
/* types of manipulator-groups for this manipulator-map type */
|
||||||
ListBase manipulator_grouptypes;
|
ListBase grouptype_refs;
|
||||||
|
|
||||||
|
/* eManipulatorMapTypeUpdateFlags */
|
||||||
|
uchar type_update_flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wm_manipulatormap_selected_clear(struct wmManipulatorMap *mmap);
|
void wm_manipulatormap_selected_clear(struct wmManipulatorMap *mmap);
|
||||||
|
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file blender/windowmanager/manipulators/intern/wm_manipulator_property.c
|
||||||
|
* \ingroup wm
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BKE_context.h"
|
||||||
|
|
||||||
|
#include "BLI_listbase.h"
|
||||||
|
#include "BLI_math.h"
|
||||||
|
#include "BLI_string.h"
|
||||||
|
#include "BLI_string_utils.h"
|
||||||
|
|
||||||
|
#include "ED_screen.h"
|
||||||
|
#include "ED_view3d.h"
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
|
#include "WM_api.h"
|
||||||
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
#include "wm.h"
|
||||||
|
|
||||||
|
/* own includes */
|
||||||
|
#include "wm_manipulator_wmapi.h"
|
||||||
|
#include "wm_manipulator_intern.h"
|
||||||
|
|
||||||
|
/* factor for precision tweaking */
|
||||||
|
#define MANIPULATOR_PRECISION_FAC 0.05f
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/** \name Property Definition
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
wmManipulatorProperty *WM_manipulator_property_find(wmManipulator *mpr, const char *idname)
|
||||||
|
{
|
||||||
|
return BLI_findstring(&mpr->properties, idname, offsetof(wmManipulatorProperty, idname));
|
||||||
|
}
|
||||||
|
|
||||||
|
static wmManipulatorProperty *wm_manipulator_property_def_internal(
|
||||||
|
wmManipulator *mpr, const char *idname)
|
||||||
|
{
|
||||||
|
wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, idname);
|
||||||
|
|
||||||
|
if (mpr_prop == NULL) {
|
||||||
|
const uint idname_size = strlen(idname) + 1;
|
||||||
|
mpr_prop = MEM_callocN(sizeof(wmManipulatorProperty) + idname_size, __func__);
|
||||||
|
memcpy(mpr_prop->idname, idname, idname_size);
|
||||||
|
BLI_addtail(&mpr->properties, mpr_prop);
|
||||||
|
}
|
||||||
|
return mpr_prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_property_def_rna(
|
||||||
|
wmManipulator *mpr, const char *idname,
|
||||||
|
PointerRNA *ptr, const char *propname, int index)
|
||||||
|
{
|
||||||
|
wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname);
|
||||||
|
|
||||||
|
/* if manipulator evokes an operator we cannot use it for property manipulation */
|
||||||
|
mpr->opname = NULL;
|
||||||
|
|
||||||
|
mpr_prop->ptr = *ptr;
|
||||||
|
mpr_prop->prop = RNA_struct_find_property(ptr, propname);
|
||||||
|
mpr_prop->index = index;
|
||||||
|
|
||||||
|
if (mpr->type->property_update) {
|
||||||
|
mpr->type->property_update(mpr, mpr_prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_property_def_func(
|
||||||
|
wmManipulator *mpr, const char *idname,
|
||||||
|
const wmManipulatorPropertyFnParams *params)
|
||||||
|
{
|
||||||
|
wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname);
|
||||||
|
|
||||||
|
/* if manipulator evokes an operator we cannot use it for property manipulation */
|
||||||
|
mpr->opname = NULL;
|
||||||
|
|
||||||
|
mpr_prop->custom_func.value_get_fn = params->value_get_fn;
|
||||||
|
mpr_prop->custom_func.value_set_fn = params->value_set_fn;
|
||||||
|
mpr_prop->custom_func.range_get_fn = params->range_get_fn;
|
||||||
|
mpr_prop->custom_func.user_data = params->user_data;
|
||||||
|
|
||||||
|
if (mpr->type->property_update) {
|
||||||
|
mpr->type->property_update(mpr, mpr_prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/** \name Property Access
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
bool WM_manipulator_property_is_valid(const wmManipulatorProperty *mpr_prop)
|
||||||
|
{
|
||||||
|
return ((mpr_prop->prop != NULL) ||
|
||||||
|
(mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_property_value_set(
|
||||||
|
bContext *C, const wmManipulator *mpr,
|
||||||
|
wmManipulatorProperty *mpr_prop, const float value)
|
||||||
|
{
|
||||||
|
if (mpr_prop->custom_func.value_set_fn) {
|
||||||
|
mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reset property */
|
||||||
|
if (mpr_prop->index == -1) {
|
||||||
|
RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value);
|
||||||
|
}
|
||||||
|
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
float WM_manipulator_property_value_get(
|
||||||
|
const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
|
||||||
|
{
|
||||||
|
if (mpr_prop->custom_func.value_get_fn) {
|
||||||
|
float value = 0.0f;
|
||||||
|
mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mpr_prop->index == -1) {
|
||||||
|
return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_property_range_get(
|
||||||
|
const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
|
||||||
|
float range[2])
|
||||||
|
{
|
||||||
|
if (mpr_prop->custom_func.range_get_fn) {
|
||||||
|
mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, range);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float step, precision;
|
||||||
|
RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
@@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file blender/windowmanager/manipulators/intern/wm_manipulator_type.c
|
||||||
|
* \ingroup wm
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BKE_context.h"
|
||||||
|
|
||||||
|
#include "BLI_ghash.h"
|
||||||
|
#include "BLI_string.h"
|
||||||
|
#include "BLI_string_utils.h"
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
|
#include "WM_api.h"
|
||||||
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */
|
||||||
|
#include "wm.h"
|
||||||
|
|
||||||
|
/* own includes */
|
||||||
|
#include "wm_manipulator_wmapi.h"
|
||||||
|
#include "wm_manipulator_intern.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** \name Manipulator Type Append
|
||||||
|
*
|
||||||
|
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
static GHash *global_manipulatortype_hash = NULL;
|
||||||
|
|
||||||
|
const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet)
|
||||||
|
{
|
||||||
|
if (idname[0]) {
|
||||||
|
wmManipulatorType *wt;
|
||||||
|
|
||||||
|
wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
|
||||||
|
if (wt) {
|
||||||
|
return wt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!quiet) {
|
||||||
|
printf("search for unknown manipulator '%s'\n", idname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!quiet) {
|
||||||
|
printf("search for empty manipulator\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* caller must free */
|
||||||
|
void WM_manipulatortype_iter(GHashIterator *ghi)
|
||||||
|
{
|
||||||
|
BLI_ghashIterator_init(ghi, global_manipulatortype_hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
static wmManipulatorType *wm_manipulatortype_append__begin(void)
|
||||||
|
{
|
||||||
|
wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype");
|
||||||
|
return wt;
|
||||||
|
}
|
||||||
|
static void wm_manipulatortype_append__end(wmManipulatorType *wt)
|
||||||
|
{
|
||||||
|
BLI_assert(wt->struct_size >= sizeof(wmManipulator));
|
||||||
|
|
||||||
|
BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *))
|
||||||
|
{
|
||||||
|
wmManipulatorType *wt = wm_manipulatortype_append__begin();
|
||||||
|
wtfunc(wt);
|
||||||
|
wm_manipulatortype_append__end(wt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata)
|
||||||
|
{
|
||||||
|
wmManipulatorType *mt = wm_manipulatortype_append__begin();
|
||||||
|
wtfunc(mt, userdata);
|
||||||
|
wm_manipulatortype_append__end(mt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free but don't remove from ghash.
|
||||||
|
*/
|
||||||
|
static void manipulatortype_free(wmManipulatorType *wt)
|
||||||
|
{
|
||||||
|
MEM_freeN(wt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulatortype_remove_ptr(wmManipulatorType *wt)
|
||||||
|
{
|
||||||
|
BLI_assert(wt == WM_manipulatortype_find(wt->idname, false));
|
||||||
|
|
||||||
|
BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL);
|
||||||
|
|
||||||
|
manipulatortype_free(wt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WM_manipulatortype_remove(const char *idname)
|
||||||
|
{
|
||||||
|
wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname);
|
||||||
|
|
||||||
|
if (wt == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WM_manipulatortype_remove_ptr(wt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt)
|
||||||
|
{
|
||||||
|
manipulatortype_free(mt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wm_manipulatortype_free(void)
|
||||||
|
{
|
||||||
|
BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb);
|
||||||
|
global_manipulatortype_hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* called on initialize WM_init() */
|
||||||
|
void wm_manipulatortype_init(void)
|
||||||
|
{
|
||||||
|
/* reserve size is set based on blender default setup */
|
||||||
|
global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
@@ -44,8 +44,6 @@
|
|||||||
|
|
||||||
#include "BPY_extern.h"
|
#include "BPY_extern.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
@@ -84,7 +82,7 @@ wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
|
|||||||
/* keep back-link */
|
/* keep back-link */
|
||||||
mgroup->parent_mmap = mmap;
|
mgroup->parent_mmap = mmap;
|
||||||
|
|
||||||
BLI_addtail(&mmap->manipulator_groups, mgroup);
|
BLI_addtail(&mmap->groups, mgroup);
|
||||||
|
|
||||||
return mgroup;
|
return mgroup;
|
||||||
}
|
}
|
||||||
@@ -118,7 +116,7 @@ void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup)
|
|||||||
MEM_SAFE_FREE(mgroup->customdata);
|
MEM_SAFE_FREE(mgroup->customdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_remlink(&mmap->manipulator_groups, mgroup);
|
BLI_remlink(&mmap->groups, mgroup);
|
||||||
|
|
||||||
MEM_freeN(mgroup);
|
MEM_freeN(mgroup);
|
||||||
}
|
}
|
||||||
@@ -391,7 +389,11 @@ void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot)
|
|||||||
ot->invoke = manipulator_tweak_invoke;
|
ot->invoke = manipulator_tweak_invoke;
|
||||||
ot->modal = manipulator_tweak_modal;
|
ot->modal = manipulator_tweak_modal;
|
||||||
|
|
||||||
|
/* TODO(campbell) This causes problems tweaking settings for operators,
|
||||||
|
* need to find a way to support this. */
|
||||||
|
#if 0
|
||||||
ot->flag = OPTYPE_UNDO;
|
ot->flag = OPTYPE_UNDO;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */ // Manipulator operators
|
/** \} */ // Manipulator operators
|
||||||
@@ -442,10 +444,11 @@ static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const
|
|||||||
/**
|
/**
|
||||||
* Common default keymap for manipulator groups
|
* Common default keymap for manipulator groups
|
||||||
*/
|
*/
|
||||||
wmKeyMap *WM_manipulatorgroup_keymap_common(const struct wmManipulatorGroupType *wgt, wmKeyConfig *config)
|
wmKeyMap *WM_manipulatorgroup_keymap_common(
|
||||||
|
const wmManipulatorGroupType *wgt, wmKeyConfig *config)
|
||||||
{
|
{
|
||||||
/* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
|
/* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
|
||||||
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->spaceid, wgt->regionid);
|
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
|
||||||
|
|
||||||
WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
|
WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
|
||||||
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
|
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
|
||||||
@@ -456,10 +459,11 @@ wmKeyMap *WM_manipulatorgroup_keymap_common(const struct wmManipulatorGroupType
|
|||||||
/**
|
/**
|
||||||
* Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection
|
* Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection
|
||||||
*/
|
*/
|
||||||
wmKeyMap *WM_manipulatorgroup_keymap_common_sel(const struct wmManipulatorGroupType *wgt, wmKeyConfig *config)
|
wmKeyMap *WM_manipulatorgroup_keymap_common_select(
|
||||||
|
const wmManipulatorGroupType *wgt, wmKeyConfig *config)
|
||||||
{
|
{
|
||||||
/* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
|
/* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */
|
||||||
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->spaceid, wgt->regionid);
|
wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid);
|
||||||
|
|
||||||
WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
|
WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
|
||||||
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
|
manipulatorgroup_tweak_modal_keymap(config, wgt->name);
|
||||||
@@ -483,99 +487,60 @@ wmKeyMap *WM_manipulatorgroup_keymap_common_sel(const struct wmManipulatorGroupT
|
|||||||
*
|
*
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr(
|
||||||
struct wmManipulatorMapType *mmaptype,
|
struct wmManipulatorMapType *mmap_type,
|
||||||
const char *idname)
|
const wmManipulatorGroupType *wgt)
|
||||||
{
|
{
|
||||||
/* could use hash lookups as operator types do, for now simple search. */
|
/* could use hash lookups as operator types do, for now simple search. */
|
||||||
for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first;
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
|
||||||
wgt;
|
wgt_ref;
|
||||||
wgt = wgt->next)
|
wgt_ref = wgt_ref->next)
|
||||||
{
|
{
|
||||||
if (STREQ(idname, wgt->idname)) {
|
if (wgt_ref->type == wgt) {
|
||||||
return wgt;
|
return wgt_ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find(
|
||||||
static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void)
|
struct wmManipulatorMapType *mmap_type,
|
||||||
|
const char *idname)
|
||||||
{
|
{
|
||||||
wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulator-group");
|
/* could use hash lookups as operator types do, for now simple search. */
|
||||||
return wgt;
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
|
||||||
}
|
wgt_ref;
|
||||||
static void wm_manipulatorgrouptype_append__end(
|
wgt_ref = wgt_ref->next)
|
||||||
wmManipulatorMapType *mmaptype, wmManipulatorGroupType *wgt)
|
{
|
||||||
{
|
if (STREQ(idname, wgt_ref->type->idname)) {
|
||||||
BLI_assert(wgt->name != NULL);
|
return wgt_ref;
|
||||||
BLI_assert(wgt->idname != NULL);
|
}
|
||||||
|
|
||||||
wgt->spaceid = mmaptype->spaceid;
|
|
||||||
wgt->regionid = mmaptype->regionid;
|
|
||||||
BLI_strncpy(wgt->mapidname, mmaptype->idname, MAX_NAME);
|
|
||||||
/* if not set, use default */
|
|
||||||
if (!wgt->setup_keymap) {
|
|
||||||
wgt->setup_keymap = WM_manipulatorgroup_keymap_common;
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
/* add the type for future created areas of the same type */
|
|
||||||
BLI_addtail(&mmaptype->manipulator_grouptypes, wgt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this for registering manipulators on startup. For runtime, use #WM_manipulatorgrouptype_append_runtime.
|
* Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime.
|
||||||
*/
|
*/
|
||||||
wmManipulatorGroupType *WM_manipulatorgrouptype_append(
|
wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link(
|
||||||
wmManipulatorMapType *mmaptype, void (*wgt_func)(wmManipulatorGroupType *))
|
wmManipulatorMapType *mmap_type, const char *idname)
|
||||||
{
|
{
|
||||||
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
|
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
|
||||||
wgt_func(wgt);
|
BLI_assert(wgt != NULL);
|
||||||
wm_manipulatorgrouptype_append__end(mmaptype, wgt);
|
return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
|
||||||
return wgt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(
|
wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr(
|
||||||
wmManipulatorMapType *mmaptype, void (*wgt_func)(wmManipulatorGroupType *, void *),
|
wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
|
||||||
void *userdata)
|
|
||||||
{
|
{
|
||||||
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
|
wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref");
|
||||||
wgt_func(wgt, userdata);
|
wgt_ref->type = wgt;
|
||||||
wm_manipulatorgrouptype_append__end(mmaptype, wgt);
|
BLI_addtail(&mmap_type->grouptype_refs, wgt_ref);
|
||||||
return wgt;
|
return wgt_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void WM_manipulatormaptype_group_init_runtime(
|
||||||
* Use this for registering manipulators on runtime.
|
const Main *bmain, wmManipulatorMapType *mmap_type,
|
||||||
*/
|
|
||||||
wmManipulatorGroupType *WM_manipulatorgrouptype_append_runtime(
|
|
||||||
const Main *main, wmManipulatorMapType *mmaptype,
|
|
||||||
void (*wgt_func)(wmManipulatorGroupType *))
|
|
||||||
{
|
|
||||||
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(mmaptype, wgt_func);
|
|
||||||
|
|
||||||
/* Main is missing on startup when we create new areas.
|
|
||||||
* So this is only called for manipulators initialized on runtime */
|
|
||||||
WM_manipulatorgrouptype_init_runtime(main, mmaptype, wgt);
|
|
||||||
|
|
||||||
return wgt;
|
|
||||||
}
|
|
||||||
wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr_runtime(
|
|
||||||
const Main *main, wmManipulatorMapType *mmaptype,
|
|
||||||
void (*wgt_func)(wmManipulatorGroupType *, void *),
|
|
||||||
void *userdata)
|
|
||||||
{
|
|
||||||
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(mmaptype, wgt_func, userdata);
|
|
||||||
|
|
||||||
/* Main is missing on startup when we create new areas.
|
|
||||||
* So this is only called for manipulators initialized on runtime */
|
|
||||||
WM_manipulatorgrouptype_init_runtime(main, mmaptype, wgt);
|
|
||||||
|
|
||||||
return wgt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WM_manipulatorgrouptype_init_runtime(
|
|
||||||
const Main *bmain, wmManipulatorMapType *mmaptype,
|
|
||||||
wmManipulatorGroupType *wgt)
|
wmManipulatorGroupType *wgt)
|
||||||
{
|
{
|
||||||
/* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */
|
/* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */
|
||||||
@@ -588,7 +553,7 @@ void WM_manipulatorgrouptype_init_runtime(
|
|||||||
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
||||||
for (ARegion *ar = lb->first; ar; ar = ar->next) {
|
for (ARegion *ar = lb->first; ar; ar = ar->next) {
|
||||||
wmManipulatorMap *mmap = ar->manipulator_map;
|
wmManipulatorMap *mmap = ar->manipulator_map;
|
||||||
if (mmap && mmap->type == mmaptype) {
|
if (mmap && mmap->type == mmap_type) {
|
||||||
wm_manipulatorgroup_new_from_type(mmap, wgt);
|
wm_manipulatorgroup_new_from_type(mmap, wgt);
|
||||||
|
|
||||||
/* just add here, drawing will occur on next update */
|
/* just add here, drawing will occur on next update */
|
||||||
@@ -603,24 +568,27 @@ void WM_manipulatorgrouptype_init_runtime(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlike #WM_manipulatorgrouptype_remove_ptr this doesn't maintain correct state, simply free.
|
* Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free.
|
||||||
*/
|
*/
|
||||||
void WM_manipulatorgrouptype_free(wmManipulatorGroupType *wgt)
|
void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref)
|
||||||
{
|
{
|
||||||
MEM_freeN(wgt);
|
MEM_freeN(wgt_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WM_manipulatorgrouptype_remove_ptr(bContext *C, Main *bmain, wmManipulatorGroupType *wgt)
|
void WM_manipulatormaptype_group_unlink(
|
||||||
|
bContext *C, Main *bmain, wmManipulatorMapType *mmap_type,
|
||||||
|
const wmManipulatorGroupType *wgt)
|
||||||
{
|
{
|
||||||
|
/* Free instances. */
|
||||||
for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
|
for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
|
||||||
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
||||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||||
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
||||||
for (ARegion *ar = lb->first; ar; ar = ar->next) {
|
for (ARegion *ar = lb->first; ar; ar = ar->next) {
|
||||||
wmManipulatorMap *mmap = ar->manipulator_map;
|
wmManipulatorMap *mmap = ar->manipulator_map;
|
||||||
if (mmap) {
|
if (mmap && mmap->type == mmap_type) {
|
||||||
wmManipulatorGroup *mgroup, *mgroup_next;
|
wmManipulatorGroup *mgroup, *mgroup_next;
|
||||||
for (mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup_next) {
|
for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) {
|
||||||
mgroup_next = mgroup->next;
|
mgroup_next = mgroup->next;
|
||||||
if (mgroup->type == wgt) {
|
if (mgroup->type == wgt) {
|
||||||
BLI_assert(mgroup->parent_mmap == mmap);
|
BLI_assert(mgroup->parent_mmap == mmap);
|
||||||
@@ -634,19 +602,80 @@ void WM_manipulatorgrouptype_remove_ptr(bContext *C, Main *bmain, wmManipulatorG
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wmManipulatorMapType *mmaptype = WM_manipulatormaptype_find(&(const struct wmManipulatorMapType_Params) {
|
/* Free types. */
|
||||||
wgt->mapidname, wgt->spaceid,
|
wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt);
|
||||||
wgt->regionid});
|
if (wgt_ref) {
|
||||||
|
BLI_remlink(&mmap_type->grouptype_refs, wgt_ref);
|
||||||
BLI_remlink(&mmaptype->manipulator_grouptypes, wgt);
|
WM_manipulatormaptype_group_free(wgt_ref);
|
||||||
wgt->prev = wgt->next = NULL;
|
}
|
||||||
|
BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL);
|
||||||
WM_manipulatorgrouptype_free(wgt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_manipulatorgrouptype_setup_keymap(wmManipulatorGroupType *wgt, wmKeyConfig *keyconf)
|
void wm_manipulatorgrouptype_setup_keymap(
|
||||||
|
wmManipulatorGroupType *wgt, wmKeyConfig *keyconf)
|
||||||
{
|
{
|
||||||
wgt->keymap = wgt->setup_keymap(wgt, keyconf);
|
wgt->keymap = wgt->setup_keymap(wgt, keyconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */ /* wmManipulatorGroupType */
|
/** \} */ /* wmManipulatorGroupType */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name High Level Add/Remove API
|
||||||
|
*
|
||||||
|
* For use directly from operators & RNA registration.
|
||||||
|
*
|
||||||
|
* \note In context of manipulator API these names are a bit misleading,
|
||||||
|
* but for general use terms its OK.
|
||||||
|
* `WM_manipulator_group_add` would be more correctly called:
|
||||||
|
* `WM_manipulatormaptype_grouptype_reference_link`
|
||||||
|
* but for general purpose API this is too detailed & annoying.
|
||||||
|
*
|
||||||
|
* \note We may want to return a value if there is nothing to remove.
|
||||||
|
*
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
void WM_manipulator_group_add_ptr_ex(
|
||||||
|
wmManipulatorGroupType *wgt,
|
||||||
|
wmManipulatorMapType *mmap_type)
|
||||||
|
{
|
||||||
|
WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
|
||||||
|
|
||||||
|
WM_manipulatorconfig_update_tag_init(mmap_type, wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_group_add_ptr(
|
||||||
|
wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
|
||||||
|
WM_manipulator_group_add_ptr_ex(wgt, mmap_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_group_add(const char *idname)
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
|
||||||
|
BLI_assert(wgt != NULL);
|
||||||
|
WM_manipulator_group_add_ptr(wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_group_remove_ptr_ex(
|
||||||
|
struct Main *bmain, wmManipulatorGroupType *wgt,
|
||||||
|
wmManipulatorMapType *mmap_type)
|
||||||
|
{
|
||||||
|
WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_group_remove_ptr(
|
||||||
|
struct Main *bmain, wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
|
||||||
|
WM_manipulator_group_remove_ptr_ex(bmain, wgt, mmap_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulator_group_remove(struct Main *bmain, const char *idname)
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
|
||||||
|
BLI_assert(wgt != NULL);
|
||||||
|
WM_manipulator_group_remove_ptr(bmain, wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
@@ -0,0 +1,185 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c
|
||||||
|
* \ingroup wm
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BKE_context.h"
|
||||||
|
|
||||||
|
#include "BLI_ghash.h"
|
||||||
|
#include "BLI_string.h"
|
||||||
|
#include "BLI_string_utils.h"
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
|
#include "WM_api.h"
|
||||||
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */
|
||||||
|
#include "wm.h"
|
||||||
|
|
||||||
|
/* own includes */
|
||||||
|
#include "wm_manipulator_wmapi.h"
|
||||||
|
#include "wm_manipulator_intern.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** \name ManipulatorGroup Type Append
|
||||||
|
*
|
||||||
|
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
static GHash *global_manipulatorgrouptype_hash = NULL;
|
||||||
|
|
||||||
|
wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet)
|
||||||
|
{
|
||||||
|
if (idname[0]) {
|
||||||
|
wmManipulatorGroupType *wgt;
|
||||||
|
|
||||||
|
wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname);
|
||||||
|
if (wgt) {
|
||||||
|
return wgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!quiet) {
|
||||||
|
printf("search for unknown manipulator group '%s'\n", idname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!quiet) {
|
||||||
|
printf("search for empty manipulator group\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* caller must free */
|
||||||
|
void WM_manipulatorgrouptype_iter(GHashIterator *ghi)
|
||||||
|
{
|
||||||
|
BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void)
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype");
|
||||||
|
|
||||||
|
return wgt;
|
||||||
|
}
|
||||||
|
static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
BLI_assert(wgt->name != NULL);
|
||||||
|
BLI_assert(wgt->idname != NULL);
|
||||||
|
|
||||||
|
/* if not set, use default */
|
||||||
|
if (wgt->setup_keymap == NULL) {
|
||||||
|
wgt->setup_keymap = WM_manipulatorgroup_keymap_common;
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
wmManipulatorGroupType *WM_manipulatorgrouptype_append(
|
||||||
|
void (*wtfunc)(struct wmManipulatorGroupType *))
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
|
||||||
|
wtfunc(wgt);
|
||||||
|
wm_manipulatorgrouptype_append__end(wgt);
|
||||||
|
return wgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(
|
||||||
|
void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata)
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin();
|
||||||
|
wtfunc(wgt, userdata);
|
||||||
|
wm_manipulatorgrouptype_append__end(wgt);
|
||||||
|
return wgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append and insert into a manipulator typemap.
|
||||||
|
* This is most common for C manipulators which are enabled by default.
|
||||||
|
*/
|
||||||
|
wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link(
|
||||||
|
wmManipulatorMapType *mmap_type,
|
||||||
|
void (*wtfunc)(struct wmManipulatorGroupType *))
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc);
|
||||||
|
|
||||||
|
wgt->mmap_params.spaceid = mmap_type->spaceid;
|
||||||
|
wgt->mmap_params.regionid = mmap_type->regionid;
|
||||||
|
|
||||||
|
return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free but don't remove from ghash.
|
||||||
|
*/
|
||||||
|
static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
MEM_freeN(wgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WM_manipulatorgrouptype_remove_ptr(wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false));
|
||||||
|
|
||||||
|
BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL);
|
||||||
|
|
||||||
|
manipulatorgrouptype_free(wgt);
|
||||||
|
|
||||||
|
/* XXX, TODO, update the world! */
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WM_manipulatorgrouptype_remove(const char *idname)
|
||||||
|
{
|
||||||
|
wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname);
|
||||||
|
|
||||||
|
if (wgt == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WM_manipulatorgrouptype_remove_ptr(wgt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *mt)
|
||||||
|
{
|
||||||
|
manipulatorgrouptype_free(mt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wm_manipulatorgrouptype_free(void)
|
||||||
|
{
|
||||||
|
BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb);
|
||||||
|
global_manipulatorgrouptype_hash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* called on initialize WM_init() */
|
||||||
|
void wm_manipulatorgrouptype_init(void)
|
||||||
|
{
|
||||||
|
/* reserve size is set based on blender default setup */
|
||||||
|
global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
@@ -29,14 +29,13 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "BKE_context.h"
|
|
||||||
|
|
||||||
#include "BLI_listbase.h"
|
#include "BLI_listbase.h"
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_ghash.h"
|
#include "BLI_ghash.h"
|
||||||
|
|
||||||
#include "DNA_manipulator_types.h"
|
#include "BKE_context.h"
|
||||||
|
#include "BKE_global.h"
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_view3d.h"
|
#include "ED_view3d.h"
|
||||||
@@ -61,6 +60,16 @@
|
|||||||
*/
|
*/
|
||||||
static ListBase manipulatormaptypes = {NULL, NULL};
|
static ListBase manipulatormaptypes = {NULL, NULL};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update when manipulator-map types change.
|
||||||
|
*/
|
||||||
|
/* so operator removal can trigger update */
|
||||||
|
enum {
|
||||||
|
WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
static char wm_mmap_type_update_flag = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manipulator-map update tagging.
|
* Manipulator-map update tagging.
|
||||||
*/
|
*/
|
||||||
@@ -80,17 +89,17 @@ enum eManipulatorMapUpdateFlags {
|
|||||||
*/
|
*/
|
||||||
wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *mmap_params)
|
wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *mmap_params)
|
||||||
{
|
{
|
||||||
wmManipulatorMapType *mmaptype = WM_manipulatormaptype_ensure(mmap_params);
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params);
|
||||||
wmManipulatorMap *mmap;
|
wmManipulatorMap *mmap;
|
||||||
|
|
||||||
mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap");
|
mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap");
|
||||||
mmap->type = mmaptype;
|
mmap->type = mmap_type;
|
||||||
mmap->update_flag = MANIPULATORMAP_REFRESH;
|
mmap->update_flag = MANIPULATORMAP_REFRESH;
|
||||||
|
|
||||||
/* create all manipulator-groups for this manipulator-map. We may create an empty one
|
/* create all manipulator-groups for this manipulator-map. We may create an empty one
|
||||||
* too in anticipation of manipulators from operators etc */
|
* too in anticipation of manipulators from operators etc */
|
||||||
for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first; wgt; wgt = wgt->next) {
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) {
|
||||||
wm_manipulatorgroup_new_from_type(mmap, wgt);
|
wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mmap;
|
return mmap;
|
||||||
@@ -107,12 +116,12 @@ void wm_manipulatormap_remove(wmManipulatorMap *mmap)
|
|||||||
if (!mmap)
|
if (!mmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) {
|
for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) {
|
||||||
mgroup_next = mgroup->next;
|
mgroup_next = mgroup->next;
|
||||||
BLI_assert(mgroup->parent_mmap == mmap);
|
BLI_assert(mgroup->parent_mmap == mmap);
|
||||||
wm_manipulatorgroup_free(NULL, mgroup);
|
wm_manipulatorgroup_free(NULL, mgroup);
|
||||||
}
|
}
|
||||||
BLI_assert(BLI_listbase_is_empty(&mmap->manipulator_groups));
|
BLI_assert(BLI_listbase_is_empty(&mmap->groups));
|
||||||
|
|
||||||
wm_manipulatormap_selected_clear(mmap);
|
wm_manipulatormap_selected_clear(mmap);
|
||||||
|
|
||||||
@@ -133,7 +142,7 @@ static GHash *WM_manipulatormap_manipulator_hash_new(
|
|||||||
GHash *hash = BLI_ghash_str_new(__func__);
|
GHash *hash = BLI_ghash_str_new(__func__);
|
||||||
|
|
||||||
/* collect manipulators */
|
/* collect manipulators */
|
||||||
for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) {
|
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
|
||||||
if (!mgroup->type->poll || mgroup->type->poll(C, mgroup->type)) {
|
if (!mgroup->type->poll || mgroup->type->poll(C, mgroup->type)) {
|
||||||
for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
|
for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) {
|
||||||
if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) &&
|
if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) &&
|
||||||
@@ -183,7 +192,7 @@ static bool manipulator_prepare_drawing(
|
|||||||
static void manipulatormap_prepare_drawing(
|
static void manipulatormap_prepare_drawing(
|
||||||
wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, const int drawstep)
|
wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, const int drawstep)
|
||||||
{
|
{
|
||||||
if (!mmap || BLI_listbase_is_empty(&mmap->manipulator_groups))
|
if (!mmap || BLI_listbase_is_empty(&mmap->groups))
|
||||||
return;
|
return;
|
||||||
wmManipulator *active_manipulator = mmap->mmap_context.active;
|
wmManipulator *active_manipulator = mmap->mmap_context.active;
|
||||||
|
|
||||||
@@ -196,7 +205,7 @@ static void manipulatormap_prepare_drawing(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) {
|
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
|
||||||
/* check group visibility - drawstep first to avoid unnecessary call of group poll callback */
|
/* check group visibility - drawstep first to avoid unnecessary call of group poll callback */
|
||||||
if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) ||
|
if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) ||
|
||||||
!wm_manipulatorgroup_is_visible(mgroup, C))
|
!wm_manipulatorgroup_is_visible(mgroup, C))
|
||||||
@@ -232,7 +241,7 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
|
|||||||
{
|
{
|
||||||
if (!mmap)
|
if (!mmap)
|
||||||
return;
|
return;
|
||||||
BLI_assert(!BLI_listbase_is_empty(&mmap->manipulator_groups));
|
BLI_assert(!BLI_listbase_is_empty(&mmap->groups));
|
||||||
|
|
||||||
const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
|
const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
|
||||||
|
|
||||||
@@ -366,7 +375,7 @@ wmManipulator *wm_manipulatormap_highlight_find(
|
|||||||
wmManipulator *mpr = NULL;
|
wmManipulator *mpr = NULL;
|
||||||
ListBase visible_3d_manipulators = {NULL};
|
ListBase visible_3d_manipulators = {NULL};
|
||||||
|
|
||||||
for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) {
|
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
|
||||||
if (wm_manipulatorgroup_is_visible(mgroup, C)) {
|
if (wm_manipulatorgroup_is_visible(mgroup, C)) {
|
||||||
if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
|
if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
|
||||||
wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators);
|
wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators);
|
||||||
@@ -700,12 +709,11 @@ wmManipulator *wm_manipulatormap_active_get(wmManipulatorMap *mmap)
|
|||||||
wmManipulatorMapType *WM_manipulatormaptype_find(
|
wmManipulatorMapType *WM_manipulatormaptype_find(
|
||||||
const struct wmManipulatorMapType_Params *mmap_params)
|
const struct wmManipulatorMapType_Params *mmap_params)
|
||||||
{
|
{
|
||||||
for (wmManipulatorMapType *mmaptype = manipulatormaptypes.first; mmaptype; mmaptype = mmaptype->next) {
|
for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) {
|
||||||
if (mmaptype->spaceid == mmap_params->spaceid &&
|
if (mmap_type->spaceid == mmap_params->spaceid &&
|
||||||
mmaptype->regionid == mmap_params->regionid &&
|
mmap_type->regionid == mmap_params->regionid)
|
||||||
STREQ(mmaptype->idname, mmap_params->idname))
|
|
||||||
{
|
{
|
||||||
return mmaptype;
|
return mmap_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,36 +723,35 @@ wmManipulatorMapType *WM_manipulatormaptype_find(
|
|||||||
wmManipulatorMapType *WM_manipulatormaptype_ensure(
|
wmManipulatorMapType *WM_manipulatormaptype_ensure(
|
||||||
const struct wmManipulatorMapType_Params *mmap_params)
|
const struct wmManipulatorMapType_Params *mmap_params)
|
||||||
{
|
{
|
||||||
wmManipulatorMapType *mmaptype = WM_manipulatormaptype_find(mmap_params);
|
wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params);
|
||||||
|
|
||||||
if (mmaptype) {
|
if (mmap_type) {
|
||||||
return mmaptype;
|
return mmap_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
mmaptype = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list");
|
mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list");
|
||||||
mmaptype->spaceid = mmap_params->spaceid;
|
mmap_type->spaceid = mmap_params->spaceid;
|
||||||
mmaptype->regionid = mmap_params->regionid;
|
mmap_type->regionid = mmap_params->regionid;
|
||||||
BLI_strncpy(mmaptype->idname, mmap_params->idname, sizeof(mmaptype->idname));
|
BLI_addhead(&manipulatormaptypes, mmap_type);
|
||||||
BLI_addhead(&manipulatormaptypes, mmaptype);
|
|
||||||
|
|
||||||
return mmaptype;
|
return mmap_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_manipulatormaptypes_free(void)
|
void wm_manipulatormaptypes_free(void)
|
||||||
{
|
{
|
||||||
for (wmManipulatorMapType *mmaptype = manipulatormaptypes.first, *mmaptype_next;
|
for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next;
|
||||||
mmaptype;
|
mmap_type;
|
||||||
mmaptype = mmaptype_next)
|
mmap_type = mmap_type_next)
|
||||||
{
|
{
|
||||||
mmaptype_next = mmaptype->next;
|
mmap_type_next = mmap_type->next;
|
||||||
for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first, *wgt_next;
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next;
|
||||||
wgt;
|
wgt_ref;
|
||||||
wgt = wgt_next)
|
wgt_ref = wgt_next)
|
||||||
{
|
{
|
||||||
wgt_next = wgt->next;
|
wgt_next = wgt_ref->next;
|
||||||
WM_manipulatorgrouptype_free(wgt);
|
WM_manipulatormaptype_group_free(wgt_ref);
|
||||||
}
|
}
|
||||||
MEM_freeN(mmaptype);
|
MEM_freeN(mmap_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,18 +760,64 @@ void wm_manipulatormaptypes_free(void)
|
|||||||
*/
|
*/
|
||||||
void wm_manipulators_keymap(wmKeyConfig *keyconf)
|
void wm_manipulators_keymap(wmKeyConfig *keyconf)
|
||||||
{
|
{
|
||||||
wmManipulatorMapType *mmaptype;
|
|
||||||
wmManipulatorGroupType *wgt;
|
|
||||||
|
|
||||||
/* we add this item-less keymap once and use it to group manipulator-group keymaps into it */
|
/* we add this item-less keymap once and use it to group manipulator-group keymaps into it */
|
||||||
WM_keymap_find(keyconf, "Manipulators", 0, 0);
|
WM_keymap_find(keyconf, "Manipulators", 0, 0);
|
||||||
|
|
||||||
for (mmaptype = manipulatormaptypes.first; mmaptype; mmaptype = mmaptype->next) {
|
for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) {
|
||||||
for (wgt = mmaptype->manipulator_grouptypes.first; wgt; wgt = wgt->next) {
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) {
|
||||||
wm_manipulatorgrouptype_setup_keymap(wgt, keyconf);
|
wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */ /* wmManipulatorMapType */
|
/** \} */ /* wmManipulatorMapType */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Updates for Dynamic Type Registraion
|
||||||
|
*
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
|
||||||
|
void WM_manipulatorconfig_update_tag_init(wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt)
|
||||||
|
{
|
||||||
|
/* tag for update on next use */
|
||||||
|
mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT;
|
||||||
|
wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT;
|
||||||
|
|
||||||
|
wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run incase new types have been added (runs often, early exit where possible).
|
||||||
|
* Follows #WM_keyconfig_update concentions.
|
||||||
|
*/
|
||||||
|
void WM_manipulatorconfig_update(const struct Main *bmain)
|
||||||
|
{
|
||||||
|
if (G.background)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (wm_mmap_type_update_flag == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) {
|
||||||
|
for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first;
|
||||||
|
mmap_type;
|
||||||
|
mmap_type = mmap_type->next)
|
||||||
|
{
|
||||||
|
if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) {
|
||||||
|
mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
|
||||||
|
for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first;
|
||||||
|
wgt_ref;
|
||||||
|
wgt_ref = wgt_ref->next)
|
||||||
|
{
|
||||||
|
wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT;
|
||||||
|
WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
@@ -30,10 +30,18 @@
|
|||||||
#include "BLI_compiler_attrs.h"
|
#include "BLI_compiler_attrs.h"
|
||||||
|
|
||||||
/* wmManipulatorGroup */
|
/* wmManipulatorGroup */
|
||||||
typedef bool (*wmManipulatorGroupFnPoll)(const struct bContext *, struct wmManipulatorGroupType *) ATTR_WARN_UNUSED_RESULT;
|
typedef bool (*wmManipulatorGroupFnPoll)(
|
||||||
typedef void (*wmManipulatorGroupFnInit)(const struct bContext *, struct wmManipulatorGroup *);
|
const struct bContext *, struct wmManipulatorGroupType *)
|
||||||
typedef void (*wmManipulatorGroupFnRefresh)(const struct bContext *, struct wmManipulatorGroup *);
|
ATTR_WARN_UNUSED_RESULT;
|
||||||
typedef void (*wmManipulatorGroupFnDrawPrepare)(const struct bContext *, struct wmManipulatorGroup *);
|
typedef void (*wmManipulatorGroupFnInit)(
|
||||||
|
const struct bContext *, struct wmManipulatorGroup *);
|
||||||
|
typedef void (*wmManipulatorGroupFnRefresh)(
|
||||||
|
const struct bContext *, struct wmManipulatorGroup *);
|
||||||
|
typedef void (*wmManipulatorGroupFnDrawPrepare)(
|
||||||
|
const struct bContext *, struct wmManipulatorGroup *);
|
||||||
|
typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)(
|
||||||
|
const struct wmManipulatorGroupType *, struct wmKeyConfig *)
|
||||||
|
ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/* wmManipulator */
|
/* wmManipulator */
|
||||||
/* See: wmManipulatorType for docs on each type. */
|
/* See: wmManipulatorType for docs on each type. */
|
||||||
@@ -48,4 +56,22 @@ typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *
|
|||||||
typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);
|
typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);
|
||||||
typedef void (*wmManipulatorFnSelect)(struct bContext *, struct wmManipulator *, const int);
|
typedef void (*wmManipulatorFnSelect)(struct bContext *, struct wmManipulator *, const int);
|
||||||
|
|
||||||
|
/* wmManipulatorProperty */
|
||||||
|
typedef void (*wmManipulatorPropertyFnGet)(
|
||||||
|
const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data,
|
||||||
|
float *value, uint value_len);
|
||||||
|
typedef void (*wmManipulatorPropertyFnSet)(
|
||||||
|
const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data,
|
||||||
|
const float *value, uint value_len);
|
||||||
|
typedef void (*wmManipulatorPropertyFnRangeGet)(
|
||||||
|
const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data,
|
||||||
|
float range[2]);
|
||||||
|
|
||||||
|
typedef struct wmManipulatorPropertyFnParams {
|
||||||
|
wmManipulatorPropertyFnGet value_get_fn;
|
||||||
|
wmManipulatorPropertyFnSet value_set_fn;
|
||||||
|
wmManipulatorPropertyFnRangeGet range_get_fn;
|
||||||
|
void *user_data;
|
||||||
|
} wmManipulatorPropertyFnParams;
|
||||||
|
|
||||||
#endif /* __WM_MANIPULATOR_FN_H__ */
|
#endif /* __WM_MANIPULATOR_FN_H__ */
|
||||||
|
@@ -47,12 +47,14 @@ struct wmOperator;
|
|||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* wmManipulator */
|
/* wmManipulator */
|
||||||
|
|
||||||
struct wmManipulatorGroup *wm_manipulator_get_parent_group(const struct wmManipulator *mpr);
|
/* wm_manipulator_type.c, for init/exit */
|
||||||
|
|
||||||
/* wm_manipulator.c, for init/exit */
|
|
||||||
void wm_manipulatortype_free(void);
|
void wm_manipulatortype_free(void);
|
||||||
void wm_manipulatortype_init(void);
|
void wm_manipulatortype_init(void);
|
||||||
|
|
||||||
|
/* wm_manipulatorgroup_type.c, for init/exit */
|
||||||
|
void wm_manipulatorgrouptype_free(void);
|
||||||
|
void wm_manipulatorgrouptype_init(void);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* wmManipulatorGroup */
|
/* wmManipulatorGroup */
|
||||||
|
|
||||||
@@ -63,7 +65,6 @@ void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot);
|
|||||||
/* wmManipulatorMap */
|
/* wmManipulatorMap */
|
||||||
|
|
||||||
void wm_manipulatormap_remove(struct wmManipulatorMap *mmap);
|
void wm_manipulatormap_remove(struct wmManipulatorMap *mmap);
|
||||||
void wm_manipulatormaptypes_free(void);
|
|
||||||
|
|
||||||
void wm_manipulators_keymap(struct wmKeyConfig *keyconf);
|
void wm_manipulators_keymap(struct wmKeyConfig *keyconf);
|
||||||
|
|
||||||
@@ -83,5 +84,10 @@ void wm_manipulatormap_active_set(
|
|||||||
const struct wmEvent *event, struct wmManipulator *mpr);
|
const struct wmEvent *event, struct wmManipulator *mpr);
|
||||||
struct wmManipulator *wm_manipulatormap_active_get(struct wmManipulatorMap *mmap);
|
struct wmManipulator *wm_manipulatormap_active_get(struct wmManipulatorMap *mmap);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* wmManipulatorMapType */
|
||||||
|
|
||||||
|
void wm_manipulatormaptypes_free(void);
|
||||||
|
|
||||||
#endif /* __WM_MANIPULATOR_WMAPI_H__ */
|
#endif /* __WM_MANIPULATOR_WMAPI_H__ */
|
||||||
|
|
||||||
|
@@ -115,6 +115,7 @@ struct bConstraintOb;
|
|||||||
struct bConstraintTarget;
|
struct bConstraintTarget;
|
||||||
struct bContextDataResult;
|
struct bContextDataResult;
|
||||||
struct bGPDlayer;
|
struct bGPDlayer;
|
||||||
|
struct bFaceMap;
|
||||||
struct bNode;
|
struct bNode;
|
||||||
struct bNodeType;
|
struct bNodeType;
|
||||||
struct bNodeSocket;
|
struct bNodeSocket;
|
||||||
@@ -132,6 +133,7 @@ struct wmOperator;
|
|||||||
struct wmOperatorType;
|
struct wmOperatorType;
|
||||||
struct wmWindow;
|
struct wmWindow;
|
||||||
struct wmWindowManager;
|
struct wmWindowManager;
|
||||||
|
struct wmManipulatorMap;
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
@@ -359,8 +361,9 @@ void WM_report(ReportType type, const char *message) RET_NONE
|
|||||||
struct wmManipulatorMapType *WM_manipulatormaptype_find(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
struct wmManipulatorMapType *WM_manipulatormaptype_find(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
||||||
struct wmManipulatorMapType *WM_manipulatormaptype_ensure(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
struct wmManipulatorMapType *WM_manipulatormaptype_ensure(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
||||||
struct wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
struct wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL
|
||||||
void WM_manipulatorgrouptype_init_runtime(
|
void WM_manipulatormaptype_group_init_runtime(
|
||||||
const struct Main *bmain, struct wmManipulatorMapType *wmaptype, struct wmManipulatorGroupType *wgt) RET_NONE
|
const struct Main *bmain, struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt) RET_NONE
|
||||||
|
void WM_manipulatorgrouptype_unregister(struct bContext *C, struct Main *bmain, struct wmManipulatorGroupType *wgt) RET_NONE
|
||||||
|
|
||||||
#ifdef WITH_INPUT_NDOF
|
#ifdef WITH_INPUT_NDOF
|
||||||
void WM_ndof_deadzone_set(float deadzone) RET_NONE
|
void WM_ndof_deadzone_set(float deadzone) RET_NONE
|
||||||
|
Reference in New Issue
Block a user