Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/CMakeLists.txt1
-rw-r--r--source/blender/editors/animation/anim_intern.h1
-rw-r--r--source/blender/editors/animation/anim_ops.c1
-rw-r--r--source/blender/editors/animation/drivers.c42
-rw-r--r--source/blender/editors/armature/armature_edit.c1
-rw-r--r--source/blender/editors/armature/pose_select.c26
-rw-r--r--source/blender/editors/curve/editcurve.c34
-rw-r--r--source/blender/editors/curve/editcurve_select.c57
-rw-r--r--source/blender/editors/include/ED_keyframing.h2
-rw-r--r--source/blender/editors/include/ED_screen.h5
-rw-r--r--source/blender/editors/include/ED_space_api.h1
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h10
-rw-r--r--source/blender/editors/include/ED_uvedit.h5
-rw-r--r--source/blender/editors/include/ED_view3d.h34
-rw-r--r--source/blender/editors/include/UI_interface.h8
-rw-r--r--source/blender/editors/interface/interface.c192
-rw-r--r--source/blender/editors/interface/interface_align.c22
-rw-r--r--source/blender/editors/interface/interface_anim.c58
-rw-r--r--source/blender/editors/interface/interface_draw.c154
-rw-r--r--source/blender/editors/interface/interface_handlers.c483
-rw-r--r--source/blender/editors/interface/interface_icons.c102
-rw-r--r--source/blender/editors/interface/interface_intern.h26
-rw-r--r--source/blender/editors/interface/interface_layout.c101
-rw-r--r--source/blender/editors/interface/interface_ops.c26
-rw-r--r--source/blender/editors/interface/interface_panel.c121
-rw-r--r--source/blender/editors/interface/interface_region_popover.c66
-rw-r--r--source/blender/editors/interface/interface_regions.c4
-rw-r--r--source/blender/editors/interface/interface_style.c56
-rw-r--r--source/blender/editors/interface/interface_templates.c228
-rw-r--r--source/blender/editors/interface/interface_utils.c10
-rw-r--r--source/blender/editors/interface/interface_widgets.c580
-rw-r--r--source/blender/editors/interface/resources.c312
-rw-r--r--source/blender/editors/interface/view2d.c510
-rw-r--r--source/blender/editors/interface/view2d_ops.c464
-rw-r--r--source/blender/editors/lattice/editlattice_select.c72
-rw-r--r--source/blender/editors/mask/mask_select.c21
-rw-r--r--source/blender/editors/mesh/editmesh_path.c113
-rw-r--r--source/blender/editors/mesh/editmesh_select.c89
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c23
-rw-r--r--source/blender/editors/object/object_bake_api.c6
-rw-r--r--source/blender/editors/object/object_edit.c1
-rw-r--r--source/blender/editors/object/object_relations.c1
-rw-r--r--source/blender/editors/object/object_transform.c4
-rw-r--r--source/blender/editors/physics/particle_edit.c15
-rw-r--r--source/blender/editors/physics/particle_object.c2
-rw-r--r--source/blender/editors/scene/scene_edit.c5
-rw-r--r--source/blender/editors/screen/area.c39
-rw-r--r--source/blender/editors/screen/screen_edit.c207
-rw-r--r--source/blender/editors/screen/screen_intern.h4
-rw-r--r--source/blender/editors/screen/screen_ops.c150
-rw-r--r--source/blender/editors/screen/workspace_edit.c5
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c46
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c1
-rw-r--r--source/blender/editors/space_action/space_action.c55
-rw-r--r--source/blender/editors/space_api/spacetypes.c3
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c287
-rw-r--r--source/blender/editors/space_graph/space_graph.c20
-rw-r--r--source/blender/editors/space_image/space_image.c4
-rw-r--r--source/blender/editors/space_nla/space_nla.c36
-rw-r--r--source/blender/editors/space_node/node_select.c18
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c37
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c58
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c12
-rw-r--r--source/blender/editors/space_statusbar/CMakeLists.txt45
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c200
-rw-r--r--source/blender/editors/space_view3d/drawobject.c14
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c85
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h5
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_camera.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c30
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_ruler.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c22
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c97
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c48
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c48
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c2
-rw-r--r--source/blender/editors/transform/transform.c8
-rw-r--r--source/blender/editors/transform/transform.h7
-rw-r--r--source/blender/editors/transform/transform_constraints.c17
-rw-r--r--source/blender/editors/transform/transform_conversions.c104
-rw-r--r--source/blender/editors/transform/transform_generics.c20
-rw-r--r--source/blender/editors/transform/transform_input.c6
-rw-r--r--source/blender/editors/transform/transform_manipulator_3d.c23
-rw-r--r--source/blender/editors/transform/transform_ops.c11
-rw-r--r--source/blender/editors/transform/transform_orientations.c12
-rw-r--r--source/blender/editors/transform/transform_snap.c119
-rw-r--r--source/blender/editors/transform/transform_snap_object.c178
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c8
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c128
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c8
105 files changed, 3804 insertions, 2696 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 358f82499c2..2b30382f4a4 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -54,6 +54,7 @@ if(WITH_BLENDER)
add_subdirectory(space_outliner)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
+ add_subdirectory(space_statusbar)
add_subdirectory(space_text)
add_subdirectory(space_topbar)
add_subdirectory(space_userpref)
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index c571da1ba74..824c1d58f44 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -79,6 +79,7 @@ void ANIM_OT_keying_set_active_set(struct wmOperatorType *ot);
/* Driver management operators for UI buttons (RMB menu) */
void ANIM_OT_driver_button_add(struct wmOperatorType *ot);
void ANIM_OT_driver_button_remove(struct wmOperatorType *ot);
+void ANIM_OT_driver_button_edit(struct wmOperatorType *ot);
void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index eace5af4701..1136dcd129e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -512,6 +512,7 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_driver_button_add);
WM_operatortype_append(ANIM_OT_driver_button_remove);
+ WM_operatortype_append(ANIM_OT_driver_button_edit);
WM_operatortype_append(ANIM_OT_copy_driver_button);
WM_operatortype_append(ANIM_OT_paste_driver_button);
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 2d04f73c4ac..2c28ecfac5d 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -41,6 +41,7 @@
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
+#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "BKE_animsys.h"
@@ -117,7 +118,6 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
/* add some new driver data */
fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
- fcu->driver->flag |= DRIVER_FLAG_SHOWDEBUG;
/* F-Modifier or Keyframes? */
// FIXME: replace these magic numbers with defines
@@ -968,6 +968,46 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array");
}
+/* Edit Driver Button Operator ------------------------ */
+
+static int edit_driver_button_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr = {{NULL}};
+ PropertyRNA *prop = NULL;
+ int index;
+ const bool all = 0; // RNA_boolean_get(op->ptr, "all");
+
+ /* try to find driver using property retrieved from UI */
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (all)
+ index = -1;
+
+ if (ptr.id.data && ptr.data && prop) {
+ UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
+ }
+
+ return OPERATOR_INTERFACE;
+}
+
+void ANIM_OT_driver_button_edit(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edit Driver";
+ ot->idname = "ANIM_OT_driver_button_edit";
+ ot->description = "Edit the drivers for the property connected represented by the highlighted button";
+
+ /* callbacks */
+ ot->exec = edit_driver_button_exec;
+ //op->poll = ??? // TODO: need to have some driver to be able to do this...
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
+
+ /* properties */
+ //RNA_def_boolean(ot->srna, "all", 1, "All", "Edit drivers for all elements of the array");
+}
+
/* Copy Driver Button Operator ------------------------ */
static int copy_driver_button_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 7372be8896f..fe0722470cd 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -1373,6 +1373,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
}
}
+ MEM_freeN(objects);
if (!changed_multi) {
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index d4b89cd6a00..f0dc680598c 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -176,7 +176,7 @@ bool ED_armature_pose_select_pick_with_buffer(
uint objects_len = 0;
Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len);
ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true);
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
}
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
@@ -299,7 +299,22 @@ void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_m
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
+ bArmature *arm = ob_iter->data;
+
ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility);
+
+ /* if there are some dependencies for visualizing armature state
+ * (e.g. Mask Modifier in 'Armature' mode), force update
+ */
+ if (arm->flag & ARM_HAS_VIZ_DEPS) {
+ /* NOTE: ob not ob_act here is intentional - it's the source of the
+ * bones being selected [T37247]
+ */
+ DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
+ }
+
+ /* need to tag armature for cow updates, or else selection doesn't update */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
}
@@ -368,6 +383,9 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&base->object->id, OB_RECALC_DATA);
}
+
+ /* need to tag armature for cow updates, or else selection doesn't update */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -907,6 +925,9 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
+ /* need to tag armature for cow updates, or else selection doesn't update */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
+
/* report done status */
if (changed)
return OPERATOR_FINISHED;
@@ -1001,6 +1022,9 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
+
+ /* need to tag armature for cow updates, or else selection doesn't update */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
FOREACH_OBJECT_IN_MODE_END;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 7e540ee074a..1987fe56bdb 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -3371,16 +3371,29 @@ static void subdividenurb(Object *obedit, int number_cuts)
static int subdivide_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- int number_cuts = RNA_int_get(op->ptr, "number_cuts");
+ const int number_cuts = RNA_int_get(op->ptr, "number_cuts");
- subdividenurb(obedit, number_cuts);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- if (ED_curve_updateAnimPaths(obedit->data))
- WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Curve *cu = obedit->data;
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
- DEG_id_tag_update(obedit->data, 0);
+ if (!ED_curve_select_check(cu, cu->editnurb)) {
+ continue;
+ }
+
+ subdividenurb(obedit, number_cuts);
+
+ if (ED_curve_updateAnimPaths(cu))
+ WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, cu);
+ DEG_id_tag_update(obedit->data, 0);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -5013,15 +5026,14 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const float mval[2] = {UNPACK2(event->mval)};
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
+ vc.scene, CTX_data_depsgraph(C), 0, vc.ar, vc.v3d);
- ED_transform_snap_object_project_view3d_mixed(
+ ED_transform_snap_object_project_view3d(
snap_context,
- SCE_SELECT_FACE,
+ SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = (vc.obedit != NULL) ? SNAP_NOT_ACTIVE : SNAP_ALL,
.use_object_edit_cage = false,
- .use_occlusion_test = true,
},
mval, NULL,
location, NULL);
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 1719fd5568a..58fb6d50575 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -520,19 +520,30 @@ void CURVE_OT_select_all(wmOperatorType *ot)
static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *obedit = CTX_data_edit_object(C);
- Curve *cu = (Curve *)obedit->data;
- EditNurb *editnurb = cu->editnurb;
- ListBase *nurbs = &editnurb->nurbs;
- Nurb *nu;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
- for (nu = nurbs->first; nu; nu = nu->next) {
- if (ED_curve_nurb_select_check(cu, nu)) {
- ED_curve_nurb_select_all(nu);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Curve *cu = obedit->data;
+ EditNurb *editnurb = cu->editnurb;
+ ListBase *nurbs = &editnurb->nurbs;
+ Nurb *nu;
+ bool changed = false;
+
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (ED_curve_nurb_select_check(cu, nu)) {
+ ED_curve_nurb_select_all(nu);
+ changed = true;
+ }
}
- }
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ if (changed) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -547,7 +558,7 @@ void CURVE_OT_select_linked(wmOperatorType *ot)
/* identifiers */
ot->name = "Select Linked All";
ot->idname = "CURVE_OT_select_linked";
- ot->description = "Select all control points linked to active one";
+ ot->description = "Select all control points linked to the current selection";
/* api callbacks */
ot->exec = select_linked_exec;
@@ -1055,17 +1066,31 @@ static void curve_select_random(ListBase *editnurb, float randfac, int seed, boo
static int curve_select_random_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- ListBase *editnurb = object_editcurve_get(obedit);
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
- curve_select_random(editnurb, randfac, seed, select);
- BKE_curve_nurb_vert_active_validate(obedit->data);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ListBase *editnurb = object_editcurve_get(obedit);
+ int seed_iter = seed;
+ /* This gives a consistent result regardless of object order. */
+ if (ob_index) {
+ seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
+ }
+
+ curve_select_random(editnurb, randfac, seed_iter, select);
+ BKE_curve_nurb_vert_active_validate(obedit->data);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 54ee0b30d52..85e51874cf3 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -109,7 +109,7 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_Keyframe
* Use this to insert a keyframe using the current value being keyframed, in the
* nominated F-Curve (no creation of animation data performed). Returns success.
*/
-bool insert_keyframe_direct(struct Depsgraph *depsgraph,struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
+bool insert_keyframe_direct(struct Depsgraph *depsgraph, struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
/* -------- */
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 3d17afc2878..919c8d14db5 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -119,14 +119,12 @@ int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *bl
void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
void ED_area_exit(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
-void ED_screen_global_topbar_area_create(
- struct wmWindow *win,
- const struct bScreen *screen);
void ED_screen_global_areas_create(
struct wmWindow *win);
void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene,
struct WorkSpace *workspace);
void ED_area_tag_redraw(ScrArea *sa);
+void ED_area_tag_redraw_no_rebuild(ScrArea *sa);
void ED_area_tag_redraw_regiontype(ScrArea *sa, int type);
void ED_area_tag_refresh(ScrArea *sa);
void ED_area_do_refresh(struct bContext *C, ScrArea *sa);
@@ -250,6 +248,7 @@ int ED_operator_screen_mainwinactive(struct bContext *C);
int ED_operator_areaactive(struct bContext *C);
int ED_operator_regionactive(struct bContext *C);
+int ED_operator_scene(struct bContext *C);
int ED_operator_scene_editable(struct bContext *C);
int ED_operator_objectmode(struct bContext *C);
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 0cb23514867..77539bff252 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -57,6 +57,7 @@ void ED_spacetype_logic(void);
void ED_spacetype_console(void);
void ED_spacetype_userpref(void);
void ED_spacetype_clip(void);
+void ED_spacetype_statusbar(void);
void ED_spacetype_topbar(void);
/* calls for instancing and freeing spacetype static data
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index e17d02abcd7..1e3c8995314 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -102,6 +102,7 @@ enum TfmMode {
#define CTX_MASK (1 << 7)
#define CTX_PAINT_CURVE (1 << 8)
#define CTX_GPENCIL_STROKES (1 << 9)
+#define CTX_CURSOR (1 << 10)
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)
@@ -152,6 +153,7 @@ int BIF_countTransformOrientation(const struct bContext *C);
#define P_NO_TEXSPACE (1 << 11)
#define P_CENTER (1 << 12)
#define P_GPENCIL_EDIT (1 << 13)
+#define P_CURSOR_EDIT (1 << 14)
void Transform_Properties(struct wmOperatorType *ot, int flags);
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index d65679e1872..18d5101ebf7 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -79,9 +79,9 @@ struct SnapObjectParams {
typedef struct SnapObjectContext SnapObjectContext;
SnapObjectContext *ED_transform_snap_object_context_create(
- struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag);
+ struct Scene *scene, struct Depsgraph *depsgraph, int flag);
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph, int flag,
+ struct Scene *scene, struct Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const struct ARegion *ar, const struct View3D *v3d);
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx);
@@ -128,12 +128,6 @@ bool ED_transform_snap_object_project_view3d(
const float mval[2], float *dist_px,
/* return args */
float r_loc[3], float r_no[3]);
-bool ED_transform_snap_object_project_view3d_mixed(
- SnapObjectContext *sctx,
- const unsigned short snap_to_flag,
- const struct SnapObjectParams *params,
- const float mval_fl[2], float *dist_px,
- float r_co[3], float r_no[3]);
bool ED_transform_snap_object_project_all_view3d_ex(
SnapObjectContext *sctx,
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index d6e8b6e9504..4d5e4585221 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -54,6 +54,11 @@ bool ED_uvedit_minmax(struct Scene *scene, struct Image *ima, struct Object *obe
bool ED_uvedit_center(Scene *scene, Image *ima, struct Object *obedit, float cent[2], char mode);
void ED_uvedit_select_all(struct BMesh *bm);
+bool ED_uvedit_minmax_multi(
+ struct Scene *scene, struct Image *ima, struct Object **objects_edit, uint objects_len, float r_min[2], float r_max[2]);
+bool ED_uvedit_center_multi(
+ Scene *scene, Image *ima, struct Object **objects_edit, uint objects_len, float r_cent[2], char mode);
+
bool ED_object_get_active_image(
struct Object *ob, int mat_nr,
struct Image **r_ima, struct ImageUser **r_iuser, struct bNode **r_node, struct bNodeTree **r_ntree);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index bb86c7ba6c5..e1a6d59a748 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -106,10 +106,14 @@ void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]);
struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d);
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist);
-void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist);
+void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist);
-void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens);
-void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist);
+void ED_view3d_from_object(
+ const struct Object *ob,
+ float ofs[3], float quat[4], float *dist, float *lens);
+void ED_view3d_to_object(
+ const struct Depsgraph *depsgraph, struct Object *ob,
+ const float ofs[3], const float quat[4], const float dist);
void ED_view3d_lastview_store(struct RegionView3D *rv3d);
@@ -225,6 +229,7 @@ eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *ar, const fl
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag);
float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3]);
+float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3]);
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]);
@@ -302,12 +307,14 @@ float ED_view3d_radius_to_dist_persp(const float angle, const float radius);
float ED_view3d_radius_to_dist_ortho(const float lens, const float radius);
float ED_view3d_radius_to_dist(
const struct View3D *v3d, const struct ARegion *ar,
+ const struct Depsgraph *depsgraph,
const char persp, const bool use_aspect,
const float radius);
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos);
/* backbuffer select and draw support */
+void ED_view3d_backbuf_validate_with_select_mode(struct ViewContext *vc, short select_mode);
void ED_view3d_backbuf_validate(struct ViewContext *vc);
struct ImBuf *ED_view3d_backbuf_read(
struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
@@ -379,7 +386,8 @@ int ED_view3d_view_layer_set(int lay, const int *values, int *active);
struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d);
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
-void ED_draw_object_facemap(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
+void ED_draw_object_facemap(
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const float col[4], const int facemap);
struct RenderEngineType *ED_view3d_engine_type(struct Scene *scene, int drawtype);
@@ -436,17 +444,25 @@ uint64_t ED_view3d_datamask(const struct Scene *scene, const struct View3D *v3d)
uint64_t ED_view3d_screen_datamask(const struct Scene *scene, const struct bScreen *screen);
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
-void ED_view3d_persp_switch_from_camera(struct View3D *v3d, struct RegionView3D *rv3d, const char persp);
-bool ED_view3d_persp_ensure(struct View3D *v3d, struct ARegion *ar);
+void ED_view3d_persp_switch_from_camera(
+ const struct Depsgraph *depsgraph,
+ struct View3D *v3d, struct RegionView3D *rv3d, const char persp);
+bool ED_view3d_persp_ensure(
+ const struct Depsgraph *depsgraph,
+ struct View3D *v3d, struct ARegion *ar);
/* camera lock functions */
bool ED_view3d_camera_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
/* copy the camera to the view before starting a view transformation */
-void ED_view3d_camera_lock_init_ex(struct View3D *v3d, struct RegionView3D *rv3d, const bool calc_dist);
-void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d);
+void ED_view3d_camera_lock_init_ex(
+ const struct Depsgraph *depsgraph,
+ struct View3D *v3d, struct RegionView3D *rv3d, const bool calc_dist);
+void ED_view3d_camera_lock_init(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d);
/* copy the view to the camera, return true if */
-bool ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d);
+bool ED_view3d_camera_lock_sync(
+ const struct Depsgraph *depsgraph,
+ struct View3D *v3d, struct RegionView3D *rv3d);
bool ED_view3d_camera_autokey(
struct Scene *scene, struct ID *id_key,
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 47ecbca227b..689fa850dea 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -42,6 +42,7 @@ struct ID;
struct IDProperty;
struct ListBase;
struct ARegion;
+struct ARegionType;
struct ScrArea;
struct bScreen;
struct wmEvent;
@@ -428,6 +429,10 @@ void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *b
typedef struct uiPopover uiPopover;
+int UI_popover_panel_invoke(
+ struct bContext *C, int space_id, int region_id, const char *idname,
+ bool keep_open, struct ReportList *reports);
+
uiPopover *UI_popover_begin(struct bContext *C) ATTR_NONNULL(1);
void UI_popover_end(struct bContext *C, struct uiPopover *head, struct wmKeyMap *keymap);
struct uiLayout *UI_popover_layout(uiPopover *head);
@@ -836,6 +841,8 @@ struct PanelCategoryDyn *UI_panel_category_find_mouse_over(struct ARegion *ar,
void UI_panel_category_clear_all(struct ARegion *ar);
void UI_panel_category_draw_all(struct ARegion *ar, const char *category_id_active);
+struct PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname);
+
/* Handlers
*
* Handlers that can be registered in regions, areas and windows for
@@ -940,6 +947,7 @@ const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
struct MenuType *UI_but_menutype_get(uiBut *but);
struct PanelType *UI_but_paneltype_get(uiBut *but);
void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout);
+void UI_paneltype_draw(struct bContext *C, struct PanelType *pt, struct uiLayout *layout);
/* Only for convenience. */
void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index be0c84f7d80..de1c1de4bcf 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -93,7 +93,7 @@
/**
* a full doc with API notes can be found in 'blender/doc/guides/interface_API.txt'
- *
+ *
* `uiBlahBlah()` external function.
* `ui_blah_blah()` internal function.
*/
@@ -318,7 +318,7 @@ void ui_block_bounds_calc(uiBlock *block)
{
uiBut *bt;
int xof;
-
+
if (BLI_listbase_is_empty(&block->buttons)) {
if (block->panel) {
block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex;
@@ -326,13 +326,13 @@ void ui_block_bounds_calc(uiBlock *block)
}
}
else {
-
+
BLI_rctf_init_minmax(&block->rect);
for (bt = block->buttons.first; bt; bt = bt->next) {
BLI_rctf_union(&block->rect, &bt->rect);
}
-
+
block->rect.xmin -= block->bounds;
block->rect.ymin -= block->bounds;
block->rect.xmax += block->bounds;
@@ -341,7 +341,7 @@ void ui_block_bounds_calc(uiBlock *block)
block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds);
- /* hardcoded exception... but that one is annoying with larger safety */
+ /* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
if (bt && STREQLEN(bt->str, "ERROR", 5)) xof = 10;
else xof = 40;
@@ -357,7 +357,7 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
int xmax, ymax;
int startx, starty;
int width, height;
-
+
/* note: this is used for the splash where window bounds event has not been
* updated by ghost, get the window bounds from ghost directly */
@@ -365,18 +365,18 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
ymax = WM_window_pixels_y(window);
ui_block_bounds_calc(block);
-
+
width = BLI_rctf_size_x(&block->rect);
height = BLI_rctf_size_y(&block->rect);
-
+
startx = (xmax * 0.5f) - (width * 0.5f);
starty = (ymax * 0.5f) - (height * 0.5f);
-
+
UI_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin);
-
+
/* now recompute bounds and safety */
ui_block_bounds_calc(block);
-
+
}
static void ui_block_bounds_calc_centered_pie(uiBlock *block)
@@ -406,7 +406,7 @@ static void ui_block_bounds_calc_popup(
/* compute mouse position with user defined offset */
ui_block_bounds_calc(block);
-
+
xmax = WM_window_pixels_x(window);
ymax = WM_window_pixels_y(window);
@@ -464,7 +464,7 @@ void UI_block_bounds_set_normal(uiBlock *block, int addval)
{
if (block == NULL)
return;
-
+
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS;
}
@@ -723,7 +723,7 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
uiBlock *oldblock;
uiBut *oldbut;
bool activate = false, found = false, isactive = false;
-
+
oldblock = block->oldblock;
if (!oldblock) {
activate = true;
@@ -746,7 +746,7 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
ui_but_free(C, but);
return false;
}
-
+
return true;
}
@@ -950,27 +950,27 @@ static bool ui_but_event_property_operator_string(
"WM_OT_context_cycle_array",
"WM_OT_context_menu_enum",
NULL
- };
+ };
const size_t num_ops = sizeof(ctx_toggle_opnames) / sizeof(const char *);
-
+
bool found = false;
-
+
/* this version is only for finding hotkeys for properties (which get set via context using operators) */
if (but->rnaprop) {
- /* to avoid massive slowdowns on property panels, for now, we only check the
+ /* to avoid massive slowdowns on property panels, for now, we only check the
* hotkeys for Editor / Scene settings...
*
* TODO: userpref settings?
*/
// TODO: value (for enum stuff)?
char *data_path = NULL;
-
+
if (but->rnapoin.id.data) {
ID *id = but->rnapoin.id.data;
-
+
if (GS(id->name) == ID_SCR) {
- /* screen/editor property
- * NOTE: in most cases, there is actually no info for backwards tracing
+ /* screen/editor property
+ * NOTE: in most cases, there is actually no info for backwards tracing
* how to get back to ID from the editor data we may be dealing with
*/
if (RNA_struct_is_a(but->rnapoin.type, &RNA_Space)) {
@@ -991,7 +991,7 @@ static bool ui_but_event_property_operator_string(
}
else if (GS(id->name) == ID_SCE) {
if (RNA_struct_is_a(but->rnapoin.type, &RNA_ToolSettings)) {
- /* toolsettings property
+ /* toolsettings property
* NOTE: toolsettings is usually accessed directly (i.e. not through scene)
*/
data_path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
@@ -999,7 +999,7 @@ static bool ui_but_event_property_operator_string(
else {
/* scene property */
char *path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
-
+
if (path) {
data_path = BLI_sprintfN("scene.%s", path);
MEM_freeN(path);
@@ -1015,23 +1015,23 @@ static bool ui_but_event_property_operator_string(
else {
//puts("other id");
}
-
+
//printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(but->rnaprop), data_path);
}
-
+
/* we have a datapath! */
if (data_path) {
size_t i;
-
+
/* create a property to host the "datapath" property we're sending to the operators */
IDProperty *prop_path;
IDProperty *prop_path_value;
-
+
IDPropertyTemplate val = {0};
prop_path = IDP_New(IDP_GROUP, &val, __func__);
prop_path_value = IDP_NewString(data_path, "data_path", strlen(data_path) + 1);
IDP_AddToGroup(prop_path, prop_path_value);
-
+
/* check each until one works... */
for (i = 0; (i < num_ops) && (ctx_toggle_opnames[i]); i++) {
if (WM_key_event_operator_string(
@@ -1042,14 +1042,14 @@ static bool ui_but_event_property_operator_string(
break;
}
}
-
+
/* cleanup */
IDP_FreeProperty(prop_path);
MEM_freeN(prop_path);
MEM_freeN(data_path);
}
}
-
+
return found;
}
@@ -1225,7 +1225,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
if (block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) {
ui_menu_block_set_keymaps(C, block);
}
-
+
/* after keymaps! */
switch (block->bounds_type) {
case UI_BLOCK_BOUNDS_NONE:
@@ -1273,12 +1273,12 @@ void ui_fontscale(short *points, float aspect)
{
if (aspect < 0.9f || aspect > 1.1f) {
float pointsf = *points;
-
+
/* for some reason scaling fonts goes too fast compared to widget size */
/* XXX not true anymore? (ton) */
//aspect = sqrt(aspect);
pointsf /= aspect;
-
+
if (aspect > 1.0f)
*points = ceilf(pointsf);
else
@@ -1303,7 +1303,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
ARegion *ar;
uiBut *but;
rcti rect;
-
+
/* get menu region or area region */
ar = CTX_wm_menu(C);
if (!ar)
@@ -1314,23 +1314,23 @@ void UI_block_draw(const bContext *C, uiBlock *block)
/* we set this only once */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
+
/* scale fonts */
ui_fontscale(&style.paneltitle.points, block->aspect);
ui_fontscale(&style.grouplabel.points, block->aspect);
ui_fontscale(&style.widgetlabel.points, block->aspect);
ui_fontscale(&style.widget.points, block->aspect);
-
+
/* scale block min/max to rect */
ui_but_to_pixelrect(&rect, ar, block, NULL);
-
+
/* pixel space for AA widgets */
gpuPushProjectionMatrix();
gpuPushMatrix();
gpuLoadIdentity();
wmOrtho2_region_pixelspace(ar);
-
+
/* back */
if (block->flag & UI_BLOCK_RADIAL)
ui_draw_pie_center(block);
@@ -1349,7 +1349,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
for (but = block->buttons.first; but; but = but->next) {
if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) {
ui_but_to_pixelrect(&rect, ar, block, but);
-
+
/* XXX: figure out why invalid coordinates happen when closing render window */
/* and material preview is redrawn in main window (temp fix for bug #23848) */
if (rect.xmin < rect.xmax && rect.ymin < rect.ymax)
@@ -1360,7 +1360,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
UI_widgetbase_draw_cache_end();
UI_icon_draw_cache_end();
BLF_batch_draw_end();
-
+
/* restore matrix */
gpuPopProjectionMatrix();
gpuPopMatrix();
@@ -1680,10 +1680,10 @@ bool ui_but_is_float(const uiBut *but)
{
if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
return true;
-
+
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
return true;
-
+
return false;
}
@@ -1714,7 +1714,7 @@ bool ui_but_is_unit(const uiBut *but)
if (ui_but_is_unit_radians_ex(unit, unit_type))
return false;
#endif
-
+
/* for now disable time unit conversion */
if (unit_type == PROP_UNIT_TIME)
return false;
@@ -1898,7 +1898,7 @@ void ui_but_value_set(uiBut *but, double value)
if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
value = fval;
}
-
+
/* then set value with possible edit override */
if (but->editval)
value = *but->editval = value;
@@ -2032,11 +2032,11 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
UnitSettings *unit = but->block->unit;
int unit_type = UI_but_unit_type_get(but);
char *orig_str;
-
+
orig_str = BLI_strdup(str);
-
+
bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
-
+
MEM_freeN(orig_str);
}
}
@@ -2692,7 +2692,7 @@ void UI_block_free(const bContext *C, uiBlock *block)
BLI_freelistN(&block->saferct);
BLI_freelistN(&block->color_pickers.list);
-
+
MEM_freeN(block);
}
@@ -2721,7 +2721,7 @@ void UI_blocklist_draw(const bContext *C, const ListBase *lb)
void UI_blocklist_free(const bContext *C, ListBase *lb)
{
uiBlock *block;
-
+
while ((block = BLI_pophead(lb))) {
UI_block_free(C, block);
}
@@ -2733,7 +2733,7 @@ void UI_blocklist_free_inactive(const bContext *C, ListBase *lb)
for (block = lb->first; block; block = nextblock) {
nextblock = block->next;
-
+
if (!block->handle) {
if (!block->active) {
BLI_remlink(lb, block);
@@ -2834,9 +2834,9 @@ void ui_but_update_ex(uiBut *but, const bool validate)
/* if something changed in the button */
double value = UI_BUT_VALUE_UNSET;
// float okwidth; // UNUSED
-
+
ui_but_update_select_flag(but, &value);
-
+
/* only update soft range while not editing */
if (!(but->editval || but->editstr || but->editvec)) {
if ((but->rnaprop != NULL) ||
@@ -2865,7 +2865,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
but->hardmin <= but->hardmax);
}
break;
-
+
case UI_BTYPE_ICON_TOGGLE:
case UI_BTYPE_ICON_TOGGLE_N:
if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
@@ -2873,21 +2873,21 @@ void ui_but_update_ex(uiBut *but, const bool validate)
else but->iconadd = 0;
}
break;
-
+
/* quiet warnings for unhandled types */
default:
break;
}
-
-
+
+
/* safety is 4 to enable small number buttons (like 'users') */
// okwidth = -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
-
+
/* name: */
switch (but->type) {
case UI_BTYPE_MENU:
- if (BLI_rctf_size_x(&but->rect) > 24.0f) {
+ if (BLI_rctf_size_x(&but->rect) >= (UI_UNIT_X * 2)) {
/* only needed for menus in popup blocks that don't recreate buttons on redraw */
if (but->block->flag & UI_BLOCK_LOOP) {
if (but->rnaprop && (RNA_property_type(but->rnaprop) == PROP_ENUM)) {
@@ -2970,7 +2970,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
else {
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
}
-
+
break;
case UI_BTYPE_TEXT:
@@ -2983,7 +2983,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
}
break;
-
+
case UI_BTYPE_KEY_EVENT:
{
const char *str;
@@ -3030,13 +3030,13 @@ void ui_but_update_ex(uiBut *but, const bool validate)
default:
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
break;
-
+
}
/* if we are doing text editing, this will override the drawstr */
if (but->editstr)
but->drawstr[0] = '\0';
-
+
/* text clipping moved to widget drawing code itself */
}
@@ -3129,7 +3129,7 @@ static uiBut *ui_def_but(
int slen;
BLI_assert(width >= 0 && height >= 0);
-
+
/* we could do some more error checks here */
if ((type & BUTTYPE) == UI_BTYPE_LABEL) {
BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == false);
@@ -3184,7 +3184,7 @@ static uiBut *ui_def_but(
but->funcN = block->funcN;
if (block->func_argN)
but->func_argN = MEM_dupallocN(block->func_argN);
-
+
but->pos = -1; /* cursor invisible */
if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { /* add a space to name */
@@ -3237,7 +3237,7 @@ static uiBut *ui_def_but(
}
BLI_addtail(&block->buttons, but);
-
+
if (block->curlayout)
ui_layout_add_but(block->curlayout, but);
@@ -3526,7 +3526,7 @@ static uiBut *ui_def_but_rna(
if (icon) {
ui_def_but_icon(but, icon, UI_HAS_ICON);
}
-
+
if ((type == UI_BTYPE_MENU) && (but->dt == UI_EMBOSS_PULLDOWN)) {
but->flag |= UI_BUT_ICON_SUBMENU;
}
@@ -3603,7 +3603,7 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, in
uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
ui_but_update(but);
-
+
return but;
}
@@ -3645,7 +3645,7 @@ struct AutoComplete {
AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen)
{
AutoComplete *autocpl;
-
+
autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
autocpl->maxlen = maxlen;
autocpl->matches = 0;
@@ -3686,7 +3686,7 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
}
int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
-{
+{
int match = AUTOCOMPLETE_NO_MATCH;
if (autocpl->truncate[0]) {
if (autocpl->matches == 1) {
@@ -3944,7 +3944,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
- if (str && str[0] == '\0')
+ if (str && str[0] == '\0')
return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip);
return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip);
}
@@ -3957,11 +3957,11 @@ int UI_blocklist_min_y_get(ListBase *lb)
{
uiBlock *block;
int min = 0;
-
+
for (block = lb->first; block; block = block->next)
if (block == lb->first || block->rect.ymin < min)
min = block->rect.ymin;
-
+
return min;
}
@@ -3980,7 +3980,7 @@ void UI_block_order_flip(uiBlock *block)
return;
else if (block->flag & UI_BLOCK_NO_FLIP)
return;
-
+
for (but = block->buttons.first; but; but = but->next) {
if (but->drawflag & UI_BUT_ALIGN) return;
if (but->rect.ymin < miny) miny = but->rect.ymin;
@@ -4129,8 +4129,8 @@ void UI_but_unit_type_set(uiBut *but, const int unit_type)
int UI_but_unit_type_get(const uiBut *but)
{
int ownUnit = (int)but->unit_type;
-
- /* own unit define always takes precedence over RNA provided, allowing for overriding
+
+ /* own unit define always takes precedence over RNA provided, allowing for overriding
* default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit)
*/
/* XXX: this doesn't allow clearing unit completely, though the same could be said for icons */
@@ -4292,7 +4292,7 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip)
{
uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);
-
+
/* XXX temp, old menu calls pass on icon arrow, which is now UI_BUT_ICON_SUBMENU flag */
if (icon != ICON_RIGHTARROW_THIN) {
ui_def_but_icon(but, icon, 0);
@@ -4303,7 +4303,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
but->block_create_func = func;
ui_but_update(but);
-
+
return but;
}
@@ -4311,14 +4311,14 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip)
{
uiBut *but = ui_def_but(block, UI_BTYPE_BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip);
-
+
ui_def_but_icon(but, icon, UI_HAS_ICON);
but->drawflag |= UI_BUT_ICON_LEFT;
-
+
but->block_create_func = func;
ui_but_update(but);
-
+
return but;
}
@@ -4345,13 +4345,13 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, in
uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip)
{
uiBut *but = ui_def_but(block, UI_BTYPE_SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip);
-
+
ui_def_but_icon(but, icon, UI_HAS_ICON);
but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
-
+
ui_but_update(but);
-
+
return but;
}
@@ -4375,7 +4375,7 @@ void UI_but_func_search_set(
but->search_create_func = search_create_func;
but->search_func = search_func;
but->search_arg = arg;
-
+
if (bfunc) {
#ifdef DEBUG
if (but->func) {
@@ -4385,7 +4385,7 @@ void UI_but_func_search_set(
#endif
UI_but_func_set(but, bfunc, arg, active);
}
-
+
/* search buttons show red-alert if item doesn't exist, not for menus */
if (0 == (but->block->flag & UI_BLOCK_LOOP)) {
/* skip empty buttons, not all buttons need input, we only show invalid */
@@ -4483,14 +4483,14 @@ uiBut *uiDefSearchButO_ptr(
void UI_but_focus_on_enter_event(wmWindow *win, uiBut *but)
{
wmEvent event;
-
+
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_OPEN;
event.val = KM_PRESS;
event.customdata = but;
event.customdatafree = false;
-
+
wm_event_add(win, &event);
}
@@ -4614,7 +4614,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
PointerRNA *ptr = NULL;
PropertyRNA *prop = NULL;
int value = 0;
-
+
/* get the enum property... */
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
/* enum property */
@@ -4625,8 +4625,11 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
else if (but->optype) {
PointerRNA *opptr = UI_but_operator_ptr_get(but);
wmOperatorType *ot = but->optype;
-
- /* if the default property of the operator is enum and it is set,
+
+ /* so the context is passed to itemf functions */
+ WM_operator_properties_sanitize(opptr, false);
+
+ /* if the default property of the operator is enum and it is set,
* fetch the tooltip of the selected value so that "Snap" and "Mirror"
* operator menus in the Anim Editors will show tooltips for the different
* operations instead of the meaningless generic operator tooltip
@@ -4639,15 +4642,12 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
}
}
-
+
/* get strings from matching enum item */
if (ptr && prop) {
if (!item) {
int i;
- /* so the context is passed to itemf functions */
- WM_operator_properties_sanitize(ptr, false);
-
RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items);
for (i = 0, item = items; i < totitems; i++, item++) {
if (item->identifier[0] && item->value == value)
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 1fc38a27303..619dce1b9d9 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -524,7 +524,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
{
uiBut *prev, *but = NULL, *next;
int flag = 0, cols = 0, rows = 0;
-
+
/* auto align */
for (but = first; but && but->alignnr == nr; but = but->next) {
@@ -535,7 +535,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
/* rows == 0: 1 row, cols == 0: 1 column */
-
+
/* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */
for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
next = but->next;
@@ -544,13 +544,13 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
/* clear old flag */
but->drawflag &= ~UI_BUT_ALIGN;
-
+
if (flag == 0) { /* first case */
if (next) {
if (buts_are_horiz(but, next)) {
if (rows == 0)
flag = UI_BUT_ALIGN_RIGHT;
- else
+ else
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT;
}
else {
@@ -597,14 +597,14 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
flag |= UI_BUT_ALIGN_TOP;
}
else { /* next button switches to new row */
-
+
if (prev && buts_are_horiz(prev, but))
flag |= UI_BUT_ALIGN_LEFT;
else {
flag &= ~UI_BUT_ALIGN_LEFT;
flag |= UI_BUT_ALIGN_TOP;
}
-
+
if ((flag & UI_BUT_ALIGN_TOP) == 0) { /* still top row */
if (prev) {
if (next && buts_are_horiz(but, next))
@@ -614,16 +614,16 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT;
}
}
- else
+ else
flag |= UI_BUT_ALIGN_DOWN;
}
- else
+ else
flag |= UI_BUT_ALIGN_TOP;
}
}
-
+
but->drawflag |= flag;
-
+
/* merge coordinates */
if (prev) {
/* simple cases */
@@ -646,7 +646,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
/* the previous button is a single one in its row */
but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f;
prev->rect.ymin = but->rect.ymax;
-
+
but->rect.xmin = prev->rect.xmin;
if (next && buts_are_horiz(but, next) == 0)
but->rect.xmax = prev->rect.xmax;
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 95a0f8704fa..ea1b58107bd 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -73,26 +73,26 @@ void ui_but_anim_flag(uiBut *but, float cfra)
FCurve *fcu;
bool driven;
bool special;
-
+
but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
-
+
/* NOTE: "special" is reserved for special F-Curves stored on the animation data
* itself (which are used to animate properties of the animation data).
* We count those as "animated" too for now
*/
fcu = ui_but_get_fcurve(but, &adt, &act, &driven, &special);
-
+
if (fcu) {
if (!driven) {
but->flag |= UI_BUT_ANIMATED;
-
- /* T41525 - When the active action is a NLA strip being edited,
+
+ /* T41525 - When the active action is a NLA strip being edited,
* we need to correct the frame number to "look inside" the
* remapped action
*/
if (adt)
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
-
+
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
but->flag |= UI_BUT_ANIMATED_KEY;
}
@@ -111,9 +111,9 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
FCurve *fcu;
ChannelDriver *driver;
bool driven, special;
-
+
fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
-
+
if (fcu && driven) {
driver = fcu->driver;
@@ -138,20 +138,20 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
if (fcu && driven) {
driver = fcu->driver;
-
+
if (driver && (driver->type == DRIVER_TYPE_PYTHON)) {
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
-
+
/* tag driver as needing to be recompiled */
driver->flag |= DRIVER_FLAG_RECOMPILE;
-
+
/* clear invalid flags which may prevent this from working */
driver->flag &= ~DRIVER_FLAG_INVALID;
fcu->flag &= ~FCURVE_DISABLED;
-
+
/* this notifier should update the Graph Editor and trigger depsgraph refresh? */
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
-
+
return true;
}
}
@@ -167,14 +167,14 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
FCurve *fcu;
char *path;
bool ok = false;
-
+
/* button must have RNA-pointer to a numeric-capable property */
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
if (G.debug & G_DEBUG)
printf("ERROR: create expression failed - button has no RNA info attached\n");
return false;
}
-
+
if (RNA_property_array_check(but->rnaprop) != 0) {
if (but->rnaindex == -1) {
if (G.debug & G_DEBUG)
@@ -182,7 +182,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
return false;
}
}
-
+
/* make sure we have animdata for this */
/* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */
id = (ID *)but->rnapoin.id.data;
@@ -191,18 +191,18 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
return false;
}
-
+
/* get path */
path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
if (path == NULL) {
return false;
}
-
+
/* create driver */
fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
if (fcu) {
ChannelDriver *driver = fcu->driver;
-
+
if (driver) {
/* set type of driver */
driver->type = DRIVER_TYPE_PYTHON;
@@ -218,9 +218,9 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
ok = true;
}
}
-
+
MEM_freeN(path);
-
+
return ok;
}
@@ -233,17 +233,17 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
bool special;
fcu = ui_but_get_fcurve(but, NULL, &action, &driven, &special);
-
+
if (fcu == NULL)
return;
-
+
if (special) {
/* NLA Strip property */
if (IS_AUTOKEY_ON(scene)) {
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
-
+
insert_keyframe_direct(depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, 0);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
@@ -256,23 +256,23 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
-
+
insert_keyframe_direct(depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, INSERTKEY_DRIVER);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
}
else {
id = but->rnapoin.id.data;
-
+
/* TODO: this should probably respect the keyingset only option for anim */
if (autokeyframe_cfra_can_key(scene, id)) {
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
short flag = ANIM_get_keyframing_flags(scene, 1);
-
+
fcu->flag &= ~FCURVE_SELECTED;
-
+
/* Note: We use but->rnaindex instead of fcu->array_index,
* because a button may control all items of an array at once.
* E.g., color wheels (see T42567). */
@@ -280,7 +280,7 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
insert_keyframe(depsgraph, reports, id, action,
((fcu->grp) ? (fcu->grp->name) : (NULL)),
fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag);
-
+
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index ce22dac9e91..f093f47519c 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -184,7 +184,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
else {
immVertex2f(pos, maxx, miny);
}
-
+
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
immVertex2f(pos, maxx, maxy - rad);
@@ -196,7 +196,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
else {
immVertex2f(pos, maxx, maxy);
}
-
+
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
immVertex2f(pos, minx + rad, maxy);
@@ -208,7 +208,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
else {
immVertex2f(pos, minx, maxy);
}
-
+
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
immVertex2f(pos, minx, miny + rad);
@@ -220,7 +220,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float
else {
immVertex2f(pos, minx, miny);
}
-
+
immEnd();
immUnbindProgram();
#endif
@@ -302,15 +302,15 @@ void UI_draw_roundbox_shade_x(
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
-
+
round_box_shade_col(color, coltop, coldown, 0.0);
immVertex2f(pos, maxx - rad, miny);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, coltop, coldown, vec[a][1] * idiv);
immVertex2f(pos, maxx - rad + vec[a][0], miny + vec[a][1]);
}
-
+
round_box_shade_col(color, coltop, coldown, rad * idiv);
immVertex2f(pos, maxx, miny + rad);
}
@@ -318,13 +318,13 @@ void UI_draw_roundbox_shade_x(
round_box_shade_col(color, coltop, coldown, 0.0);
immVertex2f(pos, maxx, miny);
}
-
+
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
-
+
round_box_shade_col(color, coltop, coldown, (div - rad) * idiv);
immVertex2f(pos, maxx, maxy - rad);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, coltop, coldown, (div - rad + vec[a][1]) * idiv);
immVertex2f(pos, maxx - vec[a][1], maxy - rad + vec[a][0]);
@@ -336,18 +336,18 @@ void UI_draw_roundbox_shade_x(
round_box_shade_col(color, coltop, coldown, 1.0);
immVertex2f(pos, maxx, maxy);
}
-
+
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
-
+
round_box_shade_col(color, coltop, coldown, 1.0);
immVertex2f(pos, minx + rad, maxy);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, coltop, coldown, (div - vec[a][1]) * idiv);
immVertex2f(pos, minx + rad - vec[a][0], maxy - vec[a][1]);
}
-
+
round_box_shade_col(color, coltop, coldown, (div - rad) * idiv);
immVertex2f(pos, minx, maxy - rad);
}
@@ -355,18 +355,18 @@ void UI_draw_roundbox_shade_x(
round_box_shade_col(color, coltop, coldown, 1.0);
immVertex2f(pos, minx, maxy);
}
-
+
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
-
+
round_box_shade_col(color, coltop, coldown, rad * idiv);
immVertex2f(pos, minx, miny + rad);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, coltop, coldown, (rad - vec[a][1]) * idiv);
immVertex2f(pos, minx + vec[a][1], miny + rad - vec[a][0]);
}
-
+
round_box_shade_col(color, coltop, coldown, 0.0);
immVertex2f(pos, minx + rad, miny);
}
@@ -418,7 +418,7 @@ void UI_draw_roundbox_shade_y(
float colLeft[3], colRight[3];
int vert_count = 0;
int a;
-
+
/* mult */
for (a = 0; a < 7; a++) {
mul_v2_fl(vec[a], rad);
@@ -450,12 +450,12 @@ void UI_draw_roundbox_shade_y(
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
round_box_shade_col(color, colLeft, colRight, 0.0);
immVertex2f(pos, maxx - rad, miny);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, colLeft, colRight, vec[a][0] * idiv);
immVertex2f(pos, maxx - rad + vec[a][0], miny + vec[a][1]);
}
-
+
round_box_shade_col(color, colLeft, colRight, rad * idiv);
immVertex2f(pos, maxx, miny + rad);
}
@@ -463,14 +463,14 @@ void UI_draw_roundbox_shade_y(
round_box_shade_col(color, colLeft, colRight, 0.0);
immVertex2f(pos, maxx, miny);
}
-
+
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
round_box_shade_col(color, colLeft, colRight, 0.0);
immVertex2f(pos, maxx, maxy - rad);
-
+
for (a = 0; a < 7; a++) {
-
+
round_box_shade_col(color, colLeft, colRight, (div - rad - vec[a][0]) * idiv);
immVertex2f(pos, maxx - vec[a][1], maxy - rad + vec[a][0]);
}
@@ -481,17 +481,17 @@ void UI_draw_roundbox_shade_y(
round_box_shade_col(color, colLeft, colRight, 0.0);
immVertex2f(pos, maxx, maxy);
}
-
+
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
round_box_shade_col(color, colLeft, colRight, (div - rad) * idiv);
immVertex2f(pos, minx + rad, maxy);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, colLeft, colRight, (div - rad + vec[a][0]) * idiv);
immVertex2f(pos, minx + rad - vec[a][0], maxy - vec[a][1]);
}
-
+
round_box_shade_col(color, colLeft, colRight, 1.0);
immVertex2f(pos, minx, maxy - rad);
}
@@ -499,17 +499,17 @@ void UI_draw_roundbox_shade_y(
round_box_shade_col(color, colLeft, colRight, 1.0);
immVertex2f(pos, minx, maxy);
}
-
+
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
round_box_shade_col(color, colLeft, colRight, 1.0);
immVertex2f(pos, minx, miny + rad);
-
+
for (a = 0; a < 7; a++) {
round_box_shade_col(color, colLeft, colRight, (vec[a][0]) * idiv);
immVertex2f(pos, minx + vec[a][1], miny + rad - vec[a][0]);
}
-
+
round_box_shade_col(color, colLeft, colRight, 1.0);
immVertex2f(pos, minx + rad, miny);
}
@@ -638,10 +638,10 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
float facx = 1.0f;
float facy = 1.0f;
-
+
int w = BLI_rcti_size_x(rect);
int h = BLI_rcti_size_y(rect);
-
+
/* scissor doesn't seem to be doing the right thing...? */
#if 0
/* prevent drawing outside widget area */
@@ -649,9 +649,9 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
glGetIntegerv(GL_SCISSOR_BOX, scissor);
glScissor(rect->xmin, rect->ymin, w, h);
#endif
-
+
glEnable(GL_BLEND);
-
+
if (w != ibuf->x || h != ibuf->y) {
facx = (float)w / (float)ibuf->x;
facy = (float)h / (float)ibuf->y;
@@ -660,14 +660,14 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state, (float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect,
facx, facy, NULL);
-
+
glDisable(GL_BLEND);
-
+
#if 0
// restore scissortest
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
#endif
-
+
#endif
}
@@ -788,10 +788,10 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
.ymin = (float)recti->ymin + 1,
.ymax = (float)recti->ymax - 1
};
-
+
float w = BLI_rctf_size_x(&rect);
float h = BLI_rctf_size_y(&rect) * hist->ymax;
-
+
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -850,7 +850,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
}
immUnbindProgram();
-
+
/* outline */
draw_scope_end(&rect, scissor);
}
@@ -884,9 +884,9 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */
float min, max;
-
+
if (scopes == NULL) return;
-
+
rctf rect = {
.xmin = (float)recti->xmin + 1,
.xmax = (float)recti->xmax - 1,
@@ -900,10 +900,10 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f;
float w3 = w / 3.0f;
-
+
/* log scale for alpha */
float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
-
+
unit_m3(colors);
for (int c = 0; c < 3; c++) {
@@ -974,7 +974,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
immEnd();
}
-
+
/* separate min max zone on the right */
immBegin(GWN_PRIM_LINES, 2);
immVertex2f(pos, rect.xmin + w, rect.ymin);
@@ -1171,20 +1171,20 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
const float colors[6][3] = {
{0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0},
{0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}};
-
+
rctf rect = {
.xmin = (float)recti->xmin + 1,
.xmax = (float)recti->xmax - 1,
.ymin = (float)recti->ymin + 1,
.ymax = (float)recti->ymax - 1
};
-
+
float w = BLI_rctf_size_x(&rect);
float h = BLI_rctf_size_y(&rect);
float centerx = rect.xmin + w * 0.5f;
float centery = rect.ymin + h * 0.5f;
float diam = (w < h) ? w : h;
-
+
float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
glEnable(GL_BLEND);
@@ -1202,7 +1202,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
(rect.ymin - 1),
(rect.xmax + 1) - (rect.xmin - 1),
(rect.ymax + 1) - (rect.ymin - 1));
-
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1243,7 +1243,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
/* saturation points */
for (int i = 0; i < 6; i++)
vectorscope_draw_target(pos, centerx, centery, diam, colors[i]);
-
+
if (scopes->ok && scopes->vecscope != NULL) {
/* pixel point cloud */
float col[3] = {alpha, alpha, alpha};
@@ -1434,16 +1434,16 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
v1[1] = y1 + sizey_solid;
v2[1] = rect->ymax;
-
+
immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2);
for (int a = 0; a <= sizex; a++) {
float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
if (display)
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
-
+
v1[0] = v2[0] = x1 + a;
-
+
immAttrib4fv(color, colf);
immVertex2fv(position, v1);
immVertex2fv(position, v2);
@@ -1499,7 +1499,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
immEnd();
glDisable(GL_BLEND);
-
+
/* layer: draw handles */
for (int a = 0; a < coba->tot; a++, cbd++) {
if (a != coba->cur) {
@@ -1524,20 +1524,20 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
float diffuse[3] = {1.0f, 1.0f, 1.0f};
float light[3];
float size;
-
+
/* backdrop */
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_3ubAlpha(true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (unsigned char *)wcol->inner, 255);
-
+
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
-
+
/* setup lights */
ui_but_v3_get(but, light);
/* transform to button */
gpuPushMatrix();
-
+
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
size = 0.5f * BLI_rcti_size_x(rect);
else
@@ -1554,7 +1554,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
/* restore */
glDisable(GL_CULL_FACE);
-
+
/* AA circle */
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1578,7 +1578,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo
float dx = step * zoomx;
float fx = rect->xmin + zoomx * (-offsx);
if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin));
-
+
float dy = step * zoomy;
float fy = rect->ymin + zoomy * (-offsy);
if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
@@ -1598,7 +1598,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo
fy += dy;
}
immEnd();
-
+
}
static void gl_shaded_color(unsigned char *col, int shade)
@@ -1732,7 +1732,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
else if (cumap->cur == 3) {
float lum = IMB_colormanagement_get_luminance(cumap->sample);
immUniformColor3ub(240, 240, 240);
-
+
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymin);
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymax);
}
@@ -1743,7 +1743,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
immUniformColor3ub(100, 240, 100);
else
immUniformColor3ub(100, 100, 240);
-
+
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
}
@@ -1755,7 +1755,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
-
+
if (cuma->table == NULL)
curvemapping_changed(cumap, false);
@@ -1811,7 +1811,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
}
immEnd();
immUnbindProgram();
-
+
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
@@ -1959,7 +1959,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
{
static const float size = 5.0f;
-
+
/* 16 values of sin function */
const float si[16] = {
0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
@@ -1974,12 +1974,12 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
-0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
};
-
+
GLint scissor[4];
-
+
/* need scissor test, can draw outside of boundary */
glGetIntegerv(GL_SCISSOR_BOX, scissor);
-
+
rcti scissor_new = {
.xmin = recti->xmin,
.ymin = recti->ymin,
@@ -1994,7 +1994,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
scissor_new.ymin,
BLI_rcti_size_x(&scissor_new),
BLI_rcti_size_y(&scissor_new));
-
+
float x = 0.5f * (recti->xmin + recti->xmax);
float y = 0.5f * (recti->ymin + recti->ymax);
@@ -2008,7 +2008,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
for (int a = 0; a < 16; a++)
immVertex2f(pos, x + size * si[a], y + size * co[a]);
immEnd();
-
+
immUniformColor4ub(0, 0, 0, 150);
glLineWidth(1);
glEnable(GL_LINE_SMOOTH);
@@ -2020,7 +2020,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
glDisable(GL_BLEND);
immUnbindProgram();
-
+
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
}
@@ -2107,7 +2107,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 7.0, (40 * alpha) >> 8);
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 5.0, (80 * alpha) >> 8);
-
+
immEnd();
immUnbindProgram();
@@ -2119,7 +2119,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
{
float rad;
-
+
if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f)
rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
else
@@ -2135,7 +2135,7 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
{
a = i * aspect;
}
-
+
glEnable(GL_BLEND);
const float dalpha = alpha * 2.0f / 255.0f;
float calpha = dalpha;
@@ -2151,7 +2151,7 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
visibility = visibility * (1.0f - calpha);
calpha += dalpha;
}
-
+
uiWidgetBaseParameters widget_params = {
.recti.xmin = rct->xmin, .recti.ymin = rct->ymin,
.recti.xmax = rct->xmax, .recti.ymax = rct->ymax - 10.0f,
@@ -2177,6 +2177,6 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
UI_draw_roundbox_4fv(false, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f, color);
glDisable(GL_LINE_SMOOTH);
-
+
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 2f91fb86b36..ce64a7e21a2 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -296,7 +296,7 @@ typedef struct uiHandleButtonData {
/* tooltip */
unsigned int tooltip_force : 1;
-
+
/* auto open */
bool used_mouse;
wmTimer *autoopentimer;
@@ -338,7 +338,7 @@ typedef struct uiHandleButtonData {
/* menu open (watch UI_screen_free_active_but) */
uiPopupBlockHandle *menu;
int menuretval;
-
+
/* search box (watch UI_screen_free_active_but) */
ARegion *searchbox;
#ifdef USE_KEYNAV_LIMIT
@@ -365,14 +365,14 @@ typedef struct uiAfterFunc {
uiButHandleFunc func;
void *func_arg1;
void *func_arg2;
-
+
uiButHandleNFunc funcN;
void *func_argN;
uiButHandleRenameFunc rename_func;
void *rename_arg1;
void *rename_orig;
-
+
uiBlockHandleFunc handle_func;
void *handle_func_arg;
int retval;
@@ -459,18 +459,18 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
}
else {
lastdy += dy;
-
+
if (ABS(lastdy) > (int)UI_UNIT_Y) {
if (U.uiflag2 & USER_TRACKPAD_NATURAL)
dy = -dy;
-
+
*val = KM_PRESS;
-
+
if (dy > 0)
*type = WHEELUPMOUSE;
else
*type = WHEELDOWNMOUSE;
-
+
lastdy = 0;
}
}
@@ -537,7 +537,7 @@ static uiBut *ui_but_next(uiBut *but)
static uiBut *ui_but_first(uiBlock *block)
{
uiBut *but;
-
+
but = block->buttons.first;
while (but) {
if (ui_but_is_editable(but)) return but;
@@ -549,7 +549,7 @@ static uiBut *ui_but_first(uiBlock *block)
static uiBut *ui_but_last(uiBlock *block)
{
uiBut *but;
-
+
but = block->buttons.last;
while (but) {
if (ui_but_is_editable(but)) return but;
@@ -606,7 +606,7 @@ static void ui_mouse_scale_warp(
float *r_mx, float *r_my, const bool shift)
{
const float fac = ui_mouse_scale_warp_factor(shift);
-
+
/* slow down the mouse, this is fairly picky */
*r_mx = (data->dragstartx * (1.0f - fac) + mx * fac);
*r_my = (data->dragstarty * (1.0f - fac) + my * fac);
@@ -717,7 +717,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->butm_func_arg = block->butm_func_arg;
after->a2 = but->a2;
}
-
+
if (block->handle)
after->popup_op = block->handle->popup_op;
@@ -832,17 +832,17 @@ static void ui_apply_but_funcs_after(bContext *C)
after.funcN(C, after.func_argN, after.func_arg2);
if (after.func_argN)
MEM_freeN(after.func_argN);
-
+
if (after.handle_func)
after.handle_func(C, after.handle_func_arg, after.retval);
if (after.butm_func)
after.butm_func(C, after.butm_func_arg, after.a2);
-
+
if (after.rename_func)
after.rename_func(C, after.rename_arg1, after.rename_orig);
if (after.rename_orig)
MEM_freeN(after.rename_orig);
-
+
if (after.undostr[0])
ED_undo_push(C, after.undostr);
}
@@ -880,32 +880,32 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
{
double value;
int w, lvalue, push;
-
+
value = ui_but_value_get(but);
lvalue = (int)value;
-
+
if (but->bit) {
w = UI_BITBUT_TEST(lvalue, but->bitnr);
if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr);
else lvalue = UI_BITBUT_SET(lvalue, but->bitnr);
-
+
ui_but_value_set(but, (double)lvalue);
if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
ui_but_update_edited(but);
}
}
else {
-
+
if (value == 0.0) push = 1;
else push = 0;
-
+
if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) push = !push;
ui_but_value_set(but, (double)push);
if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
ui_but_update_edited(but);
}
}
-
+
ui_apply_but_func(C, but);
data->retval = but->retval;
@@ -1596,6 +1596,7 @@ static void ui_selectcontext_apply(
bool b;
int i;
float f;
+ PointerRNA p;
} delta, min, max;
const bool is_array = RNA_property_array_check(prop);
@@ -1620,6 +1621,9 @@ static void ui_selectcontext_apply(
delta.b = RNA_property_boolean_get(&but->rnapoin, prop); /* not a delta infact */
}
}
+ else if (rna_type == PROP_POINTER) {
+ delta.p = RNA_property_pointer_get(&but->rnapoin, prop); /* not a delta infact */
+ }
#ifdef USE_ALLSELECT_LAYER_HACK
/* make up for not having 'handle_layer_buttons' */
@@ -1692,6 +1696,10 @@ static void ui_selectcontext_apply(
BLI_assert(!is_array);
RNA_property_enum_set(&lptr, lprop, other_value);
}
+ else if (rna_type == PROP_POINTER) {
+ const PointerRNA other_value = delta.p;
+ RNA_property_pointer_set(&lptr, lprop, other_value);
+ }
RNA_property_update(C, &lptr, prop);
}
@@ -1705,11 +1713,11 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent
{
rcti rect;
int x = event->x, y = event->y;
-
+
ui_window_to_block(ar, but->block, &x, &y);
-
+
BLI_rcti_rctf_copy(&rect, &but->rect);
-
+
if (but->imb || but->type == UI_BTYPE_COLOR) {
/* use button size itself */
}
@@ -1721,7 +1729,7 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent
rect.xmin += delta / 2;
rect.xmax -= delta / 2;
}
-
+
return BLI_rcti_isect_pt(&rect, x, y);
}
@@ -1812,7 +1820,7 @@ static bool ui_but_drag_init(
}
return true;
}
-
+
return false;
}
@@ -2028,13 +2036,13 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
{
wmDrag *wmd;
ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */
-
+
for (wmd = drags->first; wmd; wmd = wmd->next) {
if (wmd->type == WM_DRAG_ID) {
/* align these types with UI_but_active_drop_name */
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
ID *id = (ID *)wmd->poin;
-
+
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
ui_textedit_string_set(but, data, id->name + 2);
@@ -2048,7 +2056,7 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
}
}
}
-
+
}
/* ******************* copy and paste ******************** */
@@ -2086,7 +2094,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* numeric value */
if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) {
-
+
if (but->poin == NULL && but->rnapoin.data == NULL) {
/* pass */
}
@@ -2189,7 +2197,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* RGB triple */
else if (but->type == UI_BTYPE_COLOR) {
float rgba[4];
-
+
if (but->poin == NULL && but->rnapoin.data == NULL) {
/* pass */
}
@@ -2200,7 +2208,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
else
rgba[3] = 1.0f;
-
+
ui_but_v3_get(but, rgba);
/* convert to linear color to do compatible copy between gamma and non-gamma */
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
@@ -2208,7 +2216,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
BLI_snprintf(buf_copy, sizeof(buf_copy), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]);
WM_clipboard_text_set(buf_copy, 0);
-
+
}
else {
if (sscanf(buf_paste, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) {
@@ -2350,7 +2358,7 @@ static int ui_text_position_from_hidden(uiBut *but, int pos)
for (i = 0, strpos = butstr; i < pos; i++)
strpos = BLI_str_find_next_char_utf8(strpos, NULL);
-
+
return (strpos - butstr);
}
@@ -2448,7 +2456,7 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1);
changed = true;
}
-
+
but->pos = but->selend = but->selsta;
return changed;
}
@@ -2479,7 +2487,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-
+
ui_but_text_password_hide(password_str, but, false);
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
@@ -2489,13 +2497,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
}
/* but this extra .05 makes clicks inbetween characters feel nicer */
startx += ((UI_TEXT_MARGIN_X + 0.05f) * U.widget_unit) / aspect;
-
+
/* mouse dragged outside the widget to the left */
if (x < startx) {
int i = but->ofs;
str_last = &str[but->ofs];
-
+
while (i > 0) {
if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &i)) {
/* 0.25 == scale factor for less sensitivity */
@@ -2517,7 +2525,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
/* keep track of previous distance from the cursor to the char */
float cdist, cdist_prev = 0.0f;
short pos_prev;
-
+
str_last = &str[strlen(str)];
but->pos = pos_prev = ((str_last - str) - but->ofs);
@@ -2550,10 +2558,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
but->pos += but->ofs;
if (but->pos < 0) but->pos = 0;
}
-
+
if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-
+
ui_but_text_password_hide(password_str, but, true);
fstyle->points = fstyle_points_prev;
@@ -2789,7 +2797,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
char *pbuf;
bool changed = false;
int buf_len;
-
+
/* paste */
if (mode == UI_TEXTEDIT_PASTE) {
/* extract the first line from the clipboard */
@@ -2816,7 +2824,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
BLI_strncpy(buf, data->str + but->selsta, sellen + 1);
WM_clipboard_text_set(buf, 0);
MEM_freeN(buf);
-
+
/* for cut only, delete the selection afterwards */
if (mode == UI_TEXTEDIT_CUT) {
if ((but->selend - but->selsta) > 0) {
@@ -2972,7 +2980,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip);
}
}
-
+
if (data->searchbox) {
if (data->cancel == false) {
if ((ui_searchbox_apply(but, data->searchbox) == false) &&
@@ -2991,11 +2999,11 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
MEM_SAFE_FREE(but->search_arg);
}
}
-
+
but->editstr = NULL;
but->pos = -1;
}
-
+
WM_cursor_modal_restore(win);
#ifdef WITH_INPUT_IME
@@ -3092,7 +3100,7 @@ static void ui_do_but_textedit(
ui_searchbox_event(C, data->searchbox, but, event);
#endif
}
-
+
break;
case RIGHTMOUSE:
case ESCKEY:
@@ -3112,7 +3120,7 @@ static void ui_do_but_textedit(
case LEFTMOUSE:
{
bool had_selection = but->selsta != but->selend;
-
+
/* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
if (data->searchbox)
inbox = ui_searchbox_inside(data->searchbox, event->x, event->y);
@@ -3142,7 +3150,7 @@ static void ui_do_but_textedit(
retval = WM_UI_HANDLER_BREAK;
}
}
-
+
/* only select a word in button if there was no selection before */
if (event->val == KM_DBL_CLICK && had_selection == false) {
ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM);
@@ -3239,7 +3247,7 @@ static void ui_do_but_textedit(
event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
-
+
case AKEY:
/* Ctrl + A: Select all */
@@ -3317,7 +3325,7 @@ static void ui_do_but_textedit(
}
retval = WM_UI_HANDLER_BREAK;
-
+
}
/* textbutton with this flag: do live update (e.g. for search buttons) */
if (but->flag & UI_BUT_TEXTEDIT_UPDATE) {
@@ -3353,7 +3361,7 @@ static void ui_do_but_textedit(
ui_but_update_edited(but);
}
but->changed = true;
-
+
if (data->searchbox)
ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */
}
@@ -3550,7 +3558,7 @@ int ui_but_menu_direction(uiBut *but)
if (data && data->menu)
return data->menu->direction;
-
+
return 0;
}
@@ -3642,7 +3650,7 @@ static int ui_do_but_HOTKEYEVT(
return WM_UI_HANDLER_BREAK;
}
}
-
+
/* always set */
but->modifier_key = 0;
if (event->shift) but->modifier_key |= KM_SHIFT;
@@ -3652,15 +3660,15 @@ static int ui_do_but_HOTKEYEVT(
ui_but_update(but);
ED_region_tag_redraw(data->region);
-
+
if (event->val == KM_PRESS) {
if (ISHOTKEY(event->type)) {
-
+
if (WM_key_event_string(event->type, false)[0])
ui_but_value_set(but, event->type);
else
data->cancel = true;
-
+
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -3671,10 +3679,10 @@ static int ui_do_but_HOTKEYEVT(
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
-
+
}
}
-
+
return WM_UI_HANDLER_CONTINUE;
}
@@ -3899,13 +3907,13 @@ static int ui_do_but_EXIT(
bContext *C, uiBut *but,
uiHandleButtonData *data, const wmEvent *event)
{
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* first handle click on icondrag type button */
if (event->type == LEFTMOUSE && but->dragpoin) {
if (ui_but_contains_point_px_icon(but, data->region, event)) {
-
+
/* tell the button to wait and keep checking further events to
* see if it should start dragging */
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
@@ -3934,25 +3942,25 @@ static int ui_do_but_EXIT(
}
}
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
-
+
/* this function also ends state */
if (ui_but_drag_init(C, but, data, event)) {
return WM_UI_HANDLER_BREAK;
}
-
- /* If the mouse has been pressed and released, getting to
- * this point without triggering a drag, then clear the
+
+ /* If the mouse has been pressed and released, getting to
+ * this point without triggering a drag, then clear the
* drag state for this button and continue to pass on the event */
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_CONTINUE;
}
-
- /* while waiting for a drag to be triggered, always block
+
+ /* while waiting for a drag to be triggered, always block
* other events from getting handled */
return WM_UI_HANDLER_BREAK;
}
-
+
return WM_UI_HANDLER_CONTINUE;
}
@@ -3966,7 +3974,7 @@ static float ui_numedit_apply_snapf(
}
else {
float fac = 1.0f;
-
+
if (ui_but_is_unit(but)) {
UnitSettings *unit = but->block->unit;
int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
@@ -4014,7 +4022,7 @@ static float ui_numedit_apply_snapf(
else {
BLI_assert(0);
}
-
+
if (fac != 1.0f)
tempf *= fac;
}
@@ -4159,7 +4167,7 @@ static bool ui_numedit_but_NUM(
}
data->dragf += (((float)(mx - data->draglastx)) / deler) * non_linear_scale;
-
+
CLAMP(data->dragf, 0.0f, 1.0f);
data->draglastx = mx;
tempf = (softmin + data->dragf * softrange);
@@ -4172,7 +4180,7 @@ static bool ui_numedit_but_NUM(
CLAMP(temp, softmin, softmax);
lvalue = (int)data->value;
-
+
if (temp != lvalue) {
data->dragchange = true;
data->value = (double)temp;
@@ -4262,11 +4270,11 @@ static int ui_do_but_NUM(
if (data->state == BUTTON_STATE_HIGHLIGHT) {
int type = event->type, val = event->val;
-
+
if (type == MOUSEPAN) {
ui_pan_to_scroll(event, &type, &val);
}
-
+
/* XXX hardcoded keymap check.... */
if (type == MOUSEPAN && event->alt)
retval = WM_UI_HANDLER_BREAK; /* allow accumulating values, otherwise scrolling gets preference */
@@ -4302,7 +4310,7 @@ static int ui_do_but_NUM(
copy_v2_v2_int(data->multi_data.drag_start, &event->x);
#endif
}
-
+
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY || event->type == RIGHTMOUSE) {
@@ -4363,7 +4371,7 @@ static int ui_do_but_NUM(
ui_do_but_textedit_select(C, block, but, data, event);
retval = WM_UI_HANDLER_BREAK;
}
-
+
if (click) {
/* we can click on the side arrows to increment/decrement,
* or click inside to edit the value directly */
@@ -4426,7 +4434,7 @@ static int ui_do_but_NUM(
retval = WM_UI_HANDLER_BREAK;
}
-
+
data->draglastx = mx;
data->draglasty = my;
@@ -4675,13 +4683,13 @@ static int ui_do_but_SLI(
/* nudge slider to the left or right */
float f, tempf, softmin, softmax, softrange;
int temp;
-
+
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
-
+
softmin = but->softmin;
softmax = but->softmax;
softrange = softmax - softmin;
-
+
tempf = data->value;
temp = (int)data->value;
@@ -4694,13 +4702,13 @@ static int ui_do_but_SLI(
{
f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect));
}
-
+
f = softmin + f * softrange;
-
+
if (!ui_but_is_float(but)) {
if (f < temp) temp--;
else temp++;
-
+
if (temp >= softmin && temp <= softmax)
data->value = temp;
else
@@ -4709,13 +4717,13 @@ static int ui_do_but_SLI(
else {
if (f < tempf) tempf -= 0.01f;
else tempf += 0.01f;
-
+
if (tempf >= softmin && tempf <= softmax)
data->value = tempf;
else
data->cancel = true;
}
-
+
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval = WM_UI_HANDLER_BREAK;
}
@@ -4728,7 +4736,7 @@ static int ui_do_but_SLI(
data->draglastx = mx;
data->draglasty = my;
-
+
return retval;
}
@@ -4739,7 +4747,7 @@ static int ui_do_but_SCROLL(
int mx, my /*, click = 0 */;
int retval = WM_UI_HANDLER_CONTINUE;
bool horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
-
+
mx = event->x;
my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
@@ -4785,7 +4793,7 @@ static int ui_do_but_SCROLL(
retval = WM_UI_HANDLER_BREAK;
}
-
+
return retval;
}
@@ -4868,9 +4876,9 @@ static int ui_do_but_BLOCK(
bContext *C, uiBut *but,
uiHandleButtonData *data, const wmEvent *event)
{
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
-
+
/* first handle click on icondrag type button */
if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
if (ui_but_contains_point_px_icon(but, data->region, event)) {
@@ -4927,19 +4935,19 @@ static int ui_do_but_BLOCK(
}
}
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
-
+
/* this function also ends state */
if (ui_but_drag_init(C, but, data, event)) {
return WM_UI_HANDLER_BREAK;
}
-
+
/* outside icon quit, not needed if drag activated */
if (0 == ui_but_contains_point_px_icon(but, data->region, event)) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
data->cancel = true;
return WM_UI_HANDLER_BREAK;
}
-
+
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
@@ -4958,7 +4966,7 @@ static bool ui_numedit_but_UNITVEC(
float dx, dy, rad, radsq, mrad, *fp;
int mdx, mdy;
bool changed = true;
-
+
/* button is presumed square */
/* if mouse moves outside of sphere, it does negative normal */
@@ -4968,21 +4976,21 @@ static bool ui_numedit_but_UNITVEC(
fp = data->origvec;
rad = BLI_rctf_size_x(&but->rect);
radsq = rad * rad;
-
+
if (fp[2] > 0.0f) {
mdx = (rad * fp[0]);
mdy = (rad * fp[1]);
}
else if (fp[2] > -1.0f) {
mrad = rad / sqrtf(fp[0] * fp[0] + fp[1] * fp[1]);
-
+
mdx = 2.0f * mrad * fp[0] - (rad * fp[0]);
mdy = 2.0f * mrad * fp[1] - (rad * fp[1]);
}
else {
mdx = mdy = 0;
}
-
+
dx = (float)(mx + mdx - data->dragstartx);
dy = (float)(my + mdy - data->dragstarty);
@@ -4994,12 +5002,12 @@ static bool ui_numedit_but_UNITVEC(
fp[2] = sqrtf(radsq - dx * dx - dy * dy);
}
else { /* outer circle */
-
+
mrad = rad / sqrtf(mrad); // veclen
-
+
dx *= (2.0f * mrad - 1.0f);
dy *= (2.0f * mrad - 1.0f);
-
+
mrad = dx * dx + dy * dy;
if (mrad < radsq) {
fp[0] = dx;
@@ -5199,7 +5207,7 @@ static int ui_do_but_UNITVEC(
/* also do drag the first time */
if (ui_numedit_but_UNITVEC(but, data, mx, my, snap))
ui_numedit_apply(C, block, but, data);
-
+
return WM_UI_HANDLER_BREAK;
}
}
@@ -5217,7 +5225,7 @@ static int ui_do_but_UNITVEC(
return WM_UI_HANDLER_BREAK;
}
-
+
return WM_UI_HANDLER_CONTINUE;
}
@@ -5288,30 +5296,30 @@ static bool ui_numedit_but_HSVCUBE(
ui_block_cm_to_display_space_v3(but->block, rgb);
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
-
+
/* only apply the delta motion, not absolute */
if (shift) {
rcti rect_i;
float xpos, ypos, hsvo[3];
-
+
BLI_rcti_rctf_copy(&rect_i, &but->rect);
-
+
/* calculate original hsv again */
copy_v3_v3(rgb, data->origvec);
if (use_display_colorspace)
ui_block_cm_to_display_space_v3(but->block, rgb);
-
+
copy_v3_v3(hsvo, hsv);
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsvo);
-
+
/* and original position */
ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos);
-
+
mx_fl = xpos - (data->dragstartx - mx_fl);
my_fl = ypos - (data->dragstarty - my_fl);
}
-
+
/* relative position within box */
x = ((float)mx_fl - but->rect.xmin) / BLI_rctf_size_x(&but->rect);
y = ((float)my_fl - but->rect.ymin) / BLI_rctf_size_y(&but->rect);
@@ -5428,10 +5436,10 @@ static void ui_ndofedit_but_HSVCUBE(
case UI_GRAD_V_ALT:
case UI_GRAD_L_ALT:
/* vertical 'value' strip */
-
+
/* exception only for value strip - use the range set in but->min/max */
hsv[2] += ndof->rvec[0] * sensitivity;
-
+
CLAMP(hsv[2], but->softmin, but->softmax);
break;
default:
@@ -5481,19 +5489,19 @@ static int ui_do_but_HSVCUBE(
/* also do drag the first time */
if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
-
+
return WM_UI_HANDLER_BREAK;
}
#ifdef WITH_INPUT_NDOF
else if (event->type == NDOF_MOTION) {
const wmNDOFMotionData *ndof = event->customdata;
const enum eSnapType snap = ui_event_to_snap(event);
-
+
ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0);
-
+
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
-
+
return WM_UI_HANDLER_BREAK;
}
#endif /* WITH_INPUT_NDOF */
@@ -5501,9 +5509,9 @@ static int ui_do_but_HSVCUBE(
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
int len;
-
+
/* reset only value */
-
+
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
if (ELEM(len, 3, 4)) {
float rgb[3], def_hsv[3];
@@ -5519,10 +5527,10 @@ static int ui_do_but_HSVCUBE(
def_hsv[0] = hsv[0];
def_hsv[1] = hsv[1];
-
+
ui_color_picker_to_rgb_HSVCUBE_v(but, def_hsv, rgb);
ui_but_v3_set(but, rgb);
-
+
RNA_property_update(C, &but->rnapoin, but->rnaprop);
return WM_UI_HANDLER_BREAK;
}
@@ -5548,7 +5556,7 @@ static int ui_do_but_HSVCUBE(
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
-
+
return WM_UI_HANDLER_BREAK;
}
@@ -5569,7 +5577,7 @@ static bool ui_numedit_but_HSVCIRCLE(
bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
-
+
#ifdef USE_CONT_MOUSE_CORRECT
if (ui_but_is_cursor_warp(but)) {
/* OK but can go outside bounds */
@@ -5609,7 +5617,7 @@ static bool ui_numedit_but_HSVCIRCLE(
/* only apply the delta motion, not absolute */
if (shift) {
float xpos, ypos, hsvo[3], rgbo[3];
-
+
/* calculate original hsv again */
copy_v3_v3(hsvo, hsv);
copy_v3_v3(rgbo, data->origvec);
@@ -5623,9 +5631,9 @@ static bool ui_numedit_but_HSVCIRCLE(
mx_fl = xpos - (data->dragstartx - mx_fl);
my_fl = ypos - (data->dragstarty - my_fl);
-
+
}
-
+
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, mx_fl, my_fl);
if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
@@ -5645,10 +5653,10 @@ static bool ui_numedit_but_HSVCIRCLE(
ui_block_cm_to_scene_linear_v3(but->block, rgb);
ui_but_v3_set(but, rgb);
-
+
data->draglastx = mx;
data->draglasty = my;
-
+
return changed;
}
@@ -5664,28 +5672,28 @@ static void ui_ndofedit_but_HSVCIRCLE(
float rgb[3];
float phi, r /*, sqr */ /* UNUSED */, v[2];
float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
-
+
ui_but_v3_get(but, rgb);
if (use_display_colorspace)
ui_block_cm_to_display_space_v3(but->block, rgb);
ui_rgb_to_color_picker_compat_v(rgb, hsv);
-
+
/* Convert current color on hue/sat disc to circular coordinates phi, r */
phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI;
r = hsv[1];
/* sqr = r > 0.0f ? sqrtf(r) : 1; */ /* UNUSED */
-
+
/* Convert to 2d vectors */
v[0] = r * cosf(phi);
v[1] = r * sinf(phi);
-
+
/* Use ndof device y and x rotation to move the vector in 2d space */
v[0] += ndof->rvec[2] * sensitivity;
v[1] += ndof->rvec[0] * sensitivity;
/* convert back to polar coords on circle */
phi = atan2f(v[0], v[1]) / (2.0f * (float)M_PI) + 0.5f;
-
+
/* use ndof Y rotation to additionally rotate hue */
phi += ndof->rvec[1] * sensitivity * 0.5f;
r = len_v2(v);
@@ -5713,14 +5721,14 @@ static void ui_ndofedit_but_HSVCIRCLE(
hsv_clamp_v(hsv, FLT_MAX);
ui_color_picker_to_rgb_v(hsv, data->vec);
-
+
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
normalize_v3_length(data->vec, but->a2);
}
if (use_display_colorspace)
ui_block_cm_to_scene_linear_v3(but->block, data->vec);
-
+
ui_but_v3_set(but, data->vec);
}
#endif /* WITH_INPUT_NDOF */
@@ -5735,7 +5743,7 @@ static int ui_do_but_HSVCIRCLE(
mx = event->x;
my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
const enum eSnapType snap = ui_event_to_snap(event);
@@ -5744,52 +5752,52 @@ static int ui_do_but_HSVCIRCLE(
data->draglastx = mx;
data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
-
+
/* also do drag the first time */
if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
-
+
return WM_UI_HANDLER_BREAK;
}
#ifdef WITH_INPUT_NDOF
else if (event->type == NDOF_MOTION) {
const enum eSnapType snap = ui_event_to_snap(event);
const wmNDOFMotionData *ndof = event->customdata;
-
+
ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
-
+
return WM_UI_HANDLER_BREAK;
}
#endif /* WITH_INPUT_NDOF */
/* XXX hardcoded keymap check.... */
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
int len;
-
+
/* reset only saturation */
-
+
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
if (len >= 3) {
float rgb[3], def_hsv[3];
float *def;
def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
-
+
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
ui_color_picker_to_rgb_v(def, def_hsv);
-
+
ui_but_v3_get(but, rgb);
ui_rgb_to_color_picker_compat_v(rgb, hsv);
-
+
def_hsv[0] = hsv[0];
def_hsv[2] = hsv[2];
hsv_to_rgb_v(def_hsv, rgb);
ui_but_v3_set(but, rgb);
-
+
RNA_property_update(C, &but->rnapoin, but->rnaprop);
-
+
MEM_freeN(def);
}
return WM_UI_HANDLER_BREAK;
@@ -5828,7 +5836,7 @@ static int ui_do_but_HSVCIRCLE(
}
return WM_UI_HANDLER_BREAK;
}
-
+
return WM_UI_HANDLER_CONTINUE;
}
@@ -5847,10 +5855,10 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m
dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
-
+
BKE_colorband_update_sort(data->coba);
data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */
-
+
data->draglastx = mx;
changed = true;
@@ -5897,7 +5905,7 @@ static int ui_do_but_COLORBAND(
mindist = xco;
}
}
-
+
data->dragcbd = coba->data + coba->cur;
data->dragfstart = data->dragcbd->pos;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -5951,10 +5959,10 @@ static bool ui_numedit_but_CURVE(
dragx = data->draglastx;
dragy = data->draglasty;
ui_window_to_block(data->region, block, &dragx, &dragy);
-
+
zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr);
zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr);
-
+
if (snap) {
float d[2];
@@ -5993,7 +6001,7 @@ static bool ui_numedit_but_CURVE(
}
curvemapping_changed(cumap, false);
-
+
if (moved_point) {
data->draglastx = evtx;
data->draglasty = evty;
@@ -6017,7 +6025,7 @@ static bool ui_numedit_but_CURVE(
else {
fx = (mx - dragx) / zoomx;
fy = (my - dragy) / zoomy;
-
+
/* clamp for clip */
if (cumap->flag & CUMA_DO_CLIP) {
if (cumap->curr.xmin - fx < cumap->clipr.xmin)
@@ -6034,7 +6042,7 @@ static bool ui_numedit_but_CURVE(
cumap->curr.ymin -= fy;
cumap->curr.xmax -= fx;
cumap->curr.ymax -= fy;
-
+
data->draglastx = evtx;
data->draglasty = evty;
@@ -6056,7 +6064,7 @@ static int ui_do_but_CURVE(
mx = event->x;
my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
CurveMapping *cumap = (CurveMapping *)but->poin;
@@ -6069,7 +6077,7 @@ static int ui_do_but_CURVE(
if (event->ctrl) {
float f_xy[2];
BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy);
-
+
curvemap_insert(cuma, f_xy[0], f_xy[1]);
curvemapping_changed(cumap, false);
changed = true;
@@ -6091,7 +6099,7 @@ static int ui_do_but_CURVE(
int i;
float f_xy[2], f_xy_prev[2];
- /* if the click didn't select anything, check if it's clicked on the
+ /* if the click didn't select anything, check if it's clicked on the
* curve itself, and if so, add a point */
cmp = cuma->table;
@@ -6112,10 +6120,10 @@ static int ui_do_but_CURVE(
curvemapping_changed(cumap, false);
changed = true;
-
+
/* reset cmp back to the curve points again, rather than drawing segments */
cmp = cuma->curve;
-
+
/* find newly added point and make it 'sel' */
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].x == f_xy[0]) {
@@ -6146,7 +6154,7 @@ static int ui_do_but_CURVE(
}
data->dragsel = sel;
-
+
data->dragstartx = event->x;
data->dragstarty = event->y;
data->draglastx = event->x;
@@ -6159,7 +6167,7 @@ static int ui_do_but_CURVE(
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
if (event->x != data->draglastx || event->y != data->draglasty) {
-
+
if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
@@ -6220,11 +6228,11 @@ static int ui_do_but_HISTOGRAM(
uiHandleButtonData *data, const wmEvent *event)
{
int mx, my;
-
+
mx = event->x;
my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
data->dragstartx = mx;
@@ -6232,18 +6240,18 @@ static int ui_do_but_HISTOGRAM(
data->draglastx = mx;
data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
-
+
/* also do drag the first time */
if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
-
+
return WM_UI_HANDLER_BREAK;
}
/* XXX hardcoded keymap check.... */
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
Histogram *hist = (Histogram *)but->poin;
hist->ymax = 1.f;
-
+
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -6267,7 +6275,7 @@ static int ui_do_but_HISTOGRAM(
}
return WM_UI_HANDLER_BREAK;
}
-
+
return WM_UI_HANDLER_CONTINUE;
}
@@ -6438,7 +6446,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
char shortcut_str[128];
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
-
+
/* complex code to change name of button */
if (WM_key_event_operator_string(
C, but->optype->idname, but->opcontext, prop, true,
@@ -6469,18 +6477,18 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
BLI_assert(kmi != NULL);
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
-
+
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
UI_block_func_handle_set(block, but_shortcut_name_func, but);
UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT);
UI_block_direction_set(block, UI_DIR_CENTER_Y);
-
+
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
-
+
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
-
+
UI_block_bounds_set_popup(block, 6, -50, 26);
-
+
return block;
}
@@ -6500,7 +6508,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
uiStyle *style = UI_style_get_dpi();
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
int kmi_id;
-
+
/* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
km = WM_keymap_guess_opname(C, but->optype->idname);
kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
@@ -6526,7 +6534,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, 0, style);
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
-
+
UI_block_bounds_set_popup(block, 6, -50, 26);
#ifdef USE_KEYMAP_ADD_HACK
@@ -6575,7 +6583,7 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
BLI_assert(kmi != NULL);
WM_keymap_remove_item(km, kmi);
-
+
but_shortcut_name_func(C, but, 0);
}
@@ -6667,7 +6675,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
if (but->type == UI_BTYPE_IMAGE) {
return false;
}
-
+
/* highly unlikely getting the label ever fails */
UI_but_string_info_get(C, but, &label, NULL);
@@ -6698,7 +6706,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
/* determine if we can key a single component of an array */
is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0;
is_array_component = (is_array && but->rnaindex != -1);
-
+
/* Keyframes */
if (but->flag & UI_BUT_ANIMATED_KEY) {
/* replace/delete keyfraemes */
@@ -6718,11 +6726,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1);
}
-
+
/* keyframe settings */
uiItemS(layout);
-
-
+
+
}
else if (but->flag & UI_BUT_DRIVEN) {
/* pass */
@@ -6739,7 +6747,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
ICON_KEY_HLT, "ANIM_OT_keyframe_insert_button", "all", 1);
}
}
-
+
if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) {
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
@@ -6774,6 +6782,12 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
}
+
+ uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"),
+ ICON_DRIVER, "ANIM_OT_driver_button_edit");
+
+ uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
+ ICON_NONE, "SCREEN_OT_drivers_editor_show");
}
else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
/* pass */
@@ -6782,13 +6796,13 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemS(layout);
if (is_array_component) {
- uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
+ uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
ICON_DRIVER);
}
else {
- uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
- CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
+ uiItemMenuEnumO(layout, C, "ANIM_OT_driver_button_add", "mapping_type",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
ICON_DRIVER);
}
@@ -6796,8 +6810,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
}
+
+ uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
+ ICON_NONE, "SCREEN_OT_drivers_editor_show");
}
-
+
/* Keying Sets */
/* TODO: check on modifyability of Keying Set when doing this */
if (is_anim) {
@@ -6873,7 +6890,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
/* Copy Property Value
* Paste Property Value */
-
+
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"),
ICON_LOOP_BACK, "UI_OT_reset_default_button", "all", 1);
@@ -6888,7 +6905,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Unset"),
ICON_NONE, "UI_OT_unset_property_button");
}
-
+
if (is_array_component) {
uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All To Selected"),
ICON_NONE, "UI_OT_copy_to_selected_button", "all", true);
@@ -7376,7 +7393,7 @@ bool UI_but_active_drop_name(bContext *C)
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU))
return 1;
}
-
+
return 0;
}
@@ -7418,11 +7435,11 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
if (!BLI_rcti_isect_pt(&winrct, x, y)) {
for (uiBlock *block = ar->uiblocks.first; block; block = block->next)
block->auto_open = false;
-
+
return false;
}
- /* also, check that with view2d, that the mouse is not over the scrollbars
+ /* also, check that with view2d, that the mouse is not over the scrollbars
* NOTE: care is needed here, since the mask rect may include the scrollbars
* even when they are not visible, so we need to make a copy of the mask to
* use to check
@@ -7430,7 +7447,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
View2D *v2d = &ar->v2d;
int mx, my;
-
+
/* convert window coordinates to region coordinates */
mx = x;
my = y;
@@ -7441,7 +7458,7 @@ static bool ui_region_contains_point_px(ARegion *ar, int x, int y)
return false;
}
}
-
+
return true;
}
@@ -7465,7 +7482,7 @@ static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y)
else if (!ui_but_contains_pt(but, mx, my)) {
return false;
}
-
+
return true;
}
@@ -7690,7 +7707,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
but->flag |= UI_SELECT;
UI_but_tooltip_timer_remove(C, but);
}
-
+
/* text editing */
if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
ui_textedit_begin(C, but, data);
@@ -7698,7 +7715,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
ui_textedit_end(C, but, data);
else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING)
ui_textedit_end(C, but, data);
-
+
/* number editing */
if (state == BUTTON_STATE_NUM_EDITING) {
if (ui_but_is_cursor_warp(but))
@@ -7775,7 +7792,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
}
}
-
+
/* wait for mousemove to enable drag */
if (state == BUTTON_STATE_WAIT_DRAG) {
but->flag &= ~UI_SELECT;
@@ -7819,7 +7836,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
data->interactive = true;
}
}
-
+
data->state = BUTTON_STATE_INIT;
/* activate button */
@@ -7837,14 +7854,14 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
data->used_mouse = true;
}
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
-
+
/* activate right away */
if (but->flag & UI_BUT_IMMEDIATE) {
if (but->type == UI_BTYPE_HOTKEY_EVENT)
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
/* .. more to be added here */
}
-
+
if (type == BUTTON_ACTIVATE_OPEN) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
@@ -7853,7 +7870,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
ARegion *subar = data->menu->region;
uiBlock *subblock = subar->uiblocks.first;
uiBut *subbut;
-
+
if (subblock) {
subbut = ui_but_first(subblock);
@@ -8161,7 +8178,7 @@ void UI_context_update_anim_flag(const bContext *C)
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
ui_but_override_flag(but);
ED_region_tag_redraw(ar);
-
+
if (but->active) {
activebut = but;
}
@@ -8194,7 +8211,7 @@ static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event)
{
uiBlock *block;
uiBut *but;
-
+
for (block = ar->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next)
if (but == event->customdata)
@@ -8234,15 +8251,15 @@ void ui_but_activate_event(bContext *C, ARegion *ar, uiBut *but)
{
wmWindow *win = CTX_wm_window(C);
wmEvent event;
-
+
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
-
+
wm_event_init_from_window(win, &event);
event.type = EVT_BUT_OPEN;
event.val = KM_PRESS;
event.customdata = but;
event.customdatafree = false;
-
+
ui_do_button(C, but->block, but, &event);
}
@@ -8340,7 +8357,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
ar = data->region;
retval = WM_UI_HANDLER_CONTINUE;
-
+
if (data->state == BUTTON_STATE_HIGHLIGHT) {
switch (event->type) {
case WINDEACTIVATE:
@@ -8518,7 +8535,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
}
bt = ui_but_find_mouse_over(ar, event);
-
+
if (bt && bt->active != data) {
if (but->type != UI_BTYPE_COLOR) { /* exception */
data->cancel = true;
@@ -8747,7 +8764,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
menu->menuretval = 0;
}
-
+
/* now change button state or exit, which will close the submenu */
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
if (menu->menuretval != UI_RETURN_OK)
@@ -8858,7 +8875,7 @@ static bool ui_mouse_motion_towards_check(
p2[0] = rect_px.xmax + margin;
p2[1] = rect_px.ymin - margin;
-
+
p3[0] = rect_px.xmax + margin;
p3[1] = rect_px.ymax + margin;
@@ -8916,7 +8933,7 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve
static char ui_menu_scroll_test(uiBlock *block, int my)
{
if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) {
- if (block->flag & UI_BLOCK_CLIPTOP)
+ if (block->flag & UI_BLOCK_CLIPTOP)
if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE)
return 't';
if (block->flag & UI_BLOCK_CLIPBOTTOM)
@@ -8985,12 +9002,12 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt)
/* set flags again */
ui_popup_block_scrolltest(block);
-
+
ED_region_tag_redraw(ar);
-
+
return 1;
}
-
+
return 0;
}
@@ -9155,14 +9172,14 @@ static int ui_handle_menu_event(
if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) {
ui_mouse_motion_towards_init(menu, &event->x);
}
-
+
/* add menu scroll timer, if needed */
if (ui_menu_scroll_test(block, my))
if (menu->scrolltimer == NULL)
menu->scrolltimer =
WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
}
-
+
/* first block own event func */
if (block->block_event_func && block->block_event_func(C, block, event)) {
/* pass */
@@ -9202,7 +9219,7 @@ static int ui_handle_menu_event(
retval = WM_UI_HANDLER_BREAK;
break;
-
+
case UPARROWKEY:
case DOWNARROWKEY:
case WHEELUPMOUSE:
@@ -9215,11 +9232,11 @@ static int ui_handle_menu_event(
else if (inside || (block->flag & UI_BLOCK_LOOP)) {
int type = event->type;
int val = event->val;
-
+
/* convert pan to scrollwheel */
if (type == MOUSEPAN)
ui_pan_to_scroll(event, &type, &val);
-
+
if (val == KM_PRESS) {
const bool is_next =
(ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) ==
@@ -9290,10 +9307,10 @@ static int ui_handle_menu_event(
count = 0;
for (but = block->buttons.first; but; but = but->next) {
bool doit = false;
-
+
if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE))
count++;
-
+
/* exception for rna layer buts */
if (but->rnapoin.data && but->rnaprop &&
ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER))
@@ -9393,7 +9410,7 @@ static int ui_handle_menu_event(
}
}
}
-
+
/* here we check return conditions for menus */
if (block->flag & UI_BLOCK_LOOP) {
/* if we click outside the block, verify if we clicked on the
@@ -9473,7 +9490,7 @@ static int ui_handle_menu_event(
uiSafetyRct *saferct;
ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false);
-
+
/* check for all parent rects, enables arrowkeys to be used */
for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
/* for mouse move we only check our own rect, for other
@@ -10069,7 +10086,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
/* re-enable tooltips */
if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
ui_blocks_set_tooltips(ar, true);
-
+
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);
@@ -10085,7 +10102,7 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
if (ar == NULL) return;
UI_blocklist_free(C, &ar->uiblocks);
-
+
sc = CTX_wm_screen(C);
if (sc == NULL) return;
@@ -10221,7 +10238,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
win->last_pie_event = block->pie_data.event;
reset_pie = true;
}
-
+
ui_popup_block_free(C, menu);
UI_popup_handlers_remove(&win->modalhandlers, menu);
CTX_wm_menu_set(C, NULL);
@@ -10331,7 +10348,7 @@ bool UI_textbutton_activate_rna(
{
uiBlock *block;
uiBut *but = NULL;
-
+
for (block = ar->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next) {
if (but->type == UI_BTYPE_TEXT) {
@@ -10345,7 +10362,7 @@ bool UI_textbutton_activate_rna(
if (but)
break;
}
-
+
if (but) {
UI_but_active_only(C, ar, block, but);
return true;
@@ -10360,7 +10377,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
ARegion *ar = CTX_wm_region(C);
uiBlock *block;
uiBut *but = NULL;
-
+
for (block = ar->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next)
if (but == actbut && but->type == UI_BTYPE_TEXT)
@@ -10369,7 +10386,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
if (but)
break;
}
-
+
if (but) {
UI_but_active_only(C, ar, block, but);
return true;
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 9f5c2005878..51c3cff721a 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -133,7 +133,7 @@ typedef struct IconTexture {
} IconTexture;
/* ******************* STATIC LOCAL VARS ******************* */
-/* static here to cache results of icon directory scan, so it's not
+/* static here to cache results of icon directory scan, so it's not
* scanning the filesystem each time the menu is drawn */
static struct ListBase iconfilelist = {NULL, NULL};
static IconTexture icongltex = {0, 0, 0, 0.0f, 0.0f};
@@ -170,9 +170,9 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
/* icon buffers can get initialized runtime now, via datatoc */
if (bbuf) {
int y, imgsize;
-
+
iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
-
+
/* Here we store the rect in the icon - same as before */
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0)
memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
@@ -191,7 +191,7 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
new_icon->drawinfo = di;
BKE_icon_set(icon_id, new_icon);
-
+
return di;
}
@@ -255,10 +255,10 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
* (since we're doing this offscreen, free from any particular space_id)
*/
struct bThemeState theme_state;
-
+
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW);
-
+
/* the "x" and "y" given are the bottom-left coordinates of the icon,
* while the draw_keyframe_shape() function needs the midpoint for
* the keyframe
@@ -353,7 +353,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU
{ \
vicon_colorset_draw(index, x, y, w, h, alpha); \
}
-
+
DEF_VICON_COLORSET_DRAW_NTH(01, 0)
DEF_VICON_COLORSET_DRAW_NTH(02, 1)
DEF_VICON_COLORSET_DRAW_NTH(03, 2)
@@ -437,14 +437,14 @@ static void icon_verify_datatoc(IconImage *iimg)
/* if it has own rect, things are all OK */
if (iimg->rect)
return;
-
+
if (iimg->datatoc_rect) {
ImBuf *bbuf = IMB_ibImageFromMemory(iimg->datatoc_rect,
iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
/* w and h were set on initialize */
if (bbuf->x != iimg->h && bbuf->y != iimg->w)
IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
-
+
iimg->rect = bbuf->rect;
bbuf->rect = NULL;
IMB_freeImBuf(bbuf);
@@ -504,7 +504,7 @@ static void init_internal_icons(void)
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
char iconfilestr[FILE_MAX];
-
+
if (icondir) {
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */
@@ -530,7 +530,7 @@ static void init_internal_icons(void)
datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
if (b32buf)
IMB_premultiply_alpha(b32buf);
-
+
if (b16buf && b32buf) {
/* free existing texture if any */
if (icongltex.id) {
@@ -548,17 +548,17 @@ static void init_internal_icons(void)
if (icongltex.id) {
int level = 2;
-
+
icongltex.w = b32buf->x;
icongltex.h = b32buf->y;
icongltex.invw = 1.0f / b32buf->x;
icongltex.invh = 1.0f / b32buf->y;
glBindTexture(GL_TEXTURE_2D, icongltex.id);
-
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, b32buf->x, b32buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b32buf->rect);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, b16buf->x, b16buf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, b16buf->rect);
-
+
while (b16buf->x > 1) {
ImBuf *nbuf = IMB_onehalf(b16buf);
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, nbuf->x, nbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nbuf->rect);
@@ -566,10 +566,10 @@ static void init_internal_icons(void)
IMB_freeImBuf(b16buf);
b16buf = nbuf;
}
-
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
+
glBindTexture(GL_TEXTURE_2D, 0);
}
}
@@ -579,7 +579,7 @@ static void init_internal_icons(void)
icontype = ICON_TYPE_TEXTURE;
else
icontype = ICON_TYPE_BUFFER;
-
+
if (b32buf) {
for (y = 0; y < ICON_GRID_ROWS; y++) {
for (x = 0; x < ICON_GRID_COLS; x++) {
@@ -592,13 +592,13 @@ static void init_internal_icons(void)
}
def_internal_vicon(VICO_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw);
-
+
def_internal_vicon(VICO_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw);
def_internal_vicon(VICO_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw);
def_internal_vicon(VICO_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw);
def_internal_vicon(VICO_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw);
def_internal_vicon(VICO_KEYTYPE_MOVING_HOLD_VEC, vicon_keytype_moving_hold_draw);
-
+
def_internal_vicon(VICO_COLORSET_01_VEC, vicon_colorset_draw_01);
def_internal_vicon(VICO_COLORSET_02_VEC, vicon_colorset_draw_02);
def_internal_vicon(VICO_COLORSET_03_VEC, vicon_colorset_draw_03);
@@ -622,7 +622,7 @@ static void init_internal_icons(void)
IMB_freeImBuf(b16buf);
IMB_freeImBuf(b32buf);
-
+
}
#endif /* WITH_HEADLESS */
@@ -638,13 +638,13 @@ static void init_iconfile_list(struct ListBase *list)
if (icondir == NULL)
return;
-
+
totfile = BLI_filelist_dir_contents(icondir, &dir);
for (i = 0; i < totfile; i++) {
if ((dir[i].type & S_IFREG)) {
const char *filename = dir[i].relname;
-
+
if (BLI_testextensie(filename, ".png")) {
/* loading all icons on file start is overkill & slows startup
* its possible they change size after blender load anyway. */
@@ -666,7 +666,7 @@ static void init_iconfile_list(struct ListBase *list)
else {
ifilex = ifiley = 0;
}
-
+
/* bad size or failed to load */
if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
@@ -676,12 +676,12 @@ static void init_iconfile_list(struct ListBase *list)
/* found a potential icon file, so make an entry for it in the cache list */
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
-
+
BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
ifile->index = index;
BLI_addtail(list, ifile);
-
+
index++;
}
}
@@ -694,7 +694,7 @@ static void init_iconfile_list(struct ListBase *list)
static void free_iconfile_list(struct ListBase *list)
{
IconFile *ifile = NULL, *next_ifile = NULL;
-
+
for (ifile = list->first; ifile; ifile = next_ifile) {
next_ifile = ifile->next;
BLI_freelinkN(list, ifile);
@@ -707,20 +707,20 @@ int UI_iconfile_get_index(const char *filename)
{
IconFile *ifile;
ListBase *list = &(iconfilelist);
-
+
for (ifile = list->first; ifile; ifile = ifile->next) {
if (BLI_path_cmp(filename, ifile->filename) == 0) {
return ifile->index;
}
}
-
+
return 0;
}
ListBase *UI_iconfile_list(void)
{
ListBase *list = &(iconfilelist);
-
+
return list;
}
@@ -811,13 +811,13 @@ int UI_icon_get_width(int icon_id)
DrawInfo *di = NULL;
icon = BKE_icon_get(icon_id);
-
+
if (icon == NULL) {
if (G.debug & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
}
-
+
di = icon_ensure_drawinfo(icon);
if (di) {
return ICON_DEFAULT_WIDTH;
@@ -955,7 +955,7 @@ static void icon_set_image(
PreviewImage *UI_icon_to_preview(int icon_id)
{
Icon *icon = BKE_icon_get(icon_id);
-
+
if (icon) {
DrawInfo *di = (DrawInfo *)icon->drawinfo;
if (di) {
@@ -1225,10 +1225,10 @@ static void icon_draw_size(
IconImage *iimg;
const float fdraw_size = (float)draw_size;
int w, h;
-
+
icon = BKE_icon_get(icon_id);
alpha *= btheme->tui.icon_alpha;
-
+
if (icon == NULL) {
if (G.debug & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
@@ -1304,7 +1304,7 @@ static void icon_draw_size(
if (pi) {
/* no create icon on this level in code */
if (!pi->rect[size]) return; /* something has gone wrong! */
-
+
/* preview images use premul alpha ... */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -1341,10 +1341,10 @@ static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
{
PreviewImage *pi = BKE_previewimg_id_ensure(id);
enum eIconSizes i;
-
+
if (!pi)
return;
-
+
for (i = 0; i < NUM_ICON_SIZES; i++) {
/* check if rect needs to be created; changed
* only set by dynamic icons */
@@ -1365,16 +1365,21 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
ui_id_icon_render(C, id, true);
}
else {
+ WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
- SpaceImage *sima;
const EnumPropertyItem *items = NULL;
int tool = PAINT_TOOL_DRAW, mode = 0;
+ ScrArea *sa = CTX_wm_area(C);
+ char space_type = sa->spacetype;
+ if (space_type == SPACE_TOPBAR) {
+ space_type = workspace->tools_space_type;
+ }
/* XXX: this is not nice, should probably make brushes
* be strictly in one paint mode only to avoid
* checking various context stuff here */
- if (CTX_wm_view3d(C) && ob) {
+ if ((space_type == SPACE_VIEW3D) && ob) {
if (ob->mode & OB_MODE_SCULPT)
mode = OB_MODE_SCULPT;
else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
@@ -1382,10 +1387,19 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
mode = OB_MODE_TEXTURE_PAINT;
}
- else if ((sima = CTX_wm_space_image(C)) &&
- (sima->mode == SI_MODE_PAINT))
- {
- mode = OB_MODE_TEXTURE_PAINT;
+ else if (space_type == SPACE_IMAGE) {
+ int sima_mode;
+ if (sa->spacetype == space_type) {
+ SpaceImage *sima = sa->spacedata.first;
+ sima_mode = sima->mode;
+ }
+ else {
+ sima_mode = workspace->tools_mode;
+ }
+
+ if (sima_mode == SI_MODE_PAINT) {
+ mode = OB_MODE_TEXTURE_PAINT;
+ }
}
/* reset the icon */
@@ -1421,7 +1435,7 @@ static int ui_id_screen_get_icon(const bContext *C, ID *id)
int ui_id_icon_get(const bContext *C, ID *id, const bool big)
{
int iconid = 0;
-
+
/* icon */
switch (GS(id->name)) {
case ID_BR:
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e1fe64c1e35..c7cf03a44dd 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -75,19 +75,19 @@ typedef enum {
UI_WTYPE_TOOLBAR_ITEM,
UI_WTYPE_TAB,
UI_WTYPE_TOOLTIP,
-
+
/* strings */
UI_WTYPE_NAME,
UI_WTYPE_NAME_LINK,
UI_WTYPE_POINTER_LINK,
UI_WTYPE_FILENAME,
-
+
/* menus */
UI_WTYPE_MENU_RADIO,
UI_WTYPE_MENU_ICON_RADIO,
UI_WTYPE_MENU_POINTER_LINK,
UI_WTYPE_MENU_NODE_LINK,
-
+
UI_WTYPE_PULLDOWN,
UI_WTYPE_MENU_ITEM,
UI_WTYPE_MENU_ITEM_RADIAL,
@@ -245,7 +245,7 @@ struct uiBut {
uiButCompleteFunc autocomplete_func;
void *autofunc_arg;
-
+
uiButSearchCreateFunc search_create_func;
uiButSearchFunc search_func;
bool free_search_arg;
@@ -302,7 +302,7 @@ struct uiBut {
void *dragpoin;
struct ImBuf *imb;
float imb_scale;
-
+
/* active button data */
struct uiHandleButtonData *active;
@@ -314,7 +314,7 @@ struct uiBut {
float *editvec;
void *editcoba;
void *editcumap;
-
+
/* pointer back */
uiBlock *block;
};
@@ -362,9 +362,9 @@ struct uiBlock {
struct uiLayout *curlayout;
ListBase contexts;
-
+
char name[UI_MAX_NAME_STR];
-
+
float winmat[4][4];
rctf rect;
@@ -384,10 +384,10 @@ struct uiBlock {
uiBlockHandleFunc handle_func;
void *handle_func_arg;
-
+
/* custom extra handling */
int (*block_event_func)(const struct bContext *C, struct uiBlock *, const struct wmEvent *);
-
+
/* extra draw function for custom blocks */
void (*drawextra)(const struct bContext *C, void *idv, void *arg1, void *arg2, rcti *rect);
void *drawextra_arg1;
@@ -545,7 +545,7 @@ struct uiPopupBlockHandle {
void (*popup_func)(struct bContext *C, void *arg, int event);
void (*cancel_func)(struct bContext *C, void *arg);
void *popup_arg;
-
+
/* store data for refreshing popups */
struct uiPopupBlockCreate popup_create_vars;
/* true if we can re-create the popup using 'popup_create_vars' */
@@ -563,7 +563,7 @@ struct uiPopupBlockHandle {
ScrArea *ctx_area;
ARegion *ctx_region;
int opcontext;
-
+
/* return values */
int butretval;
int menuretval;
@@ -794,6 +794,8 @@ void ui_resources_free(void);
void ui_layout_add_but(uiLayout *layout, uiBut *but);
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
void ui_layout_list_set_labels_active(uiLayout *layout);
+/* menu callback */
+void ui_item_paneltype_func(struct bContext *C, struct uiLayout *layout, void *arg_pt);
/* interface_align.c */
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index d9db5c930fc..ad8dd3644ae 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -301,7 +301,7 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h)
bitem->but->rect.ymin = y;
bitem->but->rect.xmax = x + w;
bitem->but->rect.ymax = y + h;
-
+
ui_but_update(bitem->but); /* for strlen */
}
else {
@@ -321,7 +321,7 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax)
bitem->but->rect.xmin += delta_xmin;
bitem->but->rect.xmax += delta_xmax;
-
+
ui_but_update(bitem->but); /* for strlen */
}
else {
@@ -361,7 +361,7 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a
sub = uiLayoutRow(layout, align);
else
sub = uiLayoutColumn(layout, align);
-
+
sub->space = 0;
return sub;
}
@@ -431,9 +431,9 @@ static void ui_item_array(
if (ptr->type == &RNA_Armature) {
bArmature *arm = (bArmature *)ptr->data;
-
+
layer_used = arm->layer_used;
-
+
if (arm->edbo) {
if (arm->act_edbone) {
layer_active |= arm->act_edbone->layer;
@@ -452,7 +452,7 @@ static void ui_item_array(
for (a = 0; a < colbuts; a++) {
const int layer_num = a + b * colbuts;
const unsigned int layer_flag = (1u << layer_num);
-
+
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
icon = ICON_LAYER_ACTIVE;
@@ -470,7 +470,7 @@ static void ui_item_array(
for (a = 0; a < colbuts; a++) {
const int layer_num = a + len / 2 + b * colbuts;
const unsigned int layer_flag = (1u << layer_num);
-
+
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
icon = ICON_LAYER_ACTIVE;
@@ -498,7 +498,7 @@ static void ui_item_array(
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
if (totdim != 2) return; /* only 2D matrices supported in UI so far */
-
+
w /= dim_size[0];
/* h /= dim_size[1]; */ /* UNUSED */
@@ -1451,7 +1451,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (icon == ICON_NONE)
icon = RNA_property_ui_icon(prop);
-
+
if (flag & UI_ITEM_R_ICON_ONLY) {
/* pass */
}
@@ -1504,7 +1504,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (no_bg) {
layout->emboss = UI_EMBOSS_NONE;
}
-
+
/* array property */
if (index == RNA_NO_INDEX && is_array)
ui_item_array(
@@ -1526,7 +1526,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
ui_but_add_search(but, ptr, prop, NULL, NULL);
-
+
if (layout->redalert)
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
@@ -1539,7 +1539,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (toggle && but->type == UI_BTYPE_CHECKBOX)
but->type = UI_BTYPE_TOGGLE;
-
+
if (layout->redalert)
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
@@ -1783,7 +1783,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
StructRNA *icontype;
int w, h;
char namestr[UI_MAX_NAME_STR];
-
+
/* validate arguments */
prop = RNA_struct_find_property(ptr, propname);
@@ -1792,7 +1792,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
RNA_struct_identifier(ptr->type), propname);
return;
}
-
+
type = RNA_property_type(prop);
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
RNA_warning("Property %s must be a pointer, string or enum", propname);
@@ -1848,33 +1848,13 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
layout->root->block->flag ^= UI_BLOCK_IS_FLIP;
}
-static void ui_item_paneltype_func(bContext *C, uiLayout *layout, void *arg_mt)
+void ui_item_paneltype_func(bContext *C, uiLayout *layout, void *arg_pt)
{
- PanelType *pt = (PanelType *)arg_mt;
-
- /* TODO: move into UI_paneltype_draw */
- Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
- panel->type = pt;
-
- if (layout->context) {
- CTX_store_set(C, layout->context);
- }
-
- if (pt->draw_header) {
- panel->layout = uiLayoutRow(layout, false);
- pt->draw_header(C, panel);
- panel->layout = NULL;
- }
-
- panel->layout = layout;
- pt->draw(C, panel);
- panel->layout = NULL;
-
- if (layout->context) {
- CTX_store_set(C, NULL);
- }
+ PanelType *pt = (PanelType *)arg_pt;
+ UI_paneltype_draw(C, pt, layout);
- MEM_freeN(panel);
+ /* panels are created flipped (from event handling pov) */
+ layout->root->block->flag ^= UI_BLOCK_IS_FLIP;
}
static uiBut *ui_item_menu(
@@ -2296,7 +2276,7 @@ static void ui_litem_layout_row(uiLayout *litem)
if (totw == 0)
return;
-
+
if (w != 0)
w -= (tot - 1) * litem->space;
fixedw = 0;
@@ -2327,7 +2307,7 @@ static void ui_litem_layout_row(uiLayout *litem)
/* ignore min flag for rows with right or center alignment */
if (item->type != ITEM_BUTTON &&
ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) &&
- litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
+ litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
((uiItem *)litem)->flag & UI_ITEM_MIN)
{
min_flag = false;
@@ -2435,7 +2415,7 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
if (item->next && (!is_box || item != litem->items.first))
litem->h += litem->space;
}
-
+
if (min_size_flag) {
litem->item.flag |= UI_ITEM_MIN;
}
@@ -2825,7 +2805,7 @@ static void ui_litem_layout_absolute(uiLayout *litem)
scalex = (float)litem->w / (float)totw;
if (litem->h && toth > 0)
scaley = (float)litem->h / (float)toth;
-
+
x = litem->x;
y = litem->y - scaley * toth;
@@ -2876,7 +2856,7 @@ static void ui_litem_layout_split(uiLayout *litem)
y = litem->y;
percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
-
+
w = (litem->w - (tot - 1) * litem->space);
colw = w * percentage;
colw = MAX2(colw, 0);
@@ -3509,7 +3489,7 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s
BLI_addtail(&block->layouts, root);
ui_layout_add_padding_button(root);
-
+
return layout;
}
@@ -3532,7 +3512,7 @@ void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
void ui_layout_add_but(uiLayout *layout, uiBut *but)
{
uiButtonItem *bitem;
-
+
bitem = MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
bitem->item.type = ITEM_BUTTON;
bitem->but = but;
@@ -3754,3 +3734,32 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
CTX_store_set(C, NULL);
}
}
+
+/**
+ * Used for popup panels only.
+ */
+void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout)
+{
+ Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
+ panel->type = pt;
+
+ if (layout->context) {
+ CTX_store_set(C, layout->context);
+ }
+
+ if (pt->draw_header) {
+ panel->layout = uiLayoutRow(layout, false);
+ pt->draw_header(C, panel);
+ panel->layout = NULL;
+ }
+
+ panel->layout = layout;
+ pt->draw(C, panel);
+ panel->layout = NULL;
+
+ if (layout->context) {
+ CTX_store_set(C, NULL);
+ }
+
+ MEM_freeN(panel);
+}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 3c65f727133..5c2fb0e7aaa 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -78,7 +78,7 @@ static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op))
ui_theme_init_default();
ui_style_init_default();
WM_event_add_notifier(C, NC_WINDOW, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -88,10 +88,10 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot)
ot->name = "Reset to Default Theme";
ot->idname = "UI_OT_reset_default_theme";
ot->description = "Reset to the default theme colors";
-
+
/* callbacks */
ot->exec = reset_default_theme_exec;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER;
}
@@ -109,7 +109,7 @@ static int copy_data_path_button_poll(bContext *C)
if (ptr.id.data && ptr.data && prop) {
path = RNA_path_from_ID_to_property(&ptr, prop);
-
+
if (path) {
MEM_freeN(path);
return 1;
@@ -255,7 +255,7 @@ static int reset_default_button_poll(bContext *C)
int index;
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
return (ptr.data && prop && RNA_property_editable(&ptr, prop));
}
@@ -268,7 +268,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
/* try to reset the nominated setting to its default value */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
+
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
if (RNA_property_reset(&ptr, prop, (all) ? -1 : index))
@@ -291,7 +291,7 @@ static void UI_OT_reset_default_button(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
}
@@ -800,7 +800,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
/* Reports to Textblock Operator ------------------------ */
-/* FIXME: this is just a temporary operator so that we can see all the reports somewhere
+/* FIXME: this is just a temporary operator so that we can see all the reports somewhere
* when there are too many to display...
*/
@@ -815,10 +815,10 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Text *txt;
char *str;
-
+
/* create new text-block to write to */
txt = BKE_text_add(bmain, "Recent Reports");
-
+
/* convert entire list to a display string, and add this to the text-block
* - if commandline debug option enabled, show debug reports too
* - otherwise, up to info (which is what users normally see)
@@ -843,7 +843,7 @@ static void UI_OT_reports_to_textblock(wmOperatorType *ot)
ot->name = "Reports to Text Block";
ot->idname = "UI_OT_reports_to_textblock";
ot->description = "Write the reports ";
-
+
/* callbacks */
ot->poll = reports_to_text_poll;
ot->exec = reports_to_text_exec;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index f621a906789..5711f76e3e9 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -29,7 +29,7 @@
/* a full doc with API notes can be found in bf-blender/trunk/blender/doc/guides/interface_API.txt */
-
+
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -129,7 +129,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
return BUT_VERTICAL;
else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
return BUT_VERTICAL;
-
+
return 0;
}
@@ -170,7 +170,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
return 1;
}
}
-
+
return 0;
}
@@ -270,7 +270,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
else
pa->flag |= PNL_CLOSEDX;
}
-
+
pa->ofsx = 0;
pa->ofsy = 0;
pa->sizex = 0;
@@ -318,7 +318,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
for (palast = ar->panels.first; palast; palast = palast->next)
if (palast->runtime_flag & PNL_LAST_ADDED)
break;
-
+
if (newpanel) {
pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
@@ -340,7 +340,7 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, P
if (pa->flag & PNL_CLOSED) return pa;
*r_open = true;
-
+
return pa;
}
@@ -398,7 +398,7 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
float f3 = 0.15 * U.widget_unit;
float f5 = 0.25 * U.widget_unit;
float f7 = 0.35 * U.widget_unit;
-
+
if (dir == 'h') {
UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color);
}
@@ -445,10 +445,10 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float
immVertex2f(pos, x2, y1);
immEnd();
-
+
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
-
+
}
/* x 'icon' for panel header */
@@ -465,15 +465,15 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
{
float xmin, xmax, dx;
float ymin, ymax, dy;
-
+
xmin = rect->xmax - PNL_HEADER + 2;
xmax = rect->xmax - 3;
ymin = rect->ymin + 3;
ymax = rect->ymin + PNL_HEADER - 2;
-
+
dx = 0.5f * (xmax - xmin);
dy = 0.5f * (ymax - ymin);
-
+
glEnable(GL_BLEND);
immUniformColor4ub(255, 255, 255, 50);
@@ -486,7 +486,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
immVertex2f(pos, xmax, ymax - dy);
immEnd();
-
+
immUniformColor4ub(0, 0, 0, 50);
immBegin(GWN_PRIM_LINES, 4);
@@ -583,7 +583,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
UI_fontstyle_draw(&style->paneltitle, &hrect, activename, col_title);
}
else {
- /* ignore 'pnl_icons', otherwise the text gets offset horizontally
+ /* ignore 'pnl_icons', otherwise the text gets offset horizontally
* + 0.001f to avoid flirting with float inaccuracy
*/
hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
@@ -753,12 +753,12 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
/* draw collapse icon */
/* itemrect smaller */
- itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
+ itemrect.xmin = headrect.xmin + 3.0f / block->aspect;
itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
- BLI_rctf_scale(&itemrect, 0.35f);
+ BLI_rctf_scale(&itemrect, 0.25f);
if (is_closed_y)
ui_draw_tria_rect(&itemrect, 'h');
@@ -818,7 +818,7 @@ typedef struct PanelSort {
static int find_leftmost_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
-
+
if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
@@ -831,7 +831,7 @@ static int find_leftmost_panel(const void *a1, const void *a2)
static int find_highest_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
-
+
/* stick uppermost header-less panels to the top of the region -
* prevent them from being sorted (multiple header-less panels have to be sorted though) */
if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) {
@@ -844,17 +844,17 @@ static int find_highest_panel(const void *a1, const void *a2)
else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1;
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
-
+
return 0;
}
static int compare_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
-
+
if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
-
+
return 0;
}
@@ -868,7 +868,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
bool done;
int align = panel_aligned(sa, ar);
bool has_category_tabs = UI_panel_category_is_visible(ar);
-
+
/* count active, not tabbed panels */
for (pa = ar->panels.first; pa; pa = pa->next)
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL)
@@ -888,7 +888,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
/* sort panels */
panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort");
-
+
ps = panelsort;
for (pa = ar->panels.first; pa; pa = pa->next) {
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
@@ -897,7 +897,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
ps++;
}
}
-
+
if (drag) {
/* while we are dragging, we sort on location and update sortorder */
if (align == BUT_VERTICAL)
@@ -911,7 +911,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
else
/* otherwise use sortorder */
qsort(panelsort, tot, sizeof(PanelSort), compare_panel);
-
+
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
ps = panelsort;
ps->pa->ofsx = 0;
@@ -935,7 +935,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
}
}
-
+
/* we interpolate */
done = false;
ps = panelsort;
@@ -959,7 +959,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
MEM_freeN(ps->pa);
}
MEM_freeN(panelsort);
-
+
return done;
}
@@ -993,7 +993,7 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
sizex = UI_PANEL_WIDTH;
if (sizey == 0)
sizey = -UI_PANEL_WIDTH;
-
+
*x = sizex;
*y = sizey;
}
@@ -1042,7 +1042,7 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
ScrArea *sa = CTX_wm_area(C);
uiBlock *block;
Panel *panot, *panew, *patest, *pa, *firstpa;
-
+
/* offset contents */
for (block = ar->uiblocks.first; block; block = block->next)
if (block->active && block->panel)
@@ -1088,10 +1088,10 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
if (block->active && block->panel)
if (!firstpa || block->panel->sortorder < firstpa->sortorder)
firstpa = block->panel;
-
+
if (firstpa)
firstpa->runtime_flag |= PNL_FIRST;
-
+
/* compute size taken up by panel */
ui_panels_size(sa, ar, x, y);
}
@@ -1101,7 +1101,7 @@ void UI_panels_draw(const bContext *C, ARegion *ar)
uiBlock *block;
UI_ThemeClearColor(TH_BACK);
-
+
/* draw panels, selected on top */
for (block = ar->uiblocks.first; block; block = block->next) {
if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
@@ -1120,12 +1120,12 @@ void UI_panels_scale(ARegion *ar, float new_width)
{
uiBlock *block;
uiBut *but;
-
+
for (block = ar->uiblocks.first; block; block = block->next) {
if (block->panel) {
float fac = new_width / (float)block->panel->sizex;
block->panel->sizex = new_width;
-
+
for (but = block->buttons.first; but; but = but->next) {
but->rect.xmin *= fac;
but->rect.xmax *= fac;
@@ -1141,13 +1141,13 @@ static void check_panel_overlap(ARegion *ar, Panel *panel)
Panel *pa;
/* also called with (panel == NULL) for clear */
-
+
for (pa = ar->panels.first; pa; pa = pa->next) {
pa->flag &= ~PNL_OVERLAP;
if (panel && (pa != panel)) {
if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) {
float safex = 0.2, safey = 0.2;
-
+
if (pa->flag & PNL_CLOSEDX) safex = 0.05;
else if (pa->flag & PNL_CLOSEDY) safey = 0.05;
else if (panel->flag & PNL_CLOSEDX) safex = 0.05;
@@ -1171,7 +1171,7 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
short align = panel_aligned(sa, ar), dx = 0, dy = 0;
-
+
/* first clip for window, no dragging outside */
if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x))
return;
@@ -1181,10 +1181,10 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct);
dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct);
-
+
if (data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
-
+
if (data->startsizey - dy < UI_PANEL_MINY)
dy = -UI_PANEL_MINY + data->startsizey;
@@ -1194,11 +1194,11 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
else {
/* reset the panel snapping, to allow dragging away from snapped edges */
panel->snap = PNL_SNAP_NONE;
-
+
panel->ofsx = data->startofsx + dx;
panel->ofsy = data->startofsy + dy;
check_panel_overlap(ar, panel);
-
+
if (align) uiAlignPanelStep(sa, ar, 0.2, true);
}
@@ -1388,9 +1388,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
rect_leftmost = rect_pin.xmin;
/* mouse coordinates in panel space! */
-
+
/* XXX weak code, currently it assumes layout style for location of widgets */
-
+
/* check open/collapsed button */
if (event == RETKEY)
button = 1;
@@ -1411,7 +1411,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
else if (mx < rect_leftmost) {
button = 1;
}
-
+
if (button) {
if (button == 2) { /* close */
ED_region_tag_redraw(ar);
@@ -1427,7 +1427,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
if (block->panel->flag & PNL_CLOSED) {
block->panel->flag &= ~PNL_CLOSED;
/* snap back up so full panel aligns with screen edge */
- if (block->panel->snap & PNL_SNAP_BOTTOM)
+ if (block->panel->snap & PNL_SNAP_BOTTOM)
block->panel->ofsy = 0;
if (event == LEFTMOUSE) {
@@ -1444,14 +1444,14 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
else {
/* snap down to bottom screen edge */
block->panel->flag |= PNL_CLOSEDY;
- if (block->panel->snap & PNL_SNAP_BOTTOM)
+ if (block->panel->snap & PNL_SNAP_BOTTOM)
block->panel->ofsy = -block->panel->sizey;
if (event == LEFTMOUSE) {
ui_panel_drag_collapse_handler_add(C, true);
}
}
-
+
for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->paneltab == block->panel) {
if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
@@ -2068,27 +2068,27 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
/* XXX hardcoded key warning */
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) {
if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) {
-
+
if (pa->flag & PNL_CLOSEDY) {
if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my))
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
}
else
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
-
+
retval = WM_UI_HANDLER_BREAK;
continue;
}
}
-
+
/* on active button, do not handle panels */
if (ui_but_is_active(ar))
continue;
-
+
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
if (event->val == KM_PRESS) {
-
+
/* open close on header */
if (ELEM(event->type, RETKEY, PADENTER)) {
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
@@ -2100,7 +2100,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
else if (event->type == LEFTMOUSE) {
/* all inside clicks should return in break - overlapping/float panels */
retval = WM_UI_HANDLER_BREAK;
-
+
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
retval = WM_UI_HANDLER_BREAK;
@@ -2133,7 +2133,7 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
else if (event->type == PADPLUSKEY || event->type == PADMINUS) {
#if 0 /* XXX make float panel exception? */
int zoom = 0;
-
+
/* if panel is closed, only zoom if mouse is over the header */
if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
if (inside_header)
@@ -2216,7 +2216,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
uiHandlePanelData *data = pa->activedata;
wmWindow *win = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
-
+
if (data && data->state == state)
return;
@@ -2272,3 +2272,14 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
ED_region_tag_redraw(ar);
}
+PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname)
+{
+ SpaceType *st = BKE_spacetype_from_id(space_id);
+ if (st) {
+ ARegionType *art = BKE_regiontype_from_id(st, region_id);
+ if (art) {
+ return BLI_findstring(&art->paneltypes, idname, offsetof(PanelType, idname));
+ }
+ }
+ return NULL;
+}
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 54776ad9c91..9d10713c868 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -56,6 +56,8 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_screen.h"
+#include "BKE_report.h"
#include "ED_screen.h"
@@ -187,17 +189,20 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
UI_block_flag_enable(block, UI_BLOCK_LOOP);
UI_block_direction_set(block, block->direction);
block->minbounds = UI_MENU_WIDTH_MIN;
+ bool use_place_under_active = !handle->refresh;
- uiBut *but = NULL;
- for (but = block->buttons.first; but; but = but->next) {
- if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
- break;
+ if (use_place_under_active) {
+ uiBut *but = NULL;
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
+ break;
+ }
}
- }
- if (but) {
- offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
- offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ if (but) {
+ offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
+ offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ }
}
UI_block_bounds_set_popup(block, block_margin, offset[0], offset[1]);
@@ -251,6 +256,44 @@ uiPopupBlockHandle *ui_popover_panel_create(
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Standard Popover Panels
+ * \{ */
+
+int UI_popover_panel_invoke(
+ bContext *C, int space_id, int region_id, const char *idname,
+ bool keep_open, ReportList *reports)
+{
+ uiLayout *layout;
+ PanelType *pt = UI_paneltype_find(space_id, region_id, idname);
+ if (pt == NULL) {
+ BKE_reportf(
+ reports, RPT_ERROR,
+ "Panel \"%s\" not found (space %d, region %d)",
+ idname, space_id, region_id);
+ return OPERATOR_CANCELLED;
+ }
+
+ if (pt->poll && (pt->poll(C, pt) == false)) {
+ /* cancel but allow event to pass through, just like operators do */
+ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+ }
+
+ if (keep_open) {
+ ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ }
+ else {
+ uiPopover *pup = UI_popover_begin(C);
+ layout = UI_popover_layout(pup);
+ UI_paneltype_draw(C, pt, layout);
+ UI_popover_end(C, pup, NULL);
+ }
+
+ return OPERATOR_INTERFACE;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Popup Menu API with begin & end
* \{ */
@@ -312,6 +355,9 @@ void UI_popover_end(bContext *C, uiPopover *pup, wmKeyMap *keymap)
* The begin/end stype of calling popups doesn't allow to 'can_refresh' to be set.
* For now close this style of popvers when accessed. */
UI_block_flag_disable(pup->block, UI_BLOCK_KEEP_OPEN);
+
+ /* panels are created flipped (from event handling pov) */
+ pup->block->flag ^= UI_BLOCK_IS_FLIP;
}
uiLayout *UI_popover_layout(uiPopover *pup)
@@ -327,7 +373,3 @@ void UI_popover_once_clear(uiPopover *pup)
#endif
/** \} */
-
-/* We may want to support this in future */
-/* Similar to UI_popup_menu_invoke */
-// int UI_popover_panel_invoke(bContext *C, const char *idname, ReportList *reports);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index fa25a119ada..0decc937e19 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 01456e2e122..adc3a24d1a9 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -65,10 +65,10 @@
/* style + theme + layout-engine = UI */
/**
- * This is a complete set of layout rules, the 'state' of the Layout
- * Engine. Multiple styles are possible, defined via C or Python. Styles
- * get a name, and will typically get activated per region type, like
- * "Header", or "Listview" or "Toolbar". Properties of Style definitions
+ * This is a complete set of layout rules, the 'state' of the Layout
+ * Engine. Multiple styles are possible, defined via C or Python. Styles
+ * get a name, and will typically get activated per region type, like
+ * "Header", or "Listview" or "Toolbar". Properties of Style definitions
* are:
*
* - default column properties, internal spacing, aligning, min/max width
@@ -85,10 +85,10 @@
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
{
uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
-
+
BLI_addtail(styles, style);
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
-
+
style->panelzoom = 1.0; /* unused */
style->paneltitle.uifont_id = uifont_id;
@@ -129,14 +129,14 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
style->buttonspacey = 2;
style->panelspace = 8;
style->panelouter = 4;
-
+
return style;
}
static uiFont *uifont_to_blfont(int id)
{
uiFont *font = U.uifonts.first;
-
+
for (; font; font = font->next) {
if (font->uifont_id == id) {
return font;
@@ -154,7 +154,7 @@ void UI_fontstyle_draw_ex(
{
int xofs = 0, yofs;
int font_flag = BLF_CLIPPING;
-
+
UI_fontstyle_set(fs);
/* set the flag */
@@ -192,7 +192,7 @@ void UI_fontstyle_draw_ex(
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
}
-
+
/* clip is very strict, so we give it some space */
BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
@@ -349,16 +349,16 @@ uiStyle *UI_style_get_dpi(void)
{
uiStyle *style = UI_style_get();
static uiStyle _style;
-
+
_style = *style;
-
+
_style.paneltitle.shadx = (short)(UI_DPI_FAC * _style.paneltitle.shadx);
_style.paneltitle.shady = (short)(UI_DPI_FAC * _style.paneltitle.shady);
_style.grouplabel.shadx = (short)(UI_DPI_FAC * _style.grouplabel.shadx);
_style.grouplabel.shady = (short)(UI_DPI_FAC * _style.grouplabel.shady);
_style.widgetlabel.shadx = (short)(UI_DPI_FAC * _style.widgetlabel.shadx);
_style.widgetlabel.shady = (short)(UI_DPI_FAC * _style.widgetlabel.shady);
-
+
_style.columnspace = (short)(UI_DPI_FAC * _style.columnspace);
_style.templatespace = (short)(UI_DPI_FAC * _style.templatespace);
_style.boxspace = (short)(UI_DPI_FAC * _style.boxspace);
@@ -366,23 +366,23 @@ uiStyle *UI_style_get_dpi(void)
_style.buttonspacey = (short)(UI_DPI_FAC * _style.buttonspacey);
_style.panelspace = (short)(UI_DPI_FAC * _style.panelspace);
_style.panelouter = (short)(UI_DPI_FAC * _style.panelouter);
-
+
return &_style;
}
int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
{
int width;
-
+
if (fs->kerning == 1) /* for BLF_width */
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
-
+
UI_fontstyle_set(fs);
width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
-
+
if (fs->kerning == 1)
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
-
+
return width;
}
@@ -403,12 +403,12 @@ void uiStyleInit(void)
uiStyle *style = U.uistyles.first;
int monofont_size = datatoc_bmonofont_ttf_size;
unsigned char *monofont_ttf = (unsigned char *)datatoc_bmonofont_ttf;
-
+
/* recover from uninitialized dpi */
if (U.dpi == 0)
U.dpi = 72;
CLAMP(U.dpi, 48, 144);
-
+
for (font = U.uifonts.first; font; font = font->next) {
BLF_unload_id(font->blf_id);
}
@@ -439,9 +439,9 @@ void uiStyleInit(void)
BLI_strncpy(font->filename, "default", sizeof(font->filename));
font->uifont_id = UIFONT_DEFAULT;
}
-
+
for (font = U.uifonts.first; font; font = font->next) {
-
+
if (font->uifont_id == UIFONT_DEFAULT) {
#ifdef WITH_INTERNATIONAL
int font_size = datatoc_bfont_ttf_size;
@@ -493,11 +493,11 @@ void uiStyleInit(void)
BLF_size(font->blf_id, 14 * U.pixelsize, U.dpi);
}
}
-
+
if (style == NULL) {
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
}
-
+
#ifdef WITH_INTERNATIONAL
/* use unicode font for text editor and interactive console */
if (U.transopts & USER_DOTRANSLATE) {
@@ -521,7 +521,7 @@ void uiStyleInit(void)
}
BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
-
+
/**
* Second for rendering else we get threading problems,
*
@@ -537,7 +537,7 @@ void uiStyleInit(void)
void UI_fontstyle_set(const uiFontStyle *fs)
{
uiFont *font = uifont_to_blfont(fs->uifont_id);
-
+
BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ca00fb325da..d934d4dd1e4 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -426,7 +426,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
ID *id = idptr.data;
int event = GET_INT_FROM_POINTER(arg_event);
-
+
switch (event) {
case UI_ID_BROWSE:
case UI_ID_PIN:
@@ -727,14 +727,14 @@ static void template_ID(
UI_but_flag_enable(but, UI_BUT_DISABLED);
}
}
-
+
if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
-
+
if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) {
uiDefButR(block, UI_BTYPE_TOGGLE, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL);
}
}
-
+
if (flag & UI_ID_ADD_NEW) {
template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false, UI_UNIT_X);
}
@@ -745,14 +745,14 @@ static void template_ID(
but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0,
UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack"));
UI_but_operator_ptr_get(but);
-
+
RNA_string_set(but->opptr, "id_name", id->name + 2);
RNA_int_set(but->opptr, "id_type", GS(id->name));
-
+
}
else if (flag & UI_ID_OPEN) {
int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
-
+
if (openop) {
but = uiDefIconTextButO(block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"),
0, 0, w, UI_UNIT_Y, NULL);
@@ -767,7 +767,7 @@ static void template_ID(
if ((idfrom && idfrom->lib) || !editable)
UI_but_flag_enable(but, UI_BUT_DISABLED);
}
-
+
/* delete button */
/* don't use RNA_property_is_unlink here */
if (id && (flag & UI_ID_DELETE)) {
@@ -973,7 +973,7 @@ void uiTemplateAnyID(
{
PropertyRNA *propID, *propType;
uiLayout *split, *row, *sub;
-
+
/* get properties... */
propID = RNA_struct_find_property(ptr, propname);
propType = RNA_struct_find_property(ptr, proptypename);
@@ -986,13 +986,13 @@ void uiTemplateAnyID(
RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename);
return;
}
-
+
/* Start drawing UI Elements using standard defines */
split = uiLayoutSplit(layout, 0.33f, false); /* NOTE: split amount here needs to be synced with normal labels */
-
+
/* FIRST PART ................................................ */
row = uiLayoutRow(split, false);
-
+
/* Label - either use the provided text, or will become "ID-Block:" */
if (text) {
if (text[0])
@@ -1001,20 +1001,20 @@ void uiTemplateAnyID(
else {
uiItemL(row, IFACE_("ID-Block:"), ICON_NONE);
}
-
+
/* SECOND PART ................................................ */
row = uiLayoutRow(split, true);
-
+
/* ID-Type Selector - just have a menu of icons */
sub = uiLayoutRow(row, true); /* HACK: special group just for the enum, otherwise we */
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */
-
+
uiItemFullR(sub, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-
+
/* ID-Block Selector - just use pointer widget... */
sub = uiLayoutRow(row, true); /* HACK: special group to counteract the effects of the previous */
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */
-
+
uiItemFullR(sub, ptr, propID, 0, 0, 0, "", ICON_NONE);
}
@@ -1236,20 +1236,20 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
{
PropertyRNA *propPath;
uiLayout *row;
-
+
/* check that properties are valid */
propPath = RNA_struct_find_property(ptr, propname);
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
-
+
/* Start drawing UI Elements using standard defines */
row = uiLayoutRow(layout, true);
-
+
/* Path (existing string) Widget */
uiItemR(row, ptr, propname, 0, text, ICON_RNA);
-
+
/* TODO: attach something to this to make allow searching of nested properties to 'build' the path */
}
@@ -1267,7 +1267,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
nmd->mode &= ~eModifierMode_Virtual;
BLI_addhead(&ob->modifiers, nmd);
-
+
modifier_unique_name(&ob->modifiers, nmd);
ob->partype = PAROBJECT;
@@ -1327,7 +1327,7 @@ static uiLayout *draw_modifier(
/* rounded header ------------------------------------------------------------------- */
box = uiLayoutBox(column);
-
+
if (isVirtual) {
row = uiLayoutRow(box, false);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
@@ -1336,7 +1336,7 @@ static uiLayout *draw_modifier(
/* XXX this is not used now, since these cannot be accessed via RNA */
BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name);
uiDefBut(block, UI_BTYPE_LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name"));
-
+
but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0,
TIP_("Convert virtual modifier to a real modifier"));
UI_but_func_set(but, modifiers_convertToReal, ob, md);
@@ -1345,15 +1345,15 @@ static uiLayout *draw_modifier(
/* REAL MODIFIER */
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row);
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* Open/Close ................................. */
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
-
+
/* modifier-type icon */
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
UI_block_emboss_set(block, UI_EMBOSS);
-
+
/* modifier name */
md->scene = scene;
if (mti->isDisabled && mti->isDisabled(md, 0)) {
@@ -1361,7 +1361,7 @@ static uiLayout *draw_modifier(
}
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
uiLayoutSetRedAlert(row, false);
-
+
/* mode enabling buttons */
UI_block_align_begin(block);
/* Collision and Surface are always enabled, hide buttons! */
@@ -1370,7 +1370,7 @@ static uiLayout *draw_modifier(
{
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
-
+
if (mti->flags & eModifierTypeFlag_SupportsEditmode) {
sub = uiLayoutRow(row, true);
if (!(md->mode & eModifierMode_Realtime)) {
@@ -1406,13 +1406,13 @@ static uiLayout *draw_modifier(
}
UI_block_align_end(block);
-
+
/* Up/Down + Delete ........................... */
UI_block_align_begin(block);
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_modifier_move_up");
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down");
UI_block_align_end(block);
-
+
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* When Modifier is a simulation, show button to switch to context rather than the delete button. */
if (modifier_can_delete(md) &&
@@ -1429,20 +1429,20 @@ static uiLayout *draw_modifier(
UI_block_emboss_set(block, UI_EMBOSS);
}
-
+
/* modifier settings (under the header) --------------------------------------------------- */
if (!isVirtual && (md->mode & eModifierMode_Expanded)) {
/* apply/convert/copy */
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
-
+
if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
/* only here obdata, the rest of modifiers is ob level */
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
+
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
-
+
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
@@ -1456,17 +1456,17 @@ static uiLayout *draw_modifier(
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
uiItemEnumO(row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
0, "apply_as", MODIFIER_APPLY_DATA);
-
+
if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) {
uiItemEnumO(row, "OBJECT_OT_modifier_apply",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"),
0, "apply_as", MODIFIER_APPLY_SHAPE);
}
}
-
+
UI_block_lock_clear(block);
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
-
+
if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem,
eModifierType_Cloth, eModifierType_Smoke))
{
@@ -1474,19 +1474,19 @@ static uiLayout *draw_modifier(
"OBJECT_OT_modifier_copy");
}
}
-
+
/* result is the layout block inside the box, that we return so that modifier settings can be drawn */
result = uiLayoutColumn(box, false);
block = uiLayoutAbsoluteBlock(box);
}
-
+
/* error messages */
if (md->error) {
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
uiItemL(row, md->error, ICON_ERROR);
}
-
+
return result;
}
@@ -1511,9 +1511,9 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
RNA_warning("Expected modifier on object");
return NULL;
}
-
+
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
-
+
/* find modifier and draw it */
cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0);
@@ -1630,7 +1630,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
*
* object_test_constraints(ob);
* if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
-
+
if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
else DEG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -1662,7 +1662,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
else
BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
-
+
/* determine whether constraint is proxy protected or not */
if (BKE_constraints_proxylocked_owner(ob, pchan))
proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
@@ -1696,34 +1696,34 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
if (con->flag & CONSTRAINT_DISABLE)
uiLayoutSetRedAlert(row, true);
-
+
if (proxy_protected == 0) {
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
}
else
uiItemL(row, con->name, ICON_NONE);
-
+
uiLayoutSetRedAlert(row, false);
-
+
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
if (proxy_protected) {
UI_block_emboss_set(block, UI_EMBOSS_NONE);
-
+
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
-
+
UI_block_emboss_set(block, UI_EMBOSS);
}
else {
short prev_proxylock, show_upbut, show_downbut;
-
- /* Up/Down buttons:
+
+ /* Up/Down buttons:
* Proxy-constraints are not allowed to occur after local (non-proxy) constraints
* as that poses problems when restoring them, so disable the "up" button where
- * it may cause this situation.
+ * it may cause this situation.
*
* Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose.
*/
@@ -1736,29 +1736,29 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
else
prev_proxylock = 0;
-
+
show_upbut = ((prev_proxylock == 0) && (con->prev));
show_downbut = (con->next) ? 1 : 0;
-
+
/* enabled */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemR(row, &ptr, "mute", 0, "",
(con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF);
UI_block_emboss_set(block, UI_EMBOSS);
-
+
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
-
+
/* up/down */
if (show_upbut || show_downbut) {
UI_block_align_begin(block);
if (show_upbut)
uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
-
+
if (show_downbut)
uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
UI_block_align_end(block);
}
-
+
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete");
@@ -1803,7 +1803,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
RNA_warning("Expected constraint on object");
return NULL;
}
-
+
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
/* hrms, the temporal constraint should not draw! */
@@ -1922,7 +1922,7 @@ void uiTemplatePreview(
if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
if (GS(pid->name) == ID_MA) ma = (Material *)pid;
else ma = (Material *)pparent;
-
+
/* Create RNA Pointer */
RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr);
@@ -1934,7 +1934,7 @@ void uiTemplatePreview(
if (pr_texture) {
/* Create RNA Pointer */
RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr);
-
+
uiLayoutRow(layout, true);
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
@@ -1956,7 +1956,7 @@ void uiTemplatePreview(
}
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
-
+
/* Alpha button for texture preview */
if (*pr_texture != TEX_PR_OTHER) {
row = uiLayoutRow(layout, false);
@@ -2238,7 +2238,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
if (free) {
MEM_freeN((void *)item);
}
-
+
return block;
}
@@ -2416,26 +2416,26 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) {
d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr);
- if (cumap->flag & CUMA_DO_CLIP)
+ if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.xmin - d < cumap->clipr.xmin)
d1 = cumap->curr.xmin - cumap->clipr.xmin;
cumap->curr.xmin -= d1;
d1 = d;
- if (cumap->flag & CUMA_DO_CLIP)
+ if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.xmax + d > cumap->clipr.xmax)
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
cumap->curr.xmax += d1;
d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
- if (cumap->flag & CUMA_DO_CLIP)
+ if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.ymin - d < cumap->clipr.ymin)
d1 = cumap->curr.ymin - cumap->clipr.ymin;
cumap->curr.ymin -= d1;
d1 = d;
- if (cumap->flag & CUMA_DO_CLIP)
+ if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.ymax + d > cumap->clipr.ymax)
d1 = -cumap->curr.ymax + cumap->clipr.ymax;
cumap->curr.ymax += d1;
@@ -2449,7 +2449,7 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U
CurveMapping *cumap = cumap_v;
curvemapping_changed(cumap, false);
-}
+}
static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
{
@@ -2622,15 +2622,15 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
int a;
-
+
cumap->preset = CURVE_PRESET_LINE;
for (a = 0; a < CM_TOT; a++)
curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
-
+
cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
curvemapping_set_black_white(cumap, NULL, NULL);
-
+
curvemapping_changed(cumap, false);
rna_update_cb(C, cb_v, NULL);
@@ -2700,7 +2700,7 @@ static void curvemap_buttons_layout(
/* HSV */
sub = uiLayoutRow(row, true);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
-
+
if (cumap->cm[0].curve) {
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
@@ -2716,7 +2716,7 @@ static void curvemap_buttons_layout(
}
else
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
-
+
if (labeltype == 'h')
bg = UI_GRAD_H;
@@ -2906,7 +2906,7 @@ void uiTemplateColorPicker(
if (cubic)
but->flag |= UI_BUT_COLOR_CUBIC;
-
+
if (value_slider) {
switch (U.color_picker_type) {
case USER_CP_CIRCLE_HSL:
@@ -3005,7 +3005,7 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
if (!shift) {
tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
-
+
/* Normally clicking only selects one layer */
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
for (i = 0; i < tot; ++i) {
@@ -3037,8 +3037,8 @@ void uiTemplateLayers(
RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
-
- /* the number of layers determines the way we group them
+
+ /* the number of layers determines the way we group them
* - we want 2 rows only (for now)
* - the number of columns (cols) is the total number of buttons per row
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
@@ -3058,12 +3058,12 @@ void uiTemplateLayers(
if (RNA_property_array_length(used_ptr, used_prop) < layers)
used_prop = NULL;
}
-
+
/* layers are laid out going across rows, with the columns being divided into groups */
-
+
for (group = 0; group < groups; group++) {
uCol = uiLayoutColumn(layout, true);
-
+
for (row = 0; row < 2; row++) {
uiBlock *block;
uiBut *but;
@@ -3071,7 +3071,7 @@ void uiTemplateLayers(
uRow = uiLayoutRow(uCol, true);
block = uiLayoutGetBlock(uRow);
layer = groups * cols_per_group * row + cols_per_group * group;
-
+
/* add layers as toggle buts */
for (col = 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
int icon = 0;
@@ -3081,7 +3081,7 @@ void uiTemplateLayers(
icon = ICON_LAYER_ACTIVE;
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
icon = ICON_LAYER_USED;
-
+
but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
but->type = UI_BTYPE_TOGGLE;
@@ -3778,7 +3778,7 @@ void uiTemplateList(
static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
{
wmOperatorType *ot = arg2;
-
+
if (ot)
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL);
}
@@ -3827,10 +3827,10 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
if (WM_operator_poll((bContext *)C, ot)) {
char name[256];
int len = strlen(ot_ui_name);
-
+
/* display name for menu, can hold hotkey */
BLI_strncpy(name, ot_ui_name, sizeof(name));
-
+
/* check for hotkey */
if (len < sizeof(name) - 6) {
if (WM_key_event_operator_string(
@@ -3840,7 +3840,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
name[len] = UI_SEP_CHAR;
}
}
-
+
if (false == UI_search_item_add(items, name, ot, 0))
break;
}
@@ -3860,7 +3860,7 @@ void uiTemplateOperatorSearch(uiLayout *layout)
uiBlock *block;
uiBut *but;
static char search[256] = "";
-
+
block = uiLayoutGetBlock(layout);
UI_block_layout_set_current(block, layout);
@@ -4073,7 +4073,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
uiBlock *block;
void *owner = NULL;
int handle_event, icon = 0;
-
+
block = uiLayoutGetBlock(layout);
UI_block_layout_set_current(block, layout);
@@ -4157,7 +4157,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
if (owner) {
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
bool active = !(G.is_break || WM_jobs_is_stopped(wm, owner));
-
+
uiLayout *row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
@@ -4209,29 +4209,29 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
ReportList *reports = CTX_wm_reports(C);
Report *report = BKE_reports_last_displayable(reports);
ReportTimerInfo *rti;
-
+
uiLayout *ui_abs;
uiBlock *block;
uiBut *but;
uiStyle *style = UI_style_get();
int width;
int icon;
-
+
/* if the report display has timed out, don't show */
if (!reports->reporttimer) return;
-
+
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
-
+
if (!rti || rti->widthfac == 0.0f || !report) return;
-
+
ui_abs = uiLayoutAbsolute(layout, false);
block = uiLayoutGetBlock(ui_abs);
-
+
UI_fontstyle_set(&style->widgetlabel);
width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len);
width = min_ii((int)(rti->widthfac * width), width);
width = max_ii(width, 10);
-
+
/* make a box around the report to make it stand out */
UI_block_align_begin(block);
but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
@@ -4245,12 +4245,12 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
but->col[3] = 255;
UI_block_align_end(block);
-
-
+
+
/* icon and report message on top */
icon = UI_icon_from_report_type(report->type);
-
- /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report
+
+ /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report
* to be shown instead of icon when appropriate...
*/
UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -4262,7 +4262,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
UI_block_emboss_set(block, UI_EMBOSS);
-
+
uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y,
NULL, 0.0f, 0.0f, 0, 0, "");
}
@@ -4283,7 +4283,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
if (title)
uiItemL(layout, title, ICON_NONE);
-
+
flow = uiLayoutColumnFlow(layout, 2, false);
RNA_STRUCT_BEGIN (ptr, prop)
@@ -4413,17 +4413,17 @@ static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v)
ComponentMenuArgs *args = (ComponentMenuArgs *)args_v;
uiBlock *block;
uiLayout *layout;
-
+
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN);
-
+
layout = uiLayoutColumn(UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_style_get()), 0);
-
+
uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE);
-
+
UI_block_bounds_set_normal(block, 6);
UI_block_direction_set(block, UI_DIR_DOWN);
-
+
return block;
}
void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name)
@@ -4431,10 +4431,10 @@ void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *prop
ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args");
uiBlock *block;
uiBut *but;
-
+
args->ptr = *ptr;
BLI_strncpy(args->propname, propname, sizeof(args->propname));
-
+
block = uiLayoutGetBlock(layout);
UI_block_align_begin(block);
@@ -4443,7 +4443,7 @@ void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *prop
but->rnapoin = *ptr;
but->rnaprop = RNA_struct_find_property(ptr, propname);
but->rnaindex = 0;
-
+
UI_block_align_end(block);
}
@@ -4453,17 +4453,17 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color)
{
uiBlock *block;
uiBut *but;
-
+
block = uiLayoutGetBlock(layout);
UI_block_align_begin(block);
-
+
/* XXX using explicit socket colors is not quite ideal.
* Eventually it should be possible to use theme colors for this purpose,
* but this requires a better design for extendable color palettes in user prefs.
*/
but = uiDefBut(block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
rgba_float_to_uchar(but->col, color);
-
+
UI_block_align_end(block);
}
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 5841a61acc5..e049416ce07 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -71,7 +71,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
if (arraylen && index == -1)
return NULL;
-
+
if (icon && name && name[0] == '\0')
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
else if (icon)
@@ -309,7 +309,7 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char
}
-/***************************** ID Utilities *******************************/
+/***************************** ID Utilities *******************************/
int UI_icon_from_id(ID *id)
{
Object *ob;
@@ -318,7 +318,7 @@ int UI_icon_from_id(ID *id)
if (id == NULL)
return ICON_NONE;
-
+
idcode = GS(id->name);
/* exception for objects */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index cdc95d4fb32..01150758db4 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -106,10 +106,10 @@ typedef struct uiWidgetTrias {
unsigned int tot;
int type;
float size, center[2];
-
+
float vec[16][2];
const unsigned int (*index)[3];
-
+
} uiWidgetTrias;
/* max as used by round_box__edges */
@@ -123,9 +123,9 @@ typedef struct uiWidgetBase {
float outer_v[WIDGET_SIZE_MAX][2];
float inner_v[WIDGET_SIZE_MAX][2];
float inner_uv[WIDGET_SIZE_MAX][2];
-
+
bool draw_inner, draw_outline, draw_emboss;
-
+
uiWidgetTrias tria1;
uiWidgetTrias tria2;
@@ -134,22 +134,22 @@ typedef struct uiWidgetBase {
} uiWidgetBase;
/** uiWidgetType: for time being only for visual appearance,
- * later, a handling callback can be added too
+ * later, a handling callback can be added too
*/
typedef struct uiWidgetType {
-
+
/* pointer to theme color definition */
uiWidgetColors *wcol_theme;
uiWidgetStateColors *wcol_state;
-
+
/* converted colors for state */
uiWidgetColors wcol;
-
+
void (*state)(struct uiWidgetType *, int state);
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*text)(uiFontStyle *, uiWidgetColors *, uiBut *, rcti *);
-
+
} uiWidgetType;
@@ -589,9 +589,9 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
float vec[WIDGET_CURVE_RESOLU][2];
float minx, miny, maxx, maxy;
int a, tot = 0;
-
+
rad += step;
-
+
if (2.0f * rad > BLI_rcti_size_y(rect))
rad = 0.5f * BLI_rcti_size_y(rect);
@@ -599,13 +599,13 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
miny = rect->ymin - step;
maxx = rect->xmax + step;
maxy = rect->ymax + step;
-
+
/* mult */
for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
vec[a][0] = rad * cornervec[a][0];
vec[a][1] = rad * cornervec[a][1];
}
-
+
/* start with left-top, anti clockwise */
if (roundboxalign & UI_CNR_TOP_LEFT) {
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
@@ -619,7 +619,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
vert[tot][1] = maxy;
}
}
-
+
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
vert[tot][0] = minx + vec[a][1];
@@ -632,7 +632,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
vert[tot][1] = miny;
}
}
-
+
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
vert[tot][0] = maxx - rad + vec[a][0];
@@ -645,7 +645,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
vert[tot][1] = miny;
}
}
-
+
if (roundboxalign & UI_CNR_TOP_RIGHT) {
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
vert[tot][0] = maxx - vec[a][1];
@@ -680,7 +680,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
minsize = min_ii(BLI_rcti_size_x(rect) * hnum,
BLI_rcti_size_y(rect) * vnum);
-
+
if (2.0f * rad > minsize)
rad = 0.5f * minsize;
@@ -705,17 +705,17 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
vec[a][0] = rad * cornervec[a][0];
vec[a][1] = rad * cornervec[a][1];
}
-
+
/* corner left-bottom */
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
-
+
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
wt->inner_v[tot][0] = minxi + veci[a][1];
wt->inner_v[tot][1] = minyi + radi - veci[a][0];
-
+
wt->outer_v[tot][0] = minx + vec[a][1];
wt->outer_v[tot][1] = miny + rad - vec[a][0];
-
+
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
@@ -723,26 +723,26 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
else {
wt->inner_v[tot][0] = minxi;
wt->inner_v[tot][1] = minyi;
-
+
wt->outer_v[tot][0] = minx;
wt->outer_v[tot][1] = miny;
wt->inner_uv[tot][0] = 0.0f;
wt->inner_uv[tot][1] = 0.0f;
-
+
tot++;
}
-
+
/* corner right-bottom */
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
-
+
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
wt->inner_v[tot][0] = maxxi - radi + veci[a][0];
wt->inner_v[tot][1] = minyi + veci[a][1];
-
+
wt->outer_v[tot][0] = maxx - rad + vec[a][0];
wt->outer_v[tot][1] = miny + vec[a][1];
-
+
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
@@ -750,28 +750,28 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
else {
wt->inner_v[tot][0] = maxxi;
wt->inner_v[tot][1] = minyi;
-
+
wt->outer_v[tot][0] = maxx;
wt->outer_v[tot][1] = miny;
wt->inner_uv[tot][0] = 1.0f;
wt->inner_uv[tot][1] = 0.0f;
-
+
tot++;
}
-
+
wt->halfwayvert = tot;
-
+
/* corner right-top */
if (roundboxalign & UI_CNR_TOP_RIGHT) {
-
+
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
wt->inner_v[tot][0] = maxxi - veci[a][1];
wt->inner_v[tot][1] = maxyi - radi + veci[a][0];
-
+
wt->outer_v[tot][0] = maxx - vec[a][1];
wt->outer_v[tot][1] = maxy - rad + vec[a][0];
-
+
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
@@ -779,42 +779,42 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
else {
wt->inner_v[tot][0] = maxxi;
wt->inner_v[tot][1] = maxyi;
-
+
wt->outer_v[tot][0] = maxx;
wt->outer_v[tot][1] = maxy;
-
+
wt->inner_uv[tot][0] = 1.0f;
wt->inner_uv[tot][1] = 1.0f;
-
+
tot++;
}
-
+
/* corner left-top */
if (roundboxalign & UI_CNR_TOP_LEFT) {
-
+
for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
wt->inner_v[tot][0] = minxi + radi - veci[a][0];
wt->inner_v[tot][1] = maxyi - veci[a][1];
-
+
wt->outer_v[tot][0] = minx + rad - vec[a][0];
wt->outer_v[tot][1] = maxy - vec[a][1];
-
+
wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
-
+
}
else {
-
+
wt->inner_v[tot][0] = minxi;
wt->inner_v[tot][1] = maxyi;
-
+
wt->outer_v[tot][0] = minx;
wt->outer_v[tot][1] = maxy;
-
+
wt->inner_uv[tot][0] = 0.0f;
wt->inner_uv[tot][1] = 1.0f;
-
+
tot++;
}
@@ -953,17 +953,17 @@ static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rc
float centx, centy, size;
int a;
tria->type = ROUNDBOX_TRIA_CHECK;
-
+
/* center position and size */
tria->center[0] = centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect);
tria->center[1] = centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
tria->size = size = 0.5f * BLI_rcti_size_y(rect);
-
+
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * g_shape_preset_checkmark_vert[a][0] + centx;
tria->vec[a][1] = size * g_shape_preset_checkmark_vert[a][1] + centy;
}
-
+
tria->tot = 4;
tria->index = g_shape_preset_checkmark_face;
}
@@ -1256,17 +1256,17 @@ static void widget_draw_icon_ex(
{
float xs = 0.0f, ys = 0.0f;
float aspect, height;
-
+
if (but->flag & UI_BUT_ICON_PREVIEW) {
glEnable(GL_BLEND);
widget_draw_preview(icon, alpha, rect);
glDisable(GL_BLEND);
return;
}
-
+
/* this icon doesn't need draw... */
if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return;
-
+
aspect = but->block->aspect / UI_DPI_FAC;
height = icon_size / aspect;
@@ -1287,12 +1287,12 @@ static void widget_draw_icon_ex(
alpha *= 0.5f;
}
}
-
+
glEnable(GL_BLEND);
-
+
if (icon && icon != ICON_BLANK1) {
float ofs = 1.0f / aspect;
-
+
if (but->drawflag & UI_BUT_ICON_LEFT) {
/* special case - icon_only pie buttons */
if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0')
@@ -1330,10 +1330,10 @@ static void widget_draw_icon_ex(
if (show_menu_icon) {
xs = rect->xmax - UI_DPI_ICON_SIZE - aspect;
ys = (rect->ymin + rect->ymax - height) / 2.0f;
-
+
UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
}
-
+
glDisable(GL_BLEND);
}
@@ -1606,16 +1606,16 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
char *cpoin = NULL;
int drawstr_len = strlen(but->drawstr);
const char *cpend = but->drawstr + drawstr_len;
-
+
/* need to set this first */
UI_fontstyle_set(fstyle);
-
+
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-
+
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
but->ofs = 0;
-
+
/* First shorten num-buttons eg,
* Translucency: 0.000
@@ -1625,10 +1625,10 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
/* find the space after ':' separator */
cpoin = strrchr(but->drawstr, ':');
-
+
if (cpoin && (cpoin < cpend - 2)) {
char *cp2 = cpoin;
-
+
/* chop off the leading text, starting from the right */
while (but->strwidth > okwidth && cp2 > but->drawstr) {
const char *prev_utf8 = BLI_str_find_prev_char_utf8(but->drawstr, cp2);
@@ -1640,12 +1640,12 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
drawstr_len -= bytes;
// BLI_assert(strlen(but->drawstr) == drawstr_len);
-
+
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
-
-
+
+
/* after the leading text is gone, chop off the : and following space, with ofs */
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
ui_text_clip_give_next_off(but, but->drawstr);
@@ -1664,7 +1664,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
but->strwidth = strwidth;
but->drawstr[drawstr_len] = 0;
}
-
+
if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -1726,17 +1726,17 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
#endif
UI_fontstyle_set(fstyle);
-
+
if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT))
fstyle->align = UI_STYLE_TEXT_LEFT;
else if (but->drawflag & UI_BUT_TEXT_RIGHT)
fstyle->align = UI_STYLE_TEXT_RIGHT;
else
fstyle->align = UI_STYLE_TEXT_CENTER;
-
+
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-
+
/* Special case: when we're entering text for multiple buttons,
* don't draw the text for any of the multi-editing buttons */
@@ -1780,7 +1780,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* text button selection */
if ((but->selend - but->selsta) > 0) {
int selsta_draw, selwidth_draw;
-
+
if (drawstr[0] != 0) {
/* We are drawing on top of widget bases. Flush cache. */
glEnable(GL_BLEND);
@@ -1858,7 +1858,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
#endif
}
-
+
if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
@@ -1879,7 +1879,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
}
}
-
+
#ifdef USE_NUMBUTS_LR_ALIGN
if (!drawstr_right && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
/* if we're editing or multi-drag (fake editing), then use left alignment */
@@ -2116,10 +2116,10 @@ static struct uiWidgetColors wcol_num = {
{180, 180, 180, 255},
{153, 153, 153, 255},
{90, 90, 90, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
-20, 0,
0,
@@ -2131,10 +2131,10 @@ static struct uiWidgetColors wcol_numslider = {
{180, 180, 180, 255},
{153, 153, 153, 255},
{128, 128, 128, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
-20, 0,
0,
@@ -2146,10 +2146,10 @@ static struct uiWidgetColors wcol_text = {
{153, 153, 153, 255},
{153, 153, 153, 255},
{90, 90, 90, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
0, 25,
0,
@@ -2161,10 +2161,10 @@ static struct uiWidgetColors wcol_option = {
{70, 70, 70, 255},
{70, 70, 70, 255},
{255, 255, 255, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
15, -15,
0,
@@ -2177,10 +2177,10 @@ static struct uiWidgetColors wcol_menu = {
{70, 70, 70, 255},
{70, 70, 70, 255},
{255, 255, 255, 255},
-
+
{255, 255, 255, 255},
{204, 204, 204, 255},
-
+
1,
15, -15,
0,
@@ -2193,10 +2193,10 @@ static struct uiWidgetColors wcol_pulldown = {
{63, 63, 63, 255},
{86, 128, 194, 255},
{255, 255, 255, 255},
-
+
{0, 0, 0, 255},
{0, 0, 0, 255},
-
+
0,
25, -20,
0,
@@ -2209,10 +2209,10 @@ static struct uiWidgetColors wcol_menu_item = {
{0, 0, 0, 0},
{86, 128, 194, 255},
{172, 172, 172, 128},
-
+
{255, 255, 255, 255},
{0, 0, 0, 255},
-
+
1,
38, 0,
0,
@@ -2225,10 +2225,10 @@ static struct uiWidgetColors wcol_menu_back = {
{25, 25, 25, 230},
{45, 45, 45, 230},
{100, 100, 100, 255},
-
+
{160, 160, 160, 255},
{255, 255, 255, 255},
-
+
0,
25, -20,
0,
@@ -2273,10 +2273,10 @@ static struct uiWidgetColors wcol_radio = {
{70, 70, 70, 255},
{86, 128, 194, 255},
{255, 255, 255, 255},
-
+
{255, 255, 255, 255},
{0, 0, 0, 255},
-
+
1,
15, -15,
0,
@@ -2288,10 +2288,10 @@ static struct uiWidgetColors wcol_regular = {
{153, 153, 153, 255},
{100, 100, 100, 255},
{25, 25, 25, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2303,10 +2303,10 @@ static struct uiWidgetColors wcol_tool = {
{153, 153, 153, 255},
{100, 100, 100, 255},
{25, 25, 25, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
15, -15,
0,
@@ -2334,10 +2334,10 @@ static struct uiWidgetColors wcol_box = {
{128, 128, 128, 255},
{100, 100, 100, 255},
{25, 25, 25, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2349,10 +2349,10 @@ static struct uiWidgetColors wcol_toggle = {
{153, 153, 153, 255},
{100, 100, 100, 255},
{25, 25, 25, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2364,10 +2364,10 @@ static struct uiWidgetColors wcol_scroll = {
{80, 80, 80, 180},
{100, 100, 100, 180},
{128, 128, 128, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
1,
5, -5,
0,
@@ -2379,10 +2379,10 @@ static struct uiWidgetColors wcol_progress = {
{190, 190, 190, 255},
{100, 100, 100, 180},
{128, 128, 128, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2394,10 +2394,10 @@ static struct uiWidgetColors wcol_list_item = {
{0, 0, 0, 0},
{86, 128, 194, 255},
{90, 90, 90, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2425,10 +2425,10 @@ static struct uiWidgetColors wcol_tmp = {
{128, 128, 128, 255},
{100, 100, 100, 255},
{25, 25, 25, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
0, 0,
0,
@@ -2528,7 +2528,7 @@ static void widget_state(uiWidgetType *wt, int state)
widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden_sel, wcol_state->blend);
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
-
+
if (state & UI_SELECT)
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
}
@@ -2573,11 +2573,11 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
/* call this for option button */
widget_state(wt, state);
-
+
/* now, set the inner-part so that it reflects state settings too */
/* TODO: maybe we should have separate settings for the blending colors used for this case? */
if (state & UI_SELECT) {
-
+
if (state & UI_BUT_ANIMATED_KEY)
widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend);
else if (state & UI_BUT_ANIMATED)
@@ -2606,10 +2606,10 @@ static void widget_state_numslider(uiWidgetType *wt, int state)
static void widget_state_option_menu(uiWidgetType *wt, int state)
{
bTheme *btheme = UI_GetTheme(); /* XXX */
-
+
/* call this for option button */
widget_state(wt, state);
-
+
/* if not selected we get theme from menu back */
if (state & UI_SELECT)
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
@@ -2621,13 +2621,13 @@ static void widget_state_option_menu(uiWidgetType *wt, int state)
static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
{
wt->wcol = *(wt->wcol_theme);
-}
+}
/* special case, button that calls pulldown */
static void widget_state_pulldown(uiWidgetType *wt, int state)
{
wt->wcol = *(wt->wcol_theme);
-
+
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner);
@@ -2667,7 +2667,7 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state)
static void widget_state_menu_item(uiWidgetType *wt, int state)
{
wt->wcol = *(wt->wcol_theme);
-
+
/* active and disabled (not so common) */
if ((state & UI_BUT_DISABLED) && (state & UI_ACTIVE)) {
widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f);
@@ -2700,17 +2700,17 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
int step, totvert;
float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2];
const float radout = UI_ThemeMenuShadowWidth();
-
+
/* disabled shadow */
if (radout == 0.0f)
return;
-
+
/* prevent tooltips to not show round shadow */
if (radout > 0.2f * BLI_rcti_size_y(&rect1))
rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
else
rect1.ymax -= radout;
-
+
/* inner part */
totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
@@ -2723,9 +2723,9 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
for (step = 1; step <= (int)radout; step++) {
float expfac = sqrtf(step / radout);
-
+
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
-
+
immUniformColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac));
widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip);
@@ -2740,9 +2740,9 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
{
uiWidgetBase wtb;
int roundboxalign = UI_CNR_ALL;
-
+
widget_init(&wtb);
-
+
/* menu is 2nd level or deeper */
if (flag & UI_BLOCK_POPUP) {
//rect->ymin -= 4.0;
@@ -2756,14 +2756,14 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
rect->ymax += 0.1f * U.widget_unit;
}
-
+
glEnable(GL_BLEND);
widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
-
+
round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
wtb.draw_emboss = false;
widgetbase_draw(&wtb, wcol);
-
+
glDisable(GL_BLEND);
}
@@ -2775,7 +2775,7 @@ static void ui_hsv_cursor(float x, float y)
immUniformColor3f(1.0f, 1.0f, 1.0f);
imm_draw_circle_fill_2d(pos, x, y, 3.0f * U.pixelsize, 8);
-
+
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
immUniformColor3f(0.0f, 0.0f, 0.0f);
@@ -2808,14 +2808,14 @@ void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float
const float centy = BLI_rcti_cent_y_fl(rect);
float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
float ang, radius_t;
-
+
ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
-
+
if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
radius_t = (1.0f - pow3f(1.0f - hsv[1]));
else
radius_t = hsv[1];
-
+
radius = CLAMPIS(radius_t, 0.0f, 1.0f) * radius;
*xpos = centx + cosf(-ang) * radius;
*ypos = centy + sinf(-ang) * radius;
@@ -2835,7 +2835,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
const float *hsv_ptr = cpicker->color_data;
float rgb[3], hsvo[3], hsv[3], col[3], colcent[3];
bool color_profile = ui_but_is_colorpicker_display_space(but);
-
+
/* color */
ui_but_v3_get(but, rgb);
@@ -2861,7 +2861,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
else
hsv[2] = 0.5f;
}
-
+
ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2);
Gwn_VertFormat *format = immVertexFormat();
@@ -2873,12 +2873,12 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
immBegin(GWN_PRIM_TRI_FAN, tot + 2);
immAttrib3fv(color, colcent);
immVertex2f(pos, centx, centy);
-
+
float ang = 0.0f;
for (int a = 0; a <= tot; a++, ang += radstep) {
float si = sinf(ang);
float co = cosf(ang);
-
+
ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
ui_color_picker_to_rgb_v(hsv, col);
@@ -2927,7 +2927,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
float col1[4][3]; /* right half, rect bottom to top */
/* draw series of gouraud rects */
-
+
switch (type) {
case UI_GRAD_SV:
hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
@@ -2979,7 +2979,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
-
+
immBegin(GWN_PRIM_TRIS, steps * 3 * 6);
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
const float dx_next = dx + color_step;
@@ -2989,7 +2989,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
copy_v3_v3(col0[1], col1[1]);
copy_v3_v3(col0[2], col1[2]);
copy_v3_v3(col0[3], col1[3]);
-
+
/* new color */
switch (type) {
case UI_GRAD_SV:
@@ -3031,17 +3031,17 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
copy_v3_v3(col1[3], col1[2]);
break;
}
-
+
/* rect */
sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
sy = rect->ymin;
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
-
+
for (a = 0; a < 3; a++, sy += dy) {
immAttrib4f(col, col0[a][0], col0[a][1], col0[a][2], alpha);
immVertex2f(pos, sx1, sy);
-
+
immAttrib4f(col, col1[a][0], col1[a][1], col1[a][2], alpha);
immVertex2f(pos, sx2, sy);
@@ -3053,7 +3053,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
immAttrib4f(col, col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
immVertex2f(pos, sx2, sy + dy);
-
+
immAttrib4f(col, col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
immVertex2f(pos, sx1, sy + dy);
}
@@ -3117,24 +3117,24 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
float *hsv = cpicker->color_data;
float hsv_n[3];
bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
-
+
copy_v3_v3(hsv_n, hsv);
-
+
ui_but_v3_get(but, rgb);
-
+
if (use_display_colorspace)
ui_block_cm_to_display_space_v3(but->block, rgb);
-
+
rgb_to_hsv_compat_v(rgb, hsv_n);
-
+
ui_draw_gradient(rect, hsv_n, but->a1, 1.0f);
ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
-
+
ui_hsv_cursor(x, y);
-
+
/* outline */
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -3153,7 +3153,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
float x, y;
float rgb[3], hsv[3], v;
bool color_profile = but->block->color_profile;
-
+
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = false;
@@ -3167,7 +3167,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
else
rgb_to_hsv_v(rgb, hsv);
v = hsv[2];
-
+
/* map v from property range to [0,1] */
if (but->a1 == UI_GRAD_V_ALT) {
float min = but->softmin, max = but->softmax;
@@ -3178,17 +3178,17 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
}
widget_init(&wtb);
-
+
/* fully rounded */
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
-
+
/* setup temp colors */
wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0;
wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128;
wcol_tmp.shadetop = 127;
wcol_tmp.shadedown = -128;
wcol_tmp.shaded = 1;
-
+
widgetbase_draw(&wtb, &wcol_tmp);
/* We are drawing on top of widget bases. Flush cache. */
@@ -3256,9 +3256,9 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
if (state & UI_SELECT)
SWAP(short, wcol->shadetop, wcol->shadedown);
-
+
widget_init(&wtb);
-
+
if (!emboss) {
round_box_edges(&wtb, roundboxalign, rect, rad);
}
@@ -3338,7 +3338,7 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
/* inner and outline */
widgetbase_draw(&wtb, wcol);
}
-
+
if (!(state & UI_STATE_TEXT_INPUT)) {
const float textofs = 0.425f * BLI_rcti_size_y(rect);
@@ -3378,29 +3378,29 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
rad = wcol->roundness * BLI_rcti_size_y(rect);
else
rad = wcol->roundness * BLI_rcti_size_x(rect);
-
+
wtb.uniform_params.shade_dir = (horizontal) ? 1.0f : 0.0;
-
+
/* draw back part, colors swapped and shading inverted */
if (horizontal)
SWAP(short, wcol->shadetop, wcol->shadedown);
-
+
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
widgetbase_draw(&wtb, wcol);
-
+
/* slider */
if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) {
/* pass */
}
else {
SWAP(short, wcol->shadetop, wcol->shadedown);
-
+
copy_v4_v4_char(wcol->inner, wcol->item);
-
+
if (wcol->shadetop > wcol->shadedown)
wcol->shadetop += 20; /* XXX violates themes... */
else wcol->shadedown += 20;
-
+
if (state & UI_SCROLL_PRESSED) {
wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5;
wcol->inner[1] = wcol->inner[1] >= 250 ? 255 : wcol->inner[1] + 5;
@@ -3409,20 +3409,20 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
/* draw */
wtb.draw_emboss = false; /* only emboss once */
-
+
/* exception for progress bar */
if (state & UI_SCROLL_NO_OUTLINE) {
SWAP(bool, outline, wtb.draw_outline);
}
-
+
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
-
+
if (state & UI_SCROLL_ARROWS) {
if (wcol->item[0] > 48) wcol->item[0] -= 48;
if (wcol->item[1] > 48) wcol->item[1] -= 48;
if (wcol->item[2] > 48) wcol->item[2] -= 48;
wcol->item[3] = 255;
-
+
if (horizontal) {
shape_preset_init_scroll_circle(&wtb.tria1, slider, 0.6f, 'l');
shape_preset_init_scroll_circle(&wtb.tria2, slider, 0.6f, 'r');
@@ -3433,7 +3433,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
}
}
widgetbase_draw(&wtb, wcol);
-
+
if (state & UI_SCROLL_NO_OUTLINE) {
SWAP(bool, outline, wtb.draw_outline);
}
@@ -3452,13 +3452,13 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
size = (but->softmax + but->a1 - but->softmin);
size = max_ff(size, 2.0f);
-
+
/* position */
rect1 = *rect;
/* determine horizontal/vertical */
horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
-
+
if (horizontal) {
fac = BLI_rcti_size_x(rect) / size;
rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
@@ -3627,7 +3627,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
uiWidgetBase wtb;
float rad, col[4];
bool color_profile = but->block->color_profile;
-
+
col[3] = 1.0f;
if (but->rnaprop) {
@@ -3640,12 +3640,12 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
}
}
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
ui_but_v3_get(but, col);
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_OVERRIDEN | UI_BUT_REDALERT)) {
@@ -3657,18 +3657,18 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
rect->xmax -= SWATCH_KEYED_BORDER;
rect->ymin += SWATCH_KEYED_BORDER;
rect->ymax -= SWATCH_KEYED_BORDER;
-
+
round_box_edges(&wtb, roundboxalign, rect, rad);
}
-
+
if (color_profile)
ui_block_cm_to_display_space_v3(but->block, col);
-
+
rgba_float_to_uchar((unsigned char *)wcol->inner, col);
wcol->shaded = 0;
wcol->alpha_check = (wcol->inner[3] < 255);
-
+
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
/* Now we reduce alpha of the inner color (i.e. the color shown)
* so that this setting can look grayed out, while retaining
@@ -3716,16 +3716,16 @@ static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, i
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
wtb.draw_outline = false;
-
+
rad = wcol->roundness * BLI_rcti_size_y(rect);
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
widgetbase_draw(&wtb, wcol);
}
else if (but->type == UI_BTYPE_NUM) {
- /* Draw number buttons still with left/right
+ /* Draw number buttons still with left/right
* triangles when field is not embossed */
widget_numbut_embossn(but, wcol, rect, state, roundboxalign);
}
@@ -3736,15 +3736,15 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
{
uiWidgetBase wtb;
float rad;
-
+
if (state & UI_SELECT)
SWAP(short, wcol->shadetop, wcol->shadedown);
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
}
@@ -3753,19 +3753,19 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
{
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
/* decoration */
shape_preset_trias_from_rect_menu(&wtb.tria1, rect);
/* copy size and center to 2nd tria */
wtb.tria2 = wtb.tria1;
-
+
widgetbase_draw(&wtb, wcol);
-
+
/* text space, arrows are about 0.6 height of button */
rect->xmax -= (6 * BLI_rcti_size_y(rect)) / 10;
}
@@ -3774,12 +3774,12 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
{
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
/* decoration */
widgetbase_draw(&wtb, wcol);
}
@@ -3790,9 +3790,9 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
uiWidgetBase wtb;
uiWidgetColors wcol_backup = *wcol;
float rad;
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
@@ -3802,7 +3802,7 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
wcol->outline[0] = min_ii(wcol->outline[0] + 15, 255);
wcol->outline[1] = min_ii(wcol->outline[1] + 15, 255);
wcol->outline[2] = min_ii(wcol->outline[2] + 15, 255);
-
+
/* decoration */
widgetbase_draw(&wtb, wcol);
*wcol = wcol_backup;
@@ -3818,7 +3818,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
/* half rounded */
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
}
}
@@ -3826,13 +3826,13 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
{
uiWidgetBase wtb;
-
+
widget_init(&wtb);
-
+
/* not rounded, no outline */
wtb.draw_outline = false;
round_box_edges(&wtb, 0, rect, 0.0f);
-
+
widgetbase_draw(&wtb, wcol);
}
@@ -3863,14 +3863,14 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
{
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
-
+
/* no outline */
wtb.draw_outline = false;
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
}
@@ -3880,29 +3880,29 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
rcti recttemp = *rect;
float rad;
int delta;
-
+
widget_init(&wtb);
-
+
/* square */
recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
-
+
/* smaller */
delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
recttemp.xmin += delta;
recttemp.ymin += delta;
recttemp.xmax -= delta;
recttemp.ymax -= delta;
-
+
rad = wcol->roundness * BLI_rcti_size_y(&recttemp);
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
-
+
/* decoration */
if (state & UI_SELECT) {
shape_preset_trias_from_rect_checkmark(&wtb.tria1, &recttemp);
}
-
+
widgetbase_draw(&wtb, wcol);
-
+
/* text space */
rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
}
@@ -3931,12 +3931,12 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
{
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
}
@@ -3945,23 +3945,23 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
uiWidgetBase wtb;
float rad;
char old_col[3];
-
+
widget_init(&wtb);
-
+
copy_v3_v3_char(old_col, wcol->inner);
-
+
/* abuse but->hsv - if it's non-zero, use this color as the box's background */
if (but->col[3]) {
wcol->inner[0] = but->col[0];
wcol->inner[1] = but->col[1];
wcol->inner[2] = but->col[2];
}
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
-
+
copy_v3_v3_char(wcol->inner, old_col);
}
@@ -3969,12 +3969,12 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
{
uiWidgetBase wtb;
float rad;
-
+
widget_init(&wtb);
-
+
rad = wcol->roundness * U.widget_unit;
round_box_edges(&wtb, roundboxalign, rect, rad);
-
+
widgetbase_draw(&wtb, wcol);
}
@@ -3983,9 +3983,9 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
{
uiWidgetBase wtb;
const float rad = wcol->roundness * U.widget_unit;
-
+
widget_init(&wtb);
-
+
/* half rounded */
round_box_edges(&wtb, roundboxalign, rect, rad);
@@ -4077,13 +4077,13 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
/* state copy! */
wt->wcol = *(wt->wcol_theme);
-
+
widget_init(&wtb);
-
+
if (but->block->drawextra) {
/* note: drawextra can change rect +1 or -1, to match round errors of existing previews */
but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect);
-
+
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -4096,7 +4096,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
immUnbindProgram();
}
-
+
/* outline */
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
wtb.draw_outline = true;
@@ -4108,7 +4108,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
{
bTheme *btheme = UI_GetTheme();
static uiWidgetType wt;
-
+
/* defaults */
wt.wcol_theme = &btheme->tui.wcol_regular;
wt.wcol_state = &btheme->tui.wcol_state;
@@ -4116,7 +4116,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.draw = widget_but;
wt.custom = NULL;
wt.text = widget_draw_text_icon;
-
+
switch (type) {
case UI_WTYPE_REGULAR:
break;
@@ -4125,16 +4125,16 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.draw = NULL;
wt.state = widget_state_label;
break;
-
+
case UI_WTYPE_TOGGLE:
wt.wcol_theme = &btheme->tui.wcol_toggle;
break;
-
+
case UI_WTYPE_CHECKBOX:
wt.wcol_theme = &btheme->tui.wcol_option;
wt.draw = widget_optionbut;
break;
-
+
case UI_WTYPE_RADIO:
wt.wcol_theme = &btheme->tui.wcol_radio;
wt.draw = widget_radiobut;
@@ -4144,13 +4144,13 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_num;
wt.draw = widget_numbut;
break;
-
+
case UI_WTYPE_SLIDER:
wt.wcol_theme = &btheme->tui.wcol_numslider;
wt.custom = widget_numslider;
wt.state = widget_state_numslider;
break;
-
+
case UI_WTYPE_EXEC:
wt.wcol_theme = &btheme->tui.wcol_tool;
wt.draw = widget_roundbut_exec;
@@ -4160,7 +4160,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_toolbar_item;
wt.draw = widget_roundbut_exec;
break;
-
+
case UI_WTYPE_TAB:
wt.wcol_theme = &btheme->tui.wcol_tab;
wt.draw = widget_tab;
@@ -4170,24 +4170,24 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_tooltip;
wt.draw = widget_menu_back;
break;
-
-
+
+
/* strings */
case UI_WTYPE_NAME:
wt.wcol_theme = &btheme->tui.wcol_text;
wt.draw = widget_textbut;
break;
-
+
case UI_WTYPE_NAME_LINK:
break;
-
+
case UI_WTYPE_POINTER_LINK:
break;
-
+
case UI_WTYPE_FILENAME:
break;
-
-
+
+
/* start menus */
case UI_WTYPE_MENU_RADIO:
wt.wcol_theme = &btheme->tui.wcol_menu;
@@ -4198,7 +4198,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_menu;
wt.draw = widget_menuiconbut;
break;
-
+
case UI_WTYPE_MENU_POINTER_LINK:
wt.wcol_theme = &btheme->tui.wcol_menu;
wt.draw = widget_menubut;
@@ -4208,20 +4208,20 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_menu;
wt.draw = widget_menunodebut;
break;
-
+
case UI_WTYPE_PULLDOWN:
wt.wcol_theme = &btheme->tui.wcol_pulldown;
wt.draw = widget_pulldownbut;
wt.state = widget_state_pulldown;
break;
-
+
/* in menus */
case UI_WTYPE_MENU_ITEM:
wt.wcol_theme = &btheme->tui.wcol_menu_item;
wt.draw = widget_menu_itembut;
wt.state = widget_state_menu_item;
break;
-
+
case UI_WTYPE_MENU_BACK:
wt.wcol_theme = &btheme->tui.wcol_menu_back;
wt.draw = widget_menu_back;
@@ -4237,19 +4237,19 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.state = widget_state_label;
wt.custom = widget_icon_has_anim;
break;
-
+
case UI_WTYPE_SWATCH:
wt.custom = widget_swatch;
break;
-
+
case UI_WTYPE_BOX:
wt.custom = widget_box;
wt.wcol_theme = &btheme->tui.wcol_box;
break;
-
+
case UI_WTYPE_RGB_PICKER:
break;
-
+
case UI_WTYPE_UNITVEC:
wt.custom = widget_unitvec;
break;
@@ -4264,7 +4264,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme = &btheme->tui.wcol_list_item;
wt.draw = widget_list_itembut;
break;
-
+
case UI_WTYPE_PROGRESSBAR:
wt.wcol_theme = &btheme->tui.wcol_progress;
wt.custom = widget_progressbar;
@@ -4276,7 +4276,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.state = widget_state_pie_menu_item;
break;
}
-
+
return &wt;
}
@@ -4287,13 +4287,13 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
/* alignment */
if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) {
-
+
/* ui_popup_block_position has this correction too, keep in sync */
if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP))
rect->ymax += U.pixelsize;
if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT))
rect->xmin -= U.pixelsize;
-
+
switch (but->drawflag & UI_BUT_ALIGN) {
case UI_BUT_ALIGN_TOP:
roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
@@ -4402,7 +4402,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_SEPR:
case UI_BTYPE_SEPR_LINE:
break;
-
+
case UI_BTYPE_BUT:
#ifdef USE_TOOLBAR_HACK
if (UI_but_is_tool(but)) {
@@ -4419,11 +4419,11 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_NUM:
wt = widget_type(UI_WTYPE_NUMBER);
break;
-
+
case UI_BTYPE_NUM_SLIDER:
wt = widget_type(UI_WTYPE_SLIDER);
break;
-
+
case UI_BTYPE_ROW:
wt = widget_type(UI_WTYPE_RADIO);
break;
@@ -4431,7 +4431,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_LISTROW:
wt = widget_type(UI_WTYPE_LISTITEM);
break;
-
+
case UI_BTYPE_TEXT:
wt = widget_type(UI_WTYPE_NAME);
break;
@@ -4451,7 +4451,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_TOGGLE_N:
wt = widget_type(UI_WTYPE_TOGGLE);
break;
-
+
case UI_BTYPE_CHECKBOX:
case UI_BTYPE_CHECKBOX_N:
if (!(but->flag & UI_HAS_ICON)) {
@@ -4460,13 +4460,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
}
else
wt = widget_type(UI_WTYPE_TOGGLE);
-
+
/* option buttons have strings outside, on menus use different colors */
if (but->block->flag & UI_BLOCK_LOOP)
wt->state = widget_state_option_menu;
-
+
break;
-
+
case UI_BTYPE_MENU:
case UI_BTYPE_BLOCK:
case UI_BTYPE_POPOVER:
@@ -4495,15 +4495,15 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_PULLDOWN:
wt = widget_type(UI_WTYPE_PULLDOWN);
break;
-
+
case UI_BTYPE_BUT_MENU:
wt = widget_type(UI_WTYPE_MENU_ITEM);
break;
-
+
case UI_BTYPE_COLOR:
wt = widget_type(UI_WTYPE_SWATCH);
break;
-
+
case UI_BTYPE_ROUNDBOX:
case UI_BTYPE_LISTBOX:
wt = widget_type(UI_WTYPE_BOX);
@@ -4512,7 +4512,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_EXTRA:
widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect);
break;
-
+
case UI_BTYPE_HSVCUBE:
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */
ui_draw_but_HSV_v(but, rect);
@@ -4521,39 +4521,39 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
ui_draw_but_HSVCUBE(but, rect);
}
break;
-
+
case UI_BTYPE_HSVCIRCLE:
ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_COLORBAND:
ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_UNITVEC:
wt = widget_type(UI_WTYPE_UNITVEC);
break;
-
+
case UI_BTYPE_IMAGE:
ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_HISTOGRAM:
ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_WAVEFORM:
ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_VECTORSCOPE:
ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_CURVE:
ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect);
break;
-
+
case UI_BTYPE_PROGRESS_BAR:
wt = widget_type(UI_WTYPE_PROGRESSBAR);
fstyle = &style->widgetlabel;
@@ -4580,12 +4580,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
}
}
-
+
if (wt) {
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
int roundboxalign, state;
bool disabled = false;
-
+
roundboxalign = widget_roundbox_set(but, rect);
/* Mask out flags re-used for local state. */
@@ -4617,7 +4617,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
if (but->dt != UI_EMBOSS_PULLDOWN)
disabled = true;
-
+
if (disabled)
ui_widget_color_disabled(wt);
@@ -4651,7 +4651,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt->text(fstyle, &wt->wcol, but, rect);
if (disabled)
glDisable(GL_BLEND);
-
+
// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
// if (but->dt != UI_EMBOSS_PULLDOWN)
// widget_disabled(&disablerect);
@@ -4755,7 +4755,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r
if (block) {
float mval_origin[2] = {block->mx, block->my};
ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]);
- ui_draw_popover_back_impl(&wcol_menu_back, rect, block->direction, mval_origin);
+ ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, mval_origin);
}
else {
wt->state(wt, 0);
@@ -4904,7 +4904,7 @@ void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block),
void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
-
+
glEnable(GL_BLEND);
widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
glDisable(GL_BLEND);
@@ -4927,10 +4927,10 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
wt->state(wt, state);
wt->draw(&wt->wcol, rect, 0, 0);
-
+
UI_fontstyle_set(fstyle);
fstyle->align = UI_STYLE_TEXT_LEFT;
-
+
/* text location offset */
rect->xmin += 0.25f * UI_UNIT_X;
if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
@@ -4979,7 +4979,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
*cpoin = UI_SEP_CHAR;
}
}
-
+
/* restore rect, was messed with */
*rect = _rect;
@@ -4990,7 +4990,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
height = ICON_SIZE_FROM_BUTRECT(rect);
aspect = ICON_DEFAULT_HEIGHT / height;
-
+
glEnable(GL_BLEND);
UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f); /* XXX scale weak get from fstyle? */
glDisable(GL_BLEND);
@@ -5003,17 +5003,17 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
const float text_size = UI_UNIT_Y;
float font_dims[2] = {0.0f, 0.0f};
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
-
+
/* drawing button background */
wt->state(wt, state);
wt->draw(&wt->wcol, rect, 0, 0);
-
+
/* draw icon in rect above the space reserved for the label */
rect->ymin += text_size;
glEnable(GL_BLEND);
widget_draw_preview(iconid, 1.0f, rect);
glDisable(GL_BLEND);
-
+
BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
/* text rect */
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 95a7d0a0d06..979a2164199 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -98,16 +98,16 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
static char headerdesel[4] = {0, 0, 0, 255};
static char setting = 0;
const char *cp = error;
-
+
/* ensure we're not getting a color after running BKE_blender_userdef_free */
BLI_assert(BLI_findindex(&U.themes, theme_active) != -1);
BLI_assert(colorid != TH_UNDEFINED);
if (btheme) {
-
+
/* first check for ui buttons theme */
if (colorid < TH_THEMEUI) {
-
+
switch (colorid) {
case TH_REDALERT:
@@ -115,7 +115,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
}
}
else {
-
+
switch (spacetype) {
case SPACE_BUTS:
ts = &btheme->tbuts;
@@ -165,6 +165,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case SPACE_TOPBAR:
ts = &btheme->ttopbar;
break;
+ case SPACE_STATUSBAR:
+ ts = &btheme->tstatusbar;
+ break;
default:
ts = &btheme->tv3d;
break;
@@ -250,7 +253,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = &setting;
setting = ts->panelcolors.show_back;
break;
-
+
case TH_BUTBACK:
cp = ts->button; break;
case TH_BUTBACK_TEXT:
@@ -273,7 +276,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = ts->shade2; break;
case TH_HILITE:
cp = ts->hilite; break;
-
+
case TH_GRID:
cp = ts->grid; break;
case TH_VIEW_OVERLAY:
@@ -524,7 +527,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_HANDLE_VERTEX_SIZE:
cp = &ts->handle_vertex_size;
break;
-
+
case TH_GP_VERTEX:
cp = ts->gp_vertex;
break;
@@ -534,7 +537,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_GP_VERTEX_SIZE:
cp = &ts->gp_vertex_size;
break;
-
+
case TH_DOPESHEET_CHANNELOB:
cp = ts->ds_channel;
break;
@@ -622,21 +625,21 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_SKIN_ROOT:
cp = ts->skin_root;
break;
-
+
case TH_ANIM_ACTIVE:
cp = ts->anim_active;
break;
case TH_ANIM_INACTIVE:
cp = ts->anim_non_active;
break;
-
+
case TH_NLA_TWEAK:
cp = ts->nla_tweaking;
break;
case TH_NLA_TWEAK_DUPLI:
cp = ts->nla_tweakdupli;
break;
-
+
case TH_NLA_TRANSITION:
cp = ts->nla_transition;
break;
@@ -655,7 +658,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_NLA_SOUND_SEL:
cp = ts->nla_sound_sel;
break;
-
+
case TH_WIDGET_EMBOSS:
cp = btheme->tui.widget_emboss; break;
@@ -716,7 +719,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
}
}
}
-
+
return (const unsigned char *)cp;
}
@@ -724,7 +727,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
static void ui_theme_init_boneColorSets(bTheme *btheme)
{
int i;
-
+
/* define default color sets - currently we only define 15 of these, though that should be ample */
/* set 1 */
rgba_char_args_set(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
@@ -786,7 +789,7 @@ static void ui_theme_init_boneColorSets(bTheme *btheme)
rgba_char_args_set(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
rgba_char_args_set(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
rgba_char_args_set(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
-
+
/* reset flags too */
for (i = 0; i < 20; i++)
btheme->tarm[i].flag = 0;
@@ -867,16 +870,16 @@ static void ui_theme_space_init_manipulator_colors(bTheme *btheme)
void ui_theme_init_default(void)
{
bTheme *btheme;
-
+
/* we search for the theme with name Default */
btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
-
+
if (btheme == NULL) {
btheme = MEM_callocN(sizeof(bTheme), "theme");
BLI_addtail(&U.themes, btheme);
strcpy(btheme->name, "Default");
}
-
+
UI_SetTheme(0, 0); /* make sure the global used in this file is set */
/* UI buttons */
@@ -893,13 +896,13 @@ void ui_theme_init_default(void)
btheme->tui.menu_shadow_fac = 0.5f;
btheme->tui.menu_shadow_width = 12;
-
+
/* Bone Color Sets */
ui_theme_init_boneColorSets(btheme);
-
+
/* common (new) variables */
ui_theme_init_new(btheme);
-
+
/* Manipulator. */
ui_theme_space_init_manipulator_colors(btheme);
@@ -907,11 +910,11 @@ void ui_theme_init_default(void)
rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0);
rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
-
+
rgba_char_args_set_fl(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->tv3d.button, 0.45, 0.45, 0.45, 0.5);
// rgba_char_args_set(btheme->tv3d.panel, 165, 165, 165, 127);
-
+
rgba_char_args_set(btheme->tv3d.shade1, 160, 160, 160, 100);
rgba_char_args_set(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100);
@@ -1024,7 +1027,7 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
btheme->tipo.handle_vertex_size = 5;
-
+
rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
@@ -1034,9 +1037,9 @@ void ui_theme_init_default(void)
btheme->tact = btheme->tipo;
rgba_char_args_set(btheme->tact.strip, 12, 10, 10, 128);
rgba_char_args_set(btheme->tact.strip_select, 255, 140, 0, 255);
-
+
rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
-
+
rgba_char_args_set(btheme->tact.keytype_keyframe, 232, 232, 232, 255);
rgba_char_args_set(btheme->tact.keytype_keyframe_select, 255, 190, 50, 255);
rgba_char_args_set(btheme->tact.keytype_extreme, 232, 179, 204, 255);
@@ -1045,31 +1048,31 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255);
rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255);
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
-
+
rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
-
+
btheme->tact.keyframe_scale_fac = 1.0f;
-
+
/* space nla */
btheme->tnla = btheme->tact;
-
+
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
-
+
rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77);
rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
-
+
rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255);
rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255);
rgba_char_args_set(btheme->tnla.nla_meta_sel, 105, 33, 150, 255);
rgba_char_args_set(btheme->tnla.nla_sound, 43, 61, 61, 255);
rgba_char_args_set(btheme->tnla.nla_sound_sel, 31, 122, 122, 255);
-
+
rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
-
+
/* space file */
/* to have something initialized */
btheme->tfile = btheme->tv3d;
@@ -1085,7 +1088,7 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
-
+
/* space seq */
btheme->tseq = btheme->tv3d;
rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255);
@@ -1134,7 +1137,7 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->text.shade1, 143, 143, 143, 255);
rgba_char_args_set(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
rgba_char_args_set(btheme->text.hilite, 255, 0, 0, 255);
-
+
/* syntax highlighting */
rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings Red */
@@ -1144,11 +1147,11 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->text.syntaxr, 140, 60, 0, 255); /* Reserved Orange*/
rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin Red-purple */
rgba_char_args_set(btheme->text.syntaxs, 76, 76, 76, 255); /* Gray (mix between fg/bg) */
-
+
/* space oops */
btheme->toops = btheme->tv3d;
rgba_char_args_set_fl(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
-
+
rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/
rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
@@ -1169,7 +1172,7 @@ void ui_theme_init_default(void)
/* space user preferences */
btheme->tuserpref = btheme->tv3d;
rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
-
+
/* space console */
btheme->tconsole = btheme->tv3d;
rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255);
@@ -1179,16 +1182,16 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tconsole.console_error, 220, 96, 96, 255);
rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255);
rgba_char_args_set(btheme->tconsole.console_select, 255, 255, 255, 48);
-
+
/* space time */
btheme->ttime = btheme->tv3d;
rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */
-
+
rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF);
rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF);
-
+
/* space node, re-uses syntax and console color storage */
btheme->tnode = btheme->tv3d;
rgba_char_args_set(btheme->tnode.syntaxr, 115, 115, 115, 255); /* wire inner color */
@@ -1238,6 +1241,9 @@ void ui_theme_init_default(void)
copy_v4_v4_char(tmp, btheme->ttopbar.header);
copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
copy_v4_v4_char(btheme->ttopbar.back, tmp);
+
+ /* space statusbar */
+ btheme->tstatusbar = btheme->tv3d;
}
void ui_style_init_default(void)
@@ -1291,7 +1297,7 @@ void UI_Theme_Restore(struct bThemeState *theme_state)
void UI_ThemeColor(int colorid)
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor3ubv(cp);
@@ -1301,7 +1307,7 @@ void UI_ThemeColor(int colorid)
void UI_ThemeColor4(int colorid)
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor4ubv(cp);
}
@@ -1318,7 +1324,7 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
{
int r, g, b, a;
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r = coloffset + (int) cp[0];
CLAMP(r, 0, 255);
@@ -1336,7 +1342,7 @@ void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset,
{
int r, g, b, a;
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
r = coloffset + (int) cp[0];
CLAMP(r, 0, 255);
@@ -1392,7 +1398,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
{
int r, g, b;
const unsigned char *cp1, *cp2;
-
+
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -1400,11 +1406,11 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
-
+
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
CLAMP(b, 0, 255);
-
+
glColor3ub(r, g, b);
}
@@ -1413,7 +1419,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
{
int r, g, b, a;
const unsigned char *cp1, *cp2;
-
+
cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
@@ -1422,7 +1428,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
a = alphaoffset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
-
+
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
CLAMP(b, 0, 255);
@@ -1442,7 +1448,7 @@ void UI_FontThemeColor(int fontid, int colorid)
float UI_GetThemeValuef(int colorid)
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((float)cp[0]);
}
@@ -1451,7 +1457,7 @@ float UI_GetThemeValuef(int colorid)
int UI_GetThemeValue(int colorid)
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((int) cp[0]);
}
@@ -1478,7 +1484,7 @@ int UI_GetThemeValueType(int colorid, int spacetype)
void UI_GetThemeColor3fv(int colorid, float col[3])
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
@@ -1488,7 +1494,7 @@ void UI_GetThemeColor3fv(int colorid, float col[3])
void UI_GetThemeColor4fv(int colorid, float col[4])
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
@@ -1501,16 +1507,16 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
{
int r, g, b;
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
-
+
r = offset + (int) cp[0];
CLAMP(r, 0, 255);
g = offset + (int) cp[1];
CLAMP(g, 0, 255);
b = offset + (int) cp[2];
CLAMP(b, 0, 255);
-
+
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
@@ -1644,7 +1650,7 @@ void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int of
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0] = cp[0];
col[1] = cp[1];
@@ -1656,19 +1662,19 @@ void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
{
int r, g, b, a;
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
-
+
r = offset + (int) cp[0];
CLAMP(r, 0, 255);
g = offset + (int) cp[1];
CLAMP(g, 0, 255);
b = offset + (int) cp[2];
CLAMP(b, 0, 255);
-
+
a = (int) cp[3]; /* no shading offset... */
CLAMP(a, 0, 255);
-
+
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
@@ -1679,7 +1685,7 @@ void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
col[0] = cp[0];
col[1] = cp[1];
@@ -1690,7 +1696,7 @@ void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
{
const unsigned char *cp;
-
+
cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
col[0] = cp[0];
col[1] = cp[1];
@@ -1710,7 +1716,7 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c
r = r < 0 ? 0 : (r > 255 ? 255 : r);
g = g < 0 ? 0 : (g > 255 ? 255 : g);
b = b < 0 ? 0 : (b > 255 ? 255 : b);
-
+
glColor3ub(r, g, b);
}
@@ -1755,7 +1761,7 @@ void UI_GetColorPtrBlendShade3ubv(
void UI_ThemeClearColor(int colorid)
{
float col[3];
-
+
UI_GetThemeColor3fv(colorid, col);
glClearColor(col[0], col[1], col[2], 0.0f);
}
@@ -1777,7 +1783,7 @@ int UI_ThemeMenuShadowWidth(void)
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
{
unsigned char col[3];
-
+
switch (axis) {
case 'X':
UI_GetThemeColor3ubv(TH_AXIS_X, col);
@@ -1803,7 +1809,7 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
void init_userdef_do_versions(void)
{
Main *bmain = G.main;
-
+
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
/* the UserDef struct is not corrected with do_versions() .... ugh! */
@@ -1834,12 +1840,12 @@ void init_userdef_do_versions(void)
}
if (U.pad_rot_angle == 0.0f)
U.pad_rot_angle = 15.0f;
-
+
/* graph editor - unselected F-Curve visibility */
if (U.fcu_inactive_alpha == 0) {
U.fcu_inactive_alpha = 0.25f;
}
-
+
/* signal for derivedmesh to use colorband */
/* run in case this was on and is now off in the user prefs [#28096] */
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
@@ -1847,19 +1853,19 @@ void init_userdef_do_versions(void)
if (!USER_VERSION_ATLEAST(192, 0)) {
strcpy(U.sounddir, "/");
}
-
+
/* patch to set Dupli Armature */
if (!USER_VERSION_ATLEAST(220, 0)) {
U.dupflag |= USER_DUP_ARM;
}
-
+
/* added seam, normal color, undo */
if (!USER_VERSION_ATLEAST(235, 0)) {
bTheme *btheme;
-
+
U.uiflag |= USER_GLOBALUNDO;
if (U.undosteps == 0) U.undosteps = 32;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* check for (alpha == 0) is safe, then color was never set */
if (btheme->tv3d.edge_seam[3] == 0) {
@@ -1879,7 +1885,7 @@ void init_userdef_do_versions(void)
}
if (!USER_VERSION_ATLEAST(236, 0)) {
/* illegal combo... */
- if (U.flag & USER_LMOUSESELECT)
+ if (U.flag & USER_LMOUSESELECT)
U.flag &= ~USER_TWOBUTTONMOUSE;
}
if (!USER_VERSION_ATLEAST(237, 0)) {
@@ -1927,15 +1933,15 @@ void init_userdef_do_versions(void)
}
if (!USER_VERSION_ATLEAST(240, 0)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* Lamp theme, check for alpha==0 is safe, then color was never set */
if (btheme->tv3d.lamp[3] == 0) {
rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40);
-/* TEMPORAL, remove me! (ton) */
+/* TEMPORAL, remove me! (ton) */
U.uiflag |= USER_PLAINMENUS;
}
-
+
}
if (U.obcenter_dia == 0) U.obcenter_dia = 6;
}
@@ -1969,19 +1975,19 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
}
}
-
- /* set defaults for 3D View rotating axis indicator */
+
+ /* set defaults for 3D View rotating axis indicator */
/* since size can't be set to 0, this indicates it's not saved in startup.blend */
if (U.rvisize == 0) {
U.rvisize = 15;
U.rvibright = 8;
U.uiflag |= USER_SHOW_ROTVIEWICON;
}
-
+
}
if (!USER_VERSION_ATLEAST(243, 0)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* long keyframe color */
/* check for alpha==0 is safe, then color was never set */
@@ -1990,7 +1996,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
}
-
+
/* IPO-Editor - Vertex Size*/
if (btheme->tipo.vertex_size == 0) {
btheme->tipo.vertex_size = 3;
@@ -2028,7 +2034,7 @@ void init_userdef_do_versions(void)
/* action channel groups (recolor anyway) */
rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
-
+
/* bone custom-color sets */
if (btheme->tarm[0].solid[3] == 0)
ui_theme_init_boneColorSets(btheme);
@@ -2039,18 +2045,18 @@ void init_userdef_do_versions(void)
}
if (!USER_VERSION_ATLEAST(245, 3)) {
bTheme *btheme;
-
+
/* adjust themes */
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
const char *col;
-
+
/* IPO Editor: Handles/Vertices */
col = btheme->tipo.vertex;
rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
col = btheme->tipo.vertex_select;
rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size;
-
+
/* Sequence/Image Editor: colors for GPencil text */
col = btheme->tv3d.bone_pose;
rgba_char_args_set(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
@@ -2061,7 +2067,7 @@ void init_userdef_do_versions(void)
}
if (!USER_VERSION_ATLEAST(250, 0)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* this was not properly initialized in 2.45 */
if (btheme->tima.face_dot[3] == 0) {
@@ -2069,21 +2075,21 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255);
btheme->tima.facedot_size = 2;
}
-
+
/* DopeSheet - (Object) Channel color */
rgba_char_args_set(btheme->tact.ds_channel, 82, 96, 110, 255);
rgba_char_args_set(btheme->tact.ds_subchannel, 124, 137, 150, 255);
/* DopeSheet - Group Channel color (saner version) */
rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255);
rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255);
-
+
/* Graph Editor - (Object) Channel color */
rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
/* Graph Editor - Group Channel color */
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
-
+
/* Nla Editor - (Object) Channel color */
rgba_char_args_set(btheme->tnla.ds_channel, 82, 96, 110, 255);
rgba_char_args_set(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
@@ -2091,20 +2097,20 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tnla.strip, 12, 10, 10, 128);
rgba_char_args_set(btheme->tnla.strip_select, 255, 140, 0, 255);
}
-
+
/* adjust grease-pencil distances */
U.gp_manhattendist = 1;
U.gp_euclideandist = 2;
-
+
/* adjust default interpolation for new IPO-curves */
U.ipo_new = BEZT_IPO_BEZ;
}
-
+
if (!USER_VERSION_ATLEAST(250, 1)) {
bTheme *btheme;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-
+
/* common (new) variables, it checks for alpha==0 */
ui_theme_init_new(btheme);
@@ -2133,10 +2139,10 @@ void init_userdef_do_versions(void)
if (U.audiorate == 0)
U.audiorate = 48000;
}
-
+
if (!USER_VERSION_ATLEAST(250, 8)) {
wmKeyMap *km;
-
+
for (km = U.user_keymaps.first; km; km = km->next) {
if (STREQ(km->idname, "Armature_Sketch"))
strcpy(km->idname, "Armature Sketch");
@@ -2172,17 +2178,17 @@ void init_userdef_do_versions(void)
strcpy(km->idname, "Property Editor");
}
}
-
+
if (!USER_VERSION_ATLEAST(252, 3)) {
- if (U.flag & USER_LMOUSESELECT)
+ if (U.flag & USER_LMOUSESELECT)
U.flag &= ~USER_TWOBUTTONMOUSE;
}
if (!USER_VERSION_ATLEAST(252, 4)) {
bTheme *btheme;
-
+
/* default new handle type is auto handles */
U.keyhandles_new = HD_AUTO;
-
+
/* init new curve colors */
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
ui_theme_space_init_handles_color(&btheme->tv3d);
@@ -2203,21 +2209,21 @@ void init_userdef_do_versions(void)
}
if (!USER_VERSION_ATLEAST(252, 5)) {
bTheme *btheme;
-
+
/* interface_widgets.c */
struct uiWidgetColors wcol_progress = {
{0, 0, 0, 255},
{190, 190, 190, 255},
{100, 100, 100, 180},
{128, 128, 128, 255},
-
+
{0, 0, 0, 255},
{255, 255, 255, 255},
-
+
0,
5, -5
};
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* init progress bar theme */
btheme->tui.wcol_progress = wcol_progress;
@@ -2232,7 +2238,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
}
}
-
+
if (!USER_VERSION_ATLEAST(256, 4)) {
bTheme *btheme;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
@@ -2255,7 +2261,7 @@ void init_userdef_do_versions(void)
if (!USER_VERSION_ATLEAST(259, 1)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
btheme->tv3d.speaker[3] = 255;
}
@@ -2263,23 +2269,23 @@ void init_userdef_do_versions(void)
if (!USER_VERSION_ATLEAST(260, 3)) {
bTheme *btheme;
-
- /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
+
+ /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
* was changed in 260 as part of GSoC11, but version patch was wrong
*/
- if (U.keyhandles_new == HD_AUTO)
+ if (U.keyhandles_new == HD_AUTO)
U.keyhandles_new = HD_AUTO_ANIM;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tv3d.bundle_solid[3] == 0)
rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
-
+
if (btheme->tv3d.camera_path[3] == 0)
rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
-
+
if ((btheme->tclip.back[3]) == 0) {
btheme->tclip = btheme->tv3d;
-
+
rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
rgba_char_args_set(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
@@ -2294,7 +2300,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
btheme->tclip.handle_vertex_size = 5;
}
-
+
/* auto-clamped handles -> based on auto */
if (btheme->tipo.handle_auto_clamped[3] == 0)
rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
@@ -2305,16 +2311,16 @@ void init_userdef_do_versions(void)
/* enable (Cycles) addon by default */
BKE_addon_ensure(&U.addons, "cycles");
}
-
+
if (!USER_VERSION_ATLEAST(260, 5)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
btheme->tui.icon_alpha = 1.0;
}
}
-
+
if (!USER_VERSION_ATLEAST(261, 4)) {
bTheme *btheme;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
@@ -2324,11 +2330,11 @@ void init_userdef_do_versions(void)
rgba_char_args_set_fl(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0);
rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
rgba_char_args_set_fl(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140);
-
+
rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3);
rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
}
-
+
U.use_16bit_textures = true;
}
@@ -2377,21 +2383,21 @@ void init_userdef_do_versions(void)
for (btheme = U.themes.first; btheme; btheme = btheme->next)
rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
}
-
+
if (!USER_VERSION_ATLEAST(263, 7)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* DopeSheet Summary */
- rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
-
+ rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102);
+
/* NLA Colors */
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */
rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
-
+
rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77);
rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
-
+
rgba_char_args_set(btheme->tnla.nla_transition, 28, 38, 48, 255);
rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
rgba_char_args_set(btheme->tnla.nla_meta, 51, 38, 66, 255);
@@ -2440,10 +2446,10 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
}
}
-
+
if (!USER_VERSION_ATLEAST(264, 9)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255);
rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255);
@@ -2496,7 +2502,7 @@ void init_userdef_do_versions(void)
U.ndof_sensitivity = 1.0f;
U.ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE);
}
-
+
if (U.ndof_orbit_sensitivity == 0.0f) {
U.ndof_orbit_sensitivity = U.ndof_sensitivity;
@@ -2509,7 +2515,7 @@ void init_userdef_do_versions(void)
if (!USER_VERSION_ATLEAST(265, 1)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* note: the toggle operator for transparent backdrops limits to these spacetypes */
if (btheme->tnode.button[3] == 255) {
@@ -2521,18 +2527,18 @@ void init_userdef_do_versions(void)
}
}
}
-
+
/* panel header/backdrop supported locally per editor now */
if (!USER_VERSION_ATLEAST(265, 2)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
ThemeSpace *ts;
-
+
/* new color, panel backdrop. Not used anywhere yet, until you enable it */
copy_v3_v3_char(btheme->tui.panel.back, btheme->tbuts.button);
btheme->tui.panel.back[3] = 128;
-
+
for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
ts->panelcolors = btheme->tui.panel;
}
@@ -2545,7 +2551,7 @@ void init_userdef_do_versions(void)
if (!USER_VERSION_ATLEAST(266, 0)) {
bTheme *btheme;
-
+
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* rna definition limits fac to 0.01 */
if (btheme->tui.menu_shadow_fac == 0.0f) {
@@ -2645,7 +2651,7 @@ void init_userdef_do_versions(void)
rgba_char_args_test_set(btheme->tinfo.info_debug_text, 0, 0, 0, 255);
}
}
-
+
if (!USER_VERSION_ATLEAST(269, 9)) {
bTheme *btheme;
/* Action Editor (and NLA Editor) - Keyframe Colors */
@@ -2661,21 +2667,21 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tact.keytype_breakdown_select, 84, 191, 237, 255);
rgba_char_args_set(btheme->tact.keytype_jitter, 148, 229, 117, 255);
rgba_char_args_set(btheme->tact.keytype_jitter_select, 97, 192, 66, 255);
-
+
/* key border */
rgba_char_args_set(btheme->tact.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tact.keyborder_select, 0, 0, 0, 255);
-
+
/* NLA ............................ */
/* key border */
rgba_char_args_set(btheme->tnla.keyborder, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnla.keyborder_select, 0, 0, 0, 255);
-
+
/* Graph Editor ................... */
btheme->tipo.vertex_size = 6;
btheme->tipo.handle_vertex_size = 5;
}
-
+
/* grease pencil - new layer color */
if (U.gpencil_new_layer_col[3] < 0.1f) {
/* defaults to black, but must at least be visible! */
@@ -2761,7 +2767,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 0.02f);
}
}
-
+
if (!USER_VERSION_ATLEAST(273, 1)) {
bTheme *btheme;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
@@ -2769,15 +2775,15 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tv3d.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.gp_vertex_select, 255, 133, 0, 255);
btheme->tv3d.gp_vertex_size = 3;
-
+
rgba_char_args_set(btheme->tseq.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tseq.gp_vertex_select, 255, 133, 0, 255);
btheme->tseq.gp_vertex_size = 3;
-
+
rgba_char_args_set(btheme->tima.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tima.gp_vertex_select, 255, 133, 0, 255);
btheme->tima.gp_vertex_size = 3;
-
+
rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255);
btheme->tnode.gp_vertex_size = 3;
@@ -2874,7 +2880,7 @@ void init_userdef_do_versions(void)
}
}
}
-
+
if (!USER_VERSION_ATLEAST(277, 2)) {
bTheme *btheme;
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
@@ -2940,7 +2946,7 @@ void init_userdef_do_versions(void)
copy_v4_v4_char(btheme->ttopbar.back, tmp);
}
}
-
+
if (!USER_VERSION_ATLEAST(280, 9)) {
/* Timeline removal */
for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
@@ -2948,7 +2954,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tipo.anim_active, 204, 112, 26, 102);
}
if (btheme->tseq.anim_active[3] == 0) {
- rgba_char_args_set(btheme->tseq.anim_active, 204, 112, 26, 102);
+ rgba_char_args_set(btheme->tseq.anim_active, 204, 112, 26, 102);
}
}
}
@@ -3001,6 +3007,12 @@ void init_userdef_do_versions(void)
}
}
+ if (!USER_VERSION_ATLEAST(280, 16)) {
+ for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ btheme->tstatusbar = btheme->tv3d;
+ }
+ }
+
/**
* Include next version bump.
*/
@@ -3016,10 +3028,10 @@ void init_userdef_do_versions(void)
if (U.pixelsize == 0.0f)
U.pixelsize = 1.0f;
-
+
if (U.image_draw_method == 0)
U.image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
-
+
// we default to the first audio device
U.audiodevice = 0;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index c1791998ec7..530a6e28860 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -119,7 +119,7 @@ static int view2d_scroll_mapped(int scroll)
static void view2d_masks(View2D *v2d, bool check_scrollers)
{
int scroll;
-
+
/* mask - view frame */
v2d->mask.xmin = v2d->mask.ymin = 0;
v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */
@@ -144,9 +144,9 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
}
}
}
-
+
scroll = view2d_scroll_mapped(v2d->scroll);
-
+
/* scrollers are based off regionsize
* - they can only be on one to two edges of the region they define
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
@@ -170,7 +170,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */
v2d->vert.xmin = v2d->vert.xmax - scroll_width;
}
-
+
/* horizontal scroller */
if (scroll & (V2D_SCROLL_BOTTOM)) {
/* on bottom edge of region */
@@ -182,7 +182,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers)
v2d->hor = v2d->mask;
v2d->hor.ymin = v2d->hor.ymax - scroll_height;
}
-
+
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
if (scroll & V2D_SCROLL_VERTICAL) {
if (scroll & (V2D_SCROLL_BOTTOM)) {
@@ -225,20 +225,20 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM);
v2d->minzoom = 0.01f;
v2d->maxzoom = 1000.0f;
-
- /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
+
+ /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
* - region can resize 'tot' later to fit other data
* - keeptot is only within bounds, as strict locking is not that critical
* - view is aligned for (0,0) -> (winx-1, winy-1) setup
*/
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
-
+
if (do_init) {
v2d->tot.xmin = v2d->tot.ymin = 0.0f;
v2d->tot.xmax = (float)(winx - 1);
v2d->tot.ymax = (float)(winy - 1);
-
+
v2d->cur = v2d->tot;
}
/* scrollers - should we have these by default? */
@@ -251,28 +251,28 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
v2d->minzoom = v2d->maxzoom = 1.0f;
-
+
/* tot rect has strictly regulated placement, and must only occur in +/- quadrant */
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
tot_changed = do_init;
-
+
/* scroller settings are currently not set here... that is left for regions... */
break;
}
- /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
+ /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
* zoom, aspect ratio, and alignment restrictions are set here */
case V2D_COMMONVIEW_STACK:
{
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
v2d->minzoom = v2d->maxzoom = 1.0f;
-
+
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
tot_changed = do_init;
-
+
/* scroller settings are currently not set here... that is left for regions... */
break;
}
@@ -282,14 +282,14 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
v2d->minzoom = v2d->maxzoom = 1.0f;
-
+
if (do_init) {
v2d->tot.xmin = 0.0f;
v2d->tot.xmax = winx;
v2d->tot.ymin = 0.0f;
v2d->tot.ymax = winy;
v2d->cur = v2d->tot;
-
+
v2d->min[0] = v2d->max[0] = (float)(winx - 1);
v2d->min[1] = v2d->max[1] = (float)(winy - 1);
}
@@ -297,10 +297,10 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
tot_changed = do_init;
-
+
/* panning in y-axis is prohibited */
v2d->keepofs = V2D_LOCKOFS_Y;
-
+
/* absolutely no scrollers allowed */
v2d->scroll = 0;
break;
@@ -308,15 +308,15 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* panels view, with horizontal/vertical align */
case V2D_COMMONVIEW_PANELS_UI:
{
-
+
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM | V2D_KEEPZOOM);
v2d->minzoom = 0.5f;
v2d->maxzoom = 2.0f;
-
+
v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
v2d->keeptot = V2D_KEEPTOT_BOUNDS;
-
+
/* note, scroll is being flipped in ED_region_panels() drawing */
v2d->scroll |= (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE);
@@ -327,16 +327,16 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
if (do_init) {
float panelzoom = (style) ? style->panelzoom : 1.0f;
-
+
v2d->tot.xmin = 0.0f;
v2d->tot.xmax = winx;
-
+
v2d->tot.ymax = 0.0f;
v2d->tot.ymin = -winy;
-
+
v2d->cur.xmin = 0.0f;
v2d->cur.xmax = (winx) * panelzoom;
-
+
v2d->cur.ymax = 0.0f;
v2d->cur.ymin = (-winy) * panelzoom;
}
@@ -347,29 +347,29 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* we don't do anything here, as settings should be fine, but just make sure that rect */
break;
}
-
+
/* set initialized flag so that View2D doesn't get reinitialised next time again */
v2d->flag |= V2D_IS_INITIALISED;
/* store view size */
v2d->winx = winx;
v2d->winy = winy;
-
+
/* set masks (always do), but leave scroller scheck to totrect_set */
view2d_masks(v2d, 0);
-
+
if (do_init) {
/* Visible by default. */
v2d->alpha_hor = v2d->alpha_vert = 255;
}
-
+
/* set 'tot' rect before setting cur? */
/* XXX confusing stuff here still - I made this function not check scroller hide - that happens in totrect_set */
if (tot_changed)
UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init);
else
ui_view2d_curRect_validate_resize(v2d, !do_init, 0);
-
+
}
/**
@@ -382,16 +382,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
float totwidth, totheight, curwidth, curheight, width, height;
float winx, winy;
rctf *cur, *tot;
-
+
/* use mask as size of region that View2D resides in, as it takes into account
* scrollbars already - keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */
winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
-
+
/* get pointers to rcts for less typing */
cur = &v2d->cur;
tot = &v2d->tot;
-
+
/* we must satisfy the following constraints (in decreasing order of importance):
* - alignment restrictions are respected
* - cur must not fall outside of tot
@@ -399,7 +399,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
* - zoom must not be excessive (check either sizes or zoom values)
* - aspect ratio should be respected (NOTE: this is quite closely related to zoom too)
*/
-
+
/* Step 1: if keepzoom, adjust the sizes of the rects only
* - firstly, we calculate the sizes of the rects
* - curwidth and curheight are saved as reference... modify width and height values here
@@ -409,14 +409,14 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* keep in sync with zoomx/zoomy in view_zoomstep_apply_ex! */
curwidth = width = BLI_rctf_size_x(cur);
curheight = height = BLI_rctf_size_y(cur);
-
+
/* if zoom is locked, size on the appropriate axis is reset to mask size */
if (v2d->keepzoom & V2D_LOCKZOOM_X)
width = winx;
if (v2d->keepzoom & V2D_LOCKZOOM_Y)
height = winy;
-
- /* values used to divide, so make it safe
+
+ /* values used to divide, so make it safe
* NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to
* get enough resolution in Graph Editor for editing some curves
*/
@@ -424,7 +424,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (height < FLT_MIN) height = 1;
if (winx < 1) winx = 1;
if (winy < 1) winy = 1;
-
+
/* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */
if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) {
float zoom, oldzoom;
@@ -445,11 +445,11 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
height *= zoom / oldzoom;
}
}
- /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
+ /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
* NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this
*/
else if (v2d->keepzoom & V2D_LIMITZOOM) {
-
+
/* check if excessive zoom on x-axis */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
const float zoom = winx / width;
@@ -460,7 +460,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
width = winx / v2d->maxzoom;
}
}
-
+
/* check if excessive zoom on y-axis */
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
const float zoom = winy / height;
@@ -477,21 +477,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
CLAMP(width, v2d->min[0], v2d->max[0]);
CLAMP(height, v2d->min[1], v2d->max[1]);
}
-
+
/* check if we should restore aspect ratio (if view size changed) */
if (v2d->keepzoom & V2D_KEEPASPECT) {
bool do_x = false, do_y = false, do_cur /* , do_win */ /* UNUSED */;
float curRatio, winRatio;
-
+
/* when a window edge changes, the aspect ratio can't be used to
- * find which is the best new 'cur' rect. thats why it stores 'old'
+ * find which is the best new 'cur' rect. thats why it stores 'old'
*/
if (winx != v2d->oldwinx) do_x = true;
if (winy != v2d->oldwiny) do_y = true;
-
+
curRatio = height / width;
winRatio = winy / winx;
-
+
/* both sizes change (area/region maximized) */
if (do_x == do_y) {
if (do_x && do_y) {
@@ -508,7 +508,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
}
do_cur = do_x;
/* do_win = do_y; */ /* UNUSED */
-
+
if (do_cur) {
if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
/* special exception for Outliner (and later channel-lists):
@@ -518,12 +518,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
*/
if (winx < v2d->oldwinx) {
float temp = v2d->oldwinx - winx;
-
+
cur->xmin -= temp;
cur->xmax -= temp;
-
- /* width does not get modified, as keepaspect here is just set to make
- * sure visible area adjusts to changing view shape!
+
+ /* width does not get modified, as keepaspect here is just set to make
+ * sure visible area adjusts to changing view shape!
*/
}
}
@@ -540,7 +540,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (winy < v2d->oldwiny) {
float temp = v2d->oldwiny - winy;
-
+
if (v2d->align & V2D_ALIGN_NO_NEG_Y) {
cur->ymin -= temp;
cur->ymax -= temp;
@@ -557,16 +557,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
height = width * winRatio;
}
}
-
+
/* store region size for next time */
v2d->oldwinx = (short)winx;
v2d->oldwiny = (short)winy;
}
-
+
/* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
if ((width != curwidth) || (height != curheight)) {
float temp, dh;
-
+
/* resize from centerpoint, unless otherwise specified */
if (width != curwidth) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
@@ -581,7 +581,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
else {
temp = BLI_rctf_cent_x(cur);
dh = width * 0.5f;
-
+
cur->xmin = temp - dh;
cur->xmax = temp + dh;
}
@@ -599,21 +599,21 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
else {
temp = BLI_rctf_cent_y(cur);
dh = height * 0.5f;
-
+
cur->ymin = temp - dh;
cur->ymax = temp + dh;
}
}
}
-
+
/* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */
if (v2d->keeptot) {
float temp, diff;
-
+
/* recalculate extents of cur */
curwidth = BLI_rctf_size_x(cur);
curheight = BLI_rctf_size_y(cur);
-
+
/* width */
if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) {
/* if zoom doesn't have to be maintained, just clamp edges */
@@ -621,28 +621,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (cur->xmax > tot->xmax) cur->xmax = tot->xmax;
}
else if (v2d->keeptot == V2D_KEEPTOT_STRICT) {
- /* This is an exception for the outliner (and later channel-lists, headers)
+ /* This is an exception for the outliner (and later channel-lists, headers)
* - must clamp within tot rect (absolutely no excuses)
* --> therefore, cur->xmin must not be less than tot->xmin
*/
if (cur->xmin < tot->xmin) {
/* move cur across so that it sits at minimum of tot */
temp = tot->xmin - cur->xmin;
-
+
cur->xmin += temp;
cur->xmax += temp;
}
else if (cur->xmax > tot->xmax) {
- /* - only offset by difference of cur-xmax and tot-xmax if that would not move
+ /* - only offset by difference of cur-xmax and tot-xmax if that would not move
* cur-xmin to lie past tot-xmin
* - otherwise, simply shift to tot-xmin???
*/
temp = cur->xmax - tot->xmax;
-
+
if ((cur->xmin - temp) < tot->xmin) {
/* only offset by difference from cur-min and tot-min */
temp = cur->xmin - tot->xmin;
-
+
cur->xmin -= temp;
cur->xmax -= temp;
}
@@ -656,7 +656,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* This here occurs when:
* - width too big, but maintaining zoom (i.e. widths cannot be changed)
* - width is OK, but need to check if outside of boundaries
- *
+ *
* So, resolution is to just shift view by the gap between the extremities.
* We favour moving the 'minimum' across, as that's origin for most things
* (XXX - in the past, max was favored... if there are bugs, swap!)
@@ -665,28 +665,28 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
temp = BLI_rctf_cent_x(tot);
diff = curwidth * 0.5f;
-
+
cur->xmin = temp - diff;
cur->xmax = temp + diff;
}
else if (cur->xmin < tot->xmin) {
/* move cur across so that it sits at minimum of tot */
temp = tot->xmin - cur->xmin;
-
+
cur->xmin += temp;
cur->xmax += temp;
}
else if (cur->xmax > tot->xmax) {
- /* - only offset by difference of cur-xmax and tot-xmax if that would not move
+ /* - only offset by difference of cur-xmax and tot-xmax if that would not move
* cur-xmin to lie past tot-xmin
* - otherwise, simply shift to tot-xmin???
*/
temp = cur->xmax - tot->xmax;
-
+
if ((cur->xmin - temp) < tot->xmin) {
/* only offset by difference from cur-min and tot-min */
temp = cur->xmin - tot->xmin;
-
+
cur->xmin -= temp;
cur->xmax -= temp;
}
@@ -696,7 +696,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
}
}
}
-
+
/* height */
if ((curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM))) {
/* if zoom doesn't have to be maintained, just clamp edges */
@@ -707,7 +707,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* This here occurs when:
* - height too big, but maintaining zoom (i.e. heights cannot be changed)
* - height is OK, but need to check if outside of boundaries
- *
+ *
* So, resolution is to just shift view by the gap between the extremities.
* We favour moving the 'minimum' across, as that's origin for most things
*/
@@ -715,37 +715,37 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
temp = BLI_rctf_cent_y(tot);
diff = curheight * 0.5f;
-
+
cur->ymin = temp - diff;
cur->ymax = temp + diff;
}
else if (cur->ymin < tot->ymin) {
/* there's still space remaining, so shift up */
temp = tot->ymin - cur->ymin;
-
+
cur->ymin += temp;
cur->ymax += temp;
}
else if (cur->ymax > tot->ymax) {
/* there's still space remaining, so shift down */
temp = cur->ymax - tot->ymax;
-
+
cur->ymin -= temp;
cur->ymax -= temp;
}
}
}
-
+
/* Step 4: Make sure alignment restrictions are respected */
if (v2d->align) {
/* If alignment flags are set (but keeptot is not), they must still be respected, as although
- * they don't specify any particular bounds to stay within, they do define ranges which are
+ * they don't specify any particular bounds to stay within, they do define ranges which are
* invalid.
*
- * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
+ * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
* invalid zones, otherwise we offset.
*/
-
+
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* width is in negative-x half */
@@ -761,7 +761,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
v2d->cur.xmin = 0.0f;
}
}
-
+
/* handle height - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* height is in negative-y half */
@@ -778,7 +778,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
}
}
}
-
+
/* set masks */
view2d_masks(v2d, mask_scrollers);
}
@@ -795,11 +795,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
{
ScrArea *sa;
ARegion *ar;
-
+
/* don't continue if no view syncing to be done */
if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
return;
-
+
/* check if doing within area syncing (i.e. channels/vertical) */
if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) {
for (ar = area->regionbase.first; ar; ar = ar->next) {
@@ -817,14 +817,14 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
v2dcur->cur.ymin = ar->v2d.cur.ymin;
v2dcur->cur.ymax = ar->v2d.cur.ymax;
}
-
+
/* region possibly changed, so refresh */
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
}
}
}
}
-
+
/* check if doing whole screen syncing (i.e. time/horizontal) */
if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) {
for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -843,9 +843,9 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
v2dcur->cur.xmin = ar->v2d.cur.xmin;
v2dcur->cur.xmax = ar->v2d.cur.xmax;
}
-
+
/* region possibly changed, so refresh */
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
}
}
}
@@ -861,11 +861,11 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
void UI_view2d_curRect_reset(View2D *v2d)
{
float width, height;
-
+
/* assume width and height of 'cur' rect by default, should be same size as mask */
width = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
height = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
-
+
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* width is in negative-x half */
@@ -880,11 +880,11 @@ void UI_view2d_curRect_reset(View2D *v2d)
else {
/* width is centered around (x == 0) */
const float dx = width / 2.0f;
-
+
v2d->cur.xmin = -dx;
v2d->cur.xmax = dx;
}
-
+
/* handle height - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* height is in negative-y half */
@@ -899,7 +899,7 @@ void UI_view2d_curRect_reset(View2D *v2d)
else {
/* height is centered around (y == 0) */
const float dy = height / 2.0f;
-
+
v2d->cur.ymin = -dy;
v2d->cur.ymax = dy;
}
@@ -911,11 +911,11 @@ void UI_view2d_curRect_reset(View2D *v2d)
void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
{
// int scroll = view2d_scroll_mapped(v2d->scroll);
-
+
/* don't do anything if either value is 0 */
width = abs(width);
height = abs(height);
-
+
/* hrumf! */
/* XXX: there are work arounds for this in the panel and file browse code. */
/* round to int, because this is called with width + V2D_SCROLL_WIDTH */
@@ -923,13 +923,13 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
// width -= (int)V2D_SCROLL_WIDTH;
// if (scroll & V2D_SCROLL_VERTICAL)
// height -= (int)V2D_SCROLL_HEIGHT;
-
+
if (ELEM(0, width, height)) {
if (G.debug & G_DEBUG)
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info
return;
}
-
+
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* width is in negative-x half */
@@ -944,11 +944,11 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
else {
/* width is centered around (x == 0) */
const float dx = (float)width / 2.0f;
-
+
v2d->tot.xmin = -dx;
v2d->tot.xmax = dx;
}
-
+
/* handle height - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* height is in negative-y half */
@@ -963,14 +963,14 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
else {
/* height is centered around (y == 0) */
const float dy = (float)height / 2.0f;
-
+
v2d->tot.ymin = -dy;
v2d->tot.ymax = dy;
}
-
+
/* make sure that 'cur' rect is in a valid state as a result of these changes */
ui_view2d_curRect_validate_resize(v2d, resize, 1);
-
+
}
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
@@ -978,12 +978,12 @@ void UI_view2d_totRect_set(View2D *v2d, int width, int height)
int scroll = view2d_scroll_mapped(v2d->scroll);
UI_view2d_totRect_set_resize(v2d, width, height, 0);
-
+
/* solve bad recursion... if scroller state changed, mask is different, so you get different rects */
if (scroll != view2d_scroll_mapped(v2d->scroll)) {
UI_view2d_totRect_set_resize(v2d, width, height, 0);
}
-
+
}
bool UI_view2d_tab_set(View2D *v2d, int tab)
@@ -1054,21 +1054,21 @@ void UI_view2d_zoom_cache_reset(void)
static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
{
*curmasked = v2d->cur;
-
+
if (view2d_scroll_mapped(v2d->scroll)) {
float sizex = BLI_rcti_size_x(&v2d->mask);
float sizey = BLI_rcti_size_y(&v2d->mask);
-
+
/* prevent tiny or narrow regions to get invalid coordinates - mask can get negative even... */
if (sizex > 0.0f && sizey > 0.0f) {
float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
-
+
if (v2d->mask.xmin != 0)
curmasked->xmin -= dx * (float)v2d->mask.xmin;
if (v2d->mask.xmax + 1 != v2d->winx)
curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
-
+
if (v2d->mask.ymin != 0)
curmasked->ymin -= dy * (float)v2d->mask.ymin;
if (v2d->mask.ymax + 1 != v2d->winy)
@@ -1085,7 +1085,7 @@ void UI_view2d_view_ortho(View2D *v2d)
const int sizey = BLI_rcti_size_y(&v2d->mask);
const float eps = 0.001f;
float xofs = 0.0f, yofs = 0.0f;
-
+
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
*/
@@ -1095,12 +1095,12 @@ void UI_view2d_view_ortho(View2D *v2d)
xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex;
if (sizey > 0)
yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey;
-
+
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
BLI_rctf_translate(&curmasked, -xofs, -yofs);
-
+
/* XXX ton: this flag set by outliner, for icons */
if (v2d->flag & V2D_PIXELOFS_X) {
curmasked.xmin = floorf(curmasked.xmin) - (eps + xofs);
@@ -1110,7 +1110,7 @@ void UI_view2d_view_ortho(View2D *v2d)
curmasked.ymin = floorf(curmasked.ymin) - (eps + yofs);
curmasked.ymax = floorf(curmasked.ymax) - (eps + yofs);
}
-
+
/* set matrix on all appropriate axes */
wmOrtho2(curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
}
@@ -1124,23 +1124,23 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis)
{
rctf curmasked;
float xofs, yofs;
-
+
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
*/
/* XXX temp (ton) */
xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f;
-
+
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
-
+
/* only set matrix with 'cur' coordinates on relevant axes */
if (xaxis)
wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs);
else
wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
-}
+}
/* Restore view matrices after drawing */
@@ -1149,10 +1149,10 @@ void UI_view2d_view_restore(const bContext *C)
ARegion *ar = CTX_wm_region(C);
int width = BLI_rcti_size_x(&ar->winrct) + 1;
int height = BLI_rcti_size_y(&ar->winrct) + 1;
-
+
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
gpuLoadIdentity();
-
+
// ED_region_pixelspace(CTX_wm_region(C));
}
@@ -1173,25 +1173,25 @@ static void step_to_grid(float *step, int *power, int unit)
{
const float loga = (float)log10(*step);
float rem;
-
+
*power = (int)(loga);
-
+
rem = loga - (*power);
rem = (float)pow(10.0, rem);
-
+
if (loga < 0.0f) {
if (rem < 0.2f) rem = 0.2f;
else if (rem < 0.5f) rem = 0.5f;
else rem = 1.0f;
-
+
*step = rem * (float)pow(10.0, (*power));
-
+
/* for frames, we want 1.0 frame intervals only */
if (unit == V2D_UNIT_FRAMES) {
rem = 1.0f;
*step = 2.0f; /* use 2 since there are grid lines drawn in between, this way to get 1 line per frane */
}
-
+
/* prevents printing 1.0 2.0 3.0 etc */
if (rem == 1.0f) (*power)++;
}
@@ -1199,9 +1199,9 @@ static void step_to_grid(float *step, int *power, int unit)
if (rem < 2.0f) rem = 2.0f;
else if (rem < 5.0f) rem = 5.0f;
else rem = 10.0f;
-
+
*step = rem * (float)pow(10.0, (*power));
-
+
(*power)++;
/* prevents printing 1.0, 2.0, 3.0, etc. */
if (rem == 10.0f) (*power)++;
@@ -1229,14 +1229,14 @@ View2DGrid *UI_view2d_grid_calc(
View2DGrid *grid;
float space, seconddiv;
-
+
/* check that there are at least some workable args */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp))
return NULL;
-
+
/* grid here is allocated... */
grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
-
+
/* rule: gridstep is minimal GRIDSTEP pixels */
if (xunits == V2D_UNIT_SECONDS) {
seconddiv = (float)(0.01 * FPS);
@@ -1244,7 +1244,7 @@ View2DGrid *UI_view2d_grid_calc(
else {
seconddiv = 1.0f;
}
-
+
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
space = BLI_rctf_size_x(&v2d->cur);
@@ -1257,14 +1257,14 @@ View2DGrid *UI_view2d_grid_calc(
grid->dx *= seconddiv;
}
}
-
+
if (xclamp == V2D_GRID_CLAMP) {
CLAMP_MIN(grid->dx, 0.1f);
CLAMP_MIN(grid->powerx, 0);
grid->powerx -= 2;
}
}
-
+
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
space = BLI_rctf_size_y(&v2d->cur);
@@ -1281,7 +1281,7 @@ View2DGrid *UI_view2d_grid_calc(
CLAMP_MIN(grid->powery, 1);
}
}
-
+
/* calculate start position */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
@@ -1289,14 +1289,14 @@ View2DGrid *UI_view2d_grid_calc(
}
else
grid->startx = v2d->cur.xmin;
-
+
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy;
}
else
grid->starty = v2d->cur.ymin;
-
+
return grid;
}
@@ -1308,7 +1308,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC),
horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
unsigned char grid_line_color[3];
-
+
/* check for grid first, as it may not exist */
if (grid == NULL)
return;
@@ -1351,47 +1351,47 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec1[0] = vec2[0] = grid->startx;
vec1[1] = grid->starty;
vec2[1] = v2d->cur.ymax;
-
+
/* minor gridlines */
step = vertical_minor_step;
if (step != 0) {
UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
-
+
for (a = 0; a < step; a++) {
immSkipAttrib(color);
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
immVertex2fv(pos, vec2);
-
+
vec2[0] = vec1[0] += grid->dx;
}
}
-
+
/* major gridlines */
vec2[0] = vec1[0] -= 0.5f * grid->dx;
UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
-
+
step++;
for (a = 0; a <= step; a++) {
immSkipAttrib(color);
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
immVertex2fv(pos, vec2);
-
+
vec2[0] = vec1[0] -= grid->dx;
}
}
-
+
/* horizontal lines */
if (flag & V2D_HORIZONTAL_LINES) {
/* only major gridlines */
vec1[1] = vec2[1] = grid->starty;
vec1[0] = grid->startx;
vec2[0] = v2d->cur.xmax;
-
+
step = horizontal_major_step;
-
+
UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
for (a = 0; a <= step; a++) {
@@ -1399,14 +1399,14 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
immVertex2fv(pos, vec2);
-
+
vec2[1] = vec1[1] += grid->dy;
}
-
+
/* fine grid lines */
vec2[1] = vec1[1] -= 0.5f * grid->dy;
step++;
-
+
if (flag & V2D_HORIZONTAL_FINELINES) {
UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
for (a = 0; a < step; a++) {
@@ -1414,33 +1414,33 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
immVertex2fv(pos, vec2);
-
+
vec2[1] = vec1[1] -= grid->dy;
}
}
}
-
+
/* Axes are drawn as darker lines */
UI_GetThemeColorShade3ubv(TH_GRID, -50, grid_line_color);
-
+
/* horizontal axis */
if (flag & V2D_HORIZONTAL_AXIS) {
vec1[0] = v2d->cur.xmin;
vec2[0] = v2d->cur.xmax;
vec1[1] = vec2[1] = 0.0f;
-
+
immSkipAttrib(color);
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
immVertex2fv(pos, vec2);
}
-
+
/* vertical axis */
if (flag & V2D_VERTICAL_AXIS) {
vec1[1] = v2d->cur.ymin;
vec2[1] = v2d->cur.ymax;
vec1[0] = vec2[0] = 0.0f;
-
+
immSkipAttrib(color);
immVertex2fv(pos, vec1);
immAttrib3ubv(color, grid_line_color);
@@ -1456,7 +1456,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
{
float start_x, start_y;
int count_x, count_y;
-
+
start_x = v2d->cur.xmin;
if (start_x < 0.0)
start_x += -(float)fmod(v2d->cur.xmin, step);
@@ -1478,7 +1478,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
count_y = 0;
else
count_y = (v2d->cur.ymax - start_y) / step + 1;
-
+
if (count_x > 0 || count_y > 0) {
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1486,10 +1486,10 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
float theme_color[3];
UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color);
-
+
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4);
-
+
immAttrib3fv(color, theme_color);
for (int i = 0; i < count_x ; start_x += step, i++) {
immVertex2f(pos, start_x, v2d->cur.ymin);
@@ -1500,16 +1500,16 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
immVertex2f(pos, v2d->cur.xmin, start_y);
immVertex2f(pos, v2d->cur.xmax, start_y);
}
-
+
/* X and Y axis */
UI_GetThemeColorShade3fv(TH_BACK, -18, theme_color);
-
+
immAttrib3fv(color, theme_color);
immVertex2f(pos, 0.0f, v2d->cur.ymin);
immVertex2f(pos, 0.0f, v2d->cur.ymax);
immVertex2f(pos, v2d->cur.xmin, 0.0f);
immVertex2f(pos, v2d->cur.xmax, 0.0f);
-
+
immEnd();
immUnbindProgram();
}
@@ -1542,12 +1542,12 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
for (int level = 0; level < totlevels; ++level) {
UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color);
-
+
int i = (int)(v2d->cur.xmin / lstep);
if (v2d->cur.xmin > 0.0f)
i++;
float start = i * lstep;
-
+
for (; start < v2d->cur.xmax; start += lstep, ++i) {
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
@@ -1557,12 +1557,12 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
immAttrib3ubv(color, grid_line_color);
immVertex2f(pos, start, v2d->cur.ymax);
}
-
+
i = (int)(v2d->cur.ymin / lstep);
if (v2d->cur.ymin > 0.0f)
i++;
start = i * lstep;
-
+
for (; start < v2d->cur.ymax; start += lstep, ++i) {
if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
continue;
@@ -1572,7 +1572,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
immAttrib3ubv(color, grid_line_color);
immVertex2f(pos, v2d->cur.xmax, start);
}
-
+
lstep *= level_size;
offset -= 6;
}
@@ -1623,10 +1623,10 @@ struct View2DScrollers {
/* focus bubbles */
int vert_min, vert_max; /* vertical scrollbar */
int hor_min, hor_max; /* horizontal scrollbar */
-
+
rcti hor, vert; /* exact size of slider backdrop */
int horfull, vertfull; /* set if sliders are full, we don't draw them */
-
+
/* scales */
View2DGrid *grid; /* grid for coordinate drawing */
short xunits, xclamp; /* units and clamping options for x-axis */
@@ -1643,16 +1643,16 @@ View2DScrollers *UI_view2d_scrollers_calc(
float fac1, fac2, totsize, scrollsize;
int scroll = view2d_scroll_mapped(v2d->scroll);
int smaller;
-
+
/* scrollers is allocated here... */
scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
-
+
/* Always update before drawing (for dynamically sized scrollers). */
view2d_masks(v2d, false);
-
+
vert = v2d->vert;
hor = v2d->hor;
-
+
/* slider rects need to be smaller than region */
smaller = (int)(0.1f * U.widget_unit);
hor.xmin += smaller;
@@ -1661,26 +1661,26 @@ View2DScrollers *UI_view2d_scrollers_calc(
hor.ymin += smaller;
else
hor.ymax -= smaller;
-
+
if (scroll & V2D_SCROLL_LEFT)
vert.xmin += smaller;
else
vert.xmax -= smaller;
vert.ymin += smaller;
vert.ymax -= smaller;
-
+
CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
-
+
/* store in scrollers, used for drawing */
scrollers->vert = vert;
scrollers->hor = hor;
-
+
/* scroller 'buttons':
* - These should always remain within the visible region of the scrollbar
* - They represent the region of 'tot' that is visible in 'cur'
*/
-
+
/* horizontal scrollers */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
@@ -1693,15 +1693,15 @@ View2DScrollers *UI_view2d_scrollers_calc(
scrollers->hor_min = hor.xmin;
else
scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize));
-
+
fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
if (fac2 >= 1.0f)
scrollers->hor_max = hor.xmax;
else
scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize));
-
+
/* prevent inverted sliders */
- if (scrollers->hor_min > scrollers->hor_max)
+ if (scrollers->hor_min > scrollers->hor_max)
scrollers->hor_min = scrollers->hor_max;
/* prevent sliders from being too small, and disappearing */
if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) {
@@ -1710,9 +1710,9 @@ View2DScrollers *UI_view2d_scrollers_calc(
CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLLER_HANDLE_SIZE, hor.xmax);
CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
}
-
+
}
-
+
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
@@ -1725,27 +1725,27 @@ View2DScrollers *UI_view2d_scrollers_calc(
scrollers->vert_min = vert.ymin;
else
scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize));
-
+
fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
if (fac2 >= 1.0f)
scrollers->vert_max = vert.ymax;
else
scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize));
-
+
/* prevent inverted sliders */
- if (scrollers->vert_min > scrollers->vert_max)
+ if (scrollers->vert_min > scrollers->vert_max)
scrollers->vert_min = scrollers->vert_max;
/* prevent sliders from being too small, and disappearing */
if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) {
-
+
scrollers->vert_max = scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE;
-
+
CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLLER_HANDLE_SIZE, vert.ymax);
CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
}
}
-
+
/* grid markings on scrollbars */
if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) {
/* store clamping */
@@ -1753,12 +1753,12 @@ View2DScrollers *UI_view2d_scrollers_calc(
scrollers->xunits = xunits;
scrollers->yclamp = yclamp;
scrollers->yunits = yunits;
-
+
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
xunits, xclamp, yunits, yclamp,
BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert));
}
-
+
/* return scrollers */
return scrollers;
}
@@ -1768,11 +1768,11 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
{
int len;
char timecode_str[32];
-
+
/* adjust the scale unit to work ok */
if (dir == 'v') {
- /* here we bump up the power by factor of 10, as
- * rotation values (hence 'degrees') are divided by 10 to
+ /* here we bump up the power by factor of 10, as
+ * rotation values (hence 'degrees') are divided by 10 to
* be able to show the curves at the same time
*/
if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) {
@@ -1780,7 +1780,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
val *= 10;
}
}
-
+
/* get string to print */
if (unit == V2D_UNIT_SECONDS) {
/* not neces*/
@@ -1789,7 +1789,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
else {
BLI_timecode_string_from_time_seconds(timecode_str, sizeof(timecode_str), power, val);
}
-
+
/* get length of string, and adjust printing location to fit it into the horizontal scrollbar */
len = strlen(timecode_str);
if (dir == 'h') {
@@ -1799,13 +1799,13 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
else
x -= 4 * len;
}
-
+
/* Add degree sympbol to end of string for vertical scrollbar? */
if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) {
timecode_str[len] = 186;
timecode_str[len + 1] = 0;
}
-
+
/* draw it */
BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str));
}
@@ -1822,35 +1822,35 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* Color for scrollbar backs */
UI_GetThemeColor4ubv(TH_BACK, scrollers_back_color);
-
+
/* make copies of rects for less typing */
vert = vs->vert;
hor = vs->hor;
-
+
/* horizontal scrollbar */
if (scroll & V2D_SCROLL_HORIZONTAL) {
uiWidgetColors wcol = btheme->tui.wcol_scroll;
const float alpha_fac = v2d->alpha_hor / 255.0f;
rcti slider;
int state;
-
+
slider.xmin = vs->hor_min;
slider.xmax = vs->hor_max;
slider.ymin = hor.ymin;
slider.ymax = hor.ymax;
-
+
state = (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE) ? UI_SCROLL_PRESSED : 0;
-
+
wcol.inner[3] *= alpha_fac;
wcol.item[3] *= alpha_fac;
wcol.outline[3] *= alpha_fac;
btheme->tui.widget_emboss[3] *= alpha_fac; /* will be reset later */
-
+
/* show zoom handles if:
* - zooming on x-axis is allowed (no scroll otherwise)
* - slider bubble is large enough (no overdraw confusion)
- * - scale is shown on the scroller
- * (workaround to make sure that button windows don't show these,
+ * - scale is shown on the scroller
+ * (workaround to make sure that button windows don't show these,
* and only the time-grids with their zoomability can do so)
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
@@ -1861,27 +1861,27 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_draw_widget_scroll(&wcol, &hor, &slider, state);
-
+
/* scale indicators */
if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
const int font_id = BLF_default();
View2DGrid *grid = vs->grid;
float fac, dfac, fac2, val;
-
- /* the numbers: convert grid->startx and -dx to scroll coordinates
+
+ /* the numbers: convert grid->startx and -dx to scroll coordinates
* - fac is x-coordinate to draw to
* - dfac is gap between scale markings
*/
fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor);
-
+
dfac = grid->dx / BLI_rctf_size_x(&v2d->cur);
dfac = dfac * BLI_rcti_size_x(&hor);
-
+
/* set starting value, and text color */
UI_FontThemeColor(font_id, TH_TEXT);
val = grid->startx;
-
+
/* if we're clamping to whole numbers only, make sure entries won't be repeated */
if (vs->xclamp == V2D_GRID_CLAMP) {
while (grid->dx < 0.9999f) {
@@ -1899,25 +1899,25 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
BLF_batch_draw_begin();
for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) {
-
+
/* make prints look nicer for scrollers */
if (fac < hor.xmin + 0.5f * U.widget_unit)
continue;
-
+
switch (vs->xunits) {
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
break;
-
+
case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
break;
-
+
case V2D_UNIT_SECONDS: /* seconds */
fac2 = val / (float)FPS;
scroll_printstr(scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
break;
-
+
case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */
/* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v');
@@ -1929,31 +1929,31 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
}
}
-
+
/* vertical scrollbar */
if (scroll & V2D_SCROLL_VERTICAL) {
uiWidgetColors wcol = btheme->tui.wcol_scroll;
rcti slider;
const float alpha_fac = v2d->alpha_vert / 255.0f;
int state;
-
+
slider.xmin = vert.xmin;
slider.xmax = vert.xmax;
slider.ymin = vs->vert_min;
slider.ymax = vs->vert_max;
-
+
state = (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE) ? UI_SCROLL_PRESSED : 0;
-
+
wcol.inner[3] *= alpha_fac;
wcol.item[3] *= alpha_fac;
wcol.outline[3] *= alpha_fac;
btheme->tui.widget_emboss[3] *= alpha_fac; /* will be reset later */
-
+
/* show zoom handles if:
* - zooming on y-axis is allowed (no scroll otherwise)
* - slider bubble is large enough (no overdraw confusion)
- * - scale is shown on the scroller
- * (workaround to make sure that button windows don't show these,
+ * - scale is shown on the scroller
+ * (workaround to make sure that button windows don't show these,
* and only the time-grids with their zoomability can do so)
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
@@ -1962,16 +1962,16 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
{
state |= UI_SCROLL_ARROWS;
}
-
+
UI_draw_widget_scroll(&wcol, &vert, &slider, state);
-
-
+
+
/* scale indiators */
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
View2DGrid *grid = vs->grid;
float fac, dfac, val;
-
- /* the numbers: convert grid->starty and dy to scroll coordinates
+
+ /* the numbers: convert grid->starty and dy to scroll coordinates
* - fac is y-coordinate to draw to
* - dfac is gap between scale markings
* - these involve a correction for horizontal scrollbar
@@ -1979,38 +1979,38 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
fac = vert.ymin + fac * BLI_rcti_size_y(&vert);
-
+
dfac = grid->dy / BLI_rctf_size_y(&v2d->cur);
dfac = dfac * BLI_rcti_size_y(&vert);
-
+
/* set starting value, and text color */
const int font_id = BLF_default();
UI_FontThemeColor(font_id, TH_TEXT);
val = grid->starty;
-
+
/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */
if (vs->yclamp == V2D_GRID_CLAMP)
fac += 0.5f * dfac;
-
+
/* draw vertical steps */
if (dfac > 0.0f) {
BLF_rotation(font_id, M_PI_2);
BLF_enable(font_id, BLF_ROTATION);
for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) {
-
+
/* make prints look nicer for scrollers */
if (fac < vert.ymin + 10)
continue;
-
+
scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
-
+
BLF_disable(font_id, BLF_ROTATION);
}
}
}
-
+
/* Was changed above, so reset. */
btheme->tui.widget_emboss[3] = emboss_alpha;
}
@@ -2055,21 +2055,21 @@ void UI_view2d_listview_cell_to_view(
rect->ymin = rect->ymax = 0.0f;
return;
}
-
+
/* x-coordinates */
rect->xmin = startx + (float)(columnwidth * column);
rect->xmax = startx + (float)(columnwidth * (column + 1));
-
+
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
/* simply negate the values for the coordinates if in negative half */
rect->xmin = -rect->xmin;
rect->xmax = -rect->xmax;
}
-
+
/* y-coordinates */
rect->ymin = starty + (float)(rowheight * row);
rect->ymax = starty + (float)(rowheight * (row + 1));
-
+
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
/* simply negate the values for the coordinates if in negative half */
rect->ymin = -rect->ymin;
@@ -2095,21 +2095,21 @@ void UI_view2d_listview_view_to_cell(
/* adjust view coordinates to be all positive ints, corrected for the start offset */
const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx);
const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty);
-
+
/* sizes must not be negative */
if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) {
if (column) *column = 0;
if (row) *row = 0;
-
+
return;
}
-
+
/* get column */
if ((column) && (columnwidth > 0))
*column = x / columnwidth;
else if (column)
*column = 0;
-
+
/* get row */
if ((row) && (rowheight > 0))
*row = y / rowheight;
@@ -2131,11 +2131,11 @@ void UI_view2d_listview_visible_cells(
/* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */
if (v2d) {
/* min */
- UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
+ UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
/* max*/
- UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
+ UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
}
}
@@ -2196,7 +2196,7 @@ bool UI_view2d_view_to_region_clip(View2D *v2d, float x, float y, int *r_region_
/* express given coordinates as proportional values */
x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
-
+
/* check if values are within bounds */
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
*r_region_x = (int)(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
@@ -2348,7 +2348,7 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
*
* \param x, y: scale on each axis
*/
-void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
+void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
{
if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
@@ -2423,11 +2423,11 @@ short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y)
{
int co[2];
int scroll = view2d_scroll_mapped(v2d->scroll);
-
+
/* clamp x,y to region-coordinates first */
co[0] = x - ar->winrct.xmin;
co[1] = y - ar->winrct.ymin;
-
+
/* check if within scrollbars */
if (scroll & V2D_SCROLL_HORIZONTAL) {
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
@@ -2435,7 +2435,7 @@ short UI_view2d_mouse_in_scrollers(const ARegion *ar, View2D *v2d, int x, int y)
if (scroll & V2D_SCROLL_VERTICAL) {
if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
}
-
+
/* not found */
return 0;
}
@@ -2464,7 +2464,7 @@ void UI_view2d_text_cache_add(
const char *str, size_t str_len, const char col[4])
{
int mval[2];
-
+
BLI_assert(str_len == strlen(str));
if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) {
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 4101230c1ab..fbc8fe790c9 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -17,7 +17,7 @@
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
@@ -73,7 +73,7 @@ static int view2d_poll(bContext *C)
*/
/* ------------------ Shared 'core' stuff ---------------------- */
-
+
/* temp customdata for operator */
typedef struct v2dViewPanData {
bScreen *sc; /* screen where view pan was initiated */
@@ -87,10 +87,10 @@ typedef struct v2dViewPanData {
int startx, starty; /* mouse x/y values in window when operator was initiated */
int lastx, lasty; /* previous x/y values of mouse in window */
int invoke_event; /* event starting pan, for modal exit */
-
+
short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */
} v2dViewPanData;
-
+
/* initialize panning customdata */
static int view_pan_init(bContext *C, wmOperator *op)
{
@@ -98,32 +98,32 @@ static int view_pan_init(bContext *C, wmOperator *op)
v2dViewPanData *vpd;
View2D *v2d;
float winx, winy;
-
+
/* regions now have v2d-data by default, so check for region */
if (ar == NULL)
return 0;
-
+
/* check if panning is allowed at all */
v2d = &ar->v2d;
if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y))
return 0;
-
+
/* set custom-data for operator */
vpd = MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
op->customdata = vpd;
-
+
/* set pointers to owners */
vpd->sc = CTX_wm_screen(C);
vpd->sa = CTX_wm_area(C);
vpd->v2d = v2d;
vpd->ar = ar;
-
+
/* calculate translation factor - based on size of view */
winx = (float)(BLI_rcti_size_x(&ar->winrct) + 1);
winy = (float)(BLI_rcti_size_y(&ar->winrct) + 1);
vpd->facx = (BLI_rctf_size_x(&v2d->cur)) / winx;
vpd->facy = (BLI_rctf_size_y(&v2d->cur)) / winy;
-
+
return 1;
}
@@ -151,11 +151,11 @@ static int view_pan_poll(bContext *C)
static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float dy)
{
View2D *v2d = vpd->v2d;
-
+
/* calculate amount to move view by */
dx *= vpd->facx;
dy *= vpd->facy;
-
+
/* only move view on an axis if change is allowed */
if ((v2d->keepofs & V2D_LOCKOFS_X) == 0) {
v2d->cur.xmin += dx;
@@ -165,18 +165,12 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
v2d->cur.ymin += dy;
v2d->cur.ymax += dy;
}
-
+
/* validate that view is in valid configuration after this operation */
UI_view2d_curRect_validate(v2d);
-
- /* exceptions */
- if (vpd->sa->spacetype == SPACE_OUTLINER) {
- /* don't rebuild full tree, since we're just changing our view */
- ED_region_tag_redraw_no_rebuild(vpd->ar);
- }
- else {
- ED_region_tag_redraw(vpd->ar);
- }
+
+ /* don't rebuild full tree in outliner, since we're just changing our view */
+ ED_region_tag_redraw_no_rebuild(vpd->ar);
/* request updates to be done... */
WM_event_add_mousemove(C);
@@ -201,8 +195,8 @@ static void view_pan_exit(wmOperator *op)
MEM_freeN(op->customdata);
op->customdata = NULL;
}
-}
-
+}
+
/* ------------------ Modal Drag Version (1) ---------------------- */
/* for 'redo' only, with no user input */
@@ -210,7 +204,7 @@ static int view_pan_exec(bContext *C, wmOperator *op)
{
if (!view_pan_init(C, op))
return OPERATOR_CANCELLED;
-
+
view_pan_apply(C, op);
view_pan_exit(op);
return OPERATOR_FINISHED;
@@ -222,38 +216,38 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *window = CTX_wm_window(C);
v2dViewPanData *vpd;
View2D *v2d;
-
+
/* set up customdata */
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
vpd = op->customdata;
v2d = vpd->v2d;
-
+
/* set initial settings */
vpd->startx = vpd->lastx = event->x;
vpd->starty = vpd->lasty = event->y;
vpd->invoke_event = event->type;
-
+
if (event->type == MOUSEPAN) {
RNA_int_set(op->ptr, "deltax", event->prevx - event->x);
RNA_int_set(op->ptr, "deltay", event->prevy - event->y);
-
+
view_pan_apply(C, op);
view_pan_exit(op);
return OPERATOR_FINISHED;
}
-
+
RNA_int_set(op->ptr, "deltax", 0);
RNA_int_set(op->ptr, "deltay", 0);
-
+
if (v2d->keepofs & V2D_LOCKOFS_X)
WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR);
else if (v2d->keepofs & V2D_LOCKOFS_Y)
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
else
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -264,7 +258,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
v2dViewPanData *vpd = op->customdata;
-
+
/* execute the events */
switch (event->type) {
case MOUSEMOVE:
@@ -272,10 +266,10 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* calculate new delta transform, then store mouse-coordinates for next-time */
RNA_int_set(op->ptr, "deltax", (vpd->lastx - event->x));
RNA_int_set(op->ptr, "deltay", (vpd->lasty - event->y));
-
+
vpd->lastx = event->x;
vpd->lasty = event->y;
-
+
view_pan_apply(C, op);
break;
}
@@ -287,7 +281,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* calculate overall delta mouse-movement for redo */
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
-
+
view_pan_exit(op);
WM_cursor_modal_restore(CTX_wm_window(C));
WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL);
@@ -300,10 +294,10 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* calculate overall delta mouse-movement for redo */
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
-
+
view_pan_exit(op);
WM_cursor_modal_restore(CTX_wm_window(C));
-
+
return OPERATOR_FINISHED;
}
}
@@ -324,16 +318,16 @@ static void VIEW2D_OT_pan(wmOperatorType *ot)
ot->name = "Pan View";
ot->description = "Pan the view";
ot->idname = "VIEW2D_OT_pan";
-
+
/* api callbacks */
ot->exec = view_pan_exec;
ot->invoke = view_pan_invoke;
ot->modal = view_pan_modal;
ot->cancel = view_pan_cancel;
-
+
/* operator is modal */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
-
+
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
@@ -345,26 +339,26 @@ static void VIEW2D_OT_pan(wmOperatorType *ot)
static int view_scrollright_exec(bContext *C, wmOperator *op)
{
v2dViewPanData *vpd;
-
+
/* initialize default settings (and validate if ok to run) */
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* also, check if can pan in horizontal axis */
vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
}
-
+
/* set RNA-Props - only movement in positive x-direction */
RNA_int_set(op->ptr, "deltax", 20);
RNA_int_set(op->ptr, "deltay", 0);
-
+
/* apply movement, then we're done */
view_pan_apply(C, op);
view_pan_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -374,10 +368,10 @@ static void VIEW2D_OT_scroll_right(wmOperatorType *ot)
ot->name = "Scroll Right";
ot->description = "Scroll the view right";
ot->idname = "VIEW2D_OT_scroll_right";
-
+
/* api callbacks */
ot->exec = view_scrollright_exec;
-
+
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
@@ -389,26 +383,26 @@ static void VIEW2D_OT_scroll_right(wmOperatorType *ot)
static int view_scrollleft_exec(bContext *C, wmOperator *op)
{
v2dViewPanData *vpd;
-
+
/* initialize default settings (and validate if ok to run) */
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* also, check if can pan in horizontal axis */
vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
}
-
+
/* set RNA-Props - only movement in negative x-direction */
RNA_int_set(op->ptr, "deltax", -20);
RNA_int_set(op->ptr, "deltay", 0);
-
+
/* apply movement, then we're done */
view_pan_apply(C, op);
view_pan_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -418,10 +412,10 @@ static void VIEW2D_OT_scroll_left(wmOperatorType *ot)
ot->name = "Scroll Left";
ot->description = "Scroll the view left";
ot->idname = "VIEW2D_OT_scroll_left";
-
+
/* api callbacks */
ot->exec = view_scrollleft_exec;
-
+
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
@@ -432,32 +426,32 @@ static void VIEW2D_OT_scroll_left(wmOperatorType *ot)
static int view_scrolldown_exec(bContext *C, wmOperator *op)
{
v2dViewPanData *vpd;
-
+
/* initialize default settings (and validate if ok to run) */
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* also, check if can pan in vertical axis */
vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
}
-
+
/* set RNA-Props */
RNA_int_set(op->ptr, "deltax", 0);
RNA_int_set(op->ptr, "deltay", -40);
-
+
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "page");
if (RNA_property_is_set(op->ptr, prop) && RNA_property_boolean_get(op->ptr, prop)) {
ARegion *ar = CTX_wm_region(C);
RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymin - ar->v2d.mask.ymax);
}
-
+
/* apply movement, then we're done */
view_pan_apply(C, op);
view_pan_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -467,10 +461,10 @@ static void VIEW2D_OT_scroll_down(wmOperatorType *ot)
ot->name = "Scroll Down";
ot->description = "Scroll the view down";
ot->idname = "VIEW2D_OT_scroll_down";
-
+
/* api callbacks */
ot->exec = view_scrolldown_exec;
-
+
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
@@ -483,32 +477,32 @@ static void VIEW2D_OT_scroll_down(wmOperatorType *ot)
static int view_scrollup_exec(bContext *C, wmOperator *op)
{
v2dViewPanData *vpd;
-
+
/* initialize default settings (and validate if ok to run) */
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
/* also, check if can pan in vertical axis */
vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
}
-
+
/* set RNA-Props */
RNA_int_set(op->ptr, "deltax", 0);
RNA_int_set(op->ptr, "deltay", 40);
-
+
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "page");
if (RNA_property_is_set(op->ptr, prop) && RNA_property_boolean_get(op->ptr, prop)) {
ARegion *ar = CTX_wm_region(C);
RNA_int_set(op->ptr, "deltay", BLI_rcti_size_y(&ar->v2d.mask));
}
-
+
/* apply movement, then we're done */
view_pan_apply(C, op);
view_pan_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -518,10 +512,10 @@ static void VIEW2D_OT_scroll_up(wmOperatorType *ot)
ot->name = "Scroll Up";
ot->description = "Scroll the view up";
ot->idname = "VIEW2D_OT_scroll_up";
-
+
/* api callbacks */
ot->exec = view_scrollup_exec;
-
+
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX);
@@ -588,24 +582,24 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
v2dViewZoomData *vzd;
View2D *v2d;
-
+
/* regions now have v2d-data by default, so check for region */
if (ar == NULL)
return 0;
v2d = &ar->v2d;
-
+
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
return 0;
-
+
/* set custom-data for operator */
vzd = MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData");
op->customdata = vzd;
-
+
/* set pointers to owners */
vzd->v2d = v2d;
vzd->ar = ar;
-
+
return 1;
}
@@ -614,7 +608,7 @@ static int view_zoom_poll(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
View2D *v2d;
-
+
/* check if there's a region in context to work with */
if (ar == NULL)
return false;
@@ -624,15 +618,15 @@ static int view_zoom_poll(bContext *C)
return false;
v2d = &ar->v2d;
-
+
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
return false;
-
+
/* view is zoomable */
return true;
}
-
+
/* apply transform to view (i.e. adjust 'cur' rect) */
static void view_zoomstep_apply_ex(
bContext *C, v2dViewZoomData *vzd, const bool use_mousepos,
@@ -645,7 +639,7 @@ static void view_zoomstep_apply_ex(
const int snap_test = ED_region_snap_size_test(ar);
/* calculate amount to move view by, ensuring symmetry so the
- * old zoom level is restored after zooming back the same amount
+ * old zoom level is restored after zooming back the same amount
*/
if (facx >= 0.0f) {
dx = BLI_rctf_size_x(&v2d->cur) * facx;
@@ -734,7 +728,7 @@ static void view_zoomstep_apply_ex(
}
/* request updates to be done... */
- ED_region_tag_redraw(vzd->ar);
+ ED_region_tag_redraw_no_rebuild(vzd->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
@@ -767,40 +761,40 @@ static int view_zoomin_exec(bContext *C, wmOperator *op)
/* check that there's an active region, as View2D data resides there */
if (!view_zoom_poll(C))
return OPERATOR_PASS_THROUGH;
-
+
view_zoom_axis_lock_defaults(C, do_zoom_xy);
/* set RNA-Props - zooming in by uniform factor */
RNA_float_set(op->ptr, "zoomfacx", do_zoom_xy[0] ? 0.0375f : 0.0f);
RNA_float_set(op->ptr, "zoomfacy", do_zoom_xy[1] ? 0.0375f : 0.0f);
-
+
/* apply movement, then we're done */
view_zoomstep_apply(C, op);
-
+
view_zoomstep_exit(op);
-
+
return OPERATOR_FINISHED;
}
static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
v2dViewZoomData *vzd;
-
+
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
vzd = op->customdata;
-
+
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar = CTX_wm_region(C);
-
+
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
-
+
return view_zoomin_exec(C, op);
}
@@ -812,12 +806,12 @@ static void VIEW2D_OT_zoom_in(wmOperatorType *ot)
ot->name = "Zoom In";
ot->description = "Zoom in the view";
ot->idname = "VIEW2D_OT_zoom_in";
-
+
/* api callbacks */
ot->invoke = view_zoomin_invoke;
ot->exec = view_zoomin_exec; // XXX, needs view_zoomdrag_init called first.
ot->poll = view_zoom_poll;
-
+
/* rna - must keep these in sync with the other operators */
prop = RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -833,39 +827,39 @@ static int view_zoomout_exec(bContext *C, wmOperator *op)
/* check that there's an active region, as View2D data resides there */
if (!view_zoom_poll(C))
return OPERATOR_PASS_THROUGH;
-
+
view_zoom_axis_lock_defaults(C, do_zoom_xy);
/* set RNA-Props - zooming in by uniform factor */
RNA_float_set(op->ptr, "zoomfacx", do_zoom_xy[0] ? -0.0375f : 0.0f);
RNA_float_set(op->ptr, "zoomfacy", do_zoom_xy[1] ? -0.0375f : 0.0f);
-
+
/* apply movement, then we're done */
view_zoomstep_apply(C, op);
view_zoomstep_exit(op);
-
+
return OPERATOR_FINISHED;
}
static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
v2dViewZoomData *vzd;
-
+
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
vzd = op->customdata;
-
+
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar = CTX_wm_region(C);
-
+
/* store initial mouse position (in view space) */
- UI_view2d_region_to_view(&ar->v2d,
+ UI_view2d_region_to_view(&ar->v2d,
event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
-
+
return view_zoomout_exec(C, op);
}
@@ -877,12 +871,12 @@ static void VIEW2D_OT_zoom_out(wmOperatorType *ot)
ot->name = "Zoom Out";
ot->description = "Zoom out the view";
ot->idname = "VIEW2D_OT_zoom_out";
-
+
/* api callbacks */
ot->invoke = view_zoomout_invoke;
// ot->exec = view_zoomout_exec; // XXX, needs view_zoomdrag_init called first.
ot->poll = view_zoom_poll;
-
+
/* rna - must keep these in sync with the other operators */
prop = RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -916,7 +910,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
dx *= -1;
dy *= -1;
}
-
+
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
double time = PIL_check_seconds_timer();
@@ -924,7 +918,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
dx *= time_step * 0.5f;
dy *= time_step * 0.5f;
-
+
vzd->timer_lastdraw = time;
}
@@ -938,7 +932,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
-
+
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
}
@@ -957,7 +951,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
-
+
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
}
@@ -967,7 +961,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
}
}
-
+
/* validate that view is in valid configuration after this operation */
UI_view2d_curRect_validate(v2d);
@@ -978,7 +972,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
/* request updates to be done... */
- ED_region_tag_redraw(vzd->ar);
+ ED_region_tag_redraw_no_rebuild(vzd->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
@@ -989,14 +983,14 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
if (op->customdata) {
v2dViewZoomData *vzd = op->customdata;
-
+
if (vzd->timer)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
-
+
MEM_freeN(op->customdata);
op->customdata = NULL;
}
-}
+}
static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
{
@@ -1008,7 +1002,7 @@ static int view_zoomdrag_exec(bContext *C, wmOperator *op)
{
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
view_zoomdrag_apply(C, op);
view_zoomdrag_exit(C, op);
return OPERATOR_FINISHED;
@@ -1020,22 +1014,22 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
wmWindow *window = CTX_wm_window(C);
v2dViewZoomData *vzd;
View2D *v2d;
-
+
/* set up customdata */
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
-
+
vzd = op->customdata;
v2d = vzd->v2d;
-
+
if (event->type == MOUSEZOOM || event->type == MOUSEPAN) {
float dx, dy, fac;
-
+
vzd->lastx = event->prevx;
vzd->lasty = event->prevy;
-
+
/* As we have only 1D information (magnify value), feed both axes
- * with magnify information that is stored in x axis
+ * with magnify information that is stored in x axis
*/
fac = 0.01f * (event->prevx - event->x);
dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f;
@@ -1052,26 +1046,26 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
-
+
view_zoomdrag_apply(C, op);
view_zoomdrag_exit(C, op);
return OPERATOR_FINISHED;
}
-
+
/* set initial settings */
vzd->lastx = event->x;
vzd->lasty = event->y;
RNA_float_set(op->ptr, "deltax", 0);
RNA_float_set(op->ptr, "deltay", 0);
-
+
/* for modal exit test */
vzd->invoke_event = event->type;
-
+
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
ARegion *ar = CTX_wm_region(C);
-
+
/* store initial mouse position (in view space) */
- UI_view2d_region_to_view(&ar->v2d,
+ UI_view2d_region_to_view(&ar->v2d,
event->mval[0], event->mval[1],
&vzd->mx_2d, &vzd->my_2d);
}
@@ -1082,7 +1076,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
else
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
-
+
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -1100,24 +1094,24 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
{
v2dViewZoomData *vzd = op->customdata;
View2D *v2d = vzd->v2d;
-
+
/* execute the events */
if (event->type == TIMER && event->customdata == vzd->timer) {
view_zoomdrag_apply(C, op);
}
else if (event->type == MOUSEMOVE) {
float dx, dy;
-
+
/* calculate new delta transform, based on zooming mode */
if (U.viewzoom == USER_ZOOM_SCALE) {
/* 'scale' zooming */
float dist;
-
+
/* x-axis transform */
dist = BLI_rcti_size_x(&v2d->mask) / 2.0f;
dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) / (fabsf(event->mval[0] - dist) + 2.0f);
dx *= 0.5f * BLI_rctf_size_x(&v2d->cur);
-
+
/* y-axis transform */
dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
@@ -1126,21 +1120,21 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
else {
/* 'continuous' or 'dolly' */
float fac, zoomfac = 0.01f;
-
+
/* some view2d's (graph) don't have min/max zoom, or extreme ones */
if (v2d->maxzoom > 0.0f)
zoomfac = CLAMPIS(0.001f * v2d->maxzoom, 0.001f, 0.01f);
-
+
/* x-axis transform */
fac = zoomfac * (event->x - vzd->lastx);
dx = fac * BLI_rctf_size_x(&v2d->cur);
-
+
/* y-axis transform */
fac = zoomfac * (event->y - vzd->lasty);
dy = fac * BLI_rctf_size_y(&v2d->cur);
-
+
}
-
+
/* support zoom to always zoom entirely - the v2d code uses portrait or landscape exceptions */
if (v2d->keepzoom & V2D_KEEPASPECT) {
if (fabsf(dx) > fabsf(dy))
@@ -1148,14 +1142,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
else
dx = dy;
}
-
+
/* set transform amount, and add current deltas to stored total delta (for redo) */
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
vzd->dx += dx;
vzd->dy += dy;
-
+
/* store mouse coordinates for next time, if not doing continuous zoom
* - continuous zoom only depends on distance of mouse to starting point to determine rate of change
*/
@@ -1163,28 +1157,28 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
vzd->lastx = event->x;
vzd->lasty = event->y;
}
-
+
/* apply zooming */
view_zoomdrag_apply(C, op);
}
else if (event->type == vzd->invoke_event || event->type == ESCKEY) {
if (event->val == KM_RELEASE) {
-
+
/* for redo, store the overall deltas - need to respect zoom-locks here... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0)
RNA_float_set(op->ptr, "deltax", vzd->dx);
else
RNA_float_set(op->ptr, "deltax", 0);
-
+
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0)
RNA_float_set(op->ptr, "deltay", vzd->dy);
else
RNA_float_set(op->ptr, "deltay", 0);
-
+
/* free customdata */
view_zoomdrag_exit(C, op);
WM_cursor_modal_restore(CTX_wm_window(C));
-
+
return OPERATOR_FINISHED;
}
}
@@ -1199,18 +1193,18 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
ot->name = "Zoom 2D View";
ot->description = "Zoom in/out the view";
ot->idname = "VIEW2D_OT_zoom";
-
+
/* api callbacks */
ot->exec = view_zoomdrag_exec;
ot->invoke = view_zoomdrag_invoke;
ot->modal = view_zoomdrag_modal;
ot->cancel = view_zoomdrag_cancel;
-
+
ot->poll = view_zoom_poll;
-
+
/* operator is repeatable */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
-
+
/* rna - must keep these in sync with the other operators */
prop = RNA_def_float(ot->srna, "deltax", 0, -FLT_MAX, FLT_MAX, "Delta X", "", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -1231,7 +1225,7 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
* Currently, these key mappings are hardcoded, but it shouldn't be too important to
* have custom keymappings for this...
*/
-
+
static int view_borderzoom_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
@@ -1239,17 +1233,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
rctf rect;
rctf cur_new = v2d->cur;
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-
+
/* convert coordinates of rect to 'tot' rect coordinates */
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
-
+
/* check if zooming in/out view */
const bool zoom_in = !RNA_boolean_get(op->ptr, "zoom_out");
-
+
if (zoom_in) {
- /* zoom in:
- * - 'cur' rect will be defined by the coordinates of the border region
+ /* zoom in:
+ * - 'cur' rect will be defined by the coordinates of the border region
* - just set the 'cur' rect to have the same coordinates as the border region
* if zoom is allowed to be changed
*/
@@ -1269,13 +1263,13 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
* - calculate zoom factor, and adjust using center-point
*/
float zoom, center, size;
-
+
/* TODO: is this zoom factor calculation valid? It seems to produce same results every time... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
size = BLI_rctf_size_x(&cur_new);
zoom = size / BLI_rctf_size_x(&rect);
center = BLI_rctf_cent_x(&cur_new);
-
+
cur_new.xmin = center - (size * zoom);
cur_new.xmax = center + (size * zoom);
}
@@ -1283,16 +1277,16 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
size = BLI_rctf_size_y(&cur_new);
zoom = size / BLI_rctf_size_y(&rect);
center = BLI_rctf_cent_y(&cur_new);
-
+
cur_new.ymin = center - (size * zoom);
cur_new.ymax = center + (size * zoom);
}
}
-
+
UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
-
+
return OPERATOR_FINISHED;
-}
+}
static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
{
@@ -1300,15 +1294,15 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
ot->name = "Zoom to Border";
ot->description = "Zoom in the view to the nearest item contained in the border";
ot->idname = "VIEW2D_OT_zoom_border";
-
+
/* api callbacks */
ot->invoke = WM_gesture_border_invoke;
ot->exec = view_borderzoom_exec;
ot->modal = WM_gesture_border_modal;
ot->cancel = WM_gesture_border_cancel;
-
+
ot->poll = view_zoom_poll;
-
+
/* rna */
WM_operator_properties_gesture_border_zoom(ot);
}
@@ -1493,7 +1487,7 @@ void UI_view2d_smooth_view(
v2d->cur = sms.new_cur;
UI_view2d_curRect_validate(v2d);
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
}
@@ -1537,7 +1531,7 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
UI_view2d_curRect_validate(v2d);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
if (v2d->sms == NULL) {
UI_view2d_zoom_cache_reset();
@@ -1581,17 +1575,17 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot)
typedef struct v2dScrollerMove {
View2D *v2d; /* View2D data that this operation affects */
ARegion *ar; /* region that the scroller is in */
-
+
short scroller; /* scroller that mouse is in ('h' or 'v') */
short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active color?)
-
+
float fac; /* view adjustment factor, based on size of region */
float fac_round; /* for pixel rounding (avoid visible UI jitter) */
float delta; /* amount moved by mouse on axis of interest */
-
+
float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
int scrollbar_orig; /* initial location of scrollbar x/y, mouse relative */
-
+
int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
} v2dScrollerMove;
@@ -1603,7 +1597,7 @@ typedef struct v2dScrollerMove {
* \warning: The start of this struct must not change, so that it stays in sync with the 'real' version
* For now, we don't need to have a separate (internal) header for structs like this...
*/
-struct View2DScrollers {
+struct View2DScrollers {
/* focus bubbles */
int vert_min, vert_max; /* vertical scrollbar */
int hor_min, hor_max; /* horizontal scrollbar */
@@ -1630,10 +1624,10 @@ enum {
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
{
bool in_min, in_max, in_bar, out_min, out_max, in_view = 1;
-
- /* firstly, check if
- * - 'bubble' fills entire scroller
- * - 'bubble' completely out of view on either side
+
+ /* firstly, check if
+ * - 'bubble' fills entire scroller
+ * - 'bubble' completely out of view on either side
*/
if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0;
if (sh_min == sh_max) {
@@ -1644,12 +1638,12 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
if (sh_max <= sc_min) in_view = 0;
if (sh_min >= sc_max) in_view = 0;
}
-
-
+
+
if (in_view == 0) {
return SCROLLHANDLE_BAR;
}
-
+
/* check if mouse is in or past either handle */
/* TODO: check if these extents are still valid or not */
in_max = ((mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)));
@@ -1657,7 +1651,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
in_bar = ((mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)));
out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
-
+
if (in_bar)
return SCROLLHANDLE_BAR;
else if (in_max)
@@ -1668,10 +1662,10 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
return SCROLLHANDLE_MIN_OUTSIDE;
else if (out_max)
return SCROLLHANDLE_MAX_OUTSIDE;
-
+
/* unlikely to happen, though we just cover it in case */
return SCROLLHANDLE_BAR;
-}
+}
/* initialize customdata for scroller manipulation operator */
static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, short in_scroller)
@@ -1682,11 +1676,11 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
View2D *v2d = &ar->v2d;
rctf tot_cur_union;
float mask_size;
-
+
/* set custom-data for operator */
vsm = MEM_callocN(sizeof(v2dScrollerMove), "v2dScrollerMove");
op->customdata = vsm;
-
+
/* set general data */
vsm->v2d = v2d;
vsm->ar = ar;
@@ -1695,7 +1689,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
vsm->lastx = event->x;
vsm->lasty = event->y;
- /* 'zone' depends on where mouse is relative to bubble
+ /* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
*/
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
@@ -1717,7 +1711,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
vsm->zone = mouse_in_scroller_handle(event->mval[0],
v2d->hor.xmin, v2d->hor.xmax,
scrollers->hor_min, scrollers->hor_max);
-
+
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
vsm->zone = SCROLLHANDLE_BAR;
@@ -1730,7 +1724,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
/* vertical scroller - calculate adjustment factor first */
mask_size = (float)BLI_rcti_size_y(&v2d->vert);
vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size;
-
+
/* pixel rounding */
vsm->fac_round = (BLI_rctf_size_y(&v2d->cur)) / (float)(BLI_rcti_size_y(&ar->winrct) + 1);
@@ -1738,18 +1732,18 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e
vsm->zone = mouse_in_scroller_handle(event->mval[1],
v2d->vert.ymin, v2d->vert.ymax,
scrollers->vert_min, scrollers->vert_max);
-
+
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
vsm->zone = SCROLLHANDLE_BAR;
}
-
+
vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min;
vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + ar->winrct.ymin;
}
-
+
UI_view2d_scrollers_free(scrollers);
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
}
/* cleanup temp customdata */
@@ -1759,11 +1753,11 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
v2dScrollerMove *vsm = op->customdata;
vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE | V2D_SCROLL_V_ACTIVE);
-
+
MEM_freeN(op->customdata);
op->customdata = NULL;
-
- ED_region_tag_redraw(CTX_wm_region(C));
+
+ ED_region_tag_redraw_no_rebuild(CTX_wm_region(C));
}
}
@@ -1778,13 +1772,13 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
v2dScrollerMove *vsm = op->customdata;
View2D *v2d = vsm->v2d;
float temp;
-
+
/* calculate amount to move view by */
temp = vsm->fac * vsm->delta;
/* round to pixel */
temp = roundf(temp / vsm->fac_round) * vsm->fac_round;
-
+
/* type of movement */
switch (vsm->zone) {
case SCROLLHANDLE_MIN:
@@ -1794,16 +1788,16 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
v2d->cur.ymin -= temp;
break;
-
+
case SCROLLHANDLE_MAX:
-
+
/* only expand view on axis if zoom is allowed */
if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
v2d->cur.xmax += temp;
if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
v2d->cur.ymax += temp;
break;
-
+
case SCROLLHANDLE_MIN_OUTSIDE:
case SCROLLHANDLE_MAX_OUTSIDE:
case SCROLLHANDLE_BAR:
@@ -1818,14 +1812,14 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
v2d->cur.ymax += temp;
}
break;
-
+
}
-
+
/* validate that view is in valid configuration after this operation */
UI_view2d_curRect_validate(v2d);
-
+
/* request updates to be done... */
- ED_region_tag_redraw(vsm->ar);
+ ED_region_tag_redraw_no_rebuild(vsm->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
@@ -1836,7 +1830,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
v2dScrollerMove *vsm = op->customdata;
-
+
/* execute the events */
switch (event->type) {
case MOUSEMOVE:
@@ -1864,11 +1858,11 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
break;
}
}
-
+
/* store previous coordinates */
vsm->lastx = event->x;
vsm->lasty = event->y;
-
+
scroller_activate_apply(C, op);
break;
}
@@ -1881,12 +1875,12 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
vsm->delta = -vsm->scrollbarwidth * 0.8f;
else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE)
vsm->delta = vsm->scrollbarwidth * 0.8f;
-
+
scroller_activate_apply(C, op);
scroller_activate_exit(C, op);
return OPERATOR_FINISHED;
}
-
+
/* otherwise, end the drag action */
if (vsm->lastx || vsm->lasty) {
scroller_activate_exit(C, op);
@@ -1907,18 +1901,18 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
short in_scroller = 0;
-
+
/* check if mouse in scrollbars, if they're enabled */
in_scroller = UI_view2d_mouse_in_scrollers(ar, v2d, event->x, event->y);
-
+
/* if in a scroller, init customdata then set modal handler which will catch mousedown to start doing useful stuff */
if (in_scroller) {
v2dScrollerMove *vsm;
-
+
/* initialize customdata */
scroller_activate_init(C, op, event, in_scroller);
vsm = (v2dScrollerMove *)op->customdata;
-
+
/* support for quick jump to location - gtk and qt do this on linux */
if (event->type == MIDDLEMOUSE) {
switch (vsm->scroller) {
@@ -1945,7 +1939,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
vsm->zone = SCROLLHANDLE_BAR;
}
}
-
+
/* check if zone is inappropriate (i.e. 'bar' but panning is banned), so cannot continue */
if (vsm->zone == SCROLLHANDLE_BAR) {
if (((vsm->scroller == 'h') && (v2d->keepofs & V2D_LOCKOFS_X)) ||
@@ -1953,30 +1947,30 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
{
/* free customdata initialized */
scroller_activate_exit(C, op);
-
+
/* can't catch this event for ourselves, so let it go to someone else? */
return OPERATOR_PASS_THROUGH;
}
}
-
+
/* zone is also inappropriate if scroller is not visible... */
if (((vsm->scroller == 'h') && (v2d->scroll & (V2D_SCROLL_HORIZONTAL_FULLR))) ||
((vsm->scroller == 'v') && (v2d->scroll & (V2D_SCROLL_VERTICAL_FULLR))) )
{
/* free customdata initialized */
scroller_activate_exit(C, op);
-
+
/* can't catch this event for ourselves, so let it go to someone else? */
/* XXX note: if handlers use mask rect to clip input, input will fail for this case */
return OPERATOR_PASS_THROUGH;
}
-
+
/* activate the scroller */
if (vsm->scroller == 'h')
v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
else
v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
-
+
/* still ok, so can add */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -1997,7 +1991,7 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING;
-
+
/* api callbacks */
ot->invoke = scroller_activate_invoke;
ot->modal = scroller_activate_modal;
@@ -2023,7 +2017,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
-
+
/* align */
if (v2d->align) {
/* posx and negx flags are mutually exclusive, so watch out */
@@ -2059,7 +2053,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
/* request updates to be done... */
ED_region_tag_redraw(ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
-
+
UI_view2d_zoom_cache_reset();
return OPERATOR_FINISHED;
@@ -2071,27 +2065,27 @@ static void VIEW2D_OT_reset(wmOperatorType *ot)
ot->name = "Reset View";
ot->description = "Reset the view";
ot->idname = "VIEW2D_OT_reset";
-
+
/* api callbacks */
ot->exec = reset_exec;
ot->poll = view2d_poll;
}
-
+
/* ********************************************************* */
/* Registration */
void ED_operatortypes_view2d(void)
{
WM_operatortype_append(VIEW2D_OT_pan);
-
+
WM_operatortype_append(VIEW2D_OT_scroll_left);
WM_operatortype_append(VIEW2D_OT_scroll_right);
WM_operatortype_append(VIEW2D_OT_scroll_up);
WM_operatortype_append(VIEW2D_OT_scroll_down);
-
+
WM_operatortype_append(VIEW2D_OT_zoom_in);
WM_operatortype_append(VIEW2D_OT_zoom_out);
-
+
WM_operatortype_append(VIEW2D_OT_zoom);
WM_operatortype_append(VIEW2D_OT_zoom_border);
@@ -2100,7 +2094,7 @@ void ED_operatortypes_view2d(void)
#endif
WM_operatortype_append(VIEW2D_OT_smoothview);
-
+
WM_operatortype_append(VIEW2D_OT_scroller_activate);
WM_operatortype_append(VIEW2D_OT_reset);
@@ -2118,15 +2112,15 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
/* pan/scroll */
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0);
-
+
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0);
-
+
#ifdef WITH_INPUT_NDOF
WM_keymap_add_item(keymap, "VIEW2D_OT_ndof", NDOF_MOTION, 0, 0, 0);
#endif
@@ -2137,7 +2131,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
-
+
WM_keymap_verify_item(keymap, "VIEW2D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
/* scroll up/down - no modifiers, only when zoom fails */
@@ -2147,7 +2141,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
/* these may be necessary if vertical scroll is disallowed */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, 0, 0);
-
+
/* alternatives for page up/down to scroll */
#if 0 // XXX disabled, since this causes conflicts with hotkeys in animation editors
/* scroll up/down may fall through to left/right */
@@ -2159,11 +2153,11 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0);
#endif
-
+
/* zoom - drag */
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0);
-
+
/* borderzoom - drag */
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
@@ -2177,12 +2171,12 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", PAGEDOWNKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "page", true);
kmi = WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", PAGEUPKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "page", true);
-
+
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0);
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index ccf90452b0f..2ba1dde243b 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -366,51 +366,55 @@ void ED_lattice_flags_set(Object *obedit, int flag)
static int lattice_select_all_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- Lattice *lt = obedit->data;
- BPoint *bp;
- int a;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
int action = RNA_enum_get(op->ptr, "action");
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
-
- bp = lt->editlatt->latt->def;
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
- while (a--) {
- if (bp->hide == 0) {
- if (bp->f1 & SELECT) {
- action = SEL_DESELECT;
- break;
- }
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = obedit->data;
+ if (BKE_lattice_is_any_selected(lt->editlatt->latt)) {
+ action = SEL_DESELECT;
+ break;
}
- bp++;
}
}
- switch (action) {
- case SEL_SELECT:
- ED_lattice_flags_set(obedit, 1);
- break;
- case SEL_DESELECT:
- ED_lattice_flags_set(obedit, 0);
- break;
- case SEL_INVERT:
- bp = lt->editlatt->latt->def;
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
- lt->editlatt->latt->actbp = LT_ACTBP_NONE;
-
- while (a--) {
- if (bp->hide == 0) {
- bp->f1 ^= SELECT;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt;
+ BPoint *bp;
+ int a;
+
+ switch (action) {
+ case SEL_SELECT:
+ ED_lattice_flags_set(obedit, 1);
+ break;
+ case SEL_DESELECT:
+ ED_lattice_flags_set(obedit, 0);
+ break;
+ case SEL_INVERT:
+ lt = obedit->data;
+ bp = lt->editlatt->latt->def;
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
+ while (a--) {
+ if (bp->hide == 0) {
+ bp->f1 ^= SELECT;
+ }
+ bp++;
}
- bp++;
- }
- break;
+ break;
+ }
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
+ MEM_freeN(objects);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 7ffd82e262c..8559be67ece 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -481,7 +481,7 @@ void MASK_OT_select_border(wmOperatorType *ot)
WM_operator_properties_gesture_border_select(ot);
}
-static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, short select)
+static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, bool select, bool extend)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@@ -514,6 +514,10 @@ static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves
/* TODO: handles? */
/* TODO: uw? */
+ if (MASKPOINT_ISSEL_ANY(point) && select && extend) {
+ continue;
+ }
+
float screen_co[2];
/* point in screen coords */
@@ -526,9 +530,13 @@ static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves
{
BKE_mask_point_select_set(point, select);
BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select);
+ changed = true;
+ }
+ else if (select && !extend) {
+ BKE_mask_point_select_set(point, false);
+ BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, false);
+ changed = true;
}
-
- changed = true;
}
}
}
@@ -548,10 +556,9 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
- short select;
-
- select = !RNA_boolean_get(op->ptr, "deselect");
- do_lasso_select_mask(C, mcords, mcords_tot, select);
+ const bool select = !RNA_boolean_get(op->ptr, "deselect");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ do_lasso_select_mask(C, mcords, mcords_tot, select, extend);
MEM_freeN((void *)mcords);
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 4081e3b0302..64d890a7314 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -29,6 +29,8 @@
* \ingroup edmesh
*/
+#include "MEM_guardedalloc.h"
+
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
@@ -41,6 +43,7 @@
#include "BLI_math.h"
#include "BLI_linklist.h"
+#include "BKE_layer.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_report.h"
@@ -726,67 +729,87 @@ void MESH_OT_shortest_path_pick(wmOperatorType *ot)
static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMesh *bm = em->bm;
- BMIter iter;
- BMEditSelection *ese_src, *ese_dst;
- BMElem *ele_src = NULL, *ele_dst = NULL, *ele;
+ bool found_valid_elements = false;
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+ BMIter iter;
+ BMEditSelection *ese_src, *ese_dst;
+ BMElem *ele_src = NULL, *ele_dst = NULL, *ele;
+
+ if ((em->bm->totvertsel == 0) &&
+ (em->bm->totedgesel == 0) &&
+ (em->bm->totfacesel == 0))
+ {
+ continue;
+ }
- /* first try to find vertices in edit selection */
- ese_src = bm->selected.last;
- if (ese_src && (ese_dst = ese_src->prev) && (ese_src->htype == ese_dst->htype)) {
- ele_src = ese_src->ele;
- ele_dst = ese_dst->ele;
- }
- else {
- /* if selection history isn't available, find two selected elements */
- ele_src = ele_dst = NULL;
- if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) {
- BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL) ele_src = ele;
- else if (ele_dst == NULL) ele_dst = ele;
- else break;
+ /* first try to find vertices in edit selection */
+ ese_src = bm->selected.last;
+ if (ese_src && (ese_dst = ese_src->prev) && (ese_src->htype == ese_dst->htype)) {
+ ele_src = ese_src->ele;
+ ele_dst = ese_dst->ele;
+ }
+ else {
+ /* if selection history isn't available, find two selected elements */
+ ele_src = ele_dst = NULL;
+ if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) {
+ BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ if (ele_src == NULL) ele_src = ele;
+ else if (ele_dst == NULL) ele_dst = ele;
+ else break;
+ }
}
}
- }
- if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_EDGE) && (bm->totedgesel >= 2)) {
- ele_src = NULL;
- BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL) ele_src = ele;
- else if (ele_dst == NULL) ele_dst = ele;
- else break;
+ if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_EDGE) && (bm->totedgesel >= 2)) {
+ ele_src = NULL;
+ BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ if (ele_src == NULL) ele_src = ele;
+ else if (ele_dst == NULL) ele_dst = ele;
+ else break;
+ }
}
}
- }
- if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_FACE) && (bm->totfacesel >= 2)) {
- ele_src = NULL;
- BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL) ele_src = ele;
- else if (ele_dst == NULL) ele_dst = ele;
- else break;
+ if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_FACE) && (bm->totfacesel >= 2)) {
+ ele_src = NULL;
+ BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ if (ele_src == NULL) ele_src = ele;
+ else if (ele_dst == NULL) ele_dst = ele;
+ else break;
+ }
}
}
}
- }
- if (ele_src && ele_dst) {
- struct PathSelectParams op_params;
- path_select_params_from_op(op, &op_params);
+ if (ele_src && ele_dst) {
+ struct PathSelectParams op_params;
+ path_select_params_from_op(op, &op_params);
- edbm_shortest_path_pick_ex(scene, obedit, &op_params, ele_src, ele_dst);
+ edbm_shortest_path_pick_ex(scene, obedit, &op_params, ele_src, ele_dst);
- return OPERATOR_FINISHED;
+ found_valid_elements = true;
+ }
}
- else {
- BKE_report(op->reports, RPT_WARNING, "Path selection requires two matching elements to be selected");
+ MEM_freeN(objects);
+
+ if (!found_valid_elements) {
+ BKE_report(op->reports,
+ RPT_WARNING,
+ "Path selection requires two matching elements to be selected");
return OPERATOR_CANCELLED;
}
+
+ return OPERATOR_FINISHED;
}
void MESH_OT_shortest_path_select(wmOperatorType *ot)
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 41a0fa9ce38..fd8efcd84e3 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -397,6 +397,18 @@ bool EDBM_backbuf_circle_init(
* to avoid the bias interfering with distance comparisons when mixing types.
* \{ */
+#define FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, select_mode_required) \
+ short select_mode = select_mode_required; \
+ bool fake_select_mode = (select_mode & (vc)->scene->toolsettings->selectmode) == 0; \
+ if (fake_select_mode) { \
+ (vc)->v3d->flag |= V3D_INVALID_BACKBUF; \
+ } ((void)0)
+
+#define FAKE_SELECT_MODE_END(vc, fake_select_mode) \
+ if (fake_select_mode) { \
+ (vc)->v3d->flag |= V3D_INVALID_BACKBUF; \
+ } ((void)0)
+
#define FIND_NEAR_SELECT_BIAS 5
#define FIND_NEAR_CYCLE_THRESHOLD_MIN 3
@@ -470,11 +482,16 @@ BMVert *EDBM_vert_find_nearest_ex(
BMVert *eve;
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
- ED_view3d_backbuf_validate(vc);
+ {
+ FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX);
+ ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+
+ index = ED_view3d_backbuf_sample_rect(
+ vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
+ eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
- index = ED_view3d_backbuf_sample_rect(
- vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
- eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
+ FAKE_SELECT_MODE_END(vc, fake_select_mode);
+ }
if (eve) {
if (dist_test < *r_dist) {
@@ -657,23 +674,16 @@ BMEdge *EDBM_edge_find_nearest_ex(
unsigned int index;
BMEdge *eed;
- /* Make sure that the edges also are considered to find nearest.
- * TODO: cleanup: add `selectmode` as a parameter
- * XXX: Without selectmode as parameter we need to resort to this super ugly hack,
- * because we should never write to evaluate data. */
- const short ts_selectmode = vc->scene->toolsettings->selectmode;
-
- Scene *scene_eval = (Scene *)DEG_get_evaluated_id(vc->depsgraph, &vc->scene->id);
- scene_eval->toolsettings->selectmode |= SCE_SELECT_EDGE;
-
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
- ED_view3d_backbuf_validate(vc);
-
- /* restore `selectmode` */
- scene_eval->toolsettings->selectmode = ts_selectmode;
-
- index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
- eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
+ {
+ FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE);
+ ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+
+ index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
+ eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
+
+ FAKE_SELECT_MODE_END(vc, fake_select_mode);
+ }
if (r_eed_zbuf) {
*r_eed_zbuf = eed;
@@ -834,10 +844,15 @@ BMFace *EDBM_face_find_nearest_ex(
unsigned int index;
BMFace *efa;
- ED_view3d_backbuf_validate(vc);
+ {
+ FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE);
+ ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+
+ index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
+ efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
- index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
- efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
+ FAKE_SELECT_MODE_END(vc, fake_select_mode);
+ }
if (r_efa_zbuf) {
*r_efa_zbuf = efa;
@@ -1067,6 +1082,9 @@ static bool unified_findnearest(
return (hit.v.ele || hit.e.ele || hit.f.ele);
}
+#undef FAKE_SELECT_MODE_BEGIN
+#undef FAKE_SELECT_MODE_END
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1703,17 +1721,6 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de
mvalf[1] = (float)(vc.mval[1] = mval[1]);
em = vc.em;
- /* Make sure that the edges are also considered for selection.
- * TODO: cleanup: add `selectmode` as a parameter */
- const short ts_selectmode = vc.scene->toolsettings->selectmode;
- vc.scene->toolsettings->selectmode |= SCE_SELECT_EDGE;
-
- /* no afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad */
- ED_view3d_backbuf_validate(&vc);
-
- /* restore `selectmode` */
- vc.scene->toolsettings->selectmode = ts_selectmode;
-
eed = EDBM_edge_find_nearest_ex(&vc, &dist, NULL, true, true, NULL);
if (eed == NULL) {
return false;
@@ -1926,7 +1933,7 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -2028,7 +2035,7 @@ bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob_iter->data);
}
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
}
if (efa) {
@@ -2429,7 +2436,7 @@ bool EDBM_selectmode_toggle(
}
if (only_update) {
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return false;
}
@@ -2482,7 +2489,7 @@ bool EDBM_selectmode_toggle(
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return ret;
}
@@ -2929,7 +2936,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -3101,7 +3108,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
has_edges = true;
}
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
if (has_edges == false) {
return OPERATOR_CANCELLED;
}
@@ -3763,7 +3770,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
}
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
if (!found_active_elt) {
BKE_report(op->reports, RPT_ERROR,
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 0c13c900dee..510b3381b7e 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -131,7 +131,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, true, true);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -366,16 +366,16 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ar, CTX_wm_view3d(C));
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
float mval[2], co_proj[3];
if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (ED_transform_snap_object_project_view3d_mixed(
+ if (ED_transform_snap_object_project_view3d(
snap_context,
- SCE_SELECT_FACE,
+ SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = SNAP_NOT_ACTIVE,
.use_object_edit_cage = false,
@@ -438,7 +438,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
break;
case MESH_DELETE_EDGE: /* Erase Edges */
if (!(em->bm->totedgesel &&
- EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_FACES)))
+ EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)))
{
continue;
}
@@ -478,7 +478,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, true, true);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -603,7 +603,7 @@ static int edbm_delete_loose_exec(bContext *C, wmOperator *op)
edbm_report_delete_info(op->reports, totelem_old, totelem_new);
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -2312,7 +2312,7 @@ void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot)
RNA_def_int(ot->srna, "repeat", 1, 1, 1000,
"Number of iterations to smooth the mesh", "", 1, 200);
- RNA_def_float(ot->srna, "lambda_factor", 5e-5f, 1e-7f, 1000.0f,
+ RNA_def_float(ot->srna, "lambda_factor", 1.0f, 1e-7f, 1000.0f,
"Lambda factor", "", 1e-7f, 1000.0f);
RNA_def_float(ot->srna, "lambda_border", 5e-5f, 1e-7f, 1000.0f,
"Lambda factor in border", "", 1e-7f, 1000.0f);
@@ -5447,11 +5447,12 @@ static int edbm_split_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(obedit);
-
- if (em->bm->totfacesel == 0) {
+ if ((em->bm->totvertsel == 0) &&
+ (em->bm->totedgesel == 0) &&
+ (em->bm->totfacesel == 0))
+ {
continue;
}
-
BMOperator bmop;
EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, false);
BMO_op_exec(em->bm, &bmop);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index b49a58b3766..9af8169ae41 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -893,7 +893,7 @@ static int bake(
/* the baking itself */
for (i = 0; i < tot_highpoly; i++) {
- ok = RE_bake_engine(re, view_layer, highpoly[i].ob, i, pixel_array_high,
+ ok = RE_bake_engine(re, depsgraph, highpoly[i].ob, i, pixel_array_high,
num_pixels, depth, pass_type, pass_filter, result);
if (!ok) {
BKE_reportf(reports, RPT_ERROR, "Error baking from object \"%s\"", highpoly[i].ob->id.name + 2);
@@ -920,7 +920,7 @@ cage_cleanup:
ob_low->restrictflag &= ~OB_RESTRICT_RENDER;
if (RE_bake_has_engine(re)) {
- ok = RE_bake_engine(re, view_layer, ob_low, 0, pixel_array_low, num_pixels, depth, pass_type, pass_filter, result);
+ ok = RE_bake_engine(re, depsgraph, ob_low, 0, pixel_array_low, num_pixels, depth, pass_type, pass_filter, result);
}
else {
BKE_report(reports, RPT_ERROR, "Current render engine does not support baking");
@@ -1120,6 +1120,8 @@ cleanup:
if (me_cage)
BKE_libblock_free(bmain, me_cage);
+ DEG_graph_free(depsgraph);
+
return op_result;
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 364a85c4248..7a4898ec287 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -112,6 +112,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "object_intern.h" // own include
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c5cf946cfb3..6925daa4b6c 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1636,6 +1636,7 @@ static Object *single_object_users_object(Main *bmain, Scene *scene, Object *ob)
}
}
+ id_us_plus(&obn->id);
id_us_min(&ob->id);
return obn;
}
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 6b22521eedd..77514ca1e8e 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -631,6 +631,10 @@ static int apply_objects_internal(
la->area_shape = LA_AREA_RECT;
la->area_sizey = la->area_size;
}
+ else if ((la->area_shape == LA_AREA_DISK) && !keeps_aspect_ratio) {
+ la->area_shape = LA_AREA_ELLIPSE;
+ la->area_sizey = la->area_size;
+ }
la->area_size *= rsmat[0][0];
la->area_sizey *= rsmat[1][1];
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 6197457293f..b8a5c138a57 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -82,6 +82,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -427,7 +428,11 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
static bool PE_create_shape_tree(PEData *data, Object *shapeob)
{
- Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_object(shapeob, 0);
+ ModifierEvalContext ctx = {
+ .depsgraph = data->depsgraph,
+ .flag = 0,
+ };
+ Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, shapeob);
memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
@@ -2958,7 +2963,7 @@ static void PE_mirror_x(
}
else {
newpa->num_dmcache = psys_particle_dm_face_lookup(
- psmd->mesh_final, psmd->mesh_deformed, newpa->num, newpa->fuv, NULL);
+ psmd->mesh_final, psmd->mesh_original, newpa->num, newpa->fuv, NULL);
}
/* update edit key pointers */
@@ -3552,7 +3557,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
mesh = psmd->mesh_final;
}
else {
- mesh = psmd->mesh_deformed;
+ mesh = psmd->mesh_original;
}
BLI_assert(mesh);
@@ -3586,11 +3591,11 @@ static int brush_add(const bContext *C, PEData *data, short number)
add_pars[n].num = add_pars[n].num_dmcache;
add_pars[n].num_dmcache = DMCACHE_ISCHILD;
}
- else if (mesh == psmd->mesh_deformed) {
+ else if (mesh == psmd->mesh_original) {
/* Final DM is not same topology as orig mesh, we have to map num_dmcache to real final dm. */
add_pars[n].num = add_pars[n].num_dmcache;
add_pars[n].num_dmcache = psys_particle_dm_face_lookup(
- psmd->mesh_final, psmd->mesh_deformed,
+ psmd->mesh_final, psmd->mesh_original,
add_pars[n].num, add_pars[n].fuv, NULL);
}
else {
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index cb7c90a6c3d..55f518a2a8c 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -680,7 +680,7 @@ static bool remap_hair_emitter(
mesh = target_psmd->mesh_final;
}
else {
- mesh = target_psmd->mesh_deformed;
+ mesh = target_psmd->mesh_original;
}
target_mesh = target_psmd->mesh_final;
if (mesh == NULL) {
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index b6608ce600f..677fc0a068e 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -116,7 +116,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
static ViewLayer *scene_change_get_new_view_layer(const WorkSpace *workspace, const Scene *scene_new)
{
- ViewLayer *layer_new = BKE_workspace_view_layer_get(workspace, scene_new);
+ ViewLayer *layer_new = BKE_workspace_view_layer_exists(workspace, scene_new);
return layer_new ? layer_new : BKE_view_layer_default_view(scene_new);
}
@@ -202,10 +202,11 @@ bool ED_scene_view_layer_delete(
BLI_assert(BLI_listbase_is_empty(&scene->view_layers) == false);
ED_workspace_view_layer_unset(bmain, scene, layer, scene->view_layers.first);
- BKE_workspace_view_layer_remove_references(bmain, layer);
BKE_view_layer_free(layer);
+ BKE_workspace_view_layer_remove(bmain, layer);
+
DEG_id_tag_update(&scene->id, 0);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER | NA_REMOVED, scene);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index b2245886991..e8192c4ce90 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -52,6 +52,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "ED_screen.h"
#include "ED_screen_types.h"
@@ -225,7 +226,7 @@ void ED_area_azones_update(ScrArea *sa, const int mouse_xy[2])
if (changed) {
sa->flag &= ~AREA_FLAG_ACTIONZONES_UPDATE;
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw_no_rebuild(sa);
}
}
@@ -607,6 +608,15 @@ void ED_area_tag_redraw(ScrArea *sa)
ED_region_tag_redraw(ar);
}
+void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
+{
+ ARegion *ar;
+
+ if (sa)
+ for (ar = sa->regionbase.first; ar; ar = ar->next)
+ ED_region_tag_redraw_no_rebuild(ar);
+}
+
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
{
ARegion *ar;
@@ -1249,7 +1259,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
region_rect_recursive(win, sa, ar->next, remainder, overlap_remainder, quad);
}
-static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
+static void area_calc_totrct(ScrArea *sa, const rcti *window_rect)
{
short px = (short)U.pixelsize;
@@ -1259,16 +1269,16 @@ static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
sa->totrct.ymax = sa->v2->vec.y;
/* scale down totrct by 1 pixel on all sides not matching window borders */
- if (sa->totrct.xmin > 0) {
+ if (sa->totrct.xmin > window_rect->xmin) {
sa->totrct.xmin += px;
}
- if (sa->totrct.xmax < (window_size_x - 1)) {
+ if (sa->totrct.xmax < (window_rect->xmax - 1)) {
sa->totrct.xmax -= px;
}
- if (sa->totrct.ymin > 0) {
+ if (sa->totrct.ymin > window_rect->ymin) {
sa->totrct.ymin += px;
}
- if (sa->totrct.ymax < (window_size_y - 1)) {
+ if (sa->totrct.ymax < (window_rect->ymax - 1)) {
sa->totrct.ymax -= px;
}
/* Although the following asserts are correct they lead to a very unstable Blender.
@@ -1363,15 +1373,15 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
{
+ rcti rect, overlap_rect;
+ rcti window_rect;
+
if (!(area->flag & AREA_FLAG_REGION_SIZE_UPDATE)) {
return;
}
- const int size_x = WM_window_pixels_x(win);
- const int size_y = WM_window_pixels_y(win);
- rcti rect, overlap_rect;
-
- area_calc_totrct(area, size_x, size_y);
+ WM_window_rect_calc(win, &window_rect);
+ area_calc_totrct(area, &window_rect);
/* region rect sizes */
rect = area->totrct;
@@ -1396,15 +1406,14 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
WorkSpace *workspace = WM_window_get_active_workspace(win);
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
Scene *scene = WM_window_get_active_scene(win);
-
- const int window_size_x = WM_window_pixels_x(win);
- const int window_size_y = WM_window_pixels_y(win);
ARegion *ar;
rcti rect, overlap_rect;
+ rcti window_rect;
if (ED_area_is_global(sa) && (sa->global->flag & GLOBAL_AREA_IS_HIDDEN)) {
return;
}
+ WM_window_rect_calc(win, &window_rect);
/* set typedefinitions */
sa->type = BKE_spacetype_from_id(sa->spacetype);
@@ -1418,7 +1427,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
/* area sizes */
- area_calc_totrct(sa, window_size_x, window_size_y);
+ area_calc_totrct(sa, &window_rect);
/* region rect sizes */
rect = sa->totrct;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 77f7aacb68e..c7578741d24 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -111,10 +111,12 @@ bool scredge_is_horizontal(ScrEdge *se)
return (se->v1->vec.y == se->v2->vec.y);
}
-/* need win size to make sure not to include edges along screen edge */
+/**
+ * \param bounds_rect: Either window or screen bounds. Used to exclude edges along window/screen edges.
+ */
ScrEdge *screen_area_map_find_active_scredge(
const ScrAreaMap *area_map,
- const int winsize_x, const int winsize_y,
+ const rcti *bounds_rect,
const int mx, const int my)
{
int safety = U.widget_unit / 10;
@@ -123,7 +125,7 @@ ScrEdge *screen_area_map_find_active_scredge(
for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
if (scredge_is_horizontal(se)) {
- if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
+ if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) {
short min, max;
min = MIN2(se->v1->vec.x, se->v2->vec.x);
max = MAX2(se->v1->vec.x, se->v2->vec.x);
@@ -133,7 +135,7 @@ ScrEdge *screen_area_map_find_active_scredge(
}
}
else {
- if (se->v1->vec.x > 0 && se->v1->vec.x < winsize_x - 1) {
+ if ((se->v1->vec.x > bounds_rect->xmin) && (se->v1->vec.x < (bounds_rect->xmax - 1))) {
short min, max;
min = MIN2(se->v1->vec.y, se->v2->vec.y);
max = MAX2(se->v1->vec.y, se->v2->vec.y);
@@ -153,13 +155,17 @@ ScrEdge *screen_find_active_scredge(
const int mx, const int my)
{
/* Use layout size (screen excluding global areas) for screen-layout area edges */
- const int screen_x = WM_window_screen_pixels_x(win), screen_y = WM_window_screen_pixels_y(win);
- ScrEdge *se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), screen_x, screen_y, mx, my);
+ rcti screen_rect;
+ ScrEdge *se;
+
+ WM_window_screen_rect_calc(win, &screen_rect);
+ se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my);
if (!se) {
/* Use entire window size (screen including global areas) for global area edges */
- const int win_x = WM_window_pixels_x(win), win_y = WM_window_pixels_y(win);
- se = screen_area_map_find_active_scredge(&win->global_areas, win_x, win_y, mx, my);
+ rcti win_rect;
+ WM_window_rect_calc(win, &win_rect);
+ se = screen_area_map_find_active_scredge(&win->global_areas, &win_rect, mx, my);
}
return se;
}
@@ -334,7 +340,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
/**
* Empty screen, with 1 dummy area without spacedata. Uses window size.
*/
-bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y)
+bScreen *screen_add(const char *name, const rcti *rect)
{
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
@@ -343,10 +349,10 @@ bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y)
sc->do_refresh = true;
sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
- sv1 = screen_addvert(sc, 0, 0);
- sv2 = screen_addvert(sc, 0, winsize_y - 1);
- sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1);
- sv4 = screen_addvert(sc, winsize_x - 1, 0);
+ sv1 = screen_addvert(sc, rect->xmin, rect->ymin);
+ sv2 = screen_addvert(sc, rect->xmin, rect->ymax - 1);
+ sv3 = screen_addvert(sc, rect->xmax - 1, rect->ymax - 1);
+ sv4 = screen_addvert(sc, rect->xmax - 1, rect->ymin);
screen_addedge(sc, sv1, sv2);
screen_addedge(sc, sv2, sv3);
@@ -546,34 +552,29 @@ void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
*/
static void screen_vertices_scale(
const wmWindow *win, bScreen *sc,
- int window_size_x, int window_size_y,
- int screen_size_x, int screen_size_y)
+ const rcti *window_rect, const rcti *screen_rect)
{
/* clamp Y size of header sized areas when expanding windows
* avoids annoying empty space around file menu */
#define USE_HEADER_SIZE_CLAMP
const int headery_init = ED_area_headersize();
+ const int screen_size_x = BLI_rcti_size_x(screen_rect);
+ const int screen_size_y = BLI_rcti_size_y(screen_rect);
ScrVert *sv = NULL;
ScrArea *sa;
int screen_size_x_prev, screen_size_y_prev;
- float facx, facy, tempf, min[2], max[2];
-
+ float min[2], max[2];
+
/* calculate size */
min[0] = min[1] = 20000.0f;
max[0] = max[1] = 0.0f;
-
+
for (sv = sc->vertbase.first; sv; sv = sv->next) {
const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
minmax_v2v2_v2(min, max, fv);
}
-
- /* always make 0.0 left under */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
- sv->vec.x -= min[0];
- sv->vec.y -= min[1];
- }
-
+
screen_size_x_prev = (max[0] - min[0]) + 1;
screen_size_y_prev = (max[1] - min[1]) + 1;
@@ -590,12 +591,12 @@ static void screen_vertices_scale(
sa->temp = 0;
if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
- if (sa->v2->vec.y == screen_size_y_prev) {
+ if (sa->v2->vec.y == max[1]) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
sa->temp = TEMP_TOP;
}
}
- else if (sa->v1->vec.y == 0) {
+ else if (sa->v1->vec.y == min[1]) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
sa->temp = TEMP_BOTTOM;
}
@@ -607,26 +608,16 @@ static void screen_vertices_scale(
if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
- facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
- facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
-
+ const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
+ const float facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
+
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
- /* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428]
- * need some way to store these as floats internally and re-apply from there. */
- tempf = ((float)sv->vec.x) * facx;
- sv->vec.x = (short)(tempf + 0.5f);
- //sv->vec.x += AREAGRID - 1;
- //sv->vec.x -= (sv->vec.x % AREAGRID);
-
- CLAMP(sv->vec.x, 0, screen_size_x - 1);
-
- tempf = ((float)sv->vec.y) * facy;
- sv->vec.y = (short)(tempf + 0.5f);
- //sv->vec.y += AREAGRID - 1;
- //sv->vec.y -= (sv->vec.y % AREAGRID);
+ sv->vec.x = screen_rect->xmin + round_fl_to_short((sv->vec.x - min[0]) * facx);
+ CLAMP(sv->vec.x, screen_rect->xmin, screen_rect->xmax - 1);
- CLAMP(sv->vec.y, 0, screen_size_y);
+ sv->vec.y = screen_rect->ymin + round_fl_to_short((sv->vec.y - min[1]) * facy);
+ CLAMP(sv->vec.y, screen_rect->ymin, screen_rect->ymax);
}
}
@@ -688,23 +679,22 @@ static void screen_vertices_scale(
/* make each window at least ED_area_headersize() high */
for (sa = sc->areabase.first; sa; sa = sa->next) {
int headery = headery_init;
-
+
/* adjust headery if verts are along the edge of window */
- if (sa->v1->vec.y > 0)
+ if (sa->v1->vec.y > window_rect->ymin)
headery += U.pixelsize;
- if (sa->v2->vec.y < screen_size_y)
+ if (sa->v2->vec.y < window_rect->ymax)
headery += U.pixelsize;
-
+
if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
/* lower edge */
ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
if (se && sa->v1 != sa->v2) {
- int yval;
-
+ const int yval = sa->v2->vec.y - headery + 1;
+
select_connected_scredge(win, se);
-
+
/* all selected vertices get the right offset */
- yval = sa->v2->vec.y - headery + 1;
for (sv = sc->vertbase.first; sv; sv = sv->next) {
/* if is a collapsed area */
if (sv != sa->v2 && sv != sa->v3) {
@@ -717,18 +707,25 @@ static void screen_vertices_scale(
}
}
- /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set.
- * TODO Assumes global area to be top-aligned. Should be made more generic */
+ /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set. */
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) {
continue;
}
/* width */
- area->v1->vec.x = area->v2->vec.x = 0;
- area->v3->vec.x = area->v4->vec.x = window_size_x - 1;
+ area->v1->vec.x = area->v2->vec.x = window_rect->xmin;
+ area->v3->vec.x = area->v4->vec.x = window_rect->xmax - 1;
/* height */
- area->v2->vec.y = area->v3->vec.y = window_size_y - 1;
- area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
+ area->v1->vec.y = area->v4->vec.y = window_rect->ymin;
+ area->v2->vec.y = area->v3->vec.y = window_rect->ymax - 1;
+ switch (area->global->align) {
+ case GLOBAL_AREA_ALIGN_TOP:
+ area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
+ break;
+ case GLOBAL_AREA_ALIGN_BOTTOM:
+ area->v2->vec.y = area->v3->vec.y = area->v1->vec.y + ED_area_global_size_y(area);
+ break;
+ }
}
}
@@ -802,16 +799,16 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* exception for bg mode, we only need the screen context */
if (!G.background) {
- const int window_size_x = WM_window_pixels_x(win);
- const int window_size_y = WM_window_pixels_y(win);
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
+ rcti window_rect, screen_rect;
/* header size depends on DPI, let's verify */
WM_window_set_dpi(win);
screen_refresh_headersizes();
- screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+ WM_window_rect_calc(win, &window_rect);
+ WM_window_screen_rect_calc(win, &screen_rect); /* Get screen bounds __after__ updating window DPI! */
+
+ screen_vertices_scale(win, screen, &window_rect, &screen_rect);
ED_screen_areas_iter(win, screen, area) {
/* set spacetype and region callbacks, calls init() */
@@ -919,8 +916,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *prevwin = CTX_wm_window(C);
- ScrArea *sa;
- ARegion *ar;
CTX_wm_window_set(C, window);
@@ -931,13 +926,14 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
screen->active_region = NULL;
- for (ar = screen->regionbase.first; ar; ar = ar->next) {
+ for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) {
ED_region_exit(C, ar);
}
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
ED_area_exit(C, sa);
}
- for (sa = window->global_areas.areabase.first; sa; sa = sa->next) {
+ /* Don't use ED_screen_areas_iter here, it skips hidden areas. */
+ for (ScrArea *sa = window->global_areas.areabase.first; sa; sa = sa->next) {
ED_area_exit(C, sa);
}
@@ -1041,7 +1037,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
if (do_draw) {
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_HEADER) {
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
}
}
}
@@ -1111,39 +1107,56 @@ static ScrArea *screen_area_create_with_geometry(
return screen_addarea_ex(area_map, bottom_left, top_left, top_right, bottom_right, spacetype);
}
-void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
+static void screen_global_area_create(
+ wmWindow *win, eSpace_Type space_type, GlobalAreaAlign align, const rcti *rect,
+ const short height_cur, const short height_min, const short height_max)
{
- if (screen->temp == 0) {
- const short size_y = 2.25 * HEADERY;
- SpaceType *st;
- SpaceLink *sl;
- ScrArea *sa;
- rcti rect;
-
- BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
- rect.ymin = rect.ymax - size_y;
-
- sa = screen_area_create_with_geometry(&win->global_areas, &rect, SPACE_TOPBAR);
- st = BKE_spacetype_from_id(SPACE_TOPBAR);
- sl = st->new(sa, WM_window_get_active_scene(win));
- sa->regionbase = sl->regionbase;
-
- /* Data specific to global areas. */
- sa->global = MEM_callocN(sizeof(*sa->global), __func__);
- sa->global->cur_fixed_height = size_y;
- sa->global->size_max = size_y;
- sa->global->size_min = HEADERY;
-
- BLI_addhead(&sa->spacedata, sl);
- BLI_listbase_clear(&sl->regionbase);
- }
- /* Do not create more area types here! Function is called on file load (wm_window_ghostwindows_ensure). TODO */
+ ScrArea *area = screen_area_create_with_geometry(&win->global_areas, rect, space_type);
+ SpaceType *stype = BKE_spacetype_from_id(space_type);
+ SpaceLink *slink = stype->new(area, WM_window_get_active_scene(win));
+
+ area->regionbase = slink->regionbase;
+
+ /* Data specific to global areas. */
+ area->global = MEM_callocN(sizeof(*area->global), __func__);
+ area->global->cur_fixed_height = height_cur;
+ area->global->size_max = height_max;
+ area->global->size_min = height_min;
+ area->global->align = align;
+
+ BLI_addhead(&area->spacedata, slink);
+ BLI_listbase_clear(&slink->regionbase);
+}
+
+static void screen_global_topbar_area_create(wmWindow *win)
+{
+ const short size_y = 2.25 * HEADERY;
+ rcti rect;
+
+ BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
+ rect.ymin = rect.ymax - size_y;
+
+ screen_global_area_create(win, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size_y, HEADERY, size_y);
+}
+
+static void screen_global_statusbar_area_create(wmWindow *win)
+{
+ const short size_y = HEADERY;
+ rcti rect;
+
+ BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
+ rect.ymax = rect.ymin + size_y;
+
+ screen_global_area_create(win, SPACE_STATUSBAR, GLOBAL_AREA_ALIGN_BOTTOM, &rect, size_y, size_y, size_y);
}
void ED_screen_global_areas_create(wmWindow *win)
{
- const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- ED_screen_global_topbar_area_create(win, screen);
+ bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ if (screen->temp == 0) {
+ screen_global_topbar_area_create(win);
+ screen_global_statusbar_area_create(win);
+ }
}
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 045e5ee6b48..b54a5e04571 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -48,7 +48,7 @@ void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win,
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
-bScreen *screen_add(const char *name, const int winsize_x, const int winsize_y);
+bScreen *screen_add(const char *name, const rcti *rect);
void screen_data_copy(bScreen *to, bScreen *from);
void screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
void screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc);
@@ -61,7 +61,7 @@ void select_connected_scredge(const wmWindow *win, ScrEdge *edge);
bool scredge_is_horizontal(ScrEdge *se);
ScrEdge *screen_area_map_find_active_scredge(
const struct ScrAreaMap *area_map,
- const int winsize_x, const int winsize_y,
+ const rcti *bounds_rect,
const int mx, const int my);
ScrEdge *screen_find_active_scredge(
const wmWindow *win, const bScreen *screen,
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 68c05900520..5efbcd8a3f4 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -39,6 +39,7 @@
#include "BLT_translation.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_lattice_types.h"
#include "DNA_object_types.h"
@@ -53,6 +54,7 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_main.h"
@@ -70,6 +72,7 @@
#include "DEG_depsgraph.h"
+#include "ED_anim_api.h"
#include "ED_armature.h"
#include "ED_clip.h"
#include "ED_image.h"
@@ -143,6 +146,14 @@ int ED_operator_screen_mainwinactive(bContext *C)
return 1;
}
+int ED_operator_scene(bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ if (scene)
+ return 1;
+ return 0;
+}
+
int ED_operator_scene_editable(bContext *C)
{
Scene *scene = CTX_data_scene(C);
@@ -707,7 +718,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2])
}
/* XXX force redraw to show/hide the action zone */
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw_no_rebuild(sa);
break;
}
else if (az->type == AZONE_REGION_SCROLL) {
@@ -759,7 +770,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2])
}
if (redraw) {
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw_no_rebuild(sa);
}
/* Don't return! */
}
@@ -839,11 +850,8 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
switch (event->type) {
case MOUSEMOVE:
@@ -864,11 +872,15 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
sad->gesture_dir = 'w';
if (sad->az->type == AZONE_AREA) {
+ const wmWindow *win = CTX_wm_window(C);
+ rcti screen_rect;
+
+ WM_window_screen_rect_calc(win, &screen_rect);
/* once we drag outside the actionzone, register a gesture
* check we're not on an edge so join finds the other area */
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
(screen_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y) == NULL));
+ AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL));
}
else {
const int delta_min = 1;
@@ -1183,10 +1195,10 @@ typedef struct sAreaMoveData {
} sAreaMoveData;
/* helper call to move area-edge, sets limits
- * need window size in order to get correct limits */
+ * need window bounds in order to get correct limits */
static void area_move_set_limits(
wmWindow *win, bScreen *sc, int dir,
- const int winsize_x, const int winsize_y,
+ const rcti *screen_rect,
int *bigger, int *smaller,
bool *use_bigger_smaller_snap)
{
@@ -1239,9 +1251,9 @@ static void area_move_set_limits(
int y1;
areamin = areaminy;
- if (sa->v1->vec.y > 0)
+ if (sa->v1->vec.y > screen_rect->ymin)
areamin += U.pixelsize;
- if (sa->v2->vec.y < winsize_y - 1)
+ if (sa->v2->vec.y < (screen_rect->ymax - 1))
areamin += U.pixelsize;
y1 = sa->v2->vec.y - sa->v1->vec.y + 1 - areamin;
@@ -1256,9 +1268,9 @@ static void area_move_set_limits(
int x1;
areamin = AREAMINX;
- if (sa->v1->vec.x > 0)
+ if (sa->v1->vec.x > screen_rect->xmin)
areamin += U.pixelsize;
- if (sa->v4->vec.x < winsize_x - 1)
+ if (sa->v4->vec.x < (screen_rect->xmax - 1))
areamin += U.pixelsize;
x1 = sa->v4->vec.x - sa->v1->vec.x + 1 - areamin;
@@ -1280,8 +1292,7 @@ static int area_move_init(bContext *C, wmOperator *op)
wmWindow *win = CTX_wm_window(C);
ScrEdge *actedge;
sAreaMoveData *md;
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
+ rcti screen_rect;
int x, y;
/* required properties */
@@ -1305,8 +1316,10 @@ static int area_move_init(bContext *C, wmOperator *op)
v1->editflag = v1->flag;
}
+ WM_window_screen_rect_calc(win, &screen_rect);
+
bool use_bigger_smaller_snap = false;
- area_move_set_limits(win, sc, md->dir, screen_size_x, screen_size_y,
+ area_move_set_limits(win, sc, md->dir, &screen_rect,
&md->bigger, &md->smaller,
&use_bigger_smaller_snap);
@@ -1769,14 +1782,15 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sAreaSplitData *sd;
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
+ rcti screen_rect;
int dir;
/* no full window splitting allowed */
if (sc->state != SCREENNORMAL)
return OPERATOR_CANCELLED;
-
+
+ WM_window_screen_rect_calc(win, &screen_rect);
+
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
@@ -1822,8 +1836,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
y = RNA_int_get(op->ptr, "mouse_y");
else
y = event->x;
-
- actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, x, y);
+
+ actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, x, y);
if (actedge == NULL)
return OPERATOR_CANCELLED;
@@ -1843,8 +1857,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* do the split */
if (area_split_apply(C, op)) {
- area_move_set_limits(win, sc, dir, screen_size_x, screen_size_y, &sd->bigger, &sd->smaller, NULL);
-
+ area_move_set_limits(win, sc, dir, &screen_rect, &sd->bigger, &sd->smaller, NULL);
+
/* add temp handler for edge move or cancel */
WM_event_add_modal_handler(C, op);
@@ -2728,7 +2742,8 @@ static int screen_maximize_area_poll(bContext *C)
const bScreen *screen = CTX_wm_screen(C);
const ScrArea *area = CTX_wm_area(C);
return ED_operator_areaactive(C) &&
- ((screen->state != SCREENNORMAL) || (area->spacetype != SPACE_TOPBAR));
+ /* Don't allow maximizing global areas but allow minimizing from them. */
+ ((screen->state != SCREENNORMAL) || !ED_area_is_global(area));
}
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
@@ -3044,17 +3059,16 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- wmWindow *win = CTX_wm_window(C);
- bScreen *sc = CTX_wm_screen(C);
+ const wmWindow *win = CTX_wm_window(C);
+ const bScreen *sc = CTX_wm_screen(C);
uiPopupMenu *pup;
uiLayout *layout;
PointerRNA ptr;
ScrEdge *actedge;
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
+ rcti screen_rect;
- actedge = screen_area_map_find_active_scredge(
- AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y);
+ WM_window_screen_rect_calc(win, &screen_rect);
+ actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y);
if (actedge == NULL) return OPERATOR_CANCELLED;
@@ -4162,7 +4176,7 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int sizex = 800 * UI_DPI_FAC;
- int sizey = 480 * UI_DPI_FAC;
+ int sizey = 500 * UI_DPI_FAC;
/* changes context! */
if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) {
@@ -4190,6 +4204,74 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Show Drivers Editor Operator
+ * \{ */
+
+static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ PointerRNA ptr = {{NULL}};
+ PropertyRNA *prop = NULL;
+ int index = -1;
+ uiBut *but = NULL;
+
+ int sizex = 900 * UI_DPI_FAC;
+ int sizey = 580 * UI_DPI_FAC;
+
+ /* Get active property to show driver for
+ * - Need to grab it first, or else this info disappears
+ * after we've created the window
+ */
+ but = UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ /* changes context! */
+ if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_DRIVERS) != NULL) {
+ /* activate driver F-Curve for the property under the cursor */
+ if (but) {
+ FCurve *fcu;
+ bool driven, special;
+
+ fcu = rna_get_fcurve_context_ui(C,
+ &ptr, prop, index,
+ NULL, NULL, &driven, &special);
+ if (fcu) {
+ /* Isolate this F-Curve... */
+ bAnimContext ac;
+ if (ANIM_animdata_get_context(C, &ac)) {
+ int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS;
+ ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ ANIM_set_active_channel(&ac, ac.data, ac.datatype, filter, fcu, ANIMTYPE_FCURVE);
+ }
+ else {
+ /* Just blindly isolate... This isn't the best, and shouldn't happen, but may be enough... */
+ fcu->flag |= (FCURVE_ACTIVE | FCURVE_SELECTED);
+ }
+ }
+ }
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "Failed to open window!");
+ return OPERATOR_CANCELLED;
+ }
+}
+
+
+static void SCREEN_OT_drivers_editor_show(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Show Drivers Editor";
+ ot->description = "Show drivers editor in a separate window";
+ ot->idname = "SCREEN_OT_drivers_editor_show";
+
+ /* api callbacks */
+ ot->invoke = drivers_editor_show_invoke;
+ ot->poll = ED_operator_screenactive;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name New Screen Operator
* \{ */
@@ -4514,6 +4596,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_screenshot);
WM_operatortype_append(SCREEN_OT_screencast);
WM_operatortype_append(SCREEN_OT_userpref_show);
+ WM_operatortype_append(SCREEN_OT_drivers_editor_show);
WM_operatortype_append(SCREEN_OT_region_blend);
WM_operatortype_append(SCREEN_OT_space_context_cycle);
@@ -4635,13 +4718,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
- WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", DOWNARROWKEY, KM_PRESS, KM_CTRL, 0);
- /* we already have two keys for this, disabled for use by WM_OT_toolbar */
-#if 0
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_SHIFT, 0);
-#endif
- kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", F10KEY, KM_PRESS, KM_ALT, 0);
+ kmi = WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "use_hide_panels", true);
WM_keymap_add_item(keymap, "SCREEN_OT_screenshot", F3KEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 35d916e403d..d54996bad59 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -65,6 +65,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
#include "screen_intern.h"
@@ -109,7 +110,7 @@ static void workspace_change_update_view_layer(
WorkSpace *workspace_new, const WorkSpace *workspace_old,
Scene *scene)
{
- if (!BKE_workspace_view_layer_get(workspace_new, scene)) {
+ if (!BKE_workspace_view_layer_exists(workspace_new, scene)) {
BKE_workspace_view_layer_set(workspace_new, BKE_workspace_view_layer_get(workspace_old, scene), scene);
}
}
@@ -198,7 +199,7 @@ bool ED_workspace_change(
screen_change_update(C, win, screen_new);
workspace_change_update(workspace_new, workspace_old, C, wm);
- BLI_assert(BKE_workspace_view_layer_get(workspace_new, CTX_data_scene(C)) != NULL);
+ BLI_assert(BKE_workspace_view_layer_exists(workspace_new, CTX_data_scene(C)) != NULL);
BLI_assert(CTX_wm_workspace(C) == workspace_new);
WM_toolsystem_unlink_all(C, workspace_old);
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index a6f991d4bbe..6285f031836 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -50,13 +50,13 @@ WorkSpaceLayout *ED_workspace_layout_add(
wmWindow *win,
const char *name)
{
- const int screen_size_x = WM_window_screen_pixels_x(win);
- const int screen_size_y = WM_window_screen_pixels_y(win);
+ bScreen *screen;
+ rcti screen_rect;
- bScreen *screen = screen_add(name, screen_size_x, screen_size_y);
- WorkSpaceLayout *layout = BKE_workspace_layout_add(workspace, screen, name);
+ WM_window_screen_rect_calc(win, &screen_rect);
+ screen = screen_add(name, &screen_rect);
- return layout;
+ return BKE_workspace_layout_add(workspace, screen, name);
}
WorkSpaceLayout *ED_workspace_layout_duplicate(
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 6a32fdecfad..9ecdc44cd10 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -74,6 +74,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -298,7 +299,7 @@ static int image_paint_poll(bContext *C)
return image_paint_poll_ex(C, true);
}
-static int image_paint_poll_ignore_tool(bContext *C)
+static int image_paint_ignore_tool_poll(bContext *C)
{
return image_paint_poll_ex(C, false);
}
@@ -1010,11 +1011,6 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int sample_color_poll(bContext *C)
-{
- return (image_paint_poll_ignore_tool(C) || image_paint_poll_ignore_tool(C));
-}
-
void PAINT_OT_sample_color(wmOperatorType *ot)
{
/* identifiers */
@@ -1026,7 +1022,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
ot->exec = sample_color_exec;
ot->invoke = sample_color_invoke;
ot->modal = sample_color_modal;
- ot->poll = sample_color_poll;
+ ot->poll = image_paint_ignore_tool_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index a1435d5916a..76449b61d4d 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -81,6 +81,7 @@
#include "BKE_texture.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
@@ -3083,7 +3084,7 @@ static void proj_paint_state_non_cddm_init(ProjPaintState *ps)
}
static void proj_paint_state_viewport_init(
- ProjPaintState *ps, const char symmetry_flag)
+ ProjPaintState *ps, const Depsgraph *depsgraph, const char symmetry_flag)
{
float mat[3][3];
float viewmat[4][4];
@@ -3144,17 +3145,17 @@ static void proj_paint_state_viewport_init(
invert_m4_m4(viewinv, viewmat);
}
else if (ps->source == PROJ_SRC_IMAGE_CAM) {
- Object *cam_ob = ps->scene->camera;
+ Object *cam_ob_eval = DEG_get_evaluated_object(depsgraph, ps->scene->camera);
CameraParams params;
/* viewmat & viewinv */
- copy_m4_m4(viewinv, cam_ob->obmat);
+ copy_m4_m4(viewinv, cam_ob_eval->obmat);
normalize_m4(viewinv);
invert_m4_m4(viewmat, viewinv);
/* window matrix, clipping and ortho */
BKE_camera_params_init(&params);
- BKE_camera_params_from_object(&params, cam_ob);
+ BKE_camera_params_from_object(&params, cam_ob_eval);
BKE_camera_params_compute_viewplane(&params, ps->winx, ps->winy, 1.0f, 1.0f);
BKE_camera_params_compute_matrix(&params);
@@ -3858,7 +3859,7 @@ static void project_paint_begin(
proj_paint_state_cavity_init(ps);
}
- proj_paint_state_viewport_init(ps, symmetry_flag);
+ proj_paint_state_viewport_init(ps, CTX_data_depsgraph(C), symmetry_flag);
/* calculate vert screen coords
* run this early so we can calculate the x/y resolution of our bucket rect */
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index f8888ad9809..b2f3c49cb00 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -50,13 +50,15 @@
#include "BKE_brush.h"
#include "BKE_context.h"
-#include "BKE_DerivedMesh.h"
+#include "BKE_customdata.h"
#include "BKE_image.h"
#include "BKE_material.h"
+#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -274,26 +276,26 @@ static void imapaint_tri_weights(float matrix[4][4], GLint view[4],
}
/* compute uv coordinates of mouse in face */
-static void imapaint_pick_uv(Depsgraph *depsgraph, Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
+static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsigned int faceindex, const int xy[2], float uv[2])
{
- DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
- const int tottri = dm->getNumLoopTri(dm);
+ const int tottri = me_eval->runtime.looptris.len;
int i, findex;
float p[2], w[3], absw, minabsw;
float matrix[4][4], proj[4][4];
GLint view[4];
const eImagePaintMode mode = scene->toolsettings->imapaint.mode;
- const MLoopTri *lt = dm->getLoopTriArray(dm);
- const MPoly *mpoly = dm->getPolyArray(dm);
- const MLoop *mloop = dm->getLoopArray(dm);
- const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ const MLoopTri *lt = me_eval->runtime.looptris.array;
+ const MVert *mvert = me_eval->mvert;
+ const MPoly *mpoly = me_eval->mpoly;
+ const MLoop *mloop = me_eval->mloop;
+ const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
/* get the needed opengl matrices */
glGetIntegerv(GL_VIEWPORT, view);
gpuGetModelViewMatrix(matrix);
gpuGetProjectionMatrix(proj);
view[0] = view[1] = 0;
- mul_m4_m4m4(matrix, matrix, ob->obmat);
+ mul_m4_m4m4(matrix, matrix, ob_eval->obmat);
mul_m4_m4m4(matrix, proj, matrix);
minabsw = 1e10;
@@ -310,25 +312,25 @@ static void imapaint_pick_uv(Depsgraph *depsgraph, Scene *scene, Object *ob, uns
const MLoopUV *tri_uv[3];
float tri_co[3][3];
- dm->getVertCo(dm, mloop[lt->tri[0]].v, tri_co[0]);
- dm->getVertCo(dm, mloop[lt->tri[1]].v, tri_co[1]);
- dm->getVertCo(dm, mloop[lt->tri[2]].v, tri_co[2]);
+ for (int j = 3; j--; ) {
+ copy_v3_v3(tri_co[j], mvert[mloop[lt->tri[j]].v].co);
+ }
if (mode == IMAGEPAINT_MODE_MATERIAL) {
const Material *ma;
const TexPaintSlot *slot;
- ma = dm->mat[mp->mat_nr];
+ ma = give_current_material(ob_eval, mp->mat_nr);
slot = &ma->texpaintslot[ma->paint_active_slot];
if (!(slot && slot->uvname &&
- (mloopuv = CustomData_get_layer_named(&dm->loopData, CD_MLOOPUV, slot->uvname))))
+ (mloopuv = CustomData_get_layer_named(&me_eval->ldata, CD_MLOOPUV, slot->uvname))))
{
- mloopuv = CustomData_get_layer(&dm->loopData, CD_MLOOPUV);
+ mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
}
}
else {
- mloopuv = CustomData_get_layer(&dm->loopData, CD_MLOOPUV);
+ mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
}
tri_uv[0] = &mloopuv[lt->tri[0]];
@@ -347,8 +349,6 @@ static void imapaint_pick_uv(Depsgraph *depsgraph, Scene *scene, Object *ob, uns
}
}
}
-
- dm->release(dm);
}
/* returns 0 if not found, otherwise 1 */
@@ -452,20 +452,21 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
/* first try getting a colour directly from the mesh faces if possible */
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bool sample_success = false;
ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
if (ob) {
Mesh *me = (Mesh *)ob->data;
- DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Mesh *me_eval = BKE_object_get_evaluated_mesh(depsgraph, ob); /* Or shall we just do ob_eval->mesh_evaluated ? */
ViewContext vc;
const int mval[2] = {x, y};
unsigned int faceindex;
unsigned int totpoly = me->totpoly;
- if (dm->getLoopDataArray(dm, CD_MLOOPUV)) {
+ if (CustomData_has_layer(&me_eval->ldata, CD_MLOOPUV)) {
ED_view3d_viewcontext_init(C, &vc);
view3d_operator_needs_opengl(C);
@@ -474,7 +475,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
Image *image;
if (use_material)
- image = imapaint_face_image(ob, me, faceindex);
+ image = imapaint_face_image(ob_eval, me_eval, faceindex);
else
image = imapaint->canvas;
@@ -483,7 +484,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
if (ibuf && ibuf->rect) {
float uv[2];
float u, v;
- imapaint_pick_uv(depsgraph, scene, ob, faceindex, mval, uv);
+ imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv);
sample_success = true;
u = fmodf(uv[0], 1.0f);
@@ -525,7 +526,6 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
}
}
}
- dm->release(dm);
}
if (!sample_success) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 3c3df2067ab..311587d6b53 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -69,6 +69,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "ED_object.h"
#include "ED_mesh.h"
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 709d6d4c690..5acc1cd0c6a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -77,6 +77,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "ED_sculpt.h"
#include "ED_object.h"
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 2a0be4eaf0d..febbcd03645 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -379,6 +379,41 @@ static void action_channel_region_listener(
}
}
+static void saction_channel_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* All dopesheet filter settings, etc. affect the drawing of this editor,
+ * so just whitelist the entire struct for updates
+ */
+ {
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ StructRNA *type_array[] = {
+ &RNA_DopeSheet,
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
+ msg_key_params.ptr.type = type_array[i];
+ WM_msg_subscribe_rna_params(
+ mbus,
+ &msg_key_params,
+ &msg_sub_value_region_tag_redraw,
+ __func__);
+ }
+ }
+}
+
static void action_main_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
@@ -472,6 +507,25 @@ static void saction_main_region_message_subscribe(
WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
}
}
+
+ /* All dopesheet filter settings, etc. affect the drawing of this editor,
+ * so just whitelist the entire struct for updates
+ */
+ {
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ StructRNA *type_array[] = {
+ &RNA_DopeSheet,
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
+ msg_key_params.ptr.type = type_array[i];
+ WM_msg_subscribe_rna_params(
+ mbus,
+ &msg_key_params,
+ &msg_sub_value_region_tag_redraw,
+ __func__);
+ }
+ }
}
/* editor level listener */
@@ -835,6 +889,7 @@ void ED_spacetype_action(void)
art->init = action_channel_region_init;
art->draw = action_channel_region_draw;
art->listener = action_channel_region_listener;
+ art->message_subscribe = saction_channel_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 12f16f1fe42..4d4bcf4dffc 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -97,9 +97,10 @@ void ED_spacetypes_init(void)
ED_spacetype_console();
ED_spacetype_userpref();
ED_spacetype_clip();
+ ED_spacetype_statusbar();
ED_spacetype_topbar();
// ...
-
+
/* register operator types for screen and all spaces */
ED_operatortypes_workspace();
ED_operatortypes_scene();
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index c79652795ac..3c75bc5763d 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -154,17 +154,12 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
PointerRNA fcu_ptr;
uiLayout *layout = pa->layout;
uiLayout *col, *row, *sub;
- // uiBlock *block; // UNUSED
char name[256];
int icon = 0;
if (!graph_panel_context(C, &ale, &fcu))
return;
- // UNUSED
- // block = uiLayoutGetBlock(layout);
- // UI_block_func_handle_set(block, do_graph_region_buttons, NULL);
-
/* F-Curve pointer */
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
@@ -192,7 +187,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
icon = ICON_NLA;
}
uiItemL(col, name, icon);
-
+
/* RNA-Path Editing - only really should be enabled when things aren't working */
col = uiLayoutColumn(layout, true);
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
@@ -205,16 +200,16 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
row = uiLayoutRow(col, true);
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
-
+
sub = uiLayoutRow(row, true);
uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
-
+
/* smoothing setting */
col = uiLayoutColumn(layout, true);
uiItemL(col, IFACE_("Auto Handle Smoothing:"), ICON_NONE);
uiItemR(col, &fcu_ptr, "auto_smoothing", 0, "", ICON_NONE);
-
+
MEM_freeN(ale);
}
@@ -472,7 +467,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
#define B_IPO_DEPCHANGE 10
-static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event)
+static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -480,6 +475,16 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e
switch (event) {
case B_IPO_DEPCHANGE:
{
+ /* force F-Curve & Driver to get re-evaluated (same as the old Update Dependencies) */
+ FCurve *fcu = (FCurve *)fcu_v;
+ ChannelDriver *driver = (fcu) ? fcu->driver : NULL;
+
+ /* clear invalid flags */
+ if (fcu) {
+ fcu->flag &= ~FCURVE_DISABLED;
+ driver->flag &= ~DRIVER_FLAG_INVALID;
+ }
+
/* rebuild depsgraph for the new deps */
DEG_relations_tag_update(bmain);
break;
@@ -490,23 +495,6 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier
}
-/* callback to remove the active driver */
-static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg))
-{
- bAnimListElem *ale = (bAnimListElem *)ale_v;
- ID *id = ale->id;
- FCurve *fcu = ale->data;
- ReportList *reports = CTX_wm_reports(C);
-
- /* try to get F-Curve that driver lives on, and ID block which has this AnimData */
- if (ELEM(NULL, id, fcu))
- return;
-
- /* call API method to remove this driver */
- ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0);
- ED_undo_push(C, "Remove Driver");
-}
-
/* callback to add a target variable to the active driver */
static void driver_add_var_cb(bContext *C, void *driver_v, void *UNUSED(arg))
{
@@ -728,60 +716,88 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar
uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
}
-/* driver settings for active F-Curve (only for 'Drivers' mode) */
-static void graph_panel_drivers(const bContext *C, Panel *pa)
+/* ----------------------------------------------------------------- */
+
+
+/* property driven by the driver - duplicates Active FCurve, but useful for clarity */
+static void graph_draw_driven_property_panel(uiLayout *layout, ID *id, FCurve *fcu)
{
- bAnimListElem *ale;
- FCurve *fcu;
- ChannelDriver *driver;
+ PointerRNA fcu_ptr;
+ uiLayout *row;
+ char name[256];
+ int icon = 0;
+
+ /* F-Curve pointer */
+ RNA_pointer_create(id, &RNA_FCurve, fcu, &fcu_ptr);
+
+ /* get user-friendly 'name' for F-Curve */
+ icon = getname_anim_fcurve(name, id, fcu);
+
+ /* panel layout... */
+ row = uiLayoutRow(layout, true);
+ uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
+
+ /* -> user friendly 'name' for datablock that owns F-Curve */
+ /* XXX: Actually, we may need the datablock icons only... (e.g. right now will show bone for bone props) */
+ uiItemL(row, id->name + 2, icon);
+
+ /* -> user friendly 'name' for F-Curve/driver target */
+ uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC);
+ uiItemL(row, name, ICON_RNA);
+}
+
+/* UI properties panel layout for driver settings - shared for Drivers Editor and for */
+static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *fcu)
+{
+ ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
PointerRNA driver_ptr;
- uiLayout *col;
+ uiLayout *col, *row;
uiBlock *block;
uiBut *but;
- /* Get settings from context */
- if (!graph_panel_context(C, &ale, &fcu))
- return;
- driver = fcu->driver;
-
/* set event handler for panel */
- block = uiLayoutGetBlock(pa->layout); // xxx?
+ block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL);
- /* general actions - management */
- col = uiLayoutColumn(pa->layout, false);
- block = uiLayoutGetBlock(col);
- but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
- 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
- NULL, 0.0, 0.0, 0, 0,
- TIP_("Force updates of dependencies"));
- UI_but_func_set(but, driver_update_flags_cb, fcu, NULL);
-
- but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"),
- 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
- NULL, 0.0, 0.0, 0, 0,
- TIP_("Remove this driver"));
- UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
-
/* driver-level settings - type, expressions, and errors */
- RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
+ RNA_pointer_create(id, &RNA_Driver, driver, &driver_ptr);
- col = uiLayoutColumn(pa->layout, true);
+ col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
-
+
+ {
+ char valBuf[32];
+
+ /* value of driver */
+ row = uiLayoutRow(col, true);
+ uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
+ BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
+ uiItemL(row, valBuf, ICON_NONE);
+ }
+
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
/* expression */
- uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
+ /* TODO: "Show syntax hints" button */
+ col = uiLayoutColumn(layout, true);
+ block = uiLayoutGetBlock(col);
+
+ uiItemL(col, IFACE_("Expression:"), ICON_NONE);
+ uiItemR(col, &driver_ptr, "expression", 0, "", ICON_NONE);
+ uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
/* errors? */
+ col = uiLayoutColumn(layout, true);
+ block = uiLayoutGetBlock(col);
+
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
+ /* TODO: Add button to enable? */
uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
}
else if (driver->flag & DRIVER_FLAG_INVALID) {
@@ -803,6 +819,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
}
else {
/* errors? */
+ col = uiLayoutColumn(layout, true);
+ block = uiLayoutGetBlock(col);
+
if (driver->flag & DRIVER_FLAG_INVALID)
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
@@ -821,38 +840,16 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
}
}
}
-
- col = uiLayoutColumn(pa->layout, true);
-
- if (driver->type == DRIVER_TYPE_PYTHON) {
- uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
- }
-
- /* debug setting */
- uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
-
- /* value of driver */
- if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
- uiLayout *row = uiLayoutRow(col, true);
- char valBuf[32];
-
- uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
-
- BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
- uiItemL(row, valBuf, ICON_NONE);
- }
/* add/copy/paste driver variables */
{
- uiLayout *row;
-
/* add driver variable */
- row = uiLayoutRow(pa->layout, false);
+ row = uiLayoutRow(layout, false);
block = uiLayoutGetBlock(row);
- but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"),
+ but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Input Variable"),
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0, 0,
- TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly"));
+ TIP_("Driver variables ensure that all dependencies will be accounted for, eusuring that drivers will update correctly"));
UI_but_func_set(but, driver_add_var_cb, driver, NULL);
/* copy/paste (as sub-row) */
@@ -866,15 +863,15 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* loop over targets, drawing them */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
PointerRNA dvar_ptr;
- uiLayout *box, *row;
+ uiLayout *box;
uiLayout *subrow, *sub;
/* sub-layout column for this variable's settings */
- col = uiLayoutColumn(pa->layout, true);
+ col = uiLayoutColumn(layout, true);
/* 1) header panel */
box = uiLayoutBox(col);
- RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
+ RNA_pointer_create(id, &RNA_DriverVariable, dvar, &dvar_ptr);
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row);
@@ -915,21 +912,21 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* controls to draw depends on the type of variable */
switch (dvar->type) {
case DVAR_TYPE_SINGLE_PROP: /* single property */
- graph_panel_driverVar__singleProp(box, ale->id, dvar);
+ graph_panel_driverVar__singleProp(box, id, dvar);
break;
case DVAR_TYPE_ROT_DIFF: /* rotational difference */
- graph_panel_driverVar__rotDiff(box, ale->id, dvar);
+ graph_panel_driverVar__rotDiff(box, id, dvar);
break;
case DVAR_TYPE_LOC_DIFF: /* location difference */
- graph_panel_driverVar__locDiff(box, ale->id, dvar);
+ graph_panel_driverVar__locDiff(box, id, dvar);
break;
case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
- graph_panel_driverVar__transChan(box, ale->id, dvar);
+ graph_panel_driverVar__transChan(box, id, dvar);
break;
}
/* 3) value of variable */
- if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
+ {
char valBuf[32];
box = uiLayoutBox(col);
@@ -951,10 +948,99 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
}
}
+ /* XXX: This should become redundant. But sometimes the flushing fails, so keep this around for a while longer as a "last resort" */
+ row = uiLayoutRow(layout, true);
+ block = uiLayoutGetBlock(row);
+ but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
+ 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Force updates of dependencies - Only use this if drivers are not updating correctly"));
+ UI_but_func_set(but, driver_update_flags_cb, fcu, NULL);
+}
+
+/* ----------------------------------------------------------------- */
+
+
+/* panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve, but useful for clarity */
+static void graph_panel_driven_property(const bContext *C, Panel *pa)
+{
+ bAnimListElem *ale;
+ FCurve *fcu;
+
+ if (!graph_panel_context(C, &ale, &fcu))
+ return;
+
+ graph_draw_driven_property_panel(pa->layout, ale->id, fcu);
+
+ MEM_freeN(ale);
+}
+
+/* driver settings for active F-Curve (only for 'Drivers' mode in Graph Editor, i.e. the full "Drivers Editor") */
+static void graph_panel_drivers(const bContext *C, Panel *pa)
+{
+ bAnimListElem *ale;
+ FCurve *fcu;
+
+ /* Get settings from context */
+ if (!graph_panel_context(C, &ale, &fcu))
+ return;
+
+ graph_draw_driver_settings_panel(pa->layout, ale->id, fcu);
+
/* cleanup */
MEM_freeN(ale);
}
+/* ----------------------------------------------------------------- */
+
+/* poll to make this not show up in the graph editor, as this is only to be used as a popup elsewhere */
+static int graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+ return ED_operator_graphedit_active((bContext *)C) == false;
+}
+
+/* popover panel for driver editing anywhere in ui */
+static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
+{
+ uiLayout *layout = pa->layout;
+
+ PointerRNA ptr = {{NULL}};
+ PropertyRNA *prop = NULL;
+ int index = -1;
+ uiBut *but = NULL;
+
+ /* Get active property to show driver properties for */
+ but = UI_context_active_but_prop_get((bContext *)C, &ptr, &prop, &index);
+ if (but) {
+ FCurve *fcu;
+ bool driven, special;
+
+ fcu = rna_get_fcurve_context_ui((bContext *)C,
+ &ptr, prop, index,
+ NULL, NULL, &driven, &special);
+
+ /* Populate Panel - With a combination of the contents of the Driven and Driver panels */
+ if (fcu) {
+ ID *id = ptr.id.data;
+
+ /* Driven Property Settings */
+ uiItemL(layout, IFACE_("Driven Property:"), ICON_NONE);
+ graph_draw_driven_property_panel(pa->layout, id, fcu);
+ /* TODO: All vs Single */
+
+ uiItemS(layout);
+ uiItemS(layout);
+
+ /* Drivers Settings */
+ uiItemL(layout, IFACE_("Driver Settings:"), ICON_NONE);
+ graph_draw_driver_settings_panel(pa->layout, id, fcu);
+ }
+ }
+
+ /* Show drivers editor is always visible */
+ uiItemO(layout, IFACE_("Show in Drivers Editor"), ICON_DRIVER, "SCREEN_OT_drivers_editor_show");
+}
+
/* ******************* F-Modifiers ******************************** */
/* All the drawing code is in editors/animation/fmodifier_ui.c */
@@ -1035,15 +1121,32 @@ void graph_buttons_register(ARegionType *art)
pt->poll = graph_panel_poll;
BLI_addtail(&art->paneltypes, pt);
+ pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers driven");
+ strcpy(pt->idname, "GRAPH_PT_driven_property");
+ strcpy(pt->label, N_("Driven Property"));
+ strcpy(pt->category, "Drivers");
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->draw = graph_panel_driven_property;
+ pt->poll = graph_panel_drivers_poll;
+ BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
strcpy(pt->idname, "GRAPH_PT_drivers");
- strcpy(pt->label, N_("Drivers"));
+ strcpy(pt->label, N_("Driver"));
strcpy(pt->category, "Drivers");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = graph_panel_drivers;
pt->poll = graph_panel_drivers_poll;
BLI_addtail(&art->paneltypes, pt);
+
+ pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers pover");
+ strcpy(pt->idname, "GRAPH_PT_drivers_popover");
+ strcpy(pt->label, N_("Add/Edit Driver"));
+ strcpy(pt->category, "Drivers");
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->draw = graph_panel_drivers_popover;
+ pt->poll = graph_panel_drivers_popover_poll;
+ BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
strcpy(pt->idname, "GRAPH_PT_modifiers");
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 8d3647def9e..3732b78a026 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -525,6 +525,25 @@ static void graph_region_message_subscribe(
WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
}
}
+
+ /* All dopesheet filter settings, etc. affect the drawing of this editor,
+ * so just whitelist the entire struct for updates
+ */
+ {
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ StructRNA *type_array[] = {
+ &RNA_DopeSheet,
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
+ msg_key_params.ptr.type = type_array[i];
+ WM_msg_subscribe_rna_params(
+ mbus,
+ &msg_key_params,
+ &msg_sub_value_region_tag_redraw,
+ __func__);
+ }
+ }
}
/* editor level listener */
@@ -810,6 +829,7 @@ void ED_spacetype_ipo(void)
art->prefsizex = 200 + V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
art->listener = graph_region_listener;
+ art->message_subscribe = graph_region_message_subscribe;
art->init = graph_channel_region_init;
art->draw = graph_channel_region_draw;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 1943cb2c00b..c303a78594d 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -171,12 +171,12 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
simage->spacetype = SPACE_IMAGE;
simage->zoom = 1.0f;
simage->lock = true;
- simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA;
+ simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
simage->iuser.ok = true;
simage->iuser.fie_ima = 2;
simage->iuser.frames = 100;
- simage->iuser.flag = IMA_SHOW_STEREO;
+ simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS;
scopes_new(&simage->scopes);
simage->sample_line_hist.height = 100;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 7245fd9c17f..e56fc12c75b 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -527,6 +527,41 @@ static void nla_channel_region_listener(
}
}
+static void nla_channel_region_message_subscribe(
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene),
+ struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&screen->id, &RNA_SpaceNLA, sa->spacedata.first, &ptr);
+
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* All dopesheet filter settings, etc. affect the drawing of this editor,
+ * so just whitelist the entire struct for updates
+ */
+ {
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ StructRNA *type_array[] = {
+ &RNA_DopeSheet,
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
+ msg_key_params.ptr.type = type_array[i];
+ WM_msg_subscribe_rna_params(
+ mbus,
+ &msg_key_params,
+ &msg_sub_value_region_tag_redraw,
+ __func__);
+ }
+ }
+}
+
/* editor level listener */
static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
WorkSpace *UNUSED(workspace))
@@ -628,6 +663,7 @@ void ED_spacetype_nla(void)
art->init = nla_channel_region_init;
art->draw = nla_channel_region_draw;
art->listener = nla_channel_region_listener;
+ art->message_subscribe = nla_channel_region_message_subscribe;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 4b4add0e698..fcbd8156723 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -653,7 +653,7 @@ void NODE_OT_select_circle(wmOperatorType *ot)
/* ****** Lasso Select ****** */
-static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves, short select)
+static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves, bool select, bool extend)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
@@ -668,6 +668,11 @@ static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves
/* do actual selection */
for (node = snode->edittree->nodes.first; node; node = node->next) {
+
+ if (node->flag & NODE_SELECT && select && extend) {
+ continue;
+ }
+
int screen_co[2];
const float cent[2] = {BLI_rctf_cent_x(&node->totr),
BLI_rctf_cent_y(&node->totr)};
@@ -680,6 +685,10 @@ static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves
nodeSetSelected(node, select);
changed = true;
}
+ else if (select && !extend) {
+ nodeSetSelected(node, false);
+ changed = true;
+ }
}
if (changed) {
@@ -695,10 +704,9 @@ static int node_lasso_select_exec(bContext *C, wmOperator *op)
const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
if (mcords) {
- short select;
-
- select = !RNA_boolean_get(op->ptr, "deselect");
- do_lasso_select_node(C, mcords, mcords_tot, select);
+ const bool select = !RNA_boolean_get(op->ptr, "deselect");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ do_lasso_select_node(C, mcords, mcords_tot, select, extend);
MEM_freeN((void *)mcords);
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index c44345a168b..50df124bf22 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -104,7 +104,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
static int collections_editor_poll(bContext *C)
{
SpaceOops *so = CTX_wm_space_outliner(C);
- return (so != NULL) && ELEM(so->outlinevis, SO_VIEW_LAYER, SO_SCENES);
+ return (so != NULL) && ELEM(so->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index e51f96e7d7a..68ac2126e84 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -266,8 +266,6 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
{
Main *bmain = CTX_data_main(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
BLI_mempool *ts = soops->treestore;
TreeStoreElem *tselem = tsep;
@@ -329,37 +327,39 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
BLI_strncpy(newname, ebone->name, sizeof(ebone->name));
BLI_strncpy(ebone->name, oldname, sizeof(ebone->name));
ED_armature_bone_rename(obedit->data, oldname, newname);
- WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT(view_layer));
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
}
break;
}
case TSE_BONE:
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Scene *scene = CTX_data_scene(C);
+ bArmature *arm = (bArmature *)tselem->id;
Bone *bone = te->directdata;
- Object *ob;
char newname[sizeof(bone->name)];
/* always make current object active */
tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, true);
- ob = OBACT(view_layer);
/* restore bone name */
BLI_strncpy(newname, bone->name, sizeof(bone->name));
BLI_strncpy(bone->name, oldname, sizeof(bone->name));
- ED_armature_bone_rename(ob->data, oldname, newname);
- WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ ED_armature_bone_rename(arm, oldname, newname);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
break;
}
case TSE_POSE_CHANNEL:
{
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = (Object *)tselem->id;
bPoseChannel *pchan = te->directdata;
- Object *ob;
char newname[sizeof(pchan->name)];
/* always make current pose-bone active */
tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, true);
- ob = OBACT(view_layer);
BLI_assert(ob->type == OB_ARMATURE);
@@ -367,7 +367,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
BLI_strncpy(newname, pchan->name, sizeof(pchan->name));
BLI_strncpy(pchan->name, oldname, sizeof(pchan->name));
ED_armature_bone_rename(ob->data, oldname, newname);
- WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
break;
}
case TSE_POSEGRP:
@@ -391,10 +391,25 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd);
break;
}
+ case TSE_R_LAYER:
+ {
+ Scene *scene = (Scene *)tselem->id;
+ ViewLayer *view_layer = te->directdata;
+
+ /* Restore old name. */
+ char newname[sizeof(view_layer->name)];
+ BLI_strncpy(newname, view_layer->name, sizeof(view_layer->name));
+ BLI_strncpy(view_layer->name, oldname, sizeof(view_layer->name));
+
+ /* Rename, preserving animation and compositing data. */
+ BKE_view_layer_rename(bmain, scene, view_layer, newname);
+ WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL);
+ break;
+ }
case TSE_LAYER_COLLECTION:
{
BLI_libblock_ensure_unique_name(bmain, tselem->id->name);
- WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break;
+ WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL);
break;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 5922e208f36..9bd0c622d66 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1057,7 +1057,7 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
ar->v2d.cur.ymin += dy;
ar->v2d.cur.ymax += dy;
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw_no_rebuild(ar);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 393b40d1097..45c19ed4ff7 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -813,8 +813,11 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
}
case ID_GR:
{
- Collection *collection = (Collection *)id;
- outliner_add_collection_recursive(soops, collection, te);
+ /* Don't expand for instances, creates too many elements. */
+ if (!(te->parent && te->parent->idcode == ID_OB)) {
+ Collection *collection = (Collection *)id;
+ outliner_add_collection_recursive(soops, collection, te);
+ }
}
default:
break;
@@ -1286,9 +1289,9 @@ static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type)
return true;
}
-static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib)
+static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOops *soops, ListBase *lb, Library *lib)
{
- TreeElement *ten;
+ TreeElement *ten, *tenlib = NULL;
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
@@ -1311,11 +1314,23 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE
break;
if (id) {
+ if (!tenlib) {
+ /* Create library tree element on demand, depending if there are any datablocks. */
+ if (lib) {
+ tenlib = outliner_add_element(soops, lb, lib, NULL, 0, 0);
+ }
+ else {
+ tenlib = outliner_add_element(soops, lb, mainvar, NULL, TSE_ID_BASE, 0);
+ tenlib->name = IFACE_("Current File");
+ }
+ }
+
+ /* Create datablock list parent element on demand. */
if (filter_id_type) {
- ten = te;
+ ten = tenlib;
}
else {
- ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten = outliner_add_element(soops, &tenlib->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}
@@ -1328,6 +1343,8 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE
}
}
}
+
+ return tenlib;
}
static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
@@ -2125,20 +2142,18 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
Library *lib;
/* current file first - mainvar provides tselem with unique pointer - not used */
- ten = outliner_add_element(soops, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0);
- ten->name = IFACE_("Current File");
-
- tselem = TREESTORE(ten);
- if (!tselem->used)
- tselem->flag &= ~TSE_CLOSED;
-
- outliner_add_library_contents(mainvar, soops, ten, NULL);
+ ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL);
+ if (ten) {
+ tselem = TREESTORE(ten);
+ if (!tselem->used)
+ tselem->flag &= ~TSE_CLOSED;
+ }
for (lib = mainvar->library.first; lib; lib = lib->id.next) {
- ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0);
- lib->id.newid = (ID *)ten;
-
- outliner_add_library_contents(mainvar, soops, ten, lib);
+ ten = outliner_add_library_contents(mainvar, soops, &soops->tree, lib);
+ if (ten) {
+ lib->id.newid = (ID *)ten;
+ }
}
/* make hierarchy */
@@ -2158,9 +2173,10 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
}
else {
/* Else, make a new copy of the libtree for our parent. */
- TreeElement *dupten = outliner_add_element(soops, &par->subtree, lib, NULL, 0, 0);
- outliner_add_library_contents(mainvar, soops, dupten, lib);
- dupten->parent = par;
+ TreeElement *dupten = outliner_add_library_contents(mainvar, soops, &par->subtree, lib);
+ if (dupten) {
+ dupten->parent = par;
+ }
}
}
ten = nten;
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 896f6c016d0..6b7035dd326 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -142,13 +142,11 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, const ID *id)
if (tselem->id == id) {
return te;
}
- /* only deeper on scene collection or object */
- if (ELEM(te->idcode, ID_OB, ID_SCE, ID_GR)) {
- TreeElement *tes = outliner_find_id(soops, &te->subtree, id);
- if (tes) {
- return tes;
- }
- }
+ }
+
+ TreeElement *tes = outliner_find_id(soops, &te->subtree, id);
+ if (tes) {
+ return tes;
}
}
return NULL;
diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt
new file mode 100644
index 00000000000..31439942397
--- /dev/null
+++ b/source/blender/editors/space_statusbar/CMakeLists.txt
@@ -0,0 +1,45 @@
+# ***** 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.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../blenloader
+ ../../blentranslation
+ ../../gpu
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
+)
+
+set(INC_SYS
+ ${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+ space_statusbar.c
+)
+
+add_definitions(${GL_DEFINITIONS})
+
+blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
new file mode 100644
index 00000000000..4c6a2eea469
--- /dev/null
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -0,0 +1,200 @@
+/*
+ * ***** 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/editors/space_statusbar/space_statusbar.c
+ * \ingroup spstatusbar
+ */
+
+
+#include <string.h>
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_context.h"
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "WM_message.h"
+
+
+/* ******************** default callbacks for statusbar space ******************** */
+
+static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+{
+ ARegion *ar;
+ SpaceStatusBar *sstatusbar;
+
+ sstatusbar = MEM_callocN(sizeof(*sstatusbar), "init statusbar");
+ sstatusbar->spacetype = SPACE_STATUSBAR;
+
+ /* header regions */
+ /* *** NOTE: ***
+ * Python layout code (space_statusbar.py) depends on the list order of
+ * these! Not nice at all, but the only way to identify the correct header
+ * to draw to is using alignment + list position. It can't use alignment
+ * only since code below has to set two right aligned regions - XXX. */
+ ar = MEM_callocN(sizeof(*ar), "right aligned header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar = MEM_callocN(sizeof(*ar), "center header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT; /* Right aligned too, so region layout code scales it correctly. */
+ ar = MEM_callocN(sizeof(*ar), "left aligned header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_NONE;
+
+ return (SpaceLink *)sstatusbar;
+}
+
+/* not spacelink itself */
+static void statusbar_free(SpaceLink *UNUSED(sl))
+{
+
+}
+
+
+/* spacetype; init callback */
+static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+{
+
+}
+
+static SpaceLink *statusbar_duplicate(SpaceLink *sl)
+{
+ SpaceStatusBar *sstatusbarn = MEM_dupallocN(sl);
+
+ /* clear or remove stuff from old */
+
+ return (SpaceLink *)sstatusbarn;
+}
+
+
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void statusbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
+{
+ if (ELEM(region->alignment, RGN_ALIGN_RIGHT)) {
+ region->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ ED_region_header_init(region);
+}
+
+static void statusbar_operatortypes(void)
+{
+
+}
+
+static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
+{
+
+}
+
+static void statusbar_header_region_listener(
+ bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmNotifier *wmn, const Scene *UNUSED(scene))
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCREEN:
+ if (ELEM(wmn->data, ND_LAYER, ND_SCREENCAST, ND_ANIMPLAY)) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_WM:
+ if (wmn->data == ND_JOB)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SCENE:
+ if (wmn->data == ND_RENDER_RESULT)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_INFO)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_ID:
+ if (wmn->action == NA_RENAME)
+ ED_region_tag_redraw(ar);
+ break;
+ }
+}
+
+static void statusbar_header_region_message_subscribe(
+ const bContext *UNUSED(C),
+ WorkSpace *UNUSED(workspace), Scene *UNUSED(scene),
+ bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
+ WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw);
+}
+
+/* only called once, from space/spacetypes.c */
+void ED_spacetype_statusbar(void)
+{
+ SpaceType *st = MEM_callocN(sizeof(*st), "spacetype statusbar");
+ ARegionType *art;
+
+ st->spaceid = SPACE_STATUSBAR;
+ strncpy(st->name, "Status Bar", BKE_ST_MAXNAME);
+
+ st->new = statusbar_new;
+ st->free = statusbar_free;
+ st->init = statusbar_init;
+ st->duplicate = statusbar_duplicate;
+ st->operatortypes = statusbar_operatortypes;
+ st->keymap = statusbar_keymap;
+
+ /* regions: header window */
+ art = MEM_callocN(sizeof(*art), "spacetype statusbar header region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+ art->init = statusbar_header_region_init;
+ art->layout = ED_region_header_layout;
+ art->draw = ED_region_header_draw;
+ art->listener = statusbar_header_region_listener;
+ art->message_subscribe = statusbar_header_region_message_subscribe;
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8e04a2e17b8..b87d6c0b85e 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -610,9 +610,13 @@ static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob)
}
void draw_object_backbufsel(
- Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
+ Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob,
+ short select_mode)
{
ToolSettings *ts = scene->toolsettings;
+ if (select_mode == -1) {
+ select_mode = ts->selectmode;
+ }
gpuMultMatrix(ob->obmat);
@@ -631,8 +635,8 @@ void draw_object_backbufsel(
DM_update_materials(dm, ob);
- bbs_mesh_solid_EM(em, scene, v3d, ob, dm, (ts->selectmode & SCE_SELECT_FACE) != 0);
- if (ts->selectmode & SCE_SELECT_FACE)
+ bbs_mesh_solid_EM(em, scene, v3d, ob, dm, (select_mode & SCE_SELECT_FACE) != 0);
+ if (select_mode & SCE_SELECT_FACE)
bm_solidoffs = 1 + em->bm->totface;
else {
bm_solidoffs = 1;
@@ -641,7 +645,7 @@ void draw_object_backbufsel(
ED_view3d_polygon_offset(rv3d, 1.0);
/* we draw edges if edge select mode */
- if (ts->selectmode & SCE_SELECT_EDGE) {
+ if (select_mode & SCE_SELECT_EDGE) {
bbs_mesh_wire(em, dm, bm_solidoffs);
bm_wireoffs = bm_solidoffs + em->bm->totedge;
}
@@ -651,7 +655,7 @@ void draw_object_backbufsel(
}
/* we draw verts if vert select mode. */
- if (ts->selectmode & SCE_SELECT_VERTEX) {
+ if (select_mode & SCE_SELECT_VERTEX) {
bbs_mesh_verts(em, dm, bm_wireoffs);
bm_vertoffs = bm_wireoffs + em->bm->totvert;
}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index f26da3ad07e..6d8d4d45feb 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -69,6 +69,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 99f7abba065..b44e2da3583 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -302,6 +302,7 @@ static void view3d_camera_border(
{
CameraParams params;
rctf rect_view, rect_camera;
+ Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
/* get viewport viewplane */
BKE_camera_params_init(&params);
@@ -316,7 +317,7 @@ static void view3d_camera_border(
/* fallback for non camera objects */
params.clipsta = v3d->near;
params.clipend = v3d->far;
- BKE_camera_params_from_object(&params, v3d->camera);
+ BKE_camera_params_from_object(&params, camera_eval);
if (no_shift) {
params.shiftx = 0.0f;
params.shifty = 0.0f;
@@ -1172,7 +1173,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
if (U.uiflag & USER_SHOW_ROTVIEWICON)
offset = U.widget_unit + (U.rvisize * 2) + rect->xmin;
- BLF_draw_default(offset, 0.5f * U.widget_unit, 0.0f, info, sizeof(info));
+ BLF_draw_default(offset, rect->ymin + 0.5f * U.widget_unit, 0.0f, info, sizeof(info));
}
/* ******************** view loop ***************** */
@@ -1417,13 +1418,16 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
CameraParams params;
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
+ const Object *camera_eval = DEG_get_evaluated_object(
+ depsgraph,
+ camera);
BKE_camera_params_init(&params);
/* fallback for non camera objects */
params.clipsta = v3d->near;
params.clipend = v3d->far;
- BKE_camera_params_from_object(&params, camera);
- BKE_camera_multiview_params(&scene->r, &params, camera, viewname);
+ BKE_camera_params_from_object(&params, camera_eval);
+ BKE_camera_multiview_params(&scene->r, &params, camera_eval, viewname);
BKE_camera_params_compute_viewplane(&params, sizex, sizey, scene->r.xasp, scene->r.yasp);
BKE_camera_params_compute_matrix(&params);
@@ -1597,11 +1601,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
{
CameraParams params;
- Object *view_camera = BKE_camera_multiview_render(scene, v3d.camera, viewname);
+ const Object *view_camera_eval = DEG_get_evaluated_object(
+ depsgraph,
+ BKE_camera_multiview_render(scene, v3d.camera, viewname));
BKE_camera_params_init(&params);
- BKE_camera_params_from_object(&params, view_camera);
- BKE_camera_multiview_params(&scene->r, &params, view_camera, viewname);
+ BKE_camera_params_from_object(&params, view_camera_eval);
+ BKE_camera_multiview_params(&scene->r, &params, view_camera_eval, viewname);
BKE_camera_params_compute_viewplane(&params, width, height, scene->r.xasp, scene->r.yasp);
BKE_camera_params_compute_matrix(&params);
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 5b0f50b7a68..8505de4c7e0 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -163,7 +163,8 @@ bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const
static void backdrawview3d(
struct Depsgraph *depsgraph, Scene *scene,
ARegion *ar, View3D *v3d,
- Object *obact, Object *obedit)
+ Object *obact, Object *obedit,
+ short select_mode)
{
RegionView3D *rv3d = ar->regiondata;
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
@@ -263,7 +264,7 @@ static void backdrawview3d(
G.f |= G_BACKBUFSEL;
if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLED) != 0)) {
- draw_object_backbufsel(depsgraph, scene_eval, v3d, rv3d, obact_eval);
+ draw_object_backbufsel(depsgraph, scene_eval, v3d, rv3d, obact_eval, select_mode);
}
if (rv3d->gpuoffscreen)
@@ -301,13 +302,18 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h,
glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
}
-void ED_view3d_backbuf_validate(ViewContext *vc)
+void ED_view3d_backbuf_validate_with_select_mode(ViewContext *vc, short select_mode)
{
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
- backdrawview3d(vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit);
+ backdrawview3d(vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit, select_mode);
}
}
+void ED_view3d_backbuf_validate(ViewContext *vc)
+{
+ ED_view3d_backbuf_validate_with_select_mode(vc, -1);
+}
+
/**
* allow for small values [0.5 - 2.5],
* and large values, FLT_MAX by clamping by the area size
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 61292d9b707..66eaf34865f 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -86,8 +86,6 @@
#include "view3d_intern.h" /* own include */
-#include "DEG_depsgraph_query.h"
-
/* -------------------------------------------------------------------- */
/** \name Generic View Operator Properties
* \{ */
@@ -250,9 +248,11 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
static float lastofs[3] = {0, 0, 0};
bool is_set = false;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob_act = OBACT(view_layer);
+ ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
+ Object *ob_act_eval = OBACT(view_layer_eval);
+ Object *ob_act = DEG_get_original_object(ob_act_eval);
if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) &&
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
@@ -264,16 +264,16 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
*/
if (ob_act->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
float stroke[3];
- BKE_paint_stroke_get_average(scene, ob_act, stroke);
+ BKE_paint_stroke_get_average(scene, ob_act_eval, stroke);
copy_v3_v3(lastofs, stroke);
}
else {
- copy_v3_v3(lastofs, ob_act->obmat[3]);
+ copy_v3_v3(lastofs, ob_act_eval->obmat[3]);
}
is_set = true;
}
else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
- Curve *cu = ob_act->data;
+ Curve *cu = ob_act_eval->data;
EditFont *ef = cu->editfont;
int i;
@@ -283,32 +283,32 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
}
mul_v2_fl(lastofs, 1.0f / 4.0f);
- mul_m4_v3(ob_act->obmat, lastofs);
+ mul_m4_v3(ob_act_eval->obmat, lastofs);
is_set = true;
}
else if (ob_act == NULL || ob_act->mode == OB_MODE_OBJECT) {
/* object mode use boundbox centers */
- Base *base;
+ Base *base_eval;
unsigned int tot = 0;
float select_center[3];
zero_v3(select_center);
- for (base = FIRSTBASE(view_layer); base; base = base->next) {
- if (TESTBASE(base)) {
+ for (base_eval = FIRSTBASE(view_layer_eval); base_eval; base_eval = base_eval->next) {
+ if (TESTBASE(base_eval)) {
/* use the boundbox if we can */
- Object *ob = base->object;
+ Object *ob_eval = base_eval->object;
- if (ob->bb && !(ob->bb->flag & BOUNDBOX_DIRTY)) {
+ if (ob_eval->bb && !(ob_eval->bb->flag & BOUNDBOX_DIRTY)) {
float cent[3];
- BKE_boundbox_calc_center_aabb(ob->bb, cent);
+ BKE_boundbox_calc_center_aabb(ob_eval->bb, cent);
- mul_m4_v3(ob->obmat, cent);
+ mul_m4_v3(ob_eval->obmat, cent);
add_v3_v3(select_center, cent);
}
else {
- add_v3_v3(select_center, ob->obmat[3]);
+ add_v3_v3(select_center, ob_eval->obmat[3]);
}
tot++;
}
@@ -371,6 +371,7 @@ static void viewops_data_create(
bContext *C, wmOperator *op, const wmEvent *event,
enum eViewOpsFlag viewops_flag)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewOpsData *vod = op->customdata;
RegionView3D *rv3d = vod->rv3d;
@@ -381,7 +382,6 @@ static void viewops_data_create(
/* we need the depth info before changing any viewport options */
if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) {
- struct Depsgraph *graph = CTX_data_depsgraph(C);
float fallback_depth_pt[3];
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
@@ -389,7 +389,7 @@ static void viewops_data_create(
negate_v3_v3(fallback_depth_pt, rv3d->ofs);
vod->use_dyn_ofs = ED_view3d_autodist(
- graph, vod->ar, vod->v3d,
+ depsgraph, vod->ar, vod->v3d,
event->mval, vod->dyn_ofs, true, fallback_depth_pt);
}
else {
@@ -397,7 +397,7 @@ static void viewops_data_create(
}
if (viewops_flag & VIEWOPS_FLAG_PERSP_ENSURE) {
- if (ED_view3d_persp_ensure(vod->v3d, vod->ar)) {
+ if (ED_view3d_persp_ensure(depsgraph, vod->v3d, vod->ar)) {
/* If we're switching from camera view to the perspective one,
* need to tag viewport update, so camera vuew and borders
* are properly updated.
@@ -408,7 +408,7 @@ static void viewops_data_create(
/* set the view from the camera, if view locking is enabled.
* we may want to make this optional but for now its needed always */
- ED_view3d_camera_lock_init(vod->v3d, vod->rv3d);
+ ED_view3d_camera_lock_init(depsgraph, vod->v3d, vod->rv3d);
vod->init.dist = rv3d->dist;
vod->init.camzoom = rv3d->camzoom;
@@ -811,7 +811,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2])
vod->prev.event_xy[0] = event_xy[0];
vod->prev.event_xy[1] = event_xy[1];
- ED_view3d_camera_lock_sync(vod->v3d, rv3d);
+ ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, rv3d);
ED_region_tag_redraw(vod->ar);
}
@@ -1119,7 +1119,7 @@ static void view3d_ndof_orbit(
BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0);
- ED_view3d_persp_ensure(v3d, ar);
+ ED_view3d_persp_ensure(vod->depsgraph, v3d, ar);
rv3d->view = RV3D_VIEW_USER;
@@ -1308,6 +1308,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
else {
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewOpsData *vod;
View3D *v3d;
RegionView3D *rv3d;
@@ -1328,7 +1329,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* off by default, until changed later this function */
rv3d->rot_angle = 0.0f;
- ED_view3d_camera_lock_init_ex(v3d, rv3d, false);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
if (ndof->progress != P_FINISHING) {
const bool has_rotation = NDOF_HAS_ROTATE;
@@ -1345,7 +1346,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_region_tag_redraw(vod->ar);
@@ -1376,6 +1377,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return OPERATOR_CANCELLED;
}
else {
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ViewOpsData *vod;
View3D *v3d;
RegionView3D *rv3d;
@@ -1397,7 +1399,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* off by default, until changed later this function */
rv3d->rot_angle = 0.0f;
- ED_view3d_camera_lock_init_ex(v3d, rv3d, false);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
if (ndof->progress == P_FINISHING) {
/* pass */
@@ -1446,7 +1448,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
ED_view3d_distance_set(rv3d, dist_backup);
}
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_region_tag_redraw(vod->ar);
@@ -1480,6 +1482,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
return OPERATOR_CANCELLED;
}
else {
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
const wmNDOFMotionData *ndof = event->customdata;
@@ -1493,7 +1496,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
if (!(has_translate || has_zoom))
return OPERATOR_CANCELLED;
- ED_view3d_camera_lock_init_ex(v3d, rv3d, false);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
if (ndof->progress != P_FINISHING) {
ScrArea *sa = CTX_wm_area(C);
@@ -1504,7 +1507,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
}
}
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_region_tag_redraw(CTX_wm_region(C));
@@ -1637,7 +1640,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
vod->prev.event_xy[0] = x;
vod->prev.event_xy[1] = y;
- ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d);
+ ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
ED_region_tag_redraw(vod->ar);
}
@@ -2036,7 +2039,7 @@ static void viewzoom_apply_3d(
view3d_boxview_sync(vod->sa, vod->ar);
}
- ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d);
+ ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
ED_region_tag_redraw(vod->ar);
}
@@ -2187,7 +2190,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
ED_view3d_depth_tag_update(rv3d);
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true);
ED_region_tag_redraw(ar);
@@ -2381,7 +2384,7 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_
view3d_boxview_sync(vod->sa, vod->ar);
}
- ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d);
+ ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
ED_region_tag_redraw(vod->ar);
}
@@ -2482,7 +2485,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
ED_view3d_depth_tag_update(rv3d);
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(CTX_data_depsgraph(C), v3d, rv3d);
ED_region_tag_redraw(ar);
@@ -2516,7 +2519,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (vod->rv3d->persp != RV3D_PERSP) {
if (vod->rv3d->persp == RV3D_CAMOB) {
/* ignore rv3d->lpersp because dolly only makes sense in perspective mode */
- ED_view3d_persp_switch_from_camera(vod->v3d, vod->rv3d, RV3D_PERSP);
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP);
}
else {
vod->rv3d->persp = RV3D_PERSP;
@@ -2650,7 +2654,7 @@ static void view3d_from_minmax(
}
if (ok_dist) {
- new_dist = ED_view3d_radius_to_dist(v3d, ar, persp, true, (size / 2) * VIEW3D_MARGIN);
+ new_dist = ED_view3d_radius_to_dist(v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN);
if (rv3d->is_persp) {
/* don't zoom closer than the near clipping plane */
new_dist = max_ff(new_dist, v3d->near * 1.5f);
@@ -3674,7 +3678,8 @@ static void axis_set_view(
dist = rv3d->dist;
/* so we animate _from_ the camera location */
- ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, &rv3d->dist, NULL);
+ Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera);
+ ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL);
ED_view3d_smooth_view(
C, v3d, ar, smooth_viewtx,
@@ -3884,7 +3889,8 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
float quat_new[4];
if (view_opposite == RV3D_VIEW_USER) {
- ED_view3d_persp_ensure(v3d, ar);
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ED_view3d_persp_ensure(depsgraph, v3d, ar);
}
if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) {
@@ -4009,7 +4015,7 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y))
view3d_boxview_sync(vod->sa, vod->ar);
}
- ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d);
+ ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d);
ED_region_tag_redraw(vod->ar);
}
@@ -4594,12 +4600,11 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
cursor_curr->rotation[0] *= -1.0f;
{
- struct Main *bmain = CTX_data_main(C);
const float mval_fl[2] = {UNPACK2(mval)};
float ray_no[3];
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d);
+ scene, CTX_data_depsgraph(C), 0, ar, v3d);
float obmat[4][4];
Object *ob_dummy = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index e7f6cf36476..e0f3c412c56 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -221,6 +221,45 @@ void VIEW3D_OT_layers(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
}
+/* -------------------------------------------------------------------- */
+/** \name Toggle Bone selection Overlay Operator
+ * \{ */
+
+static int toggle_show_xray(bContext *C, wmOperator *UNUSED(op))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ v3d->shading.flag ^= V3D_SHADING_XRAY;
+ ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ return OPERATOR_FINISHED;
+}
+
+static int toggle_show_xray_poll(bContext *C)
+{
+ bool result = (ED_operator_view3d_active(C) && !ED_operator_posemode(C) && !ED_operator_editmesh(C));
+ if (result) {
+ // Additional test for SOLID or TEXTURE mode
+ View3D *v3d = CTX_wm_view3d(C);
+ result = (v3d->drawtype & (OB_SOLID | OB_TEXTURE)) > 0;
+ }
+ return result;
+}
+
+void VIEW3D_OT_toggle_xray_draw_option(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Toggle Show X-Ray";
+ ot->description = "Toggle show X-Ray";
+ ot->idname = "VIEW3D_OT_toggle_xray_draw_option";
+
+ /* api callbacks */
+ ot->exec = toggle_show_xray;
+ ot->poll = toggle_show_xray_poll;
+}
+
+/** \} */
+
+
static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
{
wmWindow *win = CTX_wm_window(C);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 1c86e5ab30b..da8afa7a390 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -65,6 +65,7 @@ enum {
/* view3d_header.c */
void VIEW3D_OT_layers(struct wmOperatorType *ot);
+void VIEW3D_OT_toggle_xray_draw_option(struct wmOperatorType *ot);
/* view3d_ops.c */
void view3d_operatortypes(void);
@@ -132,7 +133,9 @@ void VIEW3D_OT_walk(struct wmOperatorType *ot);
void VIEW3D_OT_ruler(struct wmOperatorType *ot);
/* drawobject.c */
-void draw_object_backbufsel(struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob);
+void draw_object_backbufsel(
+ struct Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob,
+ short select_mode);
int view3d_effective_drawtype(const struct View3D *v3d);
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 35127c7c8c6..145f57174fd 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -35,6 +35,7 @@
#include "BLI_utildefines.h"
#include "BLI_rect.h"
+#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
@@ -43,6 +44,7 @@
#include "BKE_context.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "bmesh.h"
@@ -449,19 +451,21 @@ void pose_foreachScreenBone(
void (*func)(void *userData, struct bPoseChannel *pchan, const float screen_co_a[2], const float screen_co_b[2]),
void *userData, const eV3DProjTest clip_flag)
{
- bArmature *arm = vc->obact->data;
+ const Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact);
+ const bArmature *arm_eval = ob_eval->data;
bPose *pose = vc->obact->pose;
bPoseChannel *pchan;
ED_view3d_check_mats_rv3d(vc->rv3d);
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (PBONE_VISIBLE(arm, pchan->bone)) {
+ if (PBONE_VISIBLE(arm_eval, pchan->bone)) {
+ bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
float screen_co_a[2], screen_co_b[2];
int points_proj_tot = 0;
/* project head location to screenspace */
- if (ED_view3d_project_float_object(vc->ar, pchan->pose_head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) {
+ if (ED_view3d_project_float_object(vc->ar, pchan_eval->pose_head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) {
points_proj_tot++;
}
else {
@@ -470,7 +474,7 @@ void pose_foreachScreenBone(
}
/* project tail location to screenspace */
- if (ED_view3d_project_float_object(vc->ar, pchan->pose_tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) {
+ if (ED_view3d_project_float_object(vc->ar, pchan_eval->pose_tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) {
points_proj_tot++;
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index 87e550ba638..d3fe17123a0 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -132,7 +132,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
struct CameraWidgetGroup *camgroup = mgroup->customdata;
Object *ob = CTX_data_active_object(C);
const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Camera *ca = ob->data;
+ Camera *ca = ob_eval->data;
PointerRNA camera_ptr;
float dir[3];
@@ -252,6 +252,7 @@ static void WIDGETGROUP_camera_message_subscribe(
extern PropertyRNA rna_Camera_shift_x;
extern PropertyRNA rna_Camera_shift_y;
extern PropertyRNA rna_Camera_type;
+ extern PropertyRNA rna_Camera_lens;
const PropertyRNA *props[] = {
&rna_Camera_dof_distance,
&rna_Camera_draw_size,
@@ -261,6 +262,7 @@ static void WIDGETGROUP_camera_message_subscribe(
&rna_Camera_shift_x,
&rna_Camera_shift_y,
&rna_Camera_type,
+ &rna_Camera_lens,
};
PointerRNA idptr;
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
index 93b6b69a105..e659c67396d 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
@@ -45,6 +45,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "DEG_depsgraph_query.h"
+
#include "view3d_intern.h" /* own include */
/* -------------------------------------------------------------------- */
@@ -80,16 +82,18 @@ static void WIDGETGROUP_lamp_spot_setup(const bContext *UNUSED(C), wmManipulator
static void WIDGETGROUP_lamp_spot_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
wmManipulatorWrapper *wwrapper = mgroup->customdata;
wmManipulator *mpr = wwrapper->manipulator;
Object *ob = CTX_data_active_object(C);
+ const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Lamp *la = ob->data;
float dir[3];
- negate_v3_v3(dir, ob->obmat[2]);
+ negate_v3_v3(dir, ob_eval->obmat[2]);
WM_manipulator_set_matrix_rotation_from_z_axis(mpr, dir);
- WM_manipulator_set_matrix_location(mpr, ob->obmat[3]);
+ WM_manipulator_set_matrix_location(mpr, ob_eval->obmat[3]);
/* need to set property here for undo. TODO would prefer to do this in _init */
PointerRNA lamp_ptr;
@@ -129,7 +133,7 @@ static void manipulator_area_lamp_prop_matrix_get(
const Lamp *la = mpr_prop->custom_func.user_data;
matrix[0][0] = la->area_size;
- matrix[1][1] = (la->area_shape == LA_AREA_RECT) ? la->area_sizey : la->area_size;
+ matrix[1][1] = ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE) ? la->area_sizey : la->area_size;
}
static void manipulator_area_lamp_prop_matrix_set(
@@ -140,7 +144,7 @@ static void manipulator_area_lamp_prop_matrix_set(
BLI_assert(mpr_prop->type->array_length == 16);
Lamp *la = mpr_prop->custom_func.user_data;
- if (la->area_shape == LA_AREA_RECT) {
+ if (ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE)) {
la->area_size = len_v3(matrix[0]);
la->area_sizey = len_v3(matrix[1]);
}
@@ -179,15 +183,19 @@ static void WIDGETGROUP_lamp_area_setup(const bContext *UNUSED(C), wmManipulator
static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
- Lamp *la = ob->data;
+ const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Lamp *la = ob_eval->data;
wmManipulator *mpr = wwrapper->manipulator;
- copy_m4_m4(mpr->matrix_basis, ob->obmat);
+ copy_m4_m4(mpr->matrix_basis, ob_eval->obmat);
- RNA_enum_set(mpr->ptr, "transform",
- ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE |
- ((la->area_shape == LA_AREA_SQUARE) ? ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM : 0));
+ int flag = ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE;
+ if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) {
+ flag |= ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE_UNIFORM;
+ }
+ RNA_enum_set(mpr->ptr, "transform", flag);
/* need to set property here for undo. TODO would prefer to do this in _init */
WM_manipulator_target_property_def_func(
@@ -264,10 +272,12 @@ static void WIDGETGROUP_lamp_target_setup(const bContext *UNUSED(C), wmManipulat
static void WIDGETGROUP_lamp_target_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
{
wmManipulatorWrapper *wwrapper = mgroup->customdata;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
+ const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
wmManipulator *mpr = wwrapper->manipulator;
- copy_m4_m4(mpr->matrix_basis, ob->obmat);
+ copy_m4_m4(mpr->matrix_basis, ob_eval->obmat);
unit_m4(mpr->matrix_offset);
mpr->matrix_offset[3][2] = -2.4f / mpr->scale_basis;
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true);
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
index d46673b4817..9cde5ffc5e3 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
@@ -54,6 +54,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
#include "view3d_intern.h" /* own include */
@@ -277,7 +278,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
@@ -320,13 +321,12 @@ static bool view3d_ruler_item_mousemove(
co_other = ruler_item->co[inter->co_index == 0 ? 2 : 0];
- if (ED_transform_snap_object_project_view3d_mixed(
+ if (ED_transform_snap_object_project_view3d(
ruler_info->snap_context,
- SCE_SELECT_FACE,
+ SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
- .use_occlusion_test = true,
},
mval_fl, &dist_px,
co, ray_normal))
@@ -345,18 +345,15 @@ static bool view3d_ruler_item_mousemove(
}
}
else if (do_snap) {
- // Scene *scene = CTX_data_scene(C);
- View3D *v3d = ruler_info->sa->spacedata.first;
const float mval_fl[2] = {UNPACK2(mval)};
- bool use_depth = (v3d->drawtype >= OB_SOLID);
- if (ED_transform_snap_object_project_view3d_mixed(
+ if (ED_transform_snap_object_project_view3d(
ruler_info->snap_context,
- (SCE_SELECT_VERTEX | SCE_SELECT_EDGE) | (use_depth ? SCE_SELECT_FACE : 0),
+ (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE),
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
- .use_occlusion_test = use_depth,
+ .use_occlusion_test = true,
},
mval_fl, &dist_px,
co, NULL))
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 43ff8af42fb..4d362ae5425 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -112,7 +112,7 @@ static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
/* api callbacks */
ot->exec = view3d_copybuffer_exec;
- ot->poll = ED_operator_view3d_active;
+ ot->poll = ED_operator_scene;
}
static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
@@ -149,7 +149,7 @@ static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
/* api callbacks */
ot->exec = view3d_pastebuffer_exec;
- ot->poll = ED_operator_view3d_active;
+ ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -222,6 +222,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
WM_operatortype_append(VIEW3D_OT_toggle_render);
+ WM_operatortype_append(VIEW3D_OT_toggle_xray_draw_option);
WM_operatortype_append(VIEW3D_OT_ruler_add);
@@ -402,18 +403,13 @@ void view3d_keymap(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10);
/* drawtype */
-
- kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0);
- RNA_string_set(kmi->ptr, "data_path", "space_data.shading.type");
- RNA_string_set(kmi->ptr, "value_1", "SOLID");
- RNA_string_set(kmi->ptr, "value_2", "WIREFRAME");
-
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.shading.type");
RNA_string_set(kmi->ptr, "value_1", "SOLID");
RNA_string_set(kmi->ptr, "value_2", "TEXTURED");
WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_render", ZKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_xray_draw_option", ZKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", ZKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "space_data.use_occlude_geometry");
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index eb86800f4a9..d0fb82eaaf4 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -282,6 +282,11 @@ float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize * U.pixelsize;
}
+float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3])
+{
+ return mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, co) * rv3d->pixsize;
+}
+
/**
* Calculate a depth value from \a co, use with #ED_view3d_win_to_delta
*/
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 64b5d32191f..c0af3c7caaa 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -282,7 +282,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
}
else if (state == RULER_STATE_DRAG) {
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), CTX_data_depsgraph(C), 0,
+ CTX_data_scene(C), CTX_data_depsgraph(C), 0,
ruler_info->ar, CTX_wm_view3d(C));
}
else {
@@ -761,13 +761,12 @@ static bool view3d_ruler_item_mousemove(
co_other = ruler_item->co[ruler_item->co_index == 0 ? 2 : 0];
- if (ED_transform_snap_object_project_view3d_mixed(
+ if (ED_transform_snap_object_project_view3d(
ruler_info->snap_context,
- SCE_SELECT_FACE,
+ SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
- .use_occlusion_test = true,
},
mval_fl, &dist_px,
co, ray_normal))
@@ -786,18 +785,15 @@ static bool view3d_ruler_item_mousemove(
}
}
else if (do_snap) {
- // Scene *scene = CTX_data_scene(C);
- View3D *v3d = ruler_info->sa->spacedata.first;
const float mval_fl[2] = {UNPACK2(mval)};
- bool use_depth = (v3d->drawtype >= OB_SOLID);
- if (ED_transform_snap_object_project_view3d_mixed(
+ if (ED_transform_snap_object_project_view3d(
ruler_info->snap_context,
- (SCE_SELECT_VERTEX | SCE_SELECT_EDGE) | (use_depth ? SCE_SELECT_FACE : 0),
+ (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE),
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
.use_object_edit_cage = true,
- .use_occlusion_test = use_depth,
+ .use_occlusion_test = true,
},
mval_fl, &dist_px,
co, NULL))
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 93ecb8a4b61..be5653a3021 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2122,22 +2122,24 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
continue;
}
/* Loop over contiguous bone hits for 'base'. */
- bool bone_selected = false;
+ bool changed = false;
for (; col != col_end; col += 4) {
/* should never fail */
if (bone != NULL) {
if (select) {
if ((bone->flag & BONE_UNSELECTABLE) == 0) {
bone->flag |= BONE_SELECTED;
- bone_selected = true;
}
}
else {
bArmature *arm = base->object->data;
- bone->flag &= ~BONE_SELECTED;
- if (arm->act_bone == bone)
- arm->act_bone = NULL;
+ if ((bone->flag & BONE_UNSELECTABLE) == 0) {
+ bone->flag &= ~BONE_SELECTED;
+ if (arm->act_bone == bone)
+ arm->act_bone = NULL;
+ }
}
+ changed = true;
}
else if (!bone_only) {
ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
@@ -2151,7 +2153,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
if ((base->object->pose != NULL) && bone_only) {
const uint hit_bone = (col[4] & ~BONESEL_ANY) >> 16;
- bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);;
+ bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone);
bone = pchan ? pchan->bone : NULL;
}
else {
@@ -2160,7 +2162,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
}
}
- if (bone_selected) {
+ if (changed) {
if (base->object && (base->object->type == OB_ARMATURE)) {
bArmature *arm = base->object->data;
@@ -2170,6 +2172,9 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA);
}
+
+ /* copy on write tag is needed (for the armature), or else no refresh happens */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
}
}
@@ -2746,6 +2751,9 @@ static void pose_circle_select(ViewContext *vc, const bool select, const int mva
/* mask modifier ('armature' mode), etc. */
DEG_id_tag_update(&vc->obact->id, OB_RECALC_DATA);
}
+
+ /* copy on write tag is needed (for the armature), or else no refresh happens */
+ DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index c5dd5d9ed24..13d2ceb4ad4 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -51,6 +51,7 @@
#include "BKE_tracking.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -74,6 +75,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r
static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
RegionView3D *rv3d = CTX_wm_region_data(C);
@@ -132,34 +134,36 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
- CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
+ FOREACH_SELECTED_EDITABLE_OBJECT_BEGIN(view_layer_eval, ob_eval)
{
+ Object *ob = DEG_get_original_object(ob_eval);
if (ob->mode & OB_MODE_POSE) {
- bPoseChannel *pchan;
- bArmature *arm = ob->data;
+ bPoseChannel *pchan_eval;
+ bArmature *arm_eval = ob_eval->data;
- invert_m4_m4(ob->imat, ob->obmat);
+ invert_m4_m4(ob_eval->imat, ob_eval->obmat);
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->bone->flag & BONE_SELECTED) {
- if (pchan->bone->layer & arm->layer) {
- if ((pchan->bone->flag & BONE_CONNECTED) == 0) {
+ for (pchan_eval = ob_eval->pose->chanbase.first; pchan_eval; pchan_eval = pchan_eval->next) {
+ if (pchan_eval->bone->flag & BONE_SELECTED) {
+ if (pchan_eval->bone->layer & arm_eval->layer) {
+ if ((pchan_eval->bone->flag & BONE_CONNECTED) == 0) {
float nLoc[3];
/* get nearest grid point to snap to */
- copy_v3_v3(nLoc, pchan->pose_mat[3]);
+ copy_v3_v3(nLoc, pchan_eval->pose_mat[3]);
/* We must operate in world space! */
- mul_m4_v3(ob->obmat, nLoc);
+ mul_m4_v3(ob_eval->obmat, nLoc);
vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf);
vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf);
vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf);
/* Back in object space... */
- mul_m4_v3(ob->imat, vec);
+ mul_m4_v3(ob_eval->imat, vec);
/* Get location of grid point in pose space. */
- BKE_armature_loc_pose_to_bone(pchan, vec, vec);
+ BKE_armature_loc_pose_to_bone(pchan_eval, vec, vec);
- /* adjust location */
+ /* adjust location on the original pchan*/
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, pchan_eval->name);
if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
pchan->loc[0] = vec[0];
if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
@@ -181,9 +185,9 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
- vec[0] = -ob->obmat[3][0] + gridf * floorf(0.5f + ob->obmat[3][0] / gridf);
- vec[1] = -ob->obmat[3][1] + gridf * floorf(0.5f + ob->obmat[3][1] / gridf);
- vec[2] = -ob->obmat[3][2] + gridf * floorf(0.5f + ob->obmat[3][2] / gridf);
+ vec[0] = -ob_eval->obmat[3][0] + gridf * floorf(0.5f + ob_eval->obmat[3][0] / gridf);
+ vec[1] = -ob_eval->obmat[3][1] + gridf * floorf(0.5f + ob_eval->obmat[3][1] / gridf);
+ vec[2] = -ob_eval->obmat[3][2] + gridf * floorf(0.5f + ob_eval->obmat[3][2] / gridf);
if (ob->parent) {
float originmat[3][3];
@@ -193,11 +197,11 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
mul_m3_v3(imat, vec);
}
if ((ob->protectflag & OB_LOCK_LOCX) == 0)
- ob->loc[0] += vec[0];
+ ob->loc[0] = ob_eval->loc[0] + vec[0];
if ((ob->protectflag & OB_LOCK_LOCY) == 0)
- ob->loc[1] += vec[1];
+ ob->loc[1] = ob_eval->loc[1] + vec[1];
if ((ob->protectflag & OB_LOCK_LOCZ) == 0)
- ob->loc[2] += vec[2];
+ ob->loc[2] = ob_eval->loc[2] + vec[2];
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
@@ -205,7 +209,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_OB);
}
}
- CTX_DATA_END;
+ FOREACH_SELECTED_EDITABLE_OBJECT_END;
}
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -498,6 +502,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
curs[2] = gridf * floorf(0.5f + curs[2] / gridf);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -573,6 +578,8 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -586,7 +593,6 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
zero_v3(centroid);
if (obedit) {
-
if (ED_transverts_check_obedit(obedit))
ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);
@@ -594,13 +600,14 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
return false;
}
- copy_m3_m4(bmat, obedit->obmat);
+ Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
+ copy_m3_m4(bmat, obedit_eval->obmat);
tv = tvs.transverts;
for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
- add_v3_v3(vec, obedit->obmat[3]);
+ add_v3_v3(vec, obedit_eval->obmat[3]);
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
}
@@ -617,15 +624,16 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
}
else {
Object *obact = CTX_data_active_object(C);
-
+
if (obact && (obact->mode & OB_MODE_POSE)) {
- bArmature *arm = obact->data;
+ Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact);
+ bArmature *arm = obact_eval->data;
bPoseChannel *pchan;
- for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = obact_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
if (arm->layer & pchan->bone->layer) {
if (pchan->bone->flag & BONE_SELECTED) {
copy_v3_v3(vec, pchan->pose_head);
- mul_m4_v3(obact->obmat, vec);
+ mul_m4_v3(obact_eval->obmat, vec);
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
count++;
@@ -634,15 +642,15 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
}
}
else {
- CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
+ FOREACH_SELECTED_OBJECT_BEGIN(view_layer_eval, ob_eval)
{
- copy_v3_v3(vec, ob->obmat[3]);
+ copy_v3_v3(vec, ob_eval->obmat[3]);
/* special case for camera -- snap to bundles */
- if (ob->type == OB_CAMERA) {
+ if (ob_eval->type == OB_CAMERA) {
/* snap to bundles should happen only when bundles are visible */
if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) {
- bundle_midpoint(scene, ob, vec);
+ bundle_midpoint(scene, DEG_get_original_object(ob_eval), vec);
}
}
@@ -650,7 +658,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
minmax_v3v3_v3(min, max, vec);
count++;
}
- CTX_DATA_END;
+ FOREACH_SELECTED_OBJECT_END;
}
if (count == 0) {
@@ -678,6 +686,7 @@ static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
if (snap_curs_to_sel_ex(C, curs)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}
@@ -708,31 +717,36 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
static bool snap_calc_active_center(bContext *C, const bool select_only, float r_center[3])
{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
- if (ED_object_editmode_calc_active_center(obedit, select_only, r_center)) {
- mul_m4_v3(obedit->obmat, r_center);
+ Object *ob_edit_eval = DEG_get_evaluated_object(depsgraph, obedit);
+
+ if (ED_object_editmode_calc_active_center(ob_edit_eval, select_only, r_center)) {
+ mul_m4_v3(ob_edit_eval->obmat, r_center);
return true;
}
}
else {
Object *ob = CTX_data_active_object(C);
-
if (ob) {
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
if (ob->mode & OB_MODE_POSE) {
- bPoseChannel *pchan = BKE_pose_channel_active(ob);
+ bPoseChannel *pchan = BKE_pose_channel_active(ob_eval);
if (pchan) {
if (!select_only || (pchan->bone->flag & BONE_SELECTED)) {
copy_v3_v3(r_center, pchan->pose_head);
- mul_m4_v3(ob->obmat, r_center);
+ mul_m4_v3(ob_eval->obmat, r_center);
return true;
}
}
}
else {
- if (!select_only || (ob->flag & SELECT)) {
- copy_v3_v3(r_center, ob->obmat[3]);
+
+ if (!select_only || (ob_eval->flag & SELECT)) {
+ copy_v3_v3(r_center, ob_eval->obmat[3]);
return true;
}
}
@@ -752,6 +766,8 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
if (snap_calc_active_center(C, false, curs)) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+
return OPERATOR_FINISHED;
}
else {
@@ -786,7 +802,8 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
zero_v3(curs);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
-
+ DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index bc6d174efa0..90b1b043de6 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -395,14 +395,15 @@ void ED_view3d_lock_clear(View3D *v3d)
* sets the ``ofs`` and ``dist`` values of the viewport so it matches the camera,
* otherwise switching out of camera view may jump to a different part of the scene.
*/
-void ED_view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const char persp)
+void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d, const char persp)
{
BLI_assert(rv3d->persp == RV3D_CAMOB);
BLI_assert(persp != RV3D_CAMOB);
if (v3d->camera) {
- rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
- ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
+ rv3d->dist = ED_view3d_offset_distance(ob_camera_eval->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
+ ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
}
if (!ED_view3d_camera_lock_check(v3d, rv3d)) {
@@ -415,7 +416,7 @@ void ED_view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const c
*
* shared with NDOF.
*/
-bool ED_view3d_persp_ensure(struct View3D *v3d, ARegion *ar)
+bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar)
{
RegionView3D *rv3d = ar->regiondata;
const bool autopersp = (U.uiflag & USER_AUTOPERSP) != 0;
@@ -429,7 +430,7 @@ bool ED_view3d_persp_ensure(struct View3D *v3d, ARegion *ar)
if (rv3d->persp == RV3D_CAMOB) {
/* If autopersp and previous view was an axis one, switch back to PERSP mode, else reuse previous mode. */
char persp = (autopersp && RV3D_VIEW_IS_AXIS(rv3d->lview)) ? RV3D_PERSP : rv3d->lpersp;
- ED_view3d_persp_switch_from_camera(v3d, rv3d, persp);
+ ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, persp);
}
else if (autopersp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
rv3d->persp = RV3D_PERSP;
@@ -463,20 +464,21 @@ bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
* Apply the camera object transformation to the view-port.
* (needed so we can use regular view-port manipulation operators, that sync back to the camera).
*/
-void ED_view3d_camera_lock_init_ex(View3D *v3d, RegionView3D *rv3d, const bool calc_dist)
+void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d, const bool calc_dist)
{
if (ED_view3d_camera_lock_check(v3d, rv3d)) {
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
if (calc_dist) {
/* using a fallback dist is OK here since ED_view3d_from_object() compensates for it */
- rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
+ rv3d->dist = ED_view3d_offset_distance(ob_camera_eval->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
}
- ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
+ ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
}
}
-void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d)
+void ED_view3d_camera_lock_init(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
{
- ED_view3d_camera_lock_init_ex(v3d, rv3d, true);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, true);
}
/**
@@ -484,7 +486,7 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d)
*
* \return true if the camera is moved.
*/
-bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
+bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
{
if (ED_view3d_camera_lock_check(v3d, rv3d)) {
ObjectTfmProtectedChannels obtfm;
@@ -501,15 +503,17 @@ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
while (root_parent->parent) {
root_parent = root_parent->parent;
}
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
+ Object *root_parent_eval = DEG_get_evaluated_object(depsgraph, root_parent);
ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
- normalize_m4_m4(tmat, v3d->camera->obmat);
+ normalize_m4_m4(tmat, ob_camera_eval->obmat);
invert_m4_m4(imat, tmat);
mul_m4_m4m4(diff_mat, view_mat, imat);
- mul_m4_m4m4(parent_mat, diff_mat, root_parent->obmat);
+ mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->obmat);
BKE_object_tfm_protected_backup(root_parent, &obtfm);
BKE_object_apply_mat4(root_parent, parent_mat, true, false);
@@ -526,7 +530,7 @@ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
/* always maintain the same scale */
const short protect_scale_all = (OB_LOCK_SCALEX | OB_LOCK_SCALEY | OB_LOCK_SCALEZ);
BKE_object_tfm_protected_backup(v3d->camera, &obtfm);
- ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
+ ED_view3d_to_object(depsgraph, v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag | protect_scale_all);
DEG_id_tag_update(&v3d->camera->id, OB_RECALC_OB);
@@ -1063,6 +1067,7 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius)
*/
float ED_view3d_radius_to_dist(
const View3D *v3d, const ARegion *ar,
+ const struct Depsgraph *depsgraph,
const char persp, const bool use_aspect,
const float radius)
{
@@ -1083,7 +1088,8 @@ float ED_view3d_radius_to_dist(
BKE_camera_params_init(&params);
params.clipsta = v3d->near;
params.clipend = v3d->far;
- BKE_camera_params_from_object(&params, v3d->camera);
+ Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
+ BKE_camera_params_from_object(&params, camera_eval);
lens = params.lens;
sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y);
@@ -1273,7 +1279,7 @@ bool ED_view3d_lock(RegionView3D *rv3d)
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
* \param dist The view distance from ofs, normally from RegionView3D.dist.
*/
-void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist)
+void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist)
{
float nmat[3][3];
@@ -1318,13 +1324,14 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c
/**
* Set the RegionView3D members from an objects transformation and optionally lens.
+ * \param depsgraph The depsgraph to get the evaluated object for the lens calculation.
* \param ob The object to set the view to.
* \param ofs The view offset to be set, normally from RegionView3D.ofs.
* \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat.
* \param dist The view distance from ofs to be set, normally from RegionView3D.dist.
* \param lens The view lens angle set for cameras and lamps, normally from View3D.lens.
*/
-void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
+void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
{
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
@@ -1339,16 +1346,19 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
/**
* Set the object transformation from RegionView3D members.
+ * \param depsgraph The depsgraph to get the evaluated object parent for the transformation calculation.
* \param ob The object which has the transformation assigned.
* \param ofs The view offset, normally from RegionView3D.ofs.
* \param quat The view rotation, quaternion normally from RegionView3D.viewquat.
* \param dist The view distance from ofs, normally from RegionView3D.dist.
*/
-void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist)
+void ED_view3d_to_object(const Depsgraph *depsgraph, Object *ob, const float ofs[3], const float quat[4], const float dist)
{
float mat[4][4];
ED_view3d_to_m4(mat, ofs, quat, dist);
- BKE_object_apply_mat4(ob, mat, true, true);
+
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ BKE_object_apply_mat4_ex(ob, mat, ob_eval->parent, ob_eval->parentinv, true);
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index a8ae31bbabe..0a490a8b494 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -48,6 +48,7 @@
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "UI_resources.h"
@@ -62,8 +63,6 @@
#include "DRW_engine.h"
-#include "DEG_depsgraph_query.h"
-
#include "view3d_intern.h" /* own include */
/* -------------------------------------------------------------------- */
@@ -152,7 +151,7 @@ void ED_view3d_smooth_view_ex(
* we allow camera option locking to initialize the view settings from the camera.
*/
if (sview->camera == NULL && sview->camera_old == NULL) {
- ED_view3d_camera_lock_init(v3d, rv3d);
+ ED_view3d_camera_lock_init(depsgraph, v3d, rv3d);
}
/* store the options we want to end with */
@@ -177,9 +176,9 @@ void ED_view3d_smooth_view_ex(
}
if (sview->camera) {
- Object *camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
- sms.dst.dist = ED_view3d_offset_distance(camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
- ED_view3d_from_object(camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens);
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
+ sms.dst.dist = ED_view3d_offset_distance(ob_camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
+ ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens);
sms.to_camera = true; /* restore view3d values in end */
}
@@ -203,10 +202,10 @@ void ED_view3d_smooth_view_ex(
if (changed) {
/* original values */
if (sview->camera_old) {
- Object *camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
- sms.src.dist = ED_view3d_offset_distance(camera_old_eval->obmat, rv3d->ofs, 0.0f);
+ Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
+ sms.src.dist = ED_view3d_offset_distance(ob_camera_old_eval->obmat, rv3d->ofs, 0.0f);
/* this */
- ED_view3d_from_object(camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
+ ED_view3d_from_object(ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
}
/* grid draw as floor */
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
@@ -228,10 +227,10 @@ void ED_view3d_smooth_view_ex(
/* ensure it shows correct */
if (sms.to_camera) {
/* use ortho if we move from an ortho view to an ortho camera */
- Object *camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
rv3d->persp = (((rv3d->is_persp == false) &&
- (camera_eval->type == OB_CAMERA) &&
- (((Camera *)camera_eval->data)->type == CAM_ORTHO)) ?
+ (ob_camera_eval->type == OB_CAMERA) &&
+ (((Camera *)ob_camera_eval->data)->type == CAM_ORTHO)) ?
RV3D_ORTHO : RV3D_PERSP);
}
@@ -264,7 +263,7 @@ void ED_view3d_smooth_view_ex(
rv3d->dist = sms.dst.dist;
v3d->lens = sms.dst.lens;
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
}
if (rv3d->viewlock & RV3D_BOXVIEW) {
@@ -295,6 +294,7 @@ void ED_view3d_smooth_view(
/* only meant for timer usage */
static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview)
{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
struct SmoothView3DStore *sms = rv3d->sms;
float step, step_inv;
@@ -315,7 +315,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
else {
view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d);
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
}
@@ -348,7 +348,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv;
v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv;
- ED_view3d_camera_lock_sync(v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
if (ED_screen_animation_playing(CTX_wm_manager(C))) {
ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
}
@@ -436,6 +436,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot)
static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
{
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
View3D *v3d;
ARegion *ar;
RegionView3D *rv3d;
@@ -449,7 +450,7 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
BKE_object_tfm_protected_backup(v3d->camera, &obtfm);
- ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
+ ED_view3d_to_object(depsgraph, v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist);
BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag);
@@ -511,25 +512,26 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
Object *camera_ob = v3d ? v3d->camera : scene->camera;
+ Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob);
float r_co[3]; /* the new location to apply */
float r_scale; /* only for ortho cameras */
- if (camera_ob == NULL) {
+ if (camera_ob_eval == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active camera");
return OPERATOR_CANCELLED;
}
/* this function does all the important stuff */
- if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob, r_co, &r_scale)) {
+ if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) {
ObjectTfmProtectedChannels obtfm;
float obmat_new[4][4];
- if ((camera_ob->type == OB_CAMERA) && (((Camera *)camera_ob->data)->type == CAM_ORTHO)) {
+ if ((camera_ob_eval->type == OB_CAMERA) && (((Camera *)camera_ob_eval->data)->type == CAM_ORTHO)) {
((Camera *)camera_ob->data)->ortho_scale = r_scale;
}
- copy_m4_m4(obmat_new, camera_ob->obmat);
+ copy_m4_m4(obmat_new, camera_ob_eval->obmat);
copy_v3_v3(obmat_new[3], r_co);
/* only touch location */
@@ -760,9 +762,9 @@ void view3d_viewmatrix_set(
{
if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */
if (v3d->camera) {
- Object *camera_object = DEG_get_evaluated_object(depsgraph, v3d->camera);
- BKE_object_where_is_calc(depsgraph, scene, camera_object);
- obmat_to_viewmat(rv3d, camera_object);
+ Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
+ BKE_object_where_is_calc(depsgraph, scene, ob_camera_eval);
+ obmat_to_viewmat(rv3d, ob_camera_eval);
}
else {
quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 6bbc0b7d985..a7c97ba4d4a 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -602,7 +602,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d->rflag |= RV3D_NAVIGATING;
walk->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), walk->scene, CTX_data_depsgraph(C), 0,
+ walk->scene, CTX_data_depsgraph(C), 0,
walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 318e21bb7c9..a4d08b15a6d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2118,6 +2118,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->state = TRANS_STARTING;
+ if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) && RNA_property_is_set(op->ptr, prop)) {
+ if (RNA_property_boolean_get(op->ptr, prop)) {
+ options |= CTX_CURSOR;
+ }
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
options |= CTX_TEXTURE;
@@ -3007,7 +3013,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
#else
/* hrmf, snapping radius is using 'angle' steps, need to convert to something else
* this isnt essential but nicer to give reasonable snapping values for radius */
- if (t->tsnap.mode == SCE_SNAP_MODE_INCREMENT) {
+ if (t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) {
const float radius_snap = 0.1f;
const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap;
values.scale *= snap_hack;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 892187f11db..b9f42a0d9fc 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -557,6 +557,8 @@ typedef struct TransInfo {
#define T_TEXTURE (1 << 3)
/* transforming the camera while in camera view */
#define T_CAMERA (1 << 4)
+ /* transforming the 3D cursor. */
+#define T_CURSOR (1 << 5)
// trans on points, having no rotation/scale
#define T_POINTS (1 << 6)
/**
@@ -601,6 +603,8 @@ typedef struct TransInfo {
/** #TransInfo.center has been set, don't change it. */
#define T_OVERRIDE_CENTER (1 << 25)
+#define T_MODAL_CURSOR_SET (1 << 26)
+
/* TransInfo->modifiers */
#define MOD_CONSTRAINT_SELECT 0x01
#define MOD_PRECISION 0x02
@@ -844,7 +848,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
void calculatePropRatio(TransInfo *t);
-void getViewVector(TransInfo *t, float coord[3], float vec[3]);
+void getViewVector(const TransInfo *t, const float coord[3], float vec[3]);
void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
@@ -881,7 +885,6 @@ void projectVertSlideData(TransInfo *t, bool is_final);
/* TODO. transform_queries.c */
bool checkUseAxisMatrix(TransInfo *t);
-#define TRANSFORM_DIST_MAX_PX 1000.0f
#define TRANSFORM_SNAP_MAX_PX 100.0f
#define TRANSFORM_DIST_INVALID -FLT_MAX
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 02cfc9c5e35..3c70eaae2d3 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -171,7 +171,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
mul_m3_v3(t->con.mtx, vec);
}
-static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
+static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3])
{
if (t->spacetype == SPACE_VIEW3D) {
// View3D *v3d = t->sa->spacedata.first;
@@ -195,7 +195,10 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
}
}
-static void axisProjection(TransInfo *t, const float axis[3], const float in[3], float out[3])
+/**
+ * Axis calculation taking the view into account, correcting view-aligned axis.
+ */
+static void axisProjection(const TransInfo *t, const float axis[3], const float in[3], float out[3])
{
float norm[3], vec[3], factor, angle;
float t_con_center[3];
@@ -213,12 +216,11 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
if (angle > (float)M_PI_2) {
angle = (float)M_PI - angle;
}
- angle = RAD2DEGF(angle);
/* For when view is parallel to constraint... will cause NaNs otherwise
* So we take vertical motion in 3D space and apply it to the
* constraint axis. Nice for camera grab + MMB */
- if (angle < 5.0f) {
+ if (angle < DEG2RADF(5.0f)) {
project_v3_v3v3(vec, in, t->viewinv[1]);
factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
@@ -277,7 +279,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
* Return true if the 2x axis are both aligned when projected into the view.
* In this case, we can't usefully project the cursor onto the plane.
*/
-static bool isPlaneProjectionViewAligned(TransInfo *t)
+static bool isPlaneProjectionViewAligned(const TransInfo *t)
{
const float eps = 0.001f;
const float *constraint_vector[2];
@@ -303,7 +305,7 @@ static bool isPlaneProjectionViewAligned(TransInfo *t)
return fabsf(factor) < eps;
}
-static void planeProjection(TransInfo *t, const float in[3], float out[3])
+static void planeProjection(const TransInfo *t, const float in[3], float out[3])
{
float vec[3], factor, norm[3];
@@ -341,8 +343,7 @@ static void applyAxisConstraintVec(
mul_m3_v3(t->con.pmtx, out);
// With snap, a projection is alright, no need to correct for view alignment
- if (!(!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID) && activeSnap(t))) {
-
+ if (!validSnap(t)) {
const int dims = getConstraintSpaceDimension(t);
if (dims == 2) {
if (!is_zero_v3(out)) {
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 73a722d897d..c8b09eef04b 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -345,6 +345,43 @@ static void createTransTexspace(TransInfo *t)
copy_v3_v3(td->ext->isize, td->ext->size);
}
+static void createTransCursor3D(TransInfo *t)
+{
+ TransData *td;
+
+ Scene *scene = t->scene;
+ View3D *v3d = ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) ? t->view : NULL;
+ View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
+
+ if ((cursor == &scene->cursor) && ID_IS_LINKED(scene)) {
+ BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
+ return;
+ }
+
+ {
+ BLI_assert(t->data_container_len == 1);
+ TransDataContainer *tc = t->data_container;
+ tc->data_len = 1;
+ td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
+ td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
+ }
+
+ td->flag = TD_SELECTED;
+ copy_v3_v3(td->center, cursor->location);
+ td->ob = NULL;
+
+ unit_m3(td->mtx);
+ quat_to_mat3(td->axismtx, cursor->rotation);
+ normalize_m3(td->axismtx);
+ pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON);
+
+ td->loc = cursor->location;
+ copy_v3_v3(td->iloc, cursor->location);
+
+ td->ext->quat = cursor->rotation;
+ copy_qt_qt(td->ext->iquat, cursor->rotation);
+}
+
/* ********************* edge (for crease) ***** */
static void createTransEdge(TransInfo *t)
@@ -5583,39 +5620,41 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
/* transcribe given object into TransData for Transforming */
static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{
+ Depsgraph *depsgraph = t->depsgraph;
Scene *scene = t->scene;
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bool constinv;
bool skip_invert = false;
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3];
- float ctime = BKE_scene_frame_get(scene);
+ float ctime = DEG_get_ctime(depsgraph);
/* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */
+ // XXX: This needs fixing for COW. May need rigidbody_world from scene
if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
-
/* save original object transform */
- copy_v3_v3(td->ext->oloc, ob->loc);
+ copy_v3_v3(td->ext->oloc, ob_eval->loc);
if (ob->rotmode > 0) {
- copy_v3_v3(td->ext->orot, ob->rot);
+ copy_v3_v3(td->ext->orot, ob_eval->rot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
- td->ext->orotAngle = ob->rotAngle;
- copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
+ td->ext->orotAngle = ob_eval->rotAngle;
+ copy_v3_v3(td->ext->orotAxis, ob_eval->rotAxis);
}
else {
- copy_qt_qt(td->ext->oquat, ob->quat);
+ copy_qt_qt(td->ext->oquat, ob_eval->quat);
}
/* update object's loc/rot to get current rigid body transform */
- mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
- sub_v3_v3(ob->loc, ob->dloc);
+ mat4_to_loc_rot_size(ob->loc, rot, scale, ob_eval->obmat);
+ sub_v3_v3(ob->loc, ob_eval->dloc);
BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
}
}
/* axismtx has the real orientation */
- copy_m3_m4(td->axismtx, ob->obmat);
+ copy_m3_m4(td->axismtx, ob_eval->obmat);
normalize_m3(td->axismtx);
td->con = ob->constraints.first;
@@ -5628,6 +5667,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
constinv = constraints_list_needinv(t, &ob->constraints);
/* disable constraints inversion for dummy pass */
+ // XXX: Should this use ob or ob_eval?! It's not clear!
if (t->mode == TFM_DUMMY)
skip_invert = true;
@@ -5642,7 +5682,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ob = ob;
td->loc = ob->loc;
- copy_v3_v3(td->iloc, td->loc);
+ copy_v3_v3(td->iloc, ob_eval->loc);
if (ob->rotmode > 0) {
td->ext->rot = ob->rot;
@@ -5650,8 +5690,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = NULL;
td->ext->quat = NULL;
- copy_v3_v3(td->ext->irot, ob->rot);
- copy_v3_v3(td->ext->drot, ob->drot);
+ copy_v3_v3(td->ext->irot, ob_eval->rot);
+ copy_v3_v3(td->ext->drot, ob_eval->drot);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
td->ext->rot = NULL;
@@ -5659,10 +5699,10 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = &ob->rotAngle;
td->ext->quat = NULL;
- td->ext->irotAngle = ob->rotAngle;
- copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
- // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented
- // copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
+ td->ext->irotAngle = ob_eval->rotAngle;
+ copy_v3_v3(td->ext->irotAxis, ob_eval->rotAxis);
+ // td->ext->drotAngle = ob_eval->drotAngle; // XXX, not implemented
+ // copy_v3_v3(td->ext->drotAxis, ob_eval->drotAxis); // XXX, not implemented
}
else {
td->ext->rot = NULL;
@@ -5670,18 +5710,18 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
td->ext->rotAngle = NULL;
td->ext->quat = ob->quat;
- copy_qt_qt(td->ext->iquat, ob->quat);
- copy_qt_qt(td->ext->dquat, ob->dquat);
+ copy_qt_qt(td->ext->iquat, ob_eval->quat);
+ copy_qt_qt(td->ext->dquat, ob_eval->dquat);
}
- td->ext->rotOrder = ob->rotmode;
+ td->ext->rotOrder = ob_eval->rotmode;
td->ext->size = ob->size;
- copy_v3_v3(td->ext->isize, ob->size);
- copy_v3_v3(td->ext->dscale, ob->dscale);
+ copy_v3_v3(td->ext->isize, ob_eval->size);
+ copy_v3_v3(td->ext->dscale, ob_eval->dscale);
- copy_v3_v3(td->center, ob->obmat[3]);
+ copy_v3_v3(td->center, ob_eval->obmat[3]);
- copy_m4_m4(td->ext->obmat, ob->obmat);
+ copy_m4_m4(td->ext->obmat, ob_eval->obmat);
/* is there a need to set the global<->data space conversion matrices? */
if (ob->parent || constinv) {
@@ -5691,8 +5731,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
* NOTE: some Constraints, and also Tracking should never get this
* done, as it doesn't work well.
*/
- BKE_object_to_mat3(ob, obmtx);
- copy_m3_m4(totmat, ob->obmat);
+ BKE_object_to_mat3(ob_eval, obmtx);
+ copy_m3_m4(totmat, ob_eval->obmat);
invert_m3_m3(obinv, totmat);
mul_m3_m3m3(td->smtx, obmtx, obinv);
invert_m3_m3(td->mtx, td->smtx);
@@ -6693,6 +6733,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
{
/* do nothing */
}
+ else if (t->flag & T_CURSOR) {
+ /* do nothing */
+ }
else { /* Objects */
int i;
@@ -8325,7 +8368,14 @@ void createTransData(bContext *C, TransInfo *t)
t->data_len_all = -1;
/* if tests must match recalcData for correct updates */
- if (t->options & CTX_TEXTURE) {
+ if (t->options & CTX_CURSOR) {
+ t->flag |= T_CURSOR;
+ t->obedit_type = -1;
+
+ createTransCursor3D(t);
+ countAndCleanTransDataContainer(t);
+ }
+ else if (t->options & CTX_TEXTURE) {
t->flag |= T_TEXTURE;
t->obedit_type = -1;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index ed146eb3227..576bfddd28c 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -115,7 +115,7 @@
/* ************************** Functions *************************** */
-void getViewVector(TransInfo *t, float coord[3], float vec[3])
+void getViewVector(const TransInfo *t, const float coord[3], float vec[3])
{
if (t->persp != RV3D_ORTHO) {
sub_v3_v3v3(vec, coord, t->viewinv[3]);
@@ -1007,6 +1007,11 @@ static void recalcData_objects(TransInfo *t)
}
}
+static void recalcData_cursor(TransInfo *t)
+{
+ DEG_id_tag_update(&t->scene->id, DEG_TAG_COPY_ON_WRITE);
+}
+
/* helper for recalcData() - for sequencer transforms */
static void recalcData_sequencer(TransInfo *t)
{
@@ -1056,7 +1061,10 @@ static void recalcData_gpencil_strokes(TransInfo *t)
void recalcData(TransInfo *t)
{
/* if tests must match createTransData for correct updates */
- if (t->options & CTX_TEXTURE) {
+ if (t->options & CTX_CURSOR) {
+ recalcData_cursor(t);
+ }
+ else if (t->options & CTX_TEXTURE) {
recalcData_objects(t);
}
else if (t->options & CTX_EDGE) {
@@ -1323,9 +1331,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
prop_id = "use_even_offset";
}
- if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id)) &&
- RNA_property_is_set(op->ptr, prop))
- {
+ if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
SET_FLAG_FROM_TEST(t->flag, RNA_property_boolean_get(op->ptr, prop), T_ALT_TRANSFORM);
}
}
@@ -1629,6 +1635,10 @@ void postTrans(bContext *C, TransInfo *t)
if (t->draw_handle_cursor)
WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor);
+ if (t->flag & T_MODAL_CURSOR_SET) {
+ WM_cursor_modal_restore(CTX_wm_window(C));
+ }
+
/* Free all custom-data */
freeTransCustomDataContainer(t, NULL, &t->custom);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 2004bba4f09..270ef08be50 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -351,7 +351,8 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
case HLP_NONE:
/* INPUT_VECTOR, INPUT_CUSTOM_RATIO, INPUT_CUSTOM_RATIO_FLIP */
if (t->flag & T_MODAL) {
- WM_cursor_set(win, BC_NSEW_SCROLLCURSOR);
+ t->flag |= T_MODAL_CURSOR_SET;
+ WM_cursor_modal_set(win, BC_NSEW_SCROLLCURSOR);
}
break;
case HLP_SPRING:
@@ -360,7 +361,8 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
case HLP_HARROW:
case HLP_VARROW:
if (t->flag & T_MODAL) {
- WM_cursor_set(win, CURSOR_NONE);
+ t->flag |= T_MODAL_CURSOR_SET;
+ WM_cursor_modal_set(win, CURSOR_NONE);
}
break;
default:
diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c
index 8b635bb26db..b94ccf42325 100644
--- a/source/blender/editors/transform/transform_manipulator_3d.c
+++ b/source/blender/editors/transform/transform_manipulator_3d.c
@@ -65,6 +65,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
+#include "WM_toolsystem.h"
#include "ED_armature.h"
#include "ED_curve.h"
@@ -595,8 +596,8 @@ int ED_transform_calc_manipulator_stats(
RegionView3D *rv3d = ar->regiondata;
Base *base;
Object *ob = OBACT(view_layer);
- const Object *ob_eval = NULL;
- const Object *obedit_eval = NULL;
+ Object *ob_eval = NULL;
+ Object *obedit_eval = NULL;
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
int a, totsel = 0;
@@ -628,7 +629,7 @@ int ED_transform_calc_manipulator_stats(
case V3D_MANIP_GIMBAL:
{
float mat[3][3];
- if (gimbal_axis(ob, mat)) {
+ if (gimbal_axis(ob_eval, mat)) {
copy_m4_m3(rv3d->twmat, mat);
break;
}
@@ -946,7 +947,7 @@ int ED_transform_calc_manipulator_stats(
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
bool ok = false;
- if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) {
+ if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob_eval))) {
/* doesn't check selection or visibility intentionally */
Bone *bone = pchan->bone;
if (bone) {
@@ -957,11 +958,11 @@ int ED_transform_calc_manipulator_stats(
}
}
else {
- totsel = count_set_pose_transflags(&mode, 0, ob);
+ totsel = count_set_pose_transflags(&mode, 0, ob_eval);
if (totsel) {
/* use channels to get stats */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone;
if (bone && (bone->flag & BONE_TRANSFORM)) {
calc_tw_center(tbounds, pchan->pose_head);
@@ -1017,7 +1018,7 @@ int ED_transform_calc_manipulator_stats(
if (!TESTBASELIB(base)) {
continue;
}
- const Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
+ Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
if (ob == NULL) {
ob = base->object;
ob_eval = base_object_eval;
@@ -1131,7 +1132,7 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa
static void manipulator_xform_message_subscribe(
wmManipulatorGroup *mgroup, struct wmMsgBus *mbus,
- Scene *scene, bScreen *screen, ScrArea *sa, ARegion *ar, const void *type_fn)
+ Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn)
{
/* Subscribe to view properties */
wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = {
@@ -1157,8 +1158,8 @@ static void manipulator_xform_message_subscribe(
}
}
- PointerRNA space_ptr;
- RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr);
+ PointerRNA toolsettings_ptr;
+ RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
if (type_fn == TRANSFORM_WGT_manipulator) {
extern PropertyRNA rna_ToolSettings_transform_pivot_point;
@@ -1166,7 +1167,7 @@ static void manipulator_xform_message_subscribe(
&rna_ToolSettings_transform_pivot_point
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+ WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
}
}
else if (type_fn == VIEW3D_WGT_xform_cage) {
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 36c444a0ca3..73dd0392a25 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -563,6 +563,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes");
}
+ if (flags & P_CURSOR_EDIT) {
+ RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", "");
+ }
+
if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) {
RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel");
@@ -570,7 +574,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
if (flags & P_CORRECT_UV) {
- RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
+ RNA_def_boolean(ot->srna, "correct_uv", true, "Correct UVs", "Correct UV coordinates when transforming");
}
if (flags & P_CENTER) {
@@ -609,7 +613,10 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
WM_operatortype_props_advanced_begin(ot);
- Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_GPENCIL_EDIT);
+ Transform_Properties(
+ ot,
+ P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS |
+ P_GPENCIL_EDIT | P_CURSOR_EDIT);
}
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 19df46455d7..3065007ea6b 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -56,6 +56,8 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
+#include "DEG_depsgraph_query.h"
+
#include "BLT_translation.h"
#include "ED_armature.h"
@@ -1014,12 +1016,14 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- bArmature *arm = ob->data;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+ bArmature *arm = ob_eval->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
bool ok = false;
- if (activeOnly && (pchan = BKE_pose_channel_active(ob))) {
+ if (activeOnly && (pchan = BKE_pose_channel_active(ob_eval))) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
ok = true;
@@ -1030,7 +1034,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
totsel = count_bone_select(arm, &arm->bonebase, true);
if (totsel) {
/* use channels to get stats */
- for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
@@ -1043,7 +1047,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
/* use for both active & all */
if (ok) {
/* we need the transpose of the inverse for a normal... */
- copy_m3_m4(imat, ob->obmat);
+ copy_m3_m4(imat, ob_eval->obmat);
invert_m3_m3(mat, imat);
transpose_m3(mat);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 948eb47965f..10de7f3ea36 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -280,7 +280,6 @@ void applyProject(TransInfo *t)
for (i = 0; i < tc->data_len; i++, td++) {
float iloc[3], loc[3], no[3];
float mval_fl[2];
- float dist_px = TRANSFORM_DIST_MAX_PX;
if (td->flag & TD_NOACTION)
break;
@@ -301,9 +300,15 @@ void applyProject(TransInfo *t)
}
if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
- if (snapObjectsTransform(
- t, mval_fl, &dist_px,
- loc, no))
+ if (ED_transform_snap_object_project_view3d(
+ t->tsnap.object_context,
+ SCE_SNAP_MODE_FACE,
+ &(const struct SnapObjectParams){
+ .snap_select = t->tsnap.modeSelect,
+ .use_object_edit_cage = (t->flag & T_EDIT) != 0,
+ .use_occlusion_test = false,
+ },
+ mval_fl, 0, loc, no))
{
#if 0
if (tc->use_local_mat) {
@@ -346,7 +351,7 @@ void applyGridAbsolute(TransInfo *t)
GearsType grid_action;
int i;
- if (!(activeSnap(t) && (ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID))))
+ if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))))
return;
grid_action = BIG_GEARS;
@@ -401,16 +406,14 @@ void applyGridAbsolute(TransInfo *t)
void applySnapping(TransInfo *t, float *vec)
{
- /* project is not applied this way */
- if (t->tsnap.project)
- return;
-
if (t->tsnap.status & SNAP_FORCED) {
t->tsnap.targetSnap(t);
t->tsnap.applySnap(t, vec);
}
- else if (!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID) && activeSnap(t)) {
+ else if (((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) != 0) &&
+ activeSnap(t))
+ {
double current = PIL_check_seconds_timer();
// Time base quirky code to go around findnearest slowness
@@ -512,7 +515,7 @@ static void initSnappingMode(TransInfo *t)
}
else {
/* force project off when not supported */
- if (ts->snap_mode != SCE_SNAP_MODE_FACE)
+ if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0)
t->tsnap.project = 0;
t->tsnap.mode = ts->snap_mode;
@@ -547,7 +550,9 @@ static void initSnappingMode(TransInfo *t)
{
/* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632)
* TODO: perform self snap in gpencil_strokes */
- t->tsnap.modeSelect = ((t->options & CTX_GPENCIL_STROKES) != 0) ? SNAP_ALL : SNAP_NOT_SELECTED;
+ t->tsnap.modeSelect = (
+ ((t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR)) != 0) ?
+ SNAP_ALL : SNAP_NOT_SELECTED);
}
else {
/* Grid if snap is not possible */
@@ -577,7 +582,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
- G.main, t->scene, t->depsgraph, 0, t->ar, t->view);
+ t->scene, t->depsgraph, 0, t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
t->tsnap.object_context,
@@ -948,18 +953,22 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
mval[0] = t->mval[0];
mval[1] = t->mval[1];
- if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) {
- found = peelObjectsTransform(
- t, mval,
- (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0,
- loc, no, NULL);
- }
- else {
+ if (t->tsnap.mode &
+ (SCE_SNAP_MODE_VERTEX |
+ SCE_SNAP_MODE_EDGE |
+ SCE_SNAP_MODE_FACE))
+ {
zero_v3(no); /* objects won't set this */
found = snapObjectsTransform(
t, mval, &dist_px,
loc, no);
}
+ if ((found == false) && (t->tsnap.mode & SCE_SNAP_MODE_VOLUME)) {
+ found = peelObjectsTransform(
+ t, mval,
+ (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) != 0,
+ loc, no, NULL);
+ }
if (found == true) {
copy_v3_v3(t->tsnap.snapPoint, loc);
@@ -972,35 +981,38 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
}
}
else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) {
- /* same as above but for UV's */
- Image *ima = ED_space_image(t->sa->spacedata.first);
- float co[2];
+ if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) {
+ Image *ima = ED_space_image(t->sa->spacedata.first);
+ float co[2];
- UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
+ UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]);
- if (ED_uvedit_nearest_uv(t->scene, TRANS_DATA_CONTAINER_FIRST_EVIL(t)->obedit, ima, co, t->tsnap.snapPoint)) {
- t->tsnap.snapPoint[0] *= t->aspect[0];
- t->tsnap.snapPoint[1] *= t->aspect[1];
+ if (ED_uvedit_nearest_uv(t->scene, TRANS_DATA_CONTAINER_FIRST_EVIL(t)->obedit, ima, co, t->tsnap.snapPoint)) {
+ t->tsnap.snapPoint[0] *= t->aspect[0];
+ t->tsnap.snapPoint[1] *= t->aspect[1];
- t->tsnap.status |= POINT_INIT;
- }
- else {
- t->tsnap.status &= ~POINT_INIT;
+ t->tsnap.status |= POINT_INIT;
+ }
+ else {
+ t->tsnap.status &= ~POINT_INIT;
+ }
}
}
else if (t->spacetype == SPACE_NODE) {
- float loc[2];
- float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
- char node_border;
+ if (t->tsnap.mode & (SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y)) {
+ float loc[2];
+ float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here
+ char node_border;
- if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
- copy_v2_v2(t->tsnap.snapPoint, loc);
- t->tsnap.snapNodeBorder = node_border;
+ if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) {
+ copy_v2_v2(t->tsnap.snapPoint, loc);
+ t->tsnap.snapNodeBorder = node_border;
- t->tsnap.status |= POINT_INIT;
- }
- else {
- t->tsnap.status &= ~POINT_INIT;
+ t->tsnap.status |= POINT_INIT;
+ }
+ else {
+ t->tsnap.status &= ~POINT_INIT;
+ }
}
}
}
@@ -1309,15 +1321,14 @@ static bool snapNodeTest(View2D *v2d, bNode *node, eSnapSelect snap_select)
static NodeBorder snapNodeBorder(int snap_node_mode)
{
- switch (snap_node_mode) {
- case SCE_SNAP_MODE_NODE_X:
- return NODE_LEFT | NODE_RIGHT;
- case SCE_SNAP_MODE_NODE_Y:
- return NODE_TOP | NODE_BOTTOM;
- case SCE_SNAP_MODE_NODE_XY:
- return NODE_LEFT | NODE_RIGHT | NODE_TOP | NODE_BOTTOM;
+ NodeBorder flag = 0;
+ if (snap_node_mode & SCE_SNAP_MODE_NODE_X) {
+ flag |= NODE_LEFT | NODE_RIGHT;
+ }
+ if (snap_node_mode & SCE_SNAP_MODE_NODE_Y) {
+ flag |= NODE_TOP | NODE_BOTTOM;
}
- return 0;
+ return flag;
}
static bool snapNode(
@@ -1425,9 +1436,13 @@ void snapGridIncrement(TransInfo *t, float *val)
{
GearsType action;
- /* only do something if using absolute or incremental grid snapping */
- if (!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID))
+ /* only do something if using absolute or incremental grid snapping
+ * and there is no valid snap point */
+ if (!(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) ||
+ validSnap(t))
+ {
return;
+ }
action = activeSnap(t) ? BIG_GEARS : NO_GEARS;
@@ -1467,7 +1482,7 @@ static void applyGridIncrement(TransInfo *t, float *val, int max_index, const fl
const float *asp = use_aspect ? t->aspect : asp_local;
int i;
- BLI_assert(ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID));
+ BLI_assert(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID));
BLI_assert(max_index <= 2);
/* Early bailing out if no need to snap */
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index fb49396132a..29497fe801c 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -113,7 +113,6 @@ typedef struct SnapObjectData_EditMesh {
} SnapObjectData_EditMesh;
struct SnapObjectContext {
- Main *bmain;
Scene *scene;
Depsgraph *depsgraph;
@@ -535,6 +534,10 @@ static bool raycastEditMesh(
return retval;
}
}
+ else {
+ /* COW hack: Update pointers */
+ treedata->em = em;
+ }
float imat[4][4];
float timat[3][3]; /* transpose inverse matrix for normals */
@@ -1125,8 +1128,8 @@ static short snap_mesh_polygon(
MPoly *mp = &((Mesh *)ob->data)->mpoly[*r_index];
const MLoop *ml;
- if (snapdata->snap_to_flag & SCE_SELECT_EDGE) {
- elem = SCE_SELECT_EDGE;
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
+ elem = SCE_SNAP_MODE_EDGE;
treedata->edge = ((Mesh *)ob->data)->medge;
ml = &treedata->loop[mp->loopstart];
for (int i = mp->totloop; i--; ml++) {
@@ -1137,7 +1140,7 @@ static short snap_mesh_polygon(
}
}
else {
- elem = SCE_SELECT_VERTEX;
+ elem = SCE_SNAP_MODE_VERTEX;
ml = &treedata->loop[mp->loopstart];
for (int i = mp->totloop; i--; ml++) {
cb_snap_vert(
@@ -1160,8 +1163,8 @@ static short snap_mesh_polygon(
BMFace *f = BM_face_at_index(em->bm, *r_index);
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- if (snapdata->snap_to_flag & SCE_SELECT_EDGE) {
- elem = SCE_SELECT_EDGE;
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
+ elem = SCE_SNAP_MODE_EDGE;
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE);
do {
cb_snap_edge(
@@ -1172,7 +1175,7 @@ static short snap_mesh_polygon(
} while ((l_iter = l_iter->next) != l_first);
}
else {
- elem = SCE_SELECT_VERTEX;
+ elem = SCE_SNAP_MODE_VERTEX;
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
do {
cb_snap_vert(
@@ -1195,7 +1198,7 @@ static short snap_mesh_polygon(
invert_m4_m4(imat, obmat);
copy_v3_v3(r_no, nearest.no);
- mul_transposed_mat3_m4_v3(obmat, r_no);
+ mul_transposed_mat3_m4_v3(imat, r_no);
normalize_v3(r_no);
}
@@ -1218,7 +1221,7 @@ static short snap_mesh_edge_verts_mixed(
/* return args */
float r_loc[3], float r_no[3], int *r_index)
{
- short elem = SCE_SELECT_EDGE;
+ short elem = SCE_SNAP_MODE_EDGE;
if (ob->type != OB_MESH) {
return elem;
@@ -1282,7 +1285,7 @@ static short snap_mesh_edge_verts_mixed(
{
nearest.index = vindex[v_id];
nearest2d.copy_vert_no(vindex[v_id], nearest.no, nearest2d.userdata);
- elem = SCE_SELECT_VERTEX;
+ elem = SCE_SNAP_MODE_VERTEX;
}
}
@@ -1297,7 +1300,7 @@ static short snap_mesh_edge_verts_mixed(
invert_m4_m4(imat, obmat);
copy_v3_v3(r_no, nearest.no);
- mul_transposed_mat3_m4_v3(obmat, r_no);
+ mul_transposed_mat3_m4_v3(imat, r_no);
normalize_v3(r_no);
}
@@ -1319,7 +1322,7 @@ static short snapArmature(
{
short retval = 0;
- if (snapdata->snap_to_flag == SCE_SELECT_FACE) { /* Currently only edge and vert */
+ if (snapdata->snap_to_flag == SCE_SNAP_MODE_FACE) { /* Currently only edge and vert */
return retval;
}
@@ -1361,7 +1364,7 @@ static short snapArmature(
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
bool has_vert_snap = false;
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
has_vert_snap = test_projected_vert_dist(
&neasrest_precalc,
clip_planes_local, snapdata->clip_plane_len,
@@ -1372,17 +1375,17 @@ static short snapArmature(
is_persp, eBone->tail, &dist_px_sq, r_loc);
if (has_vert_snap) {
- retval = SCE_SELECT_VERTEX;
+ retval = SCE_SNAP_MODE_VERTEX;
}
}
- if (!has_vert_snap && snapdata->snap_to_flag & SCE_SELECT_EDGE) {
+ if (!has_vert_snap && snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (test_projected_edge_dist(
&neasrest_precalc,
clip_planes_local, snapdata->clip_plane_len,
is_persp, eBone->head, eBone->tail,
&dist_px_sq, r_loc))
{
- retval = SCE_SELECT_EDGE;
+ retval = SCE_SNAP_MODE_EDGE;
}
}
}
@@ -1398,7 +1401,7 @@ static short snapArmature(
const float *head_vec = pchan->pose_head;
const float *tail_vec = pchan->pose_tail;
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
has_vert_snap = test_projected_vert_dist(
&neasrest_precalc,
clip_planes_local, snapdata->clip_plane_len,
@@ -1409,17 +1412,17 @@ static short snapArmature(
is_persp, tail_vec, &dist_px_sq, r_loc);
if (has_vert_snap) {
- retval = SCE_SELECT_VERTEX;
+ retval = SCE_SNAP_MODE_VERTEX;
}
}
- if (!has_vert_snap && snapdata->snap_to_flag & SCE_SELECT_EDGE) {
+ if (!has_vert_snap && snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (test_projected_edge_dist(
&neasrest_precalc,
clip_planes_local, snapdata->clip_plane_len,
is_persp, head_vec, tail_vec,
&dist_px_sq, r_loc))
{
- retval = SCE_SELECT_EDGE;
+ retval = SCE_SNAP_MODE_EDGE;
}
}
}
@@ -1450,7 +1453,7 @@ static short snapCurve(
bool has_snap = false;
/* only vertex snapping mode (eg control points and handles) supported for now) */
- if (snapdata->snap_to_flag != SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag != SCE_SNAP_MODE_VERTEX) {
return 0;
}
@@ -1489,7 +1492,7 @@ static short snapCurve(
for (Nurb *nu = (use_obedit ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) {
for (int u = 0; u < nu->pntsu; u++) {
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
if (use_obedit) {
if (nu->bezt) {
/* don't snap to selected (moving) or hidden */
@@ -1562,7 +1565,7 @@ static short snapCurve(
/* Does not support index yet. */
*r_index = -1;
}
- return SCE_SELECT_VERTEX;
+ return SCE_SNAP_MODE_VERTEX;
}
return 0;
@@ -1584,7 +1587,7 @@ static short snapEmpty(
}
/* for now only vertex supported */
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
struct DistProjectedAABBPrecalc neasrest_precalc;
dist_squared_to_projected_aabb_precalc(
&neasrest_precalc, snapdata->pmat, snapdata->win_size, snapdata->mval);
@@ -1605,7 +1608,7 @@ static short snapEmpty(
is_persp, co, &dist_px_sq, r_loc))
{
*dist_px = sqrtf(dist_px_sq);
- retval = SCE_SELECT_VERTEX;
+ retval = SCE_SNAP_MODE_VERTEX;
}
}
@@ -1659,7 +1662,7 @@ static short snapCamera(
invert_m4_m4(orig_camera_imat, orig_camera_mat);
invert_m4_m4(imat, obmat);
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
struct DistProjectedAABBPrecalc neasrest_precalc;
dist_squared_to_projected_aabb_precalc(
&neasrest_precalc, snapdata->pmat, snapdata->win_size, snapdata->mval);
@@ -1704,7 +1707,7 @@ static short snapCamera(
clip_planes_local, snapdata->clip_plane_len,
is_persp, bundle_pos, &dist_px_sq, r_loc))
{
- retval = SCE_SELECT_VERTEX;
+ retval = SCE_SNAP_MODE_VERTEX;
}
}
}
@@ -1730,9 +1733,9 @@ static short snapMesh(
/* return args */
float r_loc[3], float r_no[3], int *r_index)
{
- BLI_assert(snapdata->snap_to_flag != SCE_SELECT_FACE);
+ BLI_assert(snapdata->snap_to_flag != SCE_SNAP_MODE_FACE);
- if ((snapdata->snap_to_flag & ~SCE_SELECT_FACE) == SCE_SELECT_EDGE) {
+ if ((snapdata->snap_to_flag & ~SCE_SNAP_MODE_FACE) == SCE_SNAP_MODE_EDGE) {
if (me->totedge == 0) {
return 0;
}
@@ -1822,7 +1825,7 @@ static short snapMesh(
treedata->edge_allocated = dummy_treedata.edge_allocated;
}
}
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
if (sod->has_loose_vert && bvhtree[1] == NULL) {
bvhtree[1] = BKE_bvhtree_from_mesh_get(&dummy_treedata, me, BVHTREE_FROM_LOOSEVERTS, 2);
sod->has_loose_vert = bvhtree[1] != NULL;
@@ -1871,7 +1874,7 @@ static short snapMesh(
.dist_sq = dist_px_sq,
};
int last_index = nearest.index;
- short elem = SCE_SELECT_VERTEX;
+ short elem = SCE_SNAP_MODE_VERTEX;
float tobmat[4][4], clip_planes_local[MAX_CLIPPLANE_LEN][4];
transpose_m4_m4(tobmat, obmat);
@@ -1879,7 +1882,7 @@ static short snapMesh(
mul_v4_m4v4(clip_planes_local[i], tobmat, snapdata->clip_plane[i]);
}
- if (bvhtree[1] && (snapdata->snap_to_flag & SCE_SELECT_VERTEX)) {
+ if (bvhtree[1] && (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX)) {
/* snap to loose verts */
BLI_bvhtree_find_nearest_projected(
bvhtree[1], lpmat, snapdata->win_size, snapdata->mval,
@@ -1889,7 +1892,7 @@ static short snapMesh(
last_index = nearest.index;
}
- if (snapdata->snap_to_flag & SCE_SELECT_EDGE) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (bvhtree[0]) {
/* snap to loose edges */
BLI_bvhtree_find_nearest_projected(
@@ -1907,11 +1910,11 @@ static short snapMesh(
}
if (last_index != nearest.index) {
- elem = SCE_SELECT_EDGE;
+ elem = SCE_SNAP_MODE_EDGE;
}
}
else {
- BLI_assert(snapdata->snap_to_flag & SCE_SELECT_VERTEX);
+ BLI_assert(snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX);
if (bvhtree[0]) {
/* snap to loose edges */
BLI_bvhtree_find_nearest_projected(
@@ -1940,7 +1943,7 @@ static short snapMesh(
invert_m4_m4(imat, obmat);
copy_v3_v3(r_no, nearest.no);
- mul_transposed_mat3_m4_v3(obmat, r_no);
+ mul_transposed_mat3_m4_v3(imat, r_no);
normalize_v3(r_no);
}
if (r_index) {
@@ -1961,9 +1964,9 @@ static short snapEditMesh(
/* return args */
float r_loc[3], float r_no[3], int *r_index)
{
- BLI_assert(snapdata->snap_to_flag != SCE_SELECT_FACE);
+ BLI_assert(snapdata->snap_to_flag != SCE_SNAP_MODE_FACE);
- if ((snapdata->snap_to_flag & ~SCE_SELECT_FACE) == SCE_SELECT_EDGE) {
+ if ((snapdata->snap_to_flag & ~SCE_SNAP_MODE_FACE) == SCE_SNAP_MODE_EDGE) {
if (em->bm->totedge == 0) {
return 0;
}
@@ -1986,7 +1989,7 @@ static short snapEditMesh(
sod->sd.type = SNAP_EDIT_MESH;
}
- if (snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
if (sod->bvh_trees[0] == NULL) {
sod->bvh_trees[0] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(**sod->bvh_trees));
}
@@ -2006,7 +2009,7 @@ static short snapEditMesh(
}
}
- if (snapdata->snap_to_flag & SCE_SELECT_EDGE) {
+ if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
if (sod->bvh_trees[1] == NULL) {
sod->bvh_trees[1] = BLI_memarena_calloc(sctx->cache.mem_arena, sizeof(**sod->bvh_trees));
}
@@ -2040,7 +2043,7 @@ static short snapEditMesh(
.dist_sq = SQUARE(*dist_px),
};
int last_index = nearest.index;
- short elem = SCE_SELECT_VERTEX;
+ short elem = SCE_SNAP_MODE_VERTEX;
float lpmat[4][4], tobmat[4][4], clip_planes_local[MAX_CLIPPLANE_LEN][4];
mul_m4_m4m4(lpmat, snapdata->pmat, obmat);
@@ -2050,7 +2053,7 @@ static short snapEditMesh(
mul_v4_m4v4(clip_planes_local[i], tobmat, snapdata->clip_plane[i]);
}
- if (treedata_vert && snapdata->snap_to_flag & SCE_SELECT_VERTEX) {
+ if (treedata_vert && snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
BLI_bvhtree_find_nearest_projected(
treedata_vert->tree, lpmat, snapdata->win_size, snapdata->mval,
@@ -2060,7 +2063,7 @@ static short snapEditMesh(
last_index = nearest.index;
}
- if (treedata_edge && snapdata->snap_to_flag & SCE_SELECT_EDGE) {
+ if (treedata_edge && snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_VERT);
BLI_bvhtree_find_nearest_projected(
treedata_edge->tree, lpmat, snapdata->win_size, snapdata->mval,
@@ -2068,7 +2071,7 @@ static short snapEditMesh(
&nearest, cb_snap_edge, &nearest2d);
if (last_index != nearest.index) {
- elem = SCE_SELECT_EDGE;
+ elem = SCE_SNAP_MODE_EDGE;
}
}
@@ -2082,7 +2085,7 @@ static short snapEditMesh(
invert_m4_m4(imat, obmat);
copy_v3_v3(r_no, nearest.no);
- mul_transposed_mat3_m4_v3(obmat, r_no);
+ mul_transposed_mat3_m4_v3(imat, r_no);
normalize_v3(r_no);
}
if (r_index) {
@@ -2265,13 +2268,12 @@ static short snapObjectsRay(
* \{ */
SnapObjectContext *ED_transform_snap_object_context_create(
- Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag)
+ Scene *scene, Depsgraph *depsgraph, int flag)
{
SnapObjectContext *sctx = MEM_callocN(sizeof(*sctx), __func__);
sctx->flag = flag;
- sctx->bmain = bmain;
sctx->scene = scene;
sctx->depsgraph = depsgraph;
@@ -2282,11 +2284,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
}
SnapObjectContext *ED_transform_snap_object_context_create_view3d(
- Main *bmain, Scene *scene, Depsgraph *depsgraph, int flag,
+ Scene *scene, Depsgraph *depsgraph, int flag,
/* extra args for view3d */
const ARegion *ar, const View3D *v3d)
{
- SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, depsgraph, flag);
+ SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, depsgraph, flag);
sctx->use_v3d = true;
sctx->v3d_data.ar = ar;
@@ -2448,8 +2450,11 @@ static short transform_snap_context_project_view3d_mixed_impl(
float r_loc[3], float r_no[3], int *r_index,
Object **r_ob, float r_obmat[4][4])
{
- BLI_assert(snap_to_flag != 0);
- BLI_assert((snap_to_flag & ~(1 | 2 | 4)) == 0);
+ BLI_assert(
+ (snap_to_flag & (
+ SCE_SNAP_MODE_VERTEX |
+ SCE_SNAP_MODE_EDGE |
+ SCE_SNAP_MODE_FACE)) != 0);
short retval = 0;
bool has_hit = false;
@@ -2461,7 +2466,7 @@ static short transform_snap_context_project_view3d_mixed_impl(
const ARegion *ar = sctx->v3d_data.ar;
const RegionView3D *rv3d = ar->regiondata;
- if (snap_to_flag & SCE_SELECT_FACE || params->use_occlusion_test) {
+ if (snap_to_flag & SCE_SNAP_MODE_FACE || params->use_occlusion_test) {
float ray_start[3], ray_normal[3];
if (!ED_view3d_win_to_ray_ex(
@@ -2480,12 +2485,12 @@ static short transform_snap_context_project_view3d_mixed_impl(
&dummy_ray_depth, loc, no,
&index, &ob, obmat, NULL);
- if (has_hit && (snap_to_flag & SCE_SELECT_FACE)) {
- retval = SCE_SELECT_FACE;
+ if (has_hit && (snap_to_flag & SCE_SNAP_MODE_FACE)) {
+ retval = SCE_SNAP_MODE_FACE;
}
}
- if (snap_to_flag & (SCE_SELECT_VERTEX | SCE_SELECT_EDGE)) {
+ if (snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE)) {
short elem;
float dist_px_tmp = *dist_px;
@@ -2508,6 +2513,10 @@ static short transform_snap_context_project_view3d_mixed_impl(
/* Compute the new clip_pane but do not add it yet. */
float new_clipplane[4];
plane_from_point_normal_v3(new_clipplane, loc, no);
+ if (dot_v3v3(snapdata.clip_plane[0], new_clipplane) > 0.0f) {
+ /* The plane is facing the wrong direction. */
+ negate_v4(new_clipplane);
+ }
/* Try to snap only to the polygon. */
elem = snap_mesh_polygon(
@@ -2534,8 +2543,8 @@ static short transform_snap_context_project_view3d_mixed_impl(
retval = elem;
}
- if ((retval == SCE_SELECT_EDGE) &&
- (snapdata.snap_to_flag & SCE_SELECT_VERTEX))
+ if ((retval == SCE_SNAP_MODE_EDGE) &&
+ (snapdata.snap_to_flag & SCE_SNAP_MODE_VERTEX))
{
retval = snap_mesh_edge_verts_mixed(
sctx, &snapdata,
@@ -2566,32 +2575,6 @@ static short transform_snap_context_project_view3d_mixed_impl(
return 0;
}
-/**
- * Convenience function for performing snapping.
- *
- * Given a 2D region value, snap to vert/edge/face.
- *
- * \param sctx: Snap context.
- * \param mval_fl: Screenspace coordinate.
- * \param dist_px: Maximum distance to snap (in pixels).
- * \param r_co: hit location.
- * \param r_no: hit normal (optional).
- * \return Snap success
- */
-bool ED_transform_snap_object_project_view3d_mixed(
- SnapObjectContext *sctx,
- const unsigned short snap_to_flag,
- const struct SnapObjectParams *params,
- const float mval_fl[2], float *dist_px,
- float r_co[3], float r_no[3])
-{
- return transform_snap_context_project_view3d_mixed_impl(
- sctx,
- snap_to_flag, params,
- mval_fl, dist_px,
- r_co, r_no, NULL, NULL, NULL) != 0;
-}
-
bool ED_transform_snap_object_project_view3d_ex(
SnapObjectContext *sctx,
const unsigned short snap_to,
@@ -2600,28 +2583,25 @@ bool ED_transform_snap_object_project_view3d_ex(
float r_loc[3], float r_no[3], int *r_index,
Object **r_ob, float r_obmat[4][4])
{
- short snap_to_flag;
- switch (snap_to) {
- case SCE_SNAP_MODE_FACE:
- snap_to_flag = SCE_SELECT_FACE;
- break;
- case SCE_SNAP_MODE_VERTEX:
- snap_to_flag = SCE_SELECT_VERTEX;
- break;
- case SCE_SNAP_MODE_EDGE:
- snap_to_flag = SCE_SELECT_EDGE;
- break;
- default:
- return false;
- }
-
return transform_snap_context_project_view3d_mixed_impl(
sctx,
- snap_to_flag, params,
+ snap_to, params,
mval, dist_px,
r_loc, r_no, r_index, r_ob, r_obmat) != 0;
}
+/**
+ * Convenience function for performing snapping.
+ *
+ * Given a 2D region value, snap to vert/edge/face.
+ *
+ * \param sctx: Snap context.
+ * \param mval_fl: Screenspace coordinate.
+ * \param dist_px: Maximum distance to snap (in pixels).
+ * \param r_co: hit location.
+ * \param r_no: hit normal (optional).
+ * \return Snap success
+ */
bool ED_transform_snap_object_project_view3d(
SnapObjectContext *sctx,
const unsigned short snap_to,
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index a39db060886..6b8bc957b26 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -620,14 +620,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* 1. draw shadow mesh */
if (sima->flag & SI_DRAWSHADOW) {
- Object *ob_cage = DEG_get_evaluated_object(depsgraph, obedit);
+ Object *ob_cage_eval = DEG_get_evaluated_object(depsgraph, obedit);
/* XXX TODO: Need to check if shadow mesh is different than original mesh. */
- bool is_cage_like_final_meshes = (ob_cage == obedit);
+ bool is_cage_like_final_meshes = (ob_cage_eval == obedit);
/* When sync selection is enabled, all faces are drawn (except for hidden)
* so if cage is the same as the final, there is no point in drawing this. */
if (((ts->uv_flag & UV_SYNC_SELECTION) == 0) || is_cage_like_final_meshes) {
- draw_uvs_shadow(ob_cage);
+ draw_uvs_shadow(ob_cage_eval);
}
}
@@ -1061,7 +1061,7 @@ void ED_uvedit_draw_main(
Object *ob_iter = objects[ob_index];
draw_uvs(sima, scene, view_layer, ob_iter, depsgraph);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
}
else {
draw_uvs_texpaint(sima, scene, view_layer, obact);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 97075eba61e..fceb1532077 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -567,35 +567,45 @@ void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float as
}
}
-bool ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float r_min[2], float r_max[2])
+bool ED_uvedit_minmax_multi(
+ Scene *scene, Image *ima, Object **objects_edit, uint objects_len,
+ float r_min[2], float r_max[2])
{
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMFace *efa;
- BMLoop *l;
- BMIter iter, liter;
- MLoopUV *luv;
bool changed = false;
+ INIT_MINMAX2(r_min, r_max);
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects_edit[ob_index];
- INIT_MINMAX2(r_min, r_max);
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMFace *efa;
+ BMLoop *l;
+ BMIter iter, liter;
+ MLoopUV *luv;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
- continue;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- minmax_v2v2_v2(r_min, r_max, luv->uv);
- changed = true;
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ continue;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ minmax_v2v2_v2(r_min, r_max, luv->uv);
+ changed = true;
+ }
}
}
}
-
return changed;
}
+bool ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float r_min[2], float r_max[2])
+{
+ return ED_uvedit_minmax_multi(scene, ima, &obedit, 1, r_min, r_max);
+}
+
/* Be careful when using this, it bypasses all synchronization options */
void ED_uvedit_select_all(BMesh *bm)
{
@@ -614,27 +624,32 @@ void ED_uvedit_select_all(BMesh *bm)
}
}
-static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[2])
+static bool ED_uvedit_median_multi(Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float co[2])
{
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMFace *efa;
- BMLoop *l;
- BMIter iter, liter;
- MLoopUV *luv;
unsigned int sel = 0;
+ zero_v2(co);
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects_edit[ob_index];
- zero_v2(co);
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
- continue;
-
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- add_v2_v2(co, luv->uv);
- sel++;
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMFace *efa;
+ BMLoop *l;
+ BMIter iter, liter;
+ MLoopUV *luv;
+
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ continue;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ add_v2_v2(co, luv->uv);
+ sel++;
+ }
}
}
}
@@ -644,19 +659,24 @@ static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[
return (sel != 0);
}
-bool ED_uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], char mode)
+static bool UNUSED_FUNCTION(ED_uvedit_median)(Scene *scene, Image *ima, Object *obedit, float co[2])
+{
+ return ED_uvedit_median_multi(scene, ima, &obedit, 1, co);
+}
+
+bool ED_uvedit_center_multi(Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float cent[2], char mode)
{
bool changed = false;
if (mode == V3D_AROUND_CENTER_BOUNDS) { /* bounding box */
float min[2], max[2];
- if (ED_uvedit_minmax(scene, ima, obedit, min, max)) {
+ if (ED_uvedit_minmax_multi(scene, ima, objects_edit, objects_len, min, max)) {
mid_v2_v2v2(cent, min, max);
changed = true;
}
}
else {
- if (ED_uvedit_median(scene, ima, obedit, cent)) {
+ if (ED_uvedit_median_multi(scene, ima, objects_edit, objects_len, cent)) {
changed = true;
}
}
@@ -664,6 +684,11 @@ bool ED_uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], c
return changed;
}
+bool ED_uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], char mode)
+{
+ return ED_uvedit_center_multi(scene, ima, &obedit, 1, cent, mode);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -2036,7 +2061,7 @@ static int uv_select_all_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -2500,7 +2525,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
}
if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_CANCELLED;
}
}
@@ -3032,7 +3057,7 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
}
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -3357,17 +3382,16 @@ static void uv_snap_cursor_to_pixels(SpaceImage *sima)
uv_snap_to_pixel(sima->cursor, width, height);
}
-static bool uv_snap_cursor_to_selection(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
+static bool uv_snap_cursor_to_selection(
+ Scene *scene, Image *ima, Object **objects_edit, uint objects_len, SpaceImage *sima)
{
- return ED_uvedit_center(scene, ima, obedit, sima->cursor, sima->around);
+ return ED_uvedit_center_multi(scene, ima, objects_edit, objects_len, sima->cursor, sima->around);
}
static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima = CTX_wm_space_image(C);
- Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- Image *ima = CTX_data_edit_image(C);
+
bool changed = false;
switch (RNA_enum_get(op->ptr, "target")) {
@@ -3376,8 +3400,18 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
changed = true;
break;
case 1:
- changed = uv_snap_cursor_to_selection(scene, ima, obedit, sima);
+ {
+ Scene *scene = CTX_data_scene(C);
+ Image *ima = CTX_data_edit_image(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
+ view_layer, &objects_len);
+ changed = uv_snap_cursor_to_selection(scene, ima, objects, objects_len, sima);
+ MEM_freeN(objects);
break;
+ }
}
if (!changed)
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index d13a4646a2f..521470d4e5f 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -839,7 +839,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, true)) {
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_CANCELLED;
}
@@ -856,7 +856,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
}
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@ -1357,7 +1357,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
if (!uvedit_have_selection_multi(scene, objects, objects_len, implicit)) {
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_CANCELLED;
}
@@ -1418,7 +1418,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
ED_uvedit_pack_islands_multi(scene, objects, objects_len, true, true, true);
- MEM_SAFE_FREE(objects);
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}