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/animation/anim_channels_defines.c72
-rw-r--r--source/blender/editors/animation/anim_deps.c2
-rw-r--r--source/blender/editors/animation/anim_filter.c63
-rw-r--r--source/blender/editors/animation/anim_markers.c4
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c7
-rw-r--r--source/blender/editors/animation/keyframing.c4
-rw-r--r--source/blender/editors/armature/editarmature.c4
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c30
-rw-r--r--source/blender/editors/armature/meshlaplacian.c2
-rw-r--r--source/blender/editors/armature/poseobject.c111
-rw-r--r--source/blender/editors/curve/editcurve.c15
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c24
-rw-r--r--source/blender/editors/include/ED_armature.h1
-rw-r--r--source/blender/editors/include/ED_clip.h2
-rw-r--r--source/blender/editors/include/ED_curve.h2
-rw-r--r--source/blender/editors/include/ED_image.h3
-rw-r--r--source/blender/editors/include/ED_mask.h4
-rw-r--r--source/blender/editors/include/ED_mball.h2
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/ED_sequencer.h2
-rw-r--r--source/blender/editors/include/ED_util.h2
-rw-r--r--source/blender/editors/include/ED_view3d.h139
-rw-r--r--source/blender/editors/include/UI_interface.h18
-rw-r--r--source/blender/editors/include/UI_view2d.h18
-rw-r--r--source/blender/editors/interface/interface.c94
-rw-r--r--source/blender/editors/interface/interface_draw.c117
-rw-r--r--source/blender/editors/interface/interface_handlers.c405
-rw-r--r--source/blender/editors/interface/interface_icons.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h25
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/interface/interface_ops.c22
-rw-r--r--source/blender/editors/interface/interface_panel.c24
-rw-r--r--source/blender/editors/interface/interface_regions.c109
-rw-r--r--source/blender/editors/interface/interface_style.c12
-rw-r--r--source/blender/editors/interface/interface_templates.c174
-rw-r--r--source/blender/editors/interface/interface_widgets.c306
-rw-r--r--source/blender/editors/interface/view2d.c143
-rw-r--r--source/blender/editors/interface/view2d_ops.c82
-rw-r--r--source/blender/editors/io/io_collada.c54
-rw-r--r--source/blender/editors/io/io_ops.c2
-rw-r--r--source/blender/editors/mask/mask_add.c4
-rw-r--r--source/blender/editors/mask/mask_draw.c8
-rw-r--r--source/blender/editors/mask/mask_editaction.c1
-rw-r--r--source/blender/editors/mesh/editface.c4
-rw-r--r--source/blender/editors/mesh/editmesh_add.c65
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c4
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c16
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c12
-rw-r--r--source/blender/editors/mesh/editmesh_select.c9
-rw-r--r--source/blender/editors/mesh/editmesh_slide.c8
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c41
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c15
-rw-r--r--source/blender/editors/mesh/mesh_data.c183
-rw-r--r--source/blender/editors/mesh/mesh_intern.h6
-rw-r--r--source/blender/editors/mesh/mesh_ops.c5
-rw-r--r--source/blender/editors/mesh/meshtools.c96
-rw-r--r--source/blender/editors/metaball/mball_edit.c3
-rw-r--r--source/blender/editors/object/object_add.c8
-rw-r--r--source/blender/editors/object/object_bake.c13
-rw-r--r--source/blender/editors/object/object_edit.c20
-rw-r--r--source/blender/editors/object/object_hook.c6
-rw-r--r--source/blender/editors/object/object_lattice.c4
-rw-r--r--source/blender/editors/object/object_modifier.c19
-rw-r--r--source/blender/editors/object/object_select.c2
-rw-r--r--source/blender/editors/object/object_shapekey.c22
-rw-r--r--source/blender/editors/physics/particle_edit.c14
-rw-r--r--source/blender/editors/physics/physics_fluid.c4
-rw-r--r--source/blender/editors/render/render_internal.c30
-rw-r--r--source/blender/editors/render/render_opengl.c90
-rw-r--r--source/blender/editors/render/render_preview.c46
-rw-r--r--source/blender/editors/screen/area.c54
-rw-r--r--source/blender/editors/screen/glutil.c20
-rw-r--r--source/blender/editors/screen/screen_edit.c6
-rw-r--r--source/blender/editors/screen/screen_ops.c61
-rw-r--r--source/blender/editors/screen/screendump.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c58
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c111
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c19
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c4
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c4
-rw-r--r--source/blender/editors/space_action/action_select.c5
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c2
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c7
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c33
-rw-r--r--source/blender/editors/space_clip/clip_editor.c43
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c4
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c8
-rw-r--r--source/blender/editors/space_clip/clip_ops.c8
-rw-r--r--source/blender/editors/space_clip/space_clip.c4
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/file_intern.h1
-rw-r--r--source/blender/editors/space_file/file_ops.c41
-rw-r--r--source/blender/editors/space_file/file_panels.c19
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_file/filesel.c8
-rw-r--r--source/blender/editors/space_file/fsmenu.c189
-rw-r--r--source/blender/editors/space_file/fsmenu.h8
-rw-r--r--source/blender/editors/space_file/space_file.c3
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c6
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c4
-rw-r--r--source/blender/editors/space_graph/graph_select.c2
-rw-r--r--source/blender/editors/space_image/image_buttons.c109
-rw-r--r--source/blender/editors/space_image/image_draw.c131
-rw-r--r--source/blender/editors/space_image/image_edit.c8
-rw-r--r--source/blender/editors/space_image/image_intern.h2
-rw-r--r--source/blender/editors/space_image/image_ops.c136
-rw-r--r--source/blender/editors/space_image/space_image.c21
-rw-r--r--source/blender/editors/space_info/info_stats.c2
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c8
-rw-r--r--source/blender/editors/space_logic/logic_window.c2658
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c3
-rw-r--r--source/blender/editors/space_nla/nla_edit.c7
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c116
-rw-r--r--source/blender/editors/space_node/node_draw.c24
-rw-r--r--source/blender/editors/space_node/node_edit.c9
-rw-r--r--source/blender/editors/space_node/node_header.c2
-rw-r--r--source/blender/editors/space_node/node_intern.h2
-rw-r--r--source/blender/editors/space_node/node_select.c4
-rw-r--r--source/blender/editors/space_node/node_templates.c2
-rw-r--r--source/blender/editors/space_node/node_view.c34
-rw-r--r--source/blender/editors/space_node/space_node.c1
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c9
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c147
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c20
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c46
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c66
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c15
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c52
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_header.c5
-rw-r--r--source/blender/editors/space_text/text_ops.c13
-rw-r--r--source/blender/editors/space_text/text_python.c4
-rw-r--r--source/blender/editors/space_time/time_ops.c2
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c26
-rw-r--r--source/blender/editors/space_view3d/drawobject.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c114
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c68
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c25
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c180
-rw-r--r--source/blender/editors/transform/transform.c112
-rw-r--r--source/blender/editors/transform/transform_conversions.c25
-rw-r--r--source/blender/editors/transform/transform_snap.c14
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c2
162 files changed, 3002 insertions, 4964 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index f220f0ee762..12c0e851f88 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -85,6 +85,7 @@
/* size of indent steps */
#define INDENT_STEP_SIZE 7
+/* size of string buffers used for animation channel displayed names */
#define ANIM_CHAN_NAME_SIZE 256
/* get the pointer used for some flag */
@@ -293,7 +294,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree)
}
}
- // unknown
+ /* unknown */
return 0;
}
@@ -423,7 +424,7 @@ static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
BLI_strncpy(name, "DopeSheet Summary", ANIM_CHAN_NAME_SIZE);
}
-// TODO: this is really a temp icon I think
+// FIXME: this is really a temp icon I think
static int acf_summary_icon(bAnimListElem *UNUSED(ale))
{
return ICON_BORDERMOVE;
@@ -602,7 +603,6 @@ static int acf_object_icon(bAnimListElem *ale)
Object *ob = base->object;
/* icon depends on object-type */
-
switch (ob->type) {
case OB_LAMP:
return ICON_OUTLINER_OB_LAMP;
@@ -629,7 +629,6 @@ static int acf_object_icon(bAnimListElem *ale)
default:
return ICON_OBJECT_DATA;
}
-
}
/* name for object */
@@ -2256,7 +2255,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
{
/* clear extra return data first */
*neg = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return SPK_DS_EXPAND;
@@ -2280,10 +2279,10 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *
static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type)
{
Speaker *spk = (Speaker *)ale->data;
-
+
/* clear extra return data first */
*type = 0;
-
+
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(spk->flag, type);
@@ -2555,7 +2554,7 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne
return GP_LAYER_HIDE;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
+ // *neg = 1; - if we change this to editability
return GP_LAYER_LOCKED;
default: /* unsupported */
@@ -2604,7 +2603,7 @@ static void acf_mask_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale),
// TODO: just get this from RNA?
static int acf_mask_icon(bAnimListElem *UNUSED(ale))
{
- return ICON_GREASEPENCIL; // MASK_TODO - need real icon
+ return ICON_MOD_MASK;
}
/* check if some setting exists for this channel */
@@ -2651,15 +2650,15 @@ static void *acf_mask_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short
/* mask datablock type define */
static bAnimChannelType ACF_MASKDATA =
{
- "Mask Datablock", /* type name */
+ "Mask Datablock", /* type name */
acf_mask_color, /* backdrop color */
- acf_group_backdrop, /* backdrop */
- acf_generic_indention_0, /* indent level */
- acf_generic_group_offset, /* offset */
+ acf_group_backdrop, /* backdrop */
+ acf_generic_indention_0, /* indent level */
+ acf_generic_group_offset, /* offset */
- acf_generic_idblock_name, /* name */
- acf_generic_idfill_nameprop, /* name prop */
+ acf_generic_idblock_name, /* name */
+ acf_generic_idfill_nameprop, /* name prop */
acf_mask_icon, /* icon */
acf_mask_setting_valid, /* has setting */
@@ -2720,7 +2719,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short
// return GP_LAYER_HIDE;
case ACHANNEL_SETTING_PROTECT: /* protected */
- // *neg = 1; - if we change this to edtiability
+ // *neg = 1; - if we change this to editability
return MASK_LAYERFLAG_LOCKED;
default: /* unsupported */
@@ -2732,7 +2731,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short
static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
-
+
/* all flags are just in agrp->flag for now... */
return GET_ACF_FLAG_PTR(masklay->flag, type);
}
@@ -2740,20 +2739,20 @@ static void *acf_masklay_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sh
/* grease pencil layer type define */
static bAnimChannelType ACF_MASKLAYER =
{
- "Mask Layer", /* type name */
-
+ "Mask Layer", /* type name */
+
acf_generic_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */
-
- acf_masklay_name, /* name */
- acf_masklay_name_prop, /* name prop */
+
+ acf_masklay_name, /* name */
+ acf_masklay_name_prop, /* name prop */
NULL, /* icon */
-
- acf_masklay_setting_valid, /* has setting */
- acf_masklay_setting_flag, /* flag for setting */
- acf_masklay_setting_ptr /* pointer for setting */
+
+ acf_masklay_setting_valid, /* has setting */
+ acf_masklay_setting_flag, /* flag for setting */
+ acf_masklay_setting_ptr /* pointer for setting */
};
@@ -2855,7 +2854,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
acf->name(ale, name);
else
BLI_strncpy(name, "<No name>", sizeof(name));
-
+
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
@@ -2999,7 +2998,6 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting,
#define RENAME_TEXT_WIDTH 100
/* Draw the given channel */
-// TODO: make this use UI controls for the buttons
void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
@@ -3089,20 +3087,20 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel */
if (acf->name) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
-
+
/* set text color */
/* XXX: if active, highlight differently? */
if (selected)
UI_ThemeColor(TH_TEXT_HI);
else
UI_ThemeColor(TH_TEXT);
-
+
/* get name */
acf->name(ale, name);
-
+
offset += 3;
UI_DrawString(offset, ytext, name);
-
+
/* draw red underline if channel is disabled */
if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) {
/* FIXME: replace hardcoded color here, and check on extents! */
@@ -3147,7 +3145,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
}
/* check if there's enough space for the toggles if the sliders are drawn too */
- if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+ if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
offset += ICON_WIDTH;
@@ -3232,7 +3230,6 @@ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *U
ads->renameIndex = 0;
/* send notifiers */
- // XXX: right notifier?
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL);
}
@@ -3278,7 +3275,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
{
Key *key = (Key *)key_poin;
KeyBlock *kb = (KeyBlock *)kb_poin;
- char *rna_path = key_get_curValue_rnaPath(key, kb);
+ char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
@@ -3516,7 +3513,6 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
offset = 0;
// TODO: when drawing sliders, make those draw instead of these toggles if not enough space
-
if (v2d) {
short draw_sliders = 0;
@@ -3539,7 +3535,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
}
/* check if there's enough space for the toggles if the sliders are drawn too */
- if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+ if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
offset += ICON_WIDTH;
@@ -3586,7 +3582,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
KeyBlock *kb = (KeyBlock *)ale->data;
Key *key = (Key *)ale->id;
- rna_path = key_get_curValue_rnaPath(key, kb);
+ rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
free_path = 1;
}
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 6ce9fc638be..98071fafc1e 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -142,7 +142,6 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* check if there are bones, and whether the name matches any
* NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone
*/
- // TODO: if bone gets renamed, it would be best to be able to rename the group
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
bArmature *arm = ob->data;
@@ -319,7 +318,6 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
- // TODO: check on whether we need to set the area specially instead, since active area might not be ok?
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 7a80cab93e5..eb7bc68ff8f 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -100,7 +100,7 @@
/* ----------- Private Stuff - Action Editor ------------- */
/* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */
-/* Note: there's a similar function in key.c (ob_get_key) */
+/* Note: there's a similar function in key.c (BKE_key_from_object) */
static Key *actedit_get_shapekeys(bAnimContext *ac)
{
Scene *scene = ac->scene;
@@ -115,7 +115,7 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
//if (saction->pin) return NULL;
/* shapekey data is stored with geometry data */
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key) {
if (key->type == KEY_RELATIVE)
@@ -164,30 +164,30 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction)
ac->mode = saction->mode;
return 1;
-
+
case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_GPENCIL;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return 1;
-
- case SACTCONT_MASK: /* Grease Pencil */ /* XXX review how this mode is handled... */
- /* update scene-pointer (no need to check for pinning yet, as not implemented) */
+
+ case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */
{
/* TODO, other methods to get the mask */
// Sequence *seq = BKE_sequencer_active_get(ac->scene);
//MovieClip *clip = ac->scene->clip;
// struct Mask *mask = seq ? seq->mask : NULL;
-
+
+ /* update scene-pointer (no need to check for pinning yet, as not implemented) */
saction->ads.source = (ID *)ac->scene;
-
+
ac->datatype = ANIMCONT_MASK;
ac->data = &saction->ads;
-
+
ac->mode = saction->mode;
return 1;
}
@@ -689,12 +689,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
{
Speaker *spk = (Speaker *)data;
AnimData *adt = spk->adt;
-
+
ale->flag = FILTER_SPK_OBJD(spk);
-
+
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
-
+
ale->adt = BKE_animdata_from_id(data);
}
break;
@@ -813,7 +813,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
/* the corresponding keyframes are from the animdata */
if (ale->adt && ale->adt->action) {
bAction *act = ale->adt->action;
- char *rna_path = key_get_curValue_rnaPath(key, kb);
+ char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
/* try to find the F-Curve which corresponds to this exactly,
* then free the MEM_alloc'd string
@@ -838,18 +838,18 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
ale->datatype = ALE_GPFRAME;
}
break;
-
+
case ANIMTYPE_MASKLAYER:
{
MaskLayer *masklay = (MaskLayer *)data;
-
+
ale->flag = masklay->flag;
-
+
ale->key_data = NULL;
ale->datatype = ALE_MASKLAY;
}
break;
-
+
case ANIMTYPE_NLATRACK:
{
NlaTrack *nlt = (NlaTrack *)data;
@@ -1152,7 +1152,6 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
- // TODO: need a way of tagging other channels that may also be affected...
if ((filter_mode & ANIMFILTER_FOREDIT) && (act->id.lib))
return 0;
@@ -1254,11 +1253,11 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
{
AnimData *adt = BKE_animdata_from_id(id);
size_t items = 0;
-
+
/* image object datablocks have no anim-data so check for NULL */
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
-
+
/* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed
* in a few places in he rest of the code still - notably for the few cases where special mode-based
* different types of data expanders are required.
@@ -1279,7 +1278,7 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
}
);
}
-
+
return items;
}
@@ -1297,7 +1296,6 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Ke
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
- // XXX maybe in future this may become handy?
if (kb == key->block.first) continue;
/* only work with this channel and its subchannels if it is editable */
@@ -1659,7 +1657,6 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data,
/* did we find anything? */
if (tmp_items) {
/* include material-expand widget first */
- // hmm... do we need to store the index of this material in the array anywhere?
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* check if filtering by active status */
if (ANIMCHANNEL_ACTIVEOK(ma)) {
@@ -1871,11 +1868,11 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
{
Lamp *la = ob->data;
bNodeTree *ntree = la->nodetree;
-
+
/* nodetree */
if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, &la->id, ntree, filter_mode);
-
+
/* textures */
if (!(ads->filterflag & ADS_FILTER_NOTEX))
tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, &la->id, filter_mode);
@@ -2005,7 +2002,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
/* filter data contained under object first */
BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
{
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* object-level animation */
if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) {
@@ -2344,7 +2341,7 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD
size_t items = 0;
/* data to filter depends on channel type */
- // XXX: only common channel-types have been handled for now
+ /* NOTE: only common channel-types have been handled for now. More can be added as necessary */
switch (channel->type) {
case ANIMTYPE_SUMMARY:
items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode);
@@ -2357,6 +2354,10 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD
case ANIMTYPE_OBJECT:
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode);
break;
+
+ default:
+ printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", channel->type);
+ break;
}
return items;
@@ -2481,9 +2482,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo
}
break;
- case ANIMCONT_FCURVES: /* Graph Editor -> FCurves/Animation Editing */
+ case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */
- case ANIMCONT_NLA: /* NLA Editor */
+ case ANIMCONT_NLA: /* NLA Editor */
{
/* all of these editors use the basic DopeSheet data for filtering options, but don't have all the same features */
items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 445b684c261..270e7fc8f90 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -354,7 +354,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
xpos = marker->frame;
/* no time correction for framelen! space is drawn with old values */
- ypixels = BLI_RCT_SIZE_Y(&v2d->mask);
+ ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
@@ -773,7 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
if (hasNumInput(&mm->num))
break;
- dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ dx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
if (evt->x != mm->evtx) { /* XXX maybe init for first time */
int a, offs, totmark = 0;
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index e254fb7a3c4..30e4d8570cb 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -74,13 +74,6 @@
#define B_REDR 1
#define B_FMODIFIER_REDRAW 20
-/* macro for use here to draw background box and set height */
-// XXX for now, roundbox has it's callback func set to NULL to not intercept events
-#define DRAW_BACKDROP(height) \
- { \
- uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco - height, width + 3, height - 1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \
- } (void)0
-
/* callback to verify modifier data */
static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg))
{
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 8cd8cfaea51..1791d84d90b 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1086,7 +1086,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
* The flag argument is used for special settings that alter the behavior of
* the keyframe deletion. These include the quick refresh options.
*/
-short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag))
+static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, short UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1836,7 +1836,7 @@ static short object_frame_has_keyframe(Object *ob, float frame, short filter)
/* try shapekey keyframes (if available, and allowed by filter) */
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) {
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* shapekeys can have keyframes ('Relative Shape Keys')
* or depend on time (old 'Absolute Shape Keys')
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 738fdc229fb..cb52d88f985 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -4589,7 +4589,9 @@ void ED_pose_deselectall(Object *ob, int test)
int selectmode = 0;
/* we call this from outliner too */
- if (ELEM(NULL, ob, ob->pose)) return;
+ if (ob->pose == NULL) {
+ return;
+ }
/* Determine if we're selecting or deselecting */
if (test == 1) {
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 78d3d8dc64d..f3f985fa97d 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -644,7 +644,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
short pval[2];
int pdist;
- project_short_noclip(ar, stk->points[i].p, pval);
+ ED_view3d_project_short_noclip(ar, stk->points[i].p, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -679,7 +679,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
{
copy_v3_v3(vec, bone->head);
mul_m4_v3(ob->obmat, vec);
- project_short_noclip(ar, vec, pval);
+ ED_view3d_project_short_noclip(ar, vec, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -695,7 +695,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
copy_v3_v3(vec, bone->tail);
mul_m4_v3(ob->obmat, vec);
- project_short_noclip(ar, vec, pval);
+ ED_view3d_project_short_noclip(ar, vec, pval);
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
@@ -907,7 +907,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p);
float pval[2];
- project_float(ar, stk->points[i].p, pval);
+ ED_view3d_project_float(ar, stk->points[i].p, pval);
ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
mul_v3_fl(ray_normal, distance * progress / length);
@@ -934,7 +934,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
initgrabz(ar->regiondata, fp[0], fp[1], fp[2]);
/* method taken from editview.c - mouse_cursor() */
- project_short_noclip(ar, fp, cval);
+ ED_view3d_project_short_noclip(ar, fp, cval);
VECSUB2D(mval_f, cval, dd->mval);
ED_view3d_win_to_delta(ar, mval_f, dvec);
sub_v3_v3v3(vec, fp, dvec);
@@ -1453,8 +1453,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
float s_p2[3] = {0, 0, 0};
int g_i;
- project_float(ar, gesture->points[s_i].p, s_p1);
- project_float(ar, gesture->points[s_i + 1].p, s_p2);
+ ED_view3d_project_float(ar, gesture->points[s_i].p, s_p1);
+ ED_view3d_project_float(ar, gesture->points[s_i + 1].p, s_p2);
/* start checking from second next, because two consecutive cannot intersect */
for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) {
@@ -1463,8 +1463,8 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
float vi[3];
float lambda;
- project_float(ar, gesture->points[g_i].p, g_p1);
- project_float(ar, gesture->points[g_i + 1].p, g_p2);
+ ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1);
+ ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2);
if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
@@ -1531,8 +1531,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
float s_p2[3] = {0, 0, 0};
int g_i;
- project_float(ar, stk->points[s_i].p, s_p1);
- project_float(ar, stk->points[s_i + 1].p, s_p2);
+ ED_view3d_project_float(ar, stk->points[s_i].p, s_p1);
+ ED_view3d_project_float(ar, stk->points[s_i + 1].p, s_p2);
for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) {
float g_p1[3] = {0, 0, 0};
@@ -1540,8 +1540,8 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
float vi[3];
float lambda;
- project_float(ar, gesture->points[g_i].p, g_p1);
- project_float(ar, gesture->points[g_i + 1].p, g_p2);
+ ED_view3d_project_float(ar, gesture->points[g_i].p, g_p1);
+ ED_view3d_project_float(ar, gesture->points[g_i + 1].p, g_p2);
if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
@@ -1784,8 +1784,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc
short start_val[2], end_val[2];
short dist;
- project_short_noclip(ar, gest->stk->points[0].p, start_val);
- project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val);
+ ED_view3d_project_short_noclip(ar, gest->stk->points[0].p, start_val);
+ ED_view3d_project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val);
dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 6b6d2a1505f..346ed0002bd 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -667,7 +667,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
*err_str = NULL;
/* count triangles and create mask */
- if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
+ if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) ||
(use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
{
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index e9424a08b0c..2f5eaabc12b 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -74,12 +74,30 @@
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_object.h"
+#include "ED_util.h" /* clipboard */
#include "UI_interface.h"
#include "UI_resources.h"
#include "armature_intern.h"
+/* matches logic with ED_operator_posemode_context() */
+Object *ED_pose_object_from_context(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa && sa->spacetype == SPACE_BUTS) {
+ ob = ED_object_context(C);
+ }
+ else {
+ ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ }
+
+ return ob;
+}
+
/* This function is used to process the necessary updates for */
void ED_armature_enter_posemode(bContext *C, Base *base)
{
@@ -727,7 +745,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
short changed = 0;
/* sanity check */
- if (ELEM(NULL, ob, ob->pose))
+ if (ob->pose == NULL)
return OPERATOR_CANCELLED;
/* selection types
@@ -1049,7 +1067,7 @@ static void pose_copy_menu(Scene *scene)
/* Global copy/paste buffer for pose - cleared on start/end session + before every copy operation */
static bPose *g_posebuf = NULL;
-void free_posebuf(void)
+void ED_clipboard_posebuf_free(void)
{
if (g_posebuf) {
bPoseChannel *pchan;
@@ -1225,7 +1243,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op)
}
/* free existing pose buffer */
- free_posebuf();
+ ED_clipboard_posebuf_free();
/* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */
set_pose_keys(ob);
@@ -1330,15 +1348,8 @@ void POSE_OT_paste(wmOperatorType *ot)
static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+ Object *ob = ED_pose_object_from_context(C);
+
/* only continue if there's an object */
if (ob == NULL)
return OPERATOR_CANCELLED;
@@ -1361,7 +1372,7 @@ void POSE_OT_group_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_add_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1370,14 +1381,7 @@ void POSE_OT_group_add(wmOperatorType *ot)
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object */
if (ob == NULL)
@@ -1401,7 +1405,7 @@ void POSE_OT_group_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_remove_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1412,8 +1416,7 @@ void POSE_OT_group_remove(wmOperatorType *ot)
/* invoke callback which presents a list of bone-groups for the user to choose from */
static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
uiPopupMenu *pup;
@@ -1421,12 +1424,6 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
bActionGroup *grp;
int i;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1465,17 +1462,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
/* Assign selected pchans to the bone group that the user selects */
static int pose_group_assign_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
short done = FALSE;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1517,7 +1507,7 @@ void POSE_OT_group_assign(wmOperatorType *ot)
/* api callbacks */
ot->invoke = pose_groups_menu_invoke;
ot->exec = pose_group_assign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1529,16 +1519,9 @@ void POSE_OT_group_assign(wmOperatorType *ot)
static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
short done = FALSE;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1572,7 +1555,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_unassign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1580,7 +1563,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
static int group_move_exec(bContext *C, wmOperator *op)
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
bActionGroup *grp;
@@ -1653,7 +1636,7 @@ void POSE_OT_group_move(wmOperatorType *ot)
/* api callbacks */
ot->exec = group_move_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1678,7 +1661,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr)
static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
tSortActionGroup *agrp_array;
@@ -1737,7 +1720,7 @@ void POSE_OT_group_sort(wmOperatorType *ot)
/* api callbacks */
ot->exec = group_sort_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1765,14 +1748,7 @@ static void pose_group_select(bContext *C, Object *ob, int select)
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@@ -1795,7 +1771,7 @@ void POSE_OT_group_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_select_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1803,14 +1779,7 @@ void POSE_OT_group_select(wmOperatorType *ot)
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@@ -1833,7 +1802,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot)
/* api callbacks */
ot->exec = pose_group_deselect_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index d780429784f..9c13f4be6a9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1233,12 +1233,12 @@ void make_editNurb(Object *obedit)
set_actNurb(obedit, NULL);
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
- actkey = ob_get_keyblock(obedit);
+ actkey = BKE_keyblock_from_object(obedit);
if (actkey) {
// XXX strcpy(G.editModeTitleExtra, "(Key) ");
undo_editmode_clear();
- key_to_curve(actkey, cu, &cu->nurb);
+ BKE_key_convert_to_curve(actkey, cu, &cu->nurb);
}
if (editnurb) {
@@ -6070,7 +6070,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
}
/************** join operator, to be used externally? ****************/
-
+/* TODO: shape keys - as with meshes */
int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
@@ -6191,10 +6191,9 @@ static const char *get_surf_defname(int type)
}
-Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
+Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type, int newob)
{
static int xzproj = 0; /* this function calls itself... */
- Object *obedit = CTX_data_edit_object(C);
ListBase *editnurb = object_editcurve_get(obedit);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
@@ -6431,7 +6430,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
break;
case CU_PRIM_TUBE: /* Cylinder */
if (cutype == CU_NURBS) {
- nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
+ nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
nu->resolu = cu->resolu;
nu->flag = CU_SMOOTH;
BLI_addtail(editnurb, nu); /* temporal for extrude and translate */
@@ -6510,7 +6509,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
float tmp_vec[3] = {0.f, 0.f, 1.f};
xzproj = 1;
- nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
+ nu = add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */
xzproj = 0;
nu->resolu = cu->resolu;
nu->resolv = cu->resolv;
@@ -6607,7 +6606,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
- nu = add_nurbs_primitive(C, mat, type, newob);
+ nu = add_nurbs_primitive(C, obedit, mat, type, newob);
editnurb = object_editcurve_get(obedit);
BLI_addtail(editnurb, nu);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 5d67b63af18..659e99607f0 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -422,8 +422,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
}
else {
if (subrect) {
- mvalf[0] = (((float)pt->x / 100.0f) * BLI_RCT_SIZE_X(subrect)) + subrect->xmin;
- mvalf[1] = (((float)pt->y / 100.0f) * BLI_RCT_SIZE_Y(subrect)) + subrect->ymin;
+ mvalf[0] = (((float)pt->x / 100.0f) * BLI_rctf_size_x(subrect)) + subrect->xmin;
+ mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin;
}
else {
mvalf[0] = (float)pt->x / 100.0f * ar->winx;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 4e281b96fc3..8ba4985ffc4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -278,7 +278,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
gp_get_3d_reference(p, rvec);
/* method taken from editview.c - mouse_cursor() */
- project_int_noclip(p->ar, rvec, mval_prj);
+ ED_view3d_project_int_noclip(p->ar, rvec, mval_prj);
VECSUB2D(mval_f, mval_prj, mval);
ED_view3d_win_to_delta(p->ar, mval_f, dvec);
@@ -299,8 +299,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
}
else { /* camera view, use subrect */
- out[0] = ((mval[0] - p->subrect->xmin) / BLI_RCT_SIZE_X(p->subrect)) * 100;
- out[1] = ((mval[1] - p->subrect->ymin) / BLI_RCT_SIZE_Y(p->subrect)) * 100;
+ out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100;
+ out[1] = ((mval[1] - p->subrect->ymin) / BLI_rctf_size_y(p->subrect)) * 100;
}
}
}
@@ -808,7 +808,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
else if (gps->totpoints == 1) {
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- project_int(p->ar, &gps->points->x, xyval);
+ ED_view3d_project_int(p->ar, &gps->points->x, xyval);
x0 = xyval[0];
y0 = xyval[1];
}
@@ -821,8 +821,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
y0 = (int)(gps->points->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
- x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
+ x0 = (int)((gps->points->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
+ y0 = (int)((gps->points->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
}
}
@@ -847,11 +847,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* get coordinates */
if (gps->flag & GP_STROKE_3DSPACE) {
- project_int(p->ar, &pt1->x, xyval);
+ ED_view3d_project_int(p->ar, &pt1->x, xyval);
x0 = xyval[0];
y0 = xyval[1];
- project_int(p->ar, &pt2->x, xyval);
+ ED_view3d_project_int(p->ar, &pt2->x, xyval);
x1 = xyval[0];
y1 = xyval[1];
}
@@ -868,10 +868,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
y1 = (int)(pt2->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
- x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
- x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
- y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
+ x0 = (int)((pt1->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
+ y0 = (int)((pt1->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
+ x1 = (int)((pt2->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin;
+ y1 = (int)((pt2->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin;
}
}
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 07f3498580c..4e33404be7e 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -148,6 +148,7 @@ void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
void ED_pose_deselectall(struct Object *ob, int test);
void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
+struct Object *ED_pose_object_from_context(struct bContext *C);
/* sketch */
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 13c3b180230..28727c913cb 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -83,7 +83,7 @@ void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mas
/* textures buffer */
int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc);
-int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf);
+int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf, const unsigned char *display_buffer);
void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc);
void ED_space_clip_free_texture_buffer(struct SpaceClip *sc);
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index ac8d82e9060..d66cc49a5d0 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -67,7 +67,7 @@ void BKE_curve_editNurb_free(struct Curve *cu);
int mouse_nurb(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
-struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob);
+struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob);
int isNurbsel(struct Nurb *nu);
void ED_nurb_set_spline_type(struct Nurb *nu, int type);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 87f12b8ac9c..a50b33966c6 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -39,6 +39,7 @@ struct ToolSettings;
struct uiBlock;
struct wmWindowManager;
struct ARegion;
+struct Scene;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
@@ -77,7 +78,7 @@ int ED_space_image_maskedit_mask_poll(struct bContext *C);
/* UI level image (texture) updating... render calls own stuff (too) */
void ED_image_update_frame(const struct Main *mainp, int cfra);
-void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
const unsigned char cp[4], const float fp[4], int *zp, float *zpf);
#endif /* __ED_IMAGE_H__ */
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 8ebf932fd96..dc40b687dfd 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -53,14 +53,14 @@ void ED_keymap_mask(struct wmKeyConfig *keyconf);
void ED_operatormacros_mask(void);
/* mask_draw.c */
-void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type);
+void ED_mask_draw(const struct bContext *C, const char draw_flag, const char draw_type);
void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar,
const char draw_flag, const char draw_type,
const int width_i, const int height_i,
const float aspx, const float aspy,
const short do_scale_applied, const short do_post_draw,
float stabmat[4][4],
- const bContext *C);
+ const struct bContext *C);
void ED_mask_draw_frames(struct Mask *mask, struct ARegion *ar, const int cfra, const int sfra, const int efra);
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index b4b739e4d06..5ce6db97305 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -38,7 +38,7 @@ struct wmKeyConfig;
void ED_operatortypes_metaball(void);
void ED_keymap_metaball(struct wmKeyConfig *keyconf);
-struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname);
+struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newname);
int mouse_mball(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 1d4fbe81e02..3d15f349f9b 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -148,7 +148,7 @@ struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, int *dist);
int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle);
void EDBM_selectmode_set(struct BMEditMesh *em);
-void EDBM_selectmode_convert(struct BMEditMesh *em, short oldmode, const short selectmode);
+void EDBM_selectmode_convert(struct BMEditMesh *em, short selectmode_old, const short selectmode_new);
void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index fc20bdfb9c5..860d176ffb3 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -111,6 +111,7 @@ ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa);
void ED_screen_full_restore(struct bContext *C, ScrArea *sa);
struct ScrArea *ED_screen_full_toggle(struct bContext *C, struct wmWindow *win, struct ScrArea *sa);
+void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg);
/* anim */
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, int mute);
@@ -170,6 +171,7 @@ int ED_operator_editmball(struct bContext *C);
int ED_operator_uvedit(struct bContext *C);
int ED_operator_uvmap(struct bContext *C);
int ED_operator_posemode_exclusive(struct bContext *C);
+int ED_operator_posemode_context(struct bContext *C);
int ED_operator_posemode(struct bContext *C);
int ED_operator_mask(struct bContext *C);
diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h
index 7807f06594e..84fd5332316 100644
--- a/source/blender/editors/include/ED_sequencer.h
+++ b/source/blender/editors/include/ED_sequencer.h
@@ -36,7 +36,7 @@ void ED_sequencer_deselect_all(struct Scene *scene);
int ED_space_sequencer_maskedit_mask_poll(struct bContext *C);
int ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene *scene);
-int ED_space_sequencer_maskedit_poll(bContext *C);
+int ED_space_sequencer_maskedit_poll(struct bContext *C);
void ED_operatormacros_sequencer(void);
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index e10f049d0bc..d0ca079b8c9 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -84,6 +84,8 @@ void crazyspace_set_quats_mesh(struct Mesh *me, float *origcos, float *mappedcos
int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
+/* cut-paste buffer free */
+void ED_clipboard_posebuf_free(void);
/* ************** XXX OLD CRUFT WARNING ************* */
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 7f40024a056..9536dd76581 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -89,139 +89,45 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d);
int initgrabz(struct RegionView3D *rv3d, float x, float y, float z);
-/**
- * Calculate a 3d location from 2d window coordinates.
- * \param ar The region (used for the window width and height).
- * \param depth_pt The reference location used to calculate the Z depth.
- * \param mval The area relative location (such as event->mval converted to floats).
- * \param out The resulting world-space location.
- */
void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
-
-/**
- * Calculate a 3d difference vector from 2d window offset.
- * note that initgrabz() must be called first to determine
- * the depth used to calculate the delta.
- * \param ar The region (used for the window width and height).
- * \param mval The area relative 2d difference (such as event->mval[0] - other_x).
- * \param out The resulting world-space delta.
- */
void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]);
-
-/**
- * Calculate a 3d direction vector from 2d window coordinates.
- * This direction vector starts and the view in the direction of the 2d window coordinates.
- * In orthographic view all window coordinates yield the same vector.
- * \param ar The region (used for the window width and height).
- * \param mval The area relative 2d location (such as event->mval converted to floats).
- * \param out The resulting normalized world-space direction vector.
- */
void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]);
-
-/**
- * Calculate a 3d segment from 2d window coordinates.
- * This ray_start is located at the viewpoint, ray_end is a far point.
- * ray_start and ray_end are clipped by the view near and far limits
- * so points along this line are always in view.
- * In orthographic view all resulting segments will be parallel.
- * \param ar The region (used for the window width and height).
- * \param v3d The 3d viewport (used for near and far clipping range).
- * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
- * \param ray_start The world-space starting point of the segment.
- * \param ray_end The world-space end point of the segment.
- */
void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]);
-
-/**
- * Calculate a 3d viewpoint and direction vector from 2d window coordinates.
- * This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
- * ray_start is clipped by the view near limit so points in front of it are always in view.
- * In orthographic view the resulting ray_normal will match the view vector.
- * \param ar The region (used for the window width and height).
- * \param v3d The 3d viewport (used for near clipping value).
- * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
- * \param ray_start The world-space starting point of the segment.
- * \param ray_normal The normalized world-space direction of towards mval.
- */
void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
-/**
- * Calculate a normalized 3d direction vector from the viewpoint towards a global location.
- * In orthographic view the resulting vector will match the view vector.
- * \param rv3d The region (used for the window width and height).
- * \param coord The world-space location.
- * \param vec The resulting normalized vector.
- */
void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]);
-
-/**
- * Calculate the view transformation matrix from RegionView3D input.
- * The resulting matrix is equivalent to RegionView3D.viewinv
- * \param mat The view 4x4 transformation matrix to calculate.
- * \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_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist);
-
-/**
- * Set the view transformation from a 4x4 matrix.
- * \param mat The view 4x4 transformation matrix to assign.
- * \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_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist);
-/**
- * Set the RegionView3D members from an objects transformation and optionally lens.
- * \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(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens);
-
-/**
- * Set the object transformation from RegionView3D members.
- * \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(struct Object *ob, const float ofs[3], const float quat[4], const float dist);
-//#if 0 /* UNUSED */
-void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z);
-//#endif
-
/* Depth buffer */
-void ED_view3d_depth_update(struct ARegion *ar);
+void ED_view3d_depth_update(struct ARegion *ar);
float ED_view3d_depth_read_cached(struct ViewContext *vc, int x, int y);
-void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
+void ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
/* Projection */
#define IS_CLIPPED 12000
-void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect);
-
-void project_short(struct ARegion *ar, const float vec[3], short adr[2]);
-void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]);
-
-void project_int(struct ARegion *ar, const float vec[3], int adr[2]);
-void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]);
-
-void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[], float adr[2]);
-void project_float(struct ARegion *ar, const float vec[3], float adr[2]);
-void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]);
-
-int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
-int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend);
+/* TODO, these functions work quite differently, we should make them behave in a uniform way
+ * otherwise we can't be sure bugs are not added when we need to move from short->float types for eg
+ * - Campbell */
+void ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]);
+void ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]);
+void ED_view3d_project_int(struct ARegion *ar, const float co[3], int r_co[2]);
+void ED_view3d_project_int_noclip(struct ARegion *ar, const float co[3], int r_co[2]);
+void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]);
+void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float r_co[2]);
+void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]);
+void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]);
+
+void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z);
+
+int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend);
+int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend);
void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift);
-void ED_view3d_project_float_v2(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]);
-void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float adr[3], float mat[4][4]);
void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]);
/* drawobject.c iterators */
@@ -231,6 +137,7 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData,
void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData);
void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData);
+void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect);
void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float vec[3], const int is_local);
void ED_view3d_clipping_set(struct RegionView3D *rv3d);
@@ -282,10 +189,12 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active);
int ED_view3d_context_activate(struct bContext *C);
void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
- int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic);
+ int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background);
-struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256]);
-struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, int draw_background, char err_out[256]);
+struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag,
+ int draw_background, int colormanage_background, char err_out[256]);
+struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype,
+ int draw_background, int colormanage_background, char err_out[256]);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index c6f58fdd70b..32132f497a8 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -120,11 +120,12 @@ typedef struct uiLayout uiLayout;
#define UI_BLOCK_CLIP_EVENTS 8192 /* stop handling mouse events */
/* uiPopupBlockHandle->menuretval */
-#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
-#define UI_RETURN_OK 2 /* choice made */
-#define UI_RETURN_OUT 4 /* left the menu */
-#define UI_RETURN_UPDATE 8 /* update the button that opened */
-#define UI_RETURN_POPUP_OK 16 /* popup is ok to be handled */
+#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
+#define UI_RETURN_OK 2 /* choice made */
+#define UI_RETURN_OUT 4 /* left the menu */
+#define UI_RETURN_OUT_PARENT 8 /* let the parent handle this event */
+#define UI_RETURN_UPDATE 16 /* update the button that opened */
+#define UI_RETURN_POPUP_OK 32 /* popup is ok to be handled */
/* block->flag bits 12-15 are identical to but->flag bits */
@@ -810,8 +811,10 @@ void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char
void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
PointerRNA *used_ptr, const char *used_propname, int active_layer);
+void uiTemplateGameStates(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
+ PointerRNA *used_ptr, const char *used_propname, int active_state);
void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
-void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr);
+void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void uiTemplateOperatorSearch(uiLayout *layout);
@@ -831,6 +834,9 @@ void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct Poi
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int cmpact);
+void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
+void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
+
/* items */
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 792c96fe7c8..24759fa778a 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -163,7 +163,8 @@ void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, short x
void UI_view2d_view_restore(const struct bContext *C);
/* grid drawing */
-View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
+View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_constant_grid_draw(struct View2D *v2d);
void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels);
@@ -171,14 +172,21 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy);
void UI_view2d_grid_free(View2DGrid *grid);
/* scrollbar drawing */
-View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
+View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp);
void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
/* list view tools */
-void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, struct rctf *rect);
-void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row);
-void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int *column_min, int *column_max, int *row_min, int *row_max);
+void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, int column, int row,
+ struct rctf *rect);
+void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, float viewx, float viewy,
+ int *column, int *row);
+void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty, int *column_min, int *column_max,
+ int *row_min, int *row_max);
/* coordinate conversion */
void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 823f8d7be39..810cbc25862 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -75,11 +75,9 @@
#include "BPY_extern.h"
-#include "interface_intern.h"
+#include "IMB_colormanagement.h"
-#define MENU_WIDTH 120
-#define MENU_ITEM_HEIGHT 20
-#define MENU_SEP_HEIGHT 6
+#include "interface_intern.h"
#define PRECISION_FLOAT_MAX 6
#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */
@@ -104,8 +102,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float gx, gy;
int sx, sy, getsizex, getsizey;
- getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ getsizex = BLI_rcti_size_x(&ar->winrct) + 1;
+ getsizey = BLI_rcti_size_y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -150,8 +148,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float a, b, c, d, e, f, px, py;
int sx, sy, getsizex, getsizey;
- getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ getsizex = BLI_rcti_size_x(&ar->winrct) + 1;
+ getsizey = BLI_rcti_size_y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -277,7 +275,7 @@ void ui_bounds_block(uiBlock *block)
block->rect.ymax += block->bounds;
}
- block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds);
+ block->rect.xmax = block->rect.xmin + maxf(BLI_rctf_size_x(&block->rect), block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
@@ -305,8 +303,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
ui_bounds_block(block);
- width = BLI_RCT_SIZE_X(&block->rect);
- height = BLI_RCT_SIZE_Y(&block->rect);
+ 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);
@@ -330,8 +328,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
wm_window_get_size(window, &xmax, &ymax);
- oldwidth = BLI_RCT_SIZE_X(&block->rect);
- oldheight = BLI_RCT_SIZE_Y(&block->rect);
+ oldwidth = BLI_rctf_size_x(&block->rect);
+ oldheight = BLI_rctf_size_y(&block->rect);
/* first we ensure wide enough text bounds */
if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
@@ -346,8 +344,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBound
ui_bounds_block(block);
/* and we adjust the position to fit within window */
- width = BLI_RCT_SIZE_X(&block->rect);
- height = BLI_RCT_SIZE_Y(&block->rect);
+ width = BLI_rctf_size_x(&block->rect);
+ height = BLI_rctf_size_y(&block->rect);
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
@@ -493,10 +491,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
if (line->from == NULL || line->to == NULL) return;
- rect.xmin = BLI_RCT_CENTER_X(&line->from->rect);
- rect.ymin = BLI_RCT_CENTER_Y(&line->from->rect);
- rect.xmax = BLI_RCT_CENTER_X(&line->to->rect);
- rect.ymax = BLI_RCT_CENTER_Y(&line->to->rect);
+ rect.xmin = BLI_rctf_cent_x(&line->from->rect);
+ rect.ymin = BLI_rctf_cent_y(&line->from->rect);
+ rect.xmax = BLI_rctf_cent_x(&line->to->rect);
+ rect.ymax = BLI_rctf_cent_y(&line->to->rect);
if (line->flag & UI_SELECT)
glColor3ub(100, 100, 100);
@@ -2138,7 +2136,14 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
block->evil_C = (void *)C; /* XXX */
if (scn) {
- block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ block->color_profile = TRUE;
+
+ /* store display device name, don't lookup for transformations yet
+ * block could be used for non-color displays where looking up for transformation
+ * would slow down redraw, so only lookup for actual transform when it's indeed
+ * needed
+ */
+ block->display_device = scn->display_settings.display_device;
/* copy to avoid crash when scene gets deleted with ui still open */
block->unit = MEM_mallocN(sizeof(scn->unit), "UI UnitSettings");
@@ -2248,7 +2253,7 @@ void ui_check_but(uiBut *but)
/* safety is 4 to enable small number buttons (like 'users') */
- // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED
+ // okwidth= -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED
/* name: */
switch (but->type) {
@@ -2256,7 +2261,7 @@ void ui_check_but(uiBut *but)
case MENU:
case ICONTEXTROW:
- if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) {
+ if (BLI_rctf_size_x(&but->rect) > 24.0f) {
UI_GET_BUT_VALUE_INIT(but, value);
ui_set_name_menu(but, (int)value);
}
@@ -2563,7 +2568,9 @@ void ui_block_do_align(uiBlock *block)
ui_block_do_align_but(but, nr);
/* skip with same number */
- for (; but && but->alignnr == nr; but = but->next) ;
+ for (; but && but->alignnr == nr; but = but->next) {
+ /* pass */
+ }
if (!but) {
break;
@@ -2575,6 +2582,25 @@ void ui_block_do_align(uiBlock *block)
}
}
+struct ColorManagedDisplay *ui_block_display_get(uiBlock *block)
+{
+ return IMB_colormanagement_display_get_named(block->display_device);
+}
+
+void ui_block_to_display_space_v3(uiBlock *block, float pixel[3])
+{
+ struct ColorManagedDisplay *display = ui_block_display_get(block);
+
+ IMB_colormanagement_scene_linear_to_display_v3(pixel, display);
+}
+
+void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3])
+{
+ struct ColorManagedDisplay *display = ui_block_display_get(block);
+
+ IMB_colormanagement_display_to_scene_linear_v3(pixel, display);
+}
+
/**
* \brief ui_def_but is the function that draws many button types
*
@@ -2593,6 +2619,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
uiBut *but;
int slen;
+ BLI_assert(width >= 0);
+ BLI_assert(height >= 0);
+
/* we could do some more error checks here */
if ((type & BUTTYPE) == LABEL) {
BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE);
@@ -3760,15 +3789,16 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...)
if (type == BUT_GET_LABEL) {
if (but->str) {
/* Menu labels can have some complex formating stuff marked by pipes or %t, we don't want those here! */
- const char *tc;
-
- if (but->type == MENU)
- tc = strstr(but->str, "%t");
- else
- tc = strchr(but->str, '|');
-
- if (tc)
- tmp = BLI_strdupn(but->str, tc - but->str);
+ const char *tc1, *tc2;
+
+ tc1 = strstr(but->str, "%t");
+ tc2 = strstr(but->str, "|"); /* XXX For some reason strchr seems to not work here? */
+
+ if (tc2 && (!tc1 || tc1 > tc2))
+ tc1 = tc2;
+
+ if (tc1)
+ tmp = BLI_strdupn(but->str, tc1 - but->str);
else
tmp = BLI_strdup(but->str);
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 77dbbc878a7..e7c7d934f9f 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -48,6 +48,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -59,8 +60,6 @@
/* own include */
#include "interface_intern.h"
-#define UI_DISABLED_ALPHA_OFFS -160
-
static int roundboxtype = UI_CNR_ALL;
void uiSetRoundBox(int type)
@@ -85,7 +84,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
glBegin(mode);
@@ -156,18 +155,18 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- coltop[0] = color[0] + shadetop; if (coltop[0] > 1.0f) coltop[0] = 1.0f;
- coltop[1] = color[1] + shadetop; if (coltop[1] > 1.0f) coltop[1] = 1.0f;
- coltop[2] = color[2] + shadetop; if (coltop[2] > 1.0f) coltop[2] = 1.0f;
- coldown[0] = color[0] + shadedown; if (coldown[0] < 0.0f) coldown[0] = 0.0f;
- coldown[1] = color[1] + shadedown; if (coldown[1] < 0.0f) coldown[1] = 0.0f;
- coldown[2] = color[2] + shadedown; if (coldown[2] < 0.0f) coldown[2] = 0.0f;
+ coltop[0] = minf(1.0f, color[0] + shadetop);
+ coltop[1] = minf(1.0f, color[1] + shadetop);
+ coltop[2] = minf(1.0f, color[2] + shadetop);
+ coldown[0] = maxf(0.0f, color[0] + shadedown);
+ coldown[1] = maxf(0.0f, color[1] + shadedown);
+ coldown[2] = maxf(0.0f, color[2] + shadedown);
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -265,18 +264,18 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* mult */
for (a = 0; a < 7; a++) {
- vec[a][0] *= rad; vec[a][1] *= rad;
+ mul_v2_fl(vec[a], rad);
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- colLeft[0] = color[0] + shadeLeft; if (colLeft[0] > 1.0f) colLeft[0] = 1.0f;
- colLeft[1] = color[1] + shadeLeft; if (colLeft[1] > 1.0f) colLeft[1] = 1.0f;
- colLeft[2] = color[2] + shadeLeft; if (colLeft[2] > 1.0f) colLeft[2] = 1.0f;
- colRight[0] = color[0] + shadeRight; if (colRight[0] < 0.0f) colRight[0] = 0.0f;
- colRight[1] = color[1] + shadeRight; if (colRight[1] < 0.0f) colRight[1] = 0.0f;
- colRight[2] = color[2] + shadeRight; if (colRight[2] < 0.0f) colRight[2] = 0.0f;
+ colLeft[0] = minf(1.0f, color[0] + shadeLeft);
+ colLeft[1] = minf(1.0f, color[1] + shadeLeft);
+ colLeft[2] = minf(1.0f, color[2] + shadeLeft);
+ colRight[0] = maxf(0.0f, color[0] + shadeRight);
+ colRight[1] = maxf(0.0f, color[1] + shadeRight);
+ colRight[2] = maxf(0.0f, color[2] + shadeRight);
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -439,8 +438,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
//glColor4f(1.0, 0.f, 0.f, 1.f);
//fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
/* prevent drawing outside widget area */
glGetIntegerv(GL_SCISSOR_BOX, scissor);
glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
@@ -493,8 +492,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
charmax = G.charmax = 0xffff;
/* Calculate the size of the button */
- width = abs(BLI_RCT_SIZE_X(rect));
- height = abs(BLI_RCT_SIZE_Y(rect));
+ width = abs(BLI_rcti_size_x(rect));
+ height = abs(BLI_rcti_size_y(rect));
butw = floor(width / 12);
buth = floor(height / 6);
@@ -600,7 +599,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
}
/* Calculate the next position and character */
- sx += butw; ex += butw;
+ sx += butw;
+ ex += butw;
cs++;
}
/* Add the y position and reset x position */
@@ -632,7 +632,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
#endif /* WITH_INTERNATIONAL */
#endif
-static void draw_scope_end(rctf *rect, GLint *scissor)
+static void draw_scope_end(const rctf *rect, GLint *scissor)
{
float scaler_x1, scaler_x2;
@@ -642,8 +642,8 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* scale widget */
- scaler_x1 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 + SCOPE_RESIZE_PAD;
+ scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD;
+ scaler_x2 = rect->xmin + BLI_rctf_size_y(rect) / 2 + SCOPE_RESIZE_PAD;
glColor4f(0.f, 0.f, 0.f, 0.25f);
fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
@@ -732,8 +732,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- w = BLI_RCT_SIZE_X(&rect);
- h = BLI_RCT_SIZE_Y(&rect) * hist->ymax;
+ w = BLI_rctf_size_x(&rect);
+ h = BLI_rctf_size_y(&rect) * hist->ymax;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -805,9 +805,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
if (scopes->wavefrm_yfac < 0.5f)
scopes->wavefrm_yfac = 0.98f;
- w = BLI_RCT_SIZE_X(&rect) - 7;
- h = BLI_RCT_SIZE_Y(&rect) * scopes->wavefrm_yfac;
- yofs = rect.ymin + (BLI_RCT_SIZE_Y(&rect) - h) / 2.0f;
+ w = BLI_rctf_size_x(&rect) - 7;
+ h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
+ yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
w3 = w / 3.0f;
/* log scale for alpha */
@@ -1033,8 +1033,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- w = BLI_RCT_SIZE_X(&rect);
- h = BLI_RCT_SIZE_Y(&rect);
+ w = BLI_rctf_size_x(&rect);
+ h = BLI_rctf_size_y(&rect);
centerx = rect.xmin + w / 2;
centery = rect.ymin + h / 2;
diam = (w < h) ? w : h;
@@ -1110,10 +1110,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
float v3[2], v1[2], v2[2], v1a[2], v2a[2];
int a;
float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
-
+ struct ColorManagedDisplay *display = NULL;
+
coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
if (coba == NULL) return;
-
+
+ if (but->block->color_profile)
+ display = ui_block_display_get(but->block);
+
x1 = rect->xmin;
y1 = rect->ymin;
sizex = rect->xmax - x1;
@@ -1141,18 +1145,20 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
glBegin(GL_QUAD_STRIP);
glColor4fv(&cbd->r);
- glVertex2fv(v1); glVertex2fv(v2);
-
+ glVertex2fv(v1);
+ glVertex2fv(v2);
+
for (a = 1; a <= sizex; a++) {
pos = ((float)a) / (sizex - 1);
do_colorband(coba, pos, colf);
- if (but->block->color_profile != BLI_PR_NONE)
- linearrgb_to_srgb_v3_v3(colf, colf);
+ if (display)
+ IMB_colormanagement_scene_linear_to_display_v3(colf, display);
v1[0] = v2[0] = x1 + a;
glColor4fv(colf);
- glVertex2fv(v1); glVertex2fv(v2);
+ glVertex2fv(v1);
+ glVertex2fv(v2);
}
glEnd();
@@ -1239,7 +1245,8 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* sphere color */
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn);
- glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
/* disable blender light */
for (a = 0; a < 8; a++) {
@@ -1262,12 +1269,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* transform to button */
glPushMatrix();
- glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f);
+ glTranslatef(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
- if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect))
- size = BLI_RCT_SIZE_X(rect) / 200.f;
+ if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
+ size = BLI_rcti_size_x(rect) / 200.f;
else
- size = BLI_RCT_SIZE_Y(rect) / 200.f;
+ size = BLI_rcti_size_y(rect) / 200.f;
glScalef(size, size, size);
@@ -1373,12 +1380,12 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
glScissor(scissor_new.xmin,
scissor_new.ymin,
- BLI_RCT_SIZE_X(&scissor_new),
- BLI_RCT_SIZE_Y(&scissor_new));
+ BLI_rcti_size_x(&scissor_new),
+ BLI_rcti_size_y(&scissor_new));
/* calculate offset and zoom */
- zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ zoomx = (BLI_rcti_size_x(rect) - 2.0f * but->aspect) / BLI_rctf_size_x(&cumap->curr);
+ zoomy = (BLI_rcti_size_y(rect) - 2.0f * but->aspect) / BLI_rctf_size_y(&cumap->curr);
offsx = cumap->curr.xmin - but->aspect / zoomx;
offsy = cumap->curr.ymin - but->aspect / zoomy;
@@ -1556,8 +1563,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- width = BLI_RCT_SIZE_X(&rect) + 1;
- height = BLI_RCT_SIZE_Y(&rect);
+ width = BLI_rctf_size_x(&rect) + 1;
+ height = BLI_rctf_size_y(&rect);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1632,8 +1639,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
glScissor(ar->winrct.xmin + rect.xmin,
ar->winrct.ymin + rect.ymin,
- BLI_RCT_SIZE_X(&rect),
- BLI_RCT_SIZE_Y(&rect));
+ BLI_rctf_size_x(&rect),
+ BLI_rctf_size_y(&rect));
for (a = 0; a < 2; a++) {
if (a == 1) {
@@ -1724,7 +1731,7 @@ void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, fl
}
-void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
+void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
{
int i;
float rad;
@@ -1733,8 +1740,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE
glEnable(GL_BLEND);
- if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f)
- rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f;
+ if (radius > (BLI_rctf_size_y(rct) - 10.0f) / 2.0f)
+ rad = (BLI_rctf_size_y(rct) - 10.0f) / 2.0f;
else
rad = radius;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b8a84e1638a..593744f01e0 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -78,6 +78,9 @@
#include "WM_api.h"
#include "WM_types.h"
+/* place the mouse at the scaled down location when un-grabbing */
+#define USE_CONT_MOUSE_CORRECT
+
/* proto */
static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to);
static void ui_add_link(bContext *C, uiBut *from, uiBut *to);
@@ -152,6 +155,12 @@ typedef struct uiHandleButtonData {
float dragf, dragfstart;
CBData *dragcbd;
+#ifdef USE_CONT_MOUSE_CORRECT
+ /* when ungrabbing buttons which are #ui_is_a_warp_but(), we may want to position them
+ * FLT_MAX signifies do-nothing, use #ui_block_to_window_fl() to get this into a usable space */
+ float ungrab_mval[2];
+#endif
+
/* menu open (watch uiFreeActiveButtons) */
uiPopupBlockHandle *menu;
int menuretval;
@@ -697,10 +706,10 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
if (but->imb) ; /* use button size itself */
else if (but->flag & UI_ICON_LEFT) {
- rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect));
+ rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
- int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect);
+ int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
rect.xmin += delta / 2;
rect.xmax -= delta / 2;
}
@@ -721,7 +730,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
if (but->imb)
- WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect));
+ WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect));
return 1;
}
@@ -808,6 +817,8 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
uiLink *link = from->link;
+ PointerRNA props_ptr, object_ptr;
+
if (link->ppoin)
sens_from_links = (bController ***)(link->ppoin);
else return;
@@ -836,9 +847,15 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
/* only works if the sensor and the actuator are from the same object */
if (!act_iter) return;
+
+ /* in case the linked controller is not the active one */
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+
+ WM_operator_properties_create(&props_ptr, "LOGIC_OT_controller_add");
+ RNA_string_set(&props_ptr, "object", ob->id.name+2);
/* (3) add a new controller */
- if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) {
+ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, &props_ptr) & OPERATOR_FINISHED) {
cont = (bController *)ob->controllers.last;
cont->type = CONT_LOGIC_AND; /* Quick fix to make sure we always have an AND controller. It might be nicer to make sure the operator gives us the right one though... */
@@ -858,6 +875,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
MEM_freeN(tmp_but->link);
MEM_freeN(tmp_but);
}
+ WM_operator_properties_free(&props_ptr);
}
static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
@@ -1309,7 +1327,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
/* XXX solve generic */
if (but->type == NUM || but->type == NUMSLI)
- startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect)));
+ startx += (int)(0.5f * (BLI_rctf_size_y(&but->rect)));
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
startx += 5;
if (but->flag & UI_HAS_ICON)
@@ -1386,13 +1404,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, short x)
{
- if (x > data->selstartx) data->selextend = EXTEND_RIGHT;
+ if (x > data->selstartx) data->selextend = EXTEND_RIGHT;
else if (x < data->selstartx) data->selextend = EXTEND_LEFT;
ui_textedit_set_cursor_pos(but, data, x);
- if (data->selextend == EXTEND_RIGHT) but->selend = but->pos;
- if (data->selextend == EXTEND_LEFT) but->selsta = but->pos;
+ if (data->selextend == EXTEND_RIGHT) but->selend = but->pos;
+ else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos;
ui_check_but(but);
}
@@ -1596,6 +1614,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
/* paste */
if (paste) {
+ /* TODO, ensure UTF8 ui_is_but_utf8() - campbell */
/* extract the first line from the clipboard */
p = pbuf = WM_clipboard_text_get(0);
@@ -1955,8 +1974,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (changed) {
/* only update when typing for TAB key */
- if (update && data->interactive) ui_apply_button(C, block, but, data, 1);
- else ui_check_but(but);
+ if (update && data->interactive) {
+ ui_apply_button(C, block, but, data, 1);
+ }
+ else {
+ ui_check_but(but);
+ }
but->changed = TRUE;
if (data->searchbox)
@@ -2047,8 +2070,12 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
{
- if (data->interactive) ui_apply_button(C, block, but, data, 1);
- else ui_check_but(but);
+ if (data->interactive) {
+ ui_apply_button(C, block, but, data, 1);
+ }
+ else {
+ ui_check_but(but);
+ }
ED_region_tag_redraw(data->region);
}
@@ -2373,14 +2400,14 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
}
if (snap == 1) {
- if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softrange < 21.0f) tempf = floorf(tempf);
- else tempf = 10.0f * floorf(tempf / 10.0f);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
else if (snap == 2) {
- if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
- else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
- else tempf = floor(tempf);
+ if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
+ else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floor(tempf);
}
if (fac != 1.0f)
@@ -2459,9 +2486,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
}
}
else {
- if (softrange > 256) fac = 1.0; /* 1px == 1 */
- else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
- else fac = 1.0 / 16.0; /* 16px == 1? */
+ if (softrange > 256) fac = 1.0; /* 1px == 1 */
+ else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
+ else fac = 1.0 / 16.0; /* 16px == 1? */
temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
@@ -2493,10 +2520,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
deler = 500;
if (!ui_is_but_float(but)) {
/* prevent large ranges from getting too out of control */
- if (softrange > 600) deler = powf(softrange, 0.75);
-
- if (softrange < 100) deler = 200.0;
- if (softrange < 25) deler = 50.0;
+ if (softrange > 600) deler = powf(softrange, 0.75);
+ else if (softrange < 100) deler = 200.0;
+ else if (softrange < 25) deler = 50.0;
}
deler /= fac;
@@ -2582,8 +2608,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
click = 1;
+ }
else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
@@ -2611,7 +2638,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
fac = 1.0f;
if (event->shift) fac /= 10.0f;
- if (event->alt) fac /= 20.0f;
+ if (event->alt) fac /= 20.0f;
snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0;
@@ -2639,7 +2666,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
softmax = but->softmax;
if (!ui_is_but_float(but)) {
- if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value - 1;
@@ -2650,7 +2677,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
+ else if (mx > (but->rect.xmin + (2 * BLI_rctf_size_x(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value + 1;
@@ -2661,11 +2688,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else
+ else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ }
}
else {
- if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_rctf_size_x(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value - 0.01f * but->a1;
@@ -2674,7 +2702,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
+ else if (mx > but->rect.xmin + (2 * (BLI_rctf_size_x(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value + 0.01f * but->a1;
@@ -2683,8 +2711,9 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else
+ else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ }
}
retval = WM_UI_HANDLER_BREAK;
@@ -2702,14 +2731,20 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short
softmax = but->softmax;
softrange = softmax - softmin;
- if (but->type == NUMSLI) deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
- else if (but->type == HSVSLI) deler = (BLI_RCT_SIZE_X(&but->rect) / 2.0f - 5.0f * but->aspect);
+ if (but->type == NUMSLI) {
+ deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect);
+ }
+ else if (but->type == HSVSLI) {
+ deler = (BLI_rctf_size_x(&but->rect) / 2.0f - 5.0f * but->aspect);
+ }
else if (but->type == SCROLL) {
- int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
- float size = (horizontal) ? BLI_RCT_SIZE_X(&but->rect) : -BLI_RCT_SIZE_Y(&but->rect);
+ int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
+ float size = (horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect);
deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
}
- else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
+ else {
+ deler = (BLI_rctf_size_x(&but->rect) - 5.0f * but->aspect);
+ }
f = (float)(mx - data->dragstartx) / deler + data->dragfstart;
@@ -2721,19 +2756,21 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short
temp = floorf(tempf + 0.5f);
if (ctrl) {
- if (tempf == softmin || tempf == softmax) ;
+ if (tempf == softmin || tempf == softmax) {
+ /* pass */
+ }
else if (ui_is_but_float(but)) {
if (shift) {
- if (tempf == softmin || tempf == softmax) ;
+ if (tempf == softmin || tempf == softmax) {}
else if (softmax - softmin < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
- else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
- else tempf = floorf(tempf);
+ else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floorf(tempf);
}
else {
- if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softmax - softmin < 21.0f) tempf = floorf(tempf);
- else tempf = 10.0f * floorf(tempf / 10.0f);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
}
else {
@@ -2792,7 +2829,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
/* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */
else if (event->type == LEFTMOUSE && event->alt) {
- int halfpos = BLI_RCT_CENTER_X(&but->rect);
+ int halfpos = BLI_rctf_cent_x(&but->rect);
click = 2;
if (mx < halfpos)
mx = but->rect.xmin;
@@ -2805,8 +2842,9 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
click = 1;
+ }
else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
@@ -2859,12 +2897,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
#if 0
if (but->type == SLI) {
- f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */
+ f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect)); /* same as below */
}
else
#endif
{
- f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect));
+ f = (float)(mx - but->rect.xmin) / (BLI_rctf_size_x(&but->rect));
}
f = softmin + f * softrange;
@@ -2905,7 +2943,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
{
int mx, my /*, click= 0 */;
int retval = WM_UI_HANDLER_CONTINUE;
- int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
+ int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect));
mx = event->x;
my = event->y;
@@ -3063,7 +3101,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
* else we'll get a harmless but annoying jump when first clicking */
fp = data->origvec;
- rad = BLI_RCT_SIZE_X(&but->rect);
+ rad = BLI_rctf_size_x(&but->rect);
radsq = rad * rad;
if (fp[2] > 0.0f) {
@@ -3076,7 +3114,9 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
mdx = 2.0f * mrad * fp[0] - (rad * fp[0]);
mdy = 2.0f * mrad * fp[1] - (rad * fp[1]);
}
- else mdx = mdy = 0;
+ else {
+ mdx = mdy = 0;
+ }
dx = (float)(mx + mdx - data->dragstartx);
dy = (float)(my + mdy - data->dragstarty);
@@ -3140,8 +3180,9 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3160,19 +3201,30 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ data->ungrab_mval[0] = mx_fl;
+ data->ungrab_mval[1] = my_fl;
+ BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);
+ }
+#endif
+
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
}
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ if (color_profile && (int)but->a1)
+ ui_block_to_display_space_v3(but->block, rgb);
+ rgb_to_hsv_compat_v(rgb, hsv);
/* relative position within box */
- x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect);
- y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect);
+ 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);
CLAMP(x, 0.0f, 1.0f);
CLAMP(y, 0.0f, 1.0f);
@@ -3204,17 +3256,16 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
/* exception only for value strip - use the range set in but->min/max */
hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
- if (color_profile)
- hsv[2] = srgb_to_linearrgb(hsv[2]);
-
- if (hsv[2] > but->softmax)
- hsv[2] = but->softmax;
break;
default:
assert(!"invalid hsv type");
}
hsv_to_rgb_v(hsv, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_scene_linear_v3(but->block, rgb);
+
copy_v3_v3(data->vec, rgb);
data->draglastx = mx;
@@ -3233,10 +3284,14 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
}
ui_get_but_vectorf(but, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_compat_v(rgb, hsv);
switch ((int)but->a1) {
@@ -3267,15 +3322,16 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
/* exception only for value strip - use the range set in but->min/max */
hsv[2] += ndof->rx * sensitivity;
- if (color_profile)
- hsv[2] = srgb_to_linearrgb(hsv[2]);
-
CLAMP(hsv[2], but->softmin, but->softmax);
default:
assert(!"invalid hsv type");
}
-
+
hsv_to_rgb_v(hsv, rgb);
+
+ if (color_profile && (int)but->a1)
+ ui_block_to_scene_linear_v3(but->block, rgb);
+
copy_v3_v3(data->vec, rgb);
ui_set_but_vectorf(but, data->vec);
}
@@ -3358,8 +3414,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3377,6 +3434,22 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ data->ungrab_mval[0] = mx_fl;
+ data->ungrab_mval[1] = my_fl;
+ { /* clamp */
+ const float radius = minf(BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)) / 2.0f;
+ const float cent[2] = {BLI_rctf_cent_x(&but->rect), BLI_rctf_cent_y(&but->rect)};
+ const float len = len_v2v2(cent, data->ungrab_mval);
+ if (len > radius) {
+ dist_ensure_v2_v2fl(data->ungrab_mval, cent, radius);
+ }
+ }
+ }
+#endif
+
BLI_rcti_rctf_copy(&rect, &but->rect);
ui_get_but_vectorf(but, rgb);
@@ -3569,7 +3642,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx
if (data->draglastx == mx)
return changed;
- dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect);
+ dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
@@ -3598,7 +3671,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (event->ctrl) {
/* insert new key on mouse location */
- float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect);
+ float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect);
colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -3610,7 +3683,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* activate new key when mouse is close */
for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) {
- xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect));
+ xco = but->rect.xmin + (cbd->pos * BLI_rctf_size_x(&but->rect));
xco = ABS(xco - mx);
if (a == coba->cur) xco += 5; // selected one disadvantage
if (xco < mindist) {
@@ -3633,8 +3706,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -3651,8 +3725,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */;
int a, changed = 0;
- zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ 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);
/* offsx= cumap->curr.xmin; */
/* offsy= cumap->curr.ymin; */
@@ -3667,9 +3741,10 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
}
if (data->dragsel != -1) {
+ CurveMapPoint *cmp_last = NULL;
const float mval_factor = ui_mouse_scale_warp_factor(shift);
int moved_point = 0; /* for ctrl grid, can't use orig coords because of sorting */
-
+
fx = (mx - data->draglastx) / zoomx;
fy = (my - data->draglasty) / zoomy;
@@ -3687,6 +3762,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
}
if (cmp[a].x != origx || cmp[a].y != origy)
moved_point = 1;
+
+ cmp_last = &cmp[a];
}
}
@@ -3696,6 +3773,18 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
data->draglastx = mx;
data->draglasty = my;
changed = 1;
+
+#ifdef USE_CONT_MOUSE_CORRECT
+ /* note: using 'cmp_last' is weak since there may be multiple points selected,
+ * but in practice this isnt really an issue */
+ if (ui_is_a_warp_but(but)) {
+ /* OK but can go outside bounds */
+ data->ungrab_mval[0] = but->rect.xmin + ((cmp_last->x - cumap->curr.xmin) * zoomx);
+ data->ungrab_mval[1] = but->rect.ymin + ((cmp_last->y - cumap->curr.ymin) * zoomy);
+ BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);
+ }
+#endif
+
}
data->dragchange = 1; /* mark for selection */
@@ -3747,8 +3836,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
float dist, mindist = 200.0f; // 14 pixels radius
int sel = -1;
- zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
- zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
+ 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);
offsx = cumap->curr.xmin;
offsy = cumap->curr.ymin;
@@ -3812,12 +3901,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
/* ok, we move a point */
/* deselect all if this one is deselect. except if we hold shift */
if (event->shift == FALSE) {
- for (a = 0; a < cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++) {
cmp[a].flag &= ~CUMA_SELECT;
+ }
cmp[sel].flag |= CUMA_SELECT;
}
- else
+ else {
cmp[sel].flag ^= CUMA_SELECT;
+ }
}
else {
/* move the view */
@@ -3893,7 +3984,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize histogram widget itself */
- hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ hist->height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale histogram values (dy / 10 for better control) */
@@ -3977,7 +4068,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize waveform widget itself */
- scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->wavefrm_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale waveform values */
@@ -4059,7 +4150,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize vectorscope widget itself */
- scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->vecscope_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
data->draglastx = mx;
@@ -4129,8 +4220,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
/* Calculate the size of the button */
- width = abs(BLI_RCT_SIZE_X(&but->rect));
- height = abs(BLI_RCT_SIZE_Y(&but->rect));
+ width = abs(BLI_rctf_size_x(&but->rect));
+ height = abs(BLI_rctf_size_y(&but->rect));
butw = floor(width / 12);
buth = floor(height / 6);
@@ -4262,7 +4353,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize preview widget itself */
- scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
+ scopes->track_preview_height = BLI_rctf_size_y(&but->rect) + (data->dragstarty - my);
}
else {
if (!scopes->track_locked) {
@@ -4270,8 +4361,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr);
scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
- scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect);
- scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect);
+ scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_rctf_size_x(&but->block->rect);
+ scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_rctf_size_y(&but->block->rect);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
}
@@ -4460,6 +4551,7 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
static int ui_but_menu(bContext *C, uiBut *but)
{
+ ARegion *ar = CTX_wm_region(C);
uiPopupMenu *pup;
uiLayout *layout;
int length;
@@ -4471,17 +4563,8 @@ static int ui_but_menu(bContext *C, uiBut *but)
button_timers_tooltip_remove(C, but);
-#if 0
- if (but->rnaprop)
- name = RNA_property_ui_name(but->rnaprop);
- else if (but->optype && but->optype->srna)
- name = RNA_struct_ui_name(but->optype->srna);
- else
- name = IFACE_("<needs_name>"); // XXX - should never happen.
-#else
uiButGetStrInfo(C, but, 1, &label);
name = label.strinfo;
-#endif
pup = uiPupMenuBegin(C, name, ICON_NONE);
layout = uiPupMenuLayout(pup);
@@ -4525,7 +4608,9 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
- else if (but->flag & UI_BUT_DRIVEN) ;
+ else if (but->flag & UI_BUT_DRIVEN) {
+ /* pass */
+ }
else if (is_anim) {
if (length) {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"),
@@ -4533,9 +4618,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
+ }
}
if (but->flag & UI_BUT_ANIMATED) {
@@ -4561,17 +4647,21 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"),
ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"),
ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
+ }
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"),
ICON_NONE, "ANIM_OT_copy_driver_button");
- if (ANIM_driver_can_paste())
+ if (ANIM_driver_can_paste()) {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
+ }
+ }
+ else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
+ /* pass */
}
- else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) ;
else if (is_anim) {
uiItemS(layout);
@@ -4581,13 +4671,15 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single Driver"),
ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
}
- else
+ else {
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
+ }
- if (ANIM_driver_can_paste())
+ if (ANIM_driver_can_paste()) {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"),
ICON_NONE, "ANIM_OT_paste_driver_button");
+ }
}
/* Keying Sets */
@@ -4624,9 +4716,10 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"),
ICON_NONE, "UI_OT_reset_default_button", "all", 0);
}
- else
+ else {
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"),
ICON_NONE, "UI_OT_reset_default_button");
+ }
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),
ICON_NONE, "UI_OT_copy_data_path_button");
@@ -4673,7 +4766,12 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemS(layout);
}
-
+ /* Show header tools for header buttons. */
+ if (ar->regiontype == RGN_TYPE_HEADER) {
+ uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL);
+ uiItemS(layout);
+ }
+
{ /* Docs */
char buf[512];
PointerRNA ptr_props;
@@ -5231,12 +5329,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
/* automatic open pulldown block timer */
if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) {
- if ((data->used_mouse == TRUE) &&
- (data->autoopentimer == FALSE) &&
- /* don't popup the first time,
- * see description on this member for info */
- (but->block->auto_is_first_event == FALSE))
- {
+ if (data->used_mouse && !data->autoopentimer) {
int time;
if (but->block->auto_open == TRUE) { /* test for toolbox */
@@ -5256,8 +5349,6 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time);
}
}
-
- but->block->auto_is_first_event = FALSE;
}
}
else {
@@ -5281,8 +5372,24 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
ui_numedit_end(but, data);
- if (ui_is_a_warp_but(but))
- WM_cursor_grab_disable(CTX_wm_window(C));
+ if (ui_is_a_warp_but(but)) {
+
+#ifdef USE_CONT_MOUSE_CORRECT
+ if (data->ungrab_mval[0] != FLT_MAX) {
+ int mouse_ungrab_xy[2];
+ ui_block_to_window_fl(data->region, but->block, &data->ungrab_mval[0], &data->ungrab_mval[1]);
+ mouse_ungrab_xy[0] = data->ungrab_mval[0];
+ mouse_ungrab_xy[1] = data->ungrab_mval[1];
+
+ WM_cursor_grab_disable(data->window, mouse_ungrab_xy);
+ }
+ else {
+ WM_cursor_grab_disable(data->window, NULL);
+ }
+#else
+ WM_cursor_grab_disable(data->window, );
+#endif
+ }
}
/* menu open */
if (state == BUTTON_STATE_MENU_OPEN)
@@ -5345,6 +5452,10 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
data->window = CTX_wm_window(C);
data->region = ar;
+#ifdef USE_CONT_MOUSE_CORRECT
+ copy_v2_fl(data->ungrab_mval, FLT_MAX);
+#endif
+
if (ELEM(but->type, BUT_CURVE, SEARCH_MENU)) {
/* XXX curve is temp */
}
@@ -5626,20 +5737,24 @@ void uiContextAnimUpdate(const bContext *C)
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
ED_region_tag_redraw(ar);
- if (but->active)
+ if (but->active) {
activebut = but;
- else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+ }
+ else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) {
activebut = but;
+ }
}
}
if (activebut) {
/* always recurse into opened menu, so all buttons update (like colorpicker) */
uiHandleButtonData *data = activebut->active;
- if (data && data->menu)
+ if (data && data->menu) {
ar = data->menu->region;
- else
+ }
+ else {
return;
+ }
}
else {
/* no active button */
@@ -5669,8 +5784,9 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
if (event->type == MOUSEMOVE) {
but = ui_but_find_mouse_over(ar, event->x, event->y);
- if (but)
+ if (but) {
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
+ }
}
else if (event->type == EVT_BUT_OPEN) {
but = uit_but_find_open_event(ar, event);
@@ -6173,7 +6289,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
return 0;
}
-static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int UNUSED(topmenu))
+static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level)
{
ARegion *ar;
uiBlock *block;
@@ -6218,10 +6334,22 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
/* first block own event func */
- if (block->block_event_func && block->block_event_func(C, block, event)) ;
- /* events not for active search menu button */
+ if (block->block_event_func && block->block_event_func(C, block, event)) {
+ /* pass */
+ } /* events not for active search menu button */
else if (but == NULL || but->type != SEARCH_MENU) {
switch (event->type) {
+
+
+ /* let the parent menu get the event */
+#define PASS_EVENT_TO_PARENT_IF_NONACTIVE \
+ if ((level != 0) && (but == NULL)) { \
+ menu->menuretval = UI_RETURN_OUT | UI_RETURN_OUT_PARENT; \
+ BLI_assert(retval == WM_UI_HANDLER_CONTINUE); \
+ break; \
+ } (void)0
+
+
/* closing sublevels of pulldowns */
case LEFTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP))
@@ -6234,6 +6362,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
/* opening sublevels of pulldowns */
case RIGHTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
but = ui_but_find_activated(ar);
if (!but) {
@@ -6259,6 +6390,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
else if (inside || (block->flag & UI_BLOCK_LOOP)) {
if (event->val == KM_PRESS) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
but = ui_but_find_activated(ar);
if (but) {
/* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */
@@ -6338,6 +6472,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
if (act == 0) act = 10;
if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) {
+
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
if (event->alt) act += 10;
count = 0;
@@ -6415,6 +6552,8 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
(event->ctrl == FALSE) &&
(event->oskey == FALSE))
{
+ PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+
for (but = block->buttons.first; but; but = but->next) {
if (but->menu_key == event->type) {
@@ -6504,6 +6643,10 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
retval = WM_UI_HANDLER_BREAK;
}
}
+
+ /* end switch */
+#undef PASS_EVENT_TO_PARENT_IF_NONACTIVE
+
}
}
@@ -6592,7 +6735,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
return WM_UI_HANDLER_BREAK;
}
-static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu)
+static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, int level)
{
uiBut *but;
uiHandleButtonData *data;
@@ -6605,14 +6748,20 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa
submenu = (data) ? data->menu : NULL;
if (submenu)
- retval = ui_handle_menus_recursive(C, event, submenu);
+ retval = ui_handle_menus_recursive(C, event, submenu, level + 1);
/* now handle events for our own menu */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
- if (submenu && submenu->menuretval)
+ if (submenu && submenu->menuretval) {
retval = ui_handle_menu_return_submenu(C, event, menu);
- else
- retval = ui_handle_menu_event(C, event, menu, (submenu == NULL));
+ /* we may wan't to quit the submenu and handle the even in this menu */
+ if ((retval == WM_UI_HANDLER_BREAK) && (submenu->menuretval & UI_RETURN_OUT_PARENT)) {
+ retval = ui_handle_menu_event(C, event, menu, level);
+ }
+ }
+ else {
+ retval = ui_handle_menu_event(C, event, menu, level); /* same as above */
+ }
}
return retval;
@@ -6700,7 +6849,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
if (data->state == BUTTON_STATE_MENU_OPEN) {
/* handle events for menus and their buttons recursively,
* this will handle events from the top to the bottom menu */
- retval = ui_handle_menus_recursive(C, event, data->menu);
+ retval = ui_handle_menus_recursive(C, event, data->menu, 0);
/* handle events for the activated button */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
@@ -6744,7 +6893,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
retval = WM_UI_HANDLER_CONTINUE;
}
- ui_handle_menus_recursive(C, event, menu);
+ ui_handle_menus_recursive(C, event, menu, 0);
/* free if done, does not free handle itself */
if (menu->menuretval) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index f6f12f98181..0921107b8e6 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -466,7 +466,7 @@ static void init_brush_icons(void)
{ \
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
datatoc_ ##name## _png_size, \
- IB_rect, "<brush icon>"); \
+ IB_rect, NULL, "<brush icon>"); \
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
IMB_freeImBuf(bbuf); \
} (void)0
@@ -520,7 +520,7 @@ static void init_internal_icons(void)
char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
if (icondir) {
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
- bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */
+ bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL); /* if the image is missing bbuf will just be NULL */
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
IMB_freeImBuf(bbuf);
@@ -533,7 +533,7 @@ static void init_internal_icons(void)
}
if (bbuf == NULL)
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png,
- datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
+ datatoc_blender_icons_png_size, IB_rect, NULL, "<blender icons>");
if (bbuf) {
/* free existing texture if any */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 73e6427d1cb..b48c9bcab7e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -305,17 +305,7 @@ struct uiBlock {
char direction;
char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */
char auto_open;
-
- /* this setting is used so newly opened menu's dont popout the first item under the mouse,
- * the reasoning behind this is because of muscle memory for opening menus.
- *
- * Without this, the first time opening a Submenu and activating an item in it will be 2 steps,
- * but the second time the same item is accessed the menu memory would auto activate the
- * last used menu and the key intended to select that submenu ends up being passed into the submenu.
- * - Campbell
- */
- char auto_is_first_event;
- char _pad[6];
+ char _pad[7];
double auto_open_last;
const char *lockstr;
@@ -342,7 +332,12 @@ struct uiBlock {
struct UnitSettings *unit; /* unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. */
float _hsv[3]; /* XXX, only access via ui_block_hsv_get() */
+
char color_profile; /* color profile for correcting linear colors for display */
+
+ char *display_device; /* display devide name used to display this block,
+ * used by color widgets to transform colors from/to scene linear
+ */
};
typedef struct uiSafetyRct {
@@ -392,6 +387,10 @@ extern void ui_bounds_block(uiBlock *block);
extern void ui_block_translate(uiBlock *block, int x, int y);
extern void ui_block_do_align(uiBlock *block);
+extern struct ColorManagedDisplay *ui_block_display_get(uiBlock *block);
+void ui_block_to_display_space_v3(uiBlock *block, float pixel[3]);
+void ui_block_to_scene_linear_v3(uiBlock *block, float pixel[3]);
+
/* interface_regions.c */
struct uiPopupBlockHandle {
@@ -464,7 +463,7 @@ extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event);
extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *rect);
/* interface_draw.c */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
+extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha);
@@ -500,7 +499,7 @@ void ui_widget_color_init(struct ThemeUI *tui);
void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
-extern unsigned char checker_stipple_sml[];
+extern unsigned char checker_stipple_sml[32 * 32 / 8];
/* used for transp checkers */
#define UI_TRANSP_DARK 100
#define UI_TRANSP_LIGHT 160
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 803fd928085..8ffbcd6d399 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -239,10 +239,8 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h)
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
-
-
- if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect);
- if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect);
+ if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect);
+ if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect);
}
else {
uiLayout *litem = (uiLayout *)item;
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index e8b8959fd43..ded5887f7f2 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -58,6 +58,8 @@
#include "UI_interface.h"
+#include "IMB_colormanagement.h"
+
#include "interface_intern.h"
#include "WM_api.h"
@@ -75,7 +77,7 @@
/* ********************************************************** */
typedef struct Eyedropper {
- short do_color_management;
+ struct ColorManagedDisplay *display;
PointerRNA ptr;
PropertyRNA *prop;
@@ -89,8 +91,6 @@ typedef struct Eyedropper {
static int eyedropper_init(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
-
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
@@ -106,7 +106,12 @@ static int eyedropper_init(bContext *C, wmOperator *op)
return FALSE;
}
- eye->do_color_management = (color_manage && RNA_property_subtype(eye->prop) == PROP_COLOR);
+ if (RNA_property_subtype(eye->prop) == PROP_COLOR) {
+ const char *display_device;
+
+ display_device = scene->display_settings.display_device;
+ eye->display = IMB_colormanagement_display_get_named(display_device);
+ }
return TRUE;
}
@@ -194,9 +199,10 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
/* to maintain alpha */
RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv);
- /* convert from screen (srgb) space to linear rgb space */
- if (eye->do_color_management) {
- srgb_to_linearrgb_v3_v3(col_conv, col);
+ /* convert from display space to linear rgb space */
+ if (eye->display) {
+ copy_v3_v3(col_conv, col);
+ IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display);
}
else {
copy_v3_v3(col_conv, col);
@@ -906,7 +912,7 @@ static void UI_OT_editsource(wmOperatorType *ot)
* Note: this includes utility functions and button matching checks.
* this only works in conjunction with a py operator! */
-void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen)
+static void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen)
{
char tstr[32]; /* Should be more than enough! */
/* First, full lang code. */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index fa3e04d1351..49e96bea6c6 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -357,14 +357,14 @@ void UI_DrawTriIcon(float x, float y, char dir)
}
/* triangle 'icon' inside rect */
-static void ui_draw_tria_rect(rctf *rect, char dir)
+static void ui_draw_tria_rect(const rctf *rect, char dir)
{
if (dir == 'h') {
- float half = 0.5f * BLI_RCT_SIZE_Y(rect);
+ float half = 0.5f * BLI_rctf_size_y(rect);
ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
}
else {
- float half = 0.5f * BLI_RCT_SIZE_X(rect);
+ float half = 0.5f * BLI_rctf_size_x(rect);
ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
}
}
@@ -479,12 +479,12 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r
}
}
-static void rectf_scale(rctf *rect, float scale)
+static void rectf_scale(rctf *rect, const float scale)
{
- float centx = 0.5f * (rect->xmin + rect->xmax);
- float centy = 0.5f * (rect->ymin + rect->ymax);
- float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect);
- float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect);
+ float centx = BLI_rctf_cent_x(rect);
+ float centy = BLI_rctf_cent_y(rect);
+ float sizex = BLI_rctf_size_x(rect) * 0.5f * scale;
+ float sizey = BLI_rctf_size_y(rect) * 0.5f * scale;
rect->xmin = centx - sizex;
rect->xmax = centx + sizex;
@@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* itemrect smaller */
itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
- itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect);
+ itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* itemrect smaller */
itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
- itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect);
+ itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -985,8 +985,8 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
dx = (event->x - data->startx) & ~(PNL_GRID - 1);
dy = (event->y - data->starty) & ~(PNL_GRID - 1);
- dx *= (float)BLI_RCT_SIZE_X(&ar->v2d.cur) / (float)BLI_RCT_SIZE_X(&ar->winrct);
- dy *= (float)BLI_RCT_SIZE_Y(&ar->v2d.cur) / (float)BLI_RCT_SIZE_Y(&ar->winrct);
+ 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);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 10a64d50887..adf839d433b 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -66,9 +66,10 @@
#include "ED_screen.h"
+#include "IMB_colormanagement.h"
+
#include "interface_intern.h"
-#define MENU_SEPR_HEIGHT 6
#define B_NOP -1
#define MENU_SHADOW_SIDE 8
#define MENU_SHADOW_BOTTOM 10
@@ -391,7 +392,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
/* draw text */
uiStyleFontSet(&data->fstyle);
- bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth);
+ bbox.ymax = bbox.ymax - 0.5f * (BLI_rcti_size_y(&bbox) - data->toth);
bbox.ymin = bbox.ymax - data->lineh;
for (i = 0; i < data->totline; i++) {
@@ -730,9 +731,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -865,8 +866,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
{
/* thumbnail preview */
if (data->preview) {
- int butw = BLI_RCT_SIZE_X(&data->bbox) / data->prv_cols;
- int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows;
+ int butw = BLI_rcti_size_x(&data->bbox) / data->prv_cols;
+ int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows;
int row, col;
*rect = data->bbox;
@@ -882,7 +883,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
}
/* list view */
else {
- int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS;
+ int buth = (BLI_rcti_size_y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS;
*rect = data->bbox;
rect->xmin = data->bbox.xmin + 3.0f;
@@ -1095,13 +1096,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
if (data->items.more) {
ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
glEnable(GL_BLEND);
- UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
+ UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if (data->items.offset) {
ui_searchbox_butrect(&rect, data, 0);
glEnable(GL_BLEND);
- UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
+ UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
@@ -1176,16 +1177,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&ar->winrct) - MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&ar->winrct) - MENU_SHADOW_BOTTOM;
/* check if button is lower half */
- if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) {
- data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect);
+ if (but->rect.ymax < BLI_rctf_cent_y(&but->block->rect)) {
+ data->bbox.ymin += BLI_rctf_size_y(&but->rect);
}
else {
- data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect);
+ data->bbox.ymax -= BLI_rctf_size_y(&but->rect);
}
}
else {
@@ -1200,7 +1201,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
BLI_rctf_translate(&rect_fl, ofsx, ofsy);
/* minimal width */
- if (BLI_RCT_SIZE_X(&rect_fl) < 150) {
+ if (BLI_rctf_size_x(&rect_fl) < 150) {
rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */
}
@@ -1233,15 +1234,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1);
newy1 += butregion->winrct.ymin;
- rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1;
+ rect_i.ymax = BLI_rcti_size_y(&rect_i) + newy1;
rect_i.ymin = newy1;
}
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -1356,15 +1357,15 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
}
- /* aspect = (float)(BLI_RCT_SIZE_X(&block->rect) + 4);*/ /*UNUSED*/
+ /* aspect = (float)(BLI_rcti_size_x(&block->rect) + 4);*/ /*UNUSED*/
ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
//block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
//block->rect.xmax += 2.0; block->rect.ymax += 2.0;
- xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */
- ysize = BLI_RCT_SIZE_Y(&block->rect) + 4;
+ xsize = BLI_rctf_size_x(&block->rect) + 4; /* 4 for shadow */
+ ysize = BLI_rctf_size_y(&block->rect) + 4;
/* aspect /= (float)xsize;*/ /*UNUSED*/
{
@@ -1494,9 +1495,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
BLI_rctf_translate(&block->rect, xof, yof);
/* safety calculus */
- if (but) {
- const float midx = BLI_RCT_CENTER_X(&butrct);
- const float midy = BLI_RCT_CENTER_Y(&butrct);
+ {
+ const float midx = BLI_rctf_cent_x(&butrct);
+ const float midy = BLI_rctf_cent_y(&butrct);
/* when you are outside parent button, safety there should be smaller */
@@ -1521,20 +1522,13 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
block->direction = dir1;
}
- else {
- block->safety.xmin = block->rect.xmin - 40;
- block->safety.ymin = block->rect.ymin - 40;
- block->safety.xmax = block->rect.xmax + 40;
- block->safety.ymax = block->rect.ymax + 40;
- }
/* keep a list of these, needed for pulldown menus */
saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
saferct->parent = butrct;
saferct->safety = block->safety;
BLI_freelistN(&block->saferct);
- if (but)
- BLI_duplicatelist(&block->saferct, &but->block->saferct);
+ BLI_duplicatelist(&block->saferct, &but->block->saferct);
BLI_addhead(&block->saferct, saferct);
}
@@ -1879,12 +1873,6 @@ static void ui_warp_pointer(int x, int y)
/********************* Color Button ****************/
-/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK 110.0
-#define FPICK 180.0
-#define DPICK 6.0
-#define BPICK 24.0
-
/* for picker, while editing hsv */
void ui_set_but_hsv(uiBut *but)
{
@@ -1900,11 +1888,15 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
{
uiBut *bt;
float *hsv = ui_block_hsv_get(block);
+ struct ColorManagedDisplay *display = NULL;
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
rgb_to_hsv_compat_v(rgb, hsv);
+
+ if (block->color_profile)
+ display = ui_block_display_get(block);
/* this updates button strings, is hackish... but button pointers are on stack of caller function */
for (bt = block->buttons.first; bt; bt = bt->next) {
@@ -1920,12 +1912,11 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
- if (block->color_profile == BLI_PR_NONE) {
- copy_v3_v3(rgb_gamma, rgb);
- }
- else {
- /* make an sRGB version, for Hex code */
- linearrgb_to_srgb_v3_v3(rgb_gamma, rgb);
+ copy_v3_v3(rgb_gamma, rgb);
+
+ if (display) {
+ /* make a display version, for Hex code */
+ IMB_colormanagement_scene_linear_to_display_v3(rgb_gamma, display);
}
if (rgb_gamma[0] > 1.0f) rgb_gamma[0] = modf(rgb_gamma[0], &intpart);
@@ -2004,9 +1995,9 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
hex_to_rgb(hexcol, rgb, rgb + 1, rgb + 2);
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
- if (but->block->color_profile != BLI_PR_NONE) {
+ if (but->block->color_profile) {
/* so we need to linearise it for Blender */
- srgb_to_linearrgb_v3_v3(rgb, rgb);
+ ui_block_to_scene_linear_v3(but->block, rgb);
}
ui_update_block_buts_rgb(but->block, rgb);
@@ -2055,10 +2046,6 @@ static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
picker_new_hide_reveal(bt->block, colormode);
}
-/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK1 150.0
-#define DPICK1 6.0
-
#define PICKER_H 150
#define PICKER_W 150
#define PICKER_SPACE 6
@@ -2114,14 +2101,16 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
/* existence of profile means storage is in linear color space, with display correction */
/* XXX That tip message is not use anywhere! */
- if (block->color_profile == BLI_PR_NONE) {
+ if (!block->color_profile) {
BLI_strncpy(tip, N_("Value in Display Color Space"), sizeof(tip));
copy_v3_v3(rgb_gamma, rgba);
}
else {
BLI_strncpy(tip, N_("Value in Linear RGB Color Space"), sizeof(tip));
- /* make an sRGB version, for Hex code */
- linearrgb_to_srgb_v3_v3(rgb_gamma, rgba);
+
+ /* make a display version, for Hex code */
+ copy_v3_v3(rgb_gamma, rgba);
+ ui_block_to_display_space_v3(block, rgb_gamma);
}
/* sneaky way to check for alpha */
@@ -2246,7 +2235,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
- block->color_profile = BLI_PR_NONE;
+ block->color_profile = FALSE;
}
}
@@ -2343,7 +2332,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
if (pup->but) {
/* minimum width to enforece */
- minwidth = BLI_RCT_SIZE_X(&pup->but->rect);
+ minwidth = BLI_rctf_size_x(&pup->but->rect);
if (pup->but->type == PULLDOWN || pup->but->menu_create_func) {
direction = UI_DOWN;
@@ -2385,7 +2374,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
* button, so it doesn't overlap the text too much, also note
* the offset is negative because we are inverse moving the
* block to be under the mouse */
- offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect));
+ offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect));
offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y);
}
else {
@@ -2393,7 +2382,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
* on the first item */
offset[0] = 0;
for (bt = block->buttons.first; bt; bt = bt->next)
- offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)));
+ offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)));
offset[1] = 1.5 * UI_UNIT_Y;
}
@@ -2502,7 +2491,6 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
- pup->block->auto_is_first_event = TRUE;
pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
@@ -2576,6 +2564,11 @@ static void confirm_cancel_operator(void *opv)
}
static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 4, 0)))
+#endif
+;
+static void vconfirm_opname(bContext *C, const char *opname, const char *title, const char *itemfmt, va_list ap)
{
uiPopupBlockHandle *handle;
char *s, buf[512];
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index b16250021d3..acf7712f97b 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -152,17 +152,17 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
uiStyleFontSet(fs);
height = BLF_ascender(fs->uifont_id);
- yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
+ yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
if (fs->align == UI_STYLE_TEXT_CENTER) {
- xofs = floor(0.5f * (BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str)));
+ xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
xofs = 2;
}
}
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
- xofs = BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str) - 1;
+ xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str) - 1;
}
/* clip is very strict, so we give it some space */
@@ -209,7 +209,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
height = BLF_ascender(fs->uifont_id);
/* becomes x-offset when rotated */
- xofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
+ xofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
/* ignore UI_STYLE, always aligned to top */
@@ -219,8 +219,8 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
angle = 90.0f;
/* translate rect to vertical */
- txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect);
- txtrect.ymin = rect->ymin - BLI_RCT_SIZE_X(rect);
+ txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect);
+ txtrect.ymin = rect->ymin - BLI_rcti_size_x(rect);
txtrect.xmax = rect->xmin;
txtrect.ymax = rect->ymin;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 9f0dc4af226..37503acfeb0 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -35,6 +35,7 @@
#include "DNA_dynamicpaint_types.h"
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "DNA_userdef_types.h"
#include "BLI_utildefines.h"
@@ -56,6 +57,7 @@
#include "BKE_texture.h"
#include "BKE_report.h"
#include "BKE_displist.h"
+#include "BKE_sca.h"
#include "BKE_scene.h"
#include "ED_screen.h"
@@ -428,8 +430,15 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
TIP_("Display number of users of this data (click to make a single-user copy)"));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
- if (!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)
+ if (/* test only */
+ (id_copy(id, NULL, 1) == FALSE) ||
+ (idfrom && idfrom->lib) ||
+ (editable == FALSE) ||
+ /* object in editmode - don't change data */
+ (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT)))
+ {
uiButSetFlag(but, UI_BUT_DISABLED);
+ }
}
if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT);
@@ -930,28 +939,26 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
#include "BKE_action.h"
#include "BKE_constraint.h"
-#define REDRAWIPO 1
-#define REDRAWNLA 2
-#define REDRAWBUTSOBJECT 3
-#define REDRAWACTION 4
#define B_CONSTRAINT_TEST 5
-#define B_CONSTRAINT_CHANGETARGET 6
-#define REMAKEIPO 8
-#define B_DIFF 9
+// #define B_CONSTRAINT_CHANGETARGET 6
static void do_constraint_panels(bContext *C, void *ob_pt, int event)
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
Object *ob = (Object *)ob_pt;
switch (event) {
case B_CONSTRAINT_TEST:
break; /* no handling */
+#if 0 /* UNUSED */
case B_CONSTRAINT_CHANGETARGET:
+ {
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
DAG_scene_sort(bmain, scene);
break;
+ }
+#endif
default:
break;
}
@@ -1263,8 +1270,6 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
RNA_property_update(C, &cb->ptr, cb->prop);
}
-#define B_BANDCOL 1
-
static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba = coba_v;
@@ -1380,7 +1385,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
{
uiBut *bt;
- float unit = BLI_RCT_SIZE_X(butr) / 14.0f;
+ float unit = BLI_rctf_size_x(butr) / 14.0f;
float xs = butr->xmin;
uiBlockBeginAlign(block);
@@ -1406,7 +1411,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
uiBlockEndAlign(block);
@@ -1481,7 +1486,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
- bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), hist->height, hist, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1518,7 +1523,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
- bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
(void)bt; /* UNUSED */
MEM_freeN(cb);
@@ -1555,7 +1560,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
- bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1570,11 +1575,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar
float d;
/* we allow 20 times zoom */
- if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) {
- d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr);
+ if (BLI_rctf_size_x(&cumap->curr) > 0.04f * BLI_rctf_size_x(&cumap->clipr)) {
+ d = 0.1154f * BLI_rctf_size_x(&cumap->curr);
cumap->curr.xmin += d;
cumap->curr.xmax -= d;
- d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr);
+ d = 0.1154f * BLI_rctf_size_y(&cumap->curr);
cumap->curr.ymin += d;
cumap->curr.ymax -= d;
}
@@ -1588,8 +1593,8 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
float d, d1;
/* we allow 20 times zoom, but don't view outside clip */
- if (BLI_RCT_SIZE_X(&cumap->curr) < 20.0f * BLI_RCT_SIZE_X(&cumap->clipr)) {
- d = d1 = 0.15f * BLI_RCT_SIZE_X(&cumap->curr);
+ 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->curr.xmin - d < cumap->clipr.xmin)
@@ -1602,7 +1607,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
cumap->curr.xmax += d1;
- d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr);
+ d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.ymin - d < cumap->clipr.ymin)
@@ -1870,7 +1875,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- if (cumap->flag & CUMA_DO_CLIP) icon = ICON_CLIPUV_HLT; else icon = ICON_CLIPUV_DEHLT;
+ icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
@@ -2086,6 +2091,74 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
}
+void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname,
+ PointerRNA *used_ptr, const char *used_propname, int active_state)
+{
+ uiLayout *uRow, *uCol;
+ PropertyRNA *prop, *used_prop = NULL;
+ int groups, cols, states;
+ int group, col, state, row;
+ int cols_per_group = 5;
+ Object *ob = (Object *)ptr->id.data;
+
+ prop = RNA_struct_find_property(ptr, propname);
+ if (!prop) {
+ RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ /* the number of states 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
+ * - for now, only split into groups if group will have at least 5 items
+ */
+ states = RNA_property_array_length(ptr, prop);
+ cols = (states / 2) + (states % 2);
+ groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
+
+ if (used_ptr && used_propname) {
+ used_prop = RNA_struct_find_property(used_ptr, used_propname);
+ if (!used_prop) {
+ RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
+ return;
+ }
+
+ if (RNA_property_array_length(used_ptr, used_prop) < states)
+ 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;
+
+ uRow = uiLayoutRow(uCol, TRUE);
+ block = uiLayoutGetBlock(uRow);
+ state = groups * cols_per_group * row + cols_per_group * group;
+
+ /* add layers as toggle buts */
+ for (col = 0; (col < cols_per_group) && (state < states); col++, state++) {
+ int icon = 0;
+ int butlay = 1 << state;
+
+ if (active_state & butlay)
+ icon = ICON_LAYER_ACTIVE;
+ else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state))
+ icon = ICON_LAYER_USED;
+
+ but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state));
+ uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
+ but->type = TOG;
+ }
+ }
+ }
+}
+
/************************* List Template **************************/
@@ -2802,3 +2875,56 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
}
}
+/********************************* Color management *************************************/
+
+void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname)
+{
+ PropertyRNA *prop;
+ PointerRNA colorspace_settings_ptr;
+
+ prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ printf("%s: property not found: %s.%s\n",
+ __func__, RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
+
+ uiItemL(layout, "Color Space:", ICON_NONE);
+ uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE);
+}
+
+void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr, const char *propname)
+{
+ PropertyRNA *prop;
+ PointerRNA view_transform_ptr;
+ uiLayout *col, *row;
+ ColorManagedViewSettings *view_settings;
+
+ prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ printf("%s: property not found: %s.%s\n",
+ __func__, RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ view_transform_ptr = RNA_property_pointer_get(ptr, prop);
+ view_settings = view_transform_ptr.data;
+
+ col = uiLayoutColumn(layout, FALSE);
+
+ row = uiLayoutRow(col, FALSE);
+ uiItemR(row, &view_transform_ptr, "view_transform", UI_ITEM_R_EXPAND, IFACE_("View"), ICON_NONE);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
+ uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
+ if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
+ uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', TRUE, 0);
+}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 026f02d1089..f3539af821e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -259,8 +259,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r
rad += step;
- if (2.0f * rad > BLI_RCT_SIZE_Y(rect))
- rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ if (2.0f * rad > BLI_rcti_size_y(rect))
+ rad = 0.5f * BLI_rcti_size_y(rect);
minx = rect->xmin - step;
miny = rect->ymin - step;
@@ -345,8 +345,8 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
(roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
- minsize = mini(BLI_RCT_SIZE_X(rect) * hnum,
- BLI_RCT_SIZE_Y(rect) * vnum);
+ minsize = mini(BLI_rcti_size_x(rect) * hnum,
+ BLI_rcti_size_y(rect) * vnum);
if (2.0f * rad > minsize)
rad = 0.5f * minsize;
@@ -491,7 +491,7 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
- minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -526,7 +526,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize
float centx, centy, sizex, sizey, minsize;
int a, i1 = 0, i2 = 1;
- minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
+ minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -570,14 +570,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmax - 0.5f * BLI_RCT_SIZE_Y(rect);
- centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect);
- size = 0.4f * BLI_RCT_SIZE_Y(rect);
+ centx = rect->xmax - 0.5f * BLI_rcti_size_y(rect);
+ centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
+ size = 0.4f * BLI_rcti_size_y(rect);
/* XXX exception */
- asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect));
+ asp = ((float)BLI_rcti_size_x(rect)) / ((float)BLI_rcti_size_y(rect));
if (asp > 1.2f && asp < 2.6f)
- centx = rect->xmax - 0.3f * BLI_RCT_SIZE_Y(rect);
+ centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * menu_tria_vert[a][0] + centx;
@@ -594,9 +594,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmin + 0.5f * BLI_RCT_SIZE_Y(rect);
- centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect);
- size = 0.5f * BLI_RCT_SIZE_Y(rect);
+ centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect);
+ centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect);
+ size = 0.5f * BLI_rcti_size_y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * check_tria_vert[a][0] + centx;
@@ -840,8 +840,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
if (icon == ICON_NONE)
return;
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
size = MIN2(w, h);
size -= PREVIEW_PAD * 2; /* padding */
@@ -965,48 +965,77 @@ static void ui_text_clip_give_next_off(uiBut *but)
but->ofs += bytes;
}
-/* sets but->ofs to make sure text is correctly visible */
-static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+/**
+ * Cut off the start of the text to fit into the width of \a rect
+ *
+ * \note Sets but->ofs to make sure text is correctly visible.
+ * \note Clips right in some cases, this function could be cleaned up.
+ */
+static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = BLI_RCT_SIZE_X(rect) - border;
-
+ int okwidth = BLI_rcti_size_x(rect) - border;
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
-
+
/* need to set this first */
uiStyleFontSet(fstyle);
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- /* if text editing we define ofs dynamically */
- if (but->editstr && but->pos >= 0) {
+ but->ofs = 0;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
+
+ while (but->strwidth > okwidth) {
+ ui_text_clip_give_next_off(but);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ if (but->strwidth < 10) break;
+ }
+
+ if (fstyle->kerning == 1) {
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
+}
+
+/**
+ * Cut off the text, taking into account the cursor location (text display while editing).
+ */
+static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+{
+ int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int okwidth = BLI_rcti_size_x(rect) - border;
+ if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
+
+ BLI_assert(but->editstr && but->pos >= 0);
+
+ /* need to set this first */
+ uiStyleFontSet(fstyle);
+
+ if (fstyle->kerning == 1) /* for BLF_width */
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+
+ if ((but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr)) <= okwidth) {
+ but->ofs = 0;
+ }
+ else {
+ /* define ofs dynamically */
if (but->ofs > but->pos)
but->ofs = but->pos;
- if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth)
- but->ofs = 0;
- }
- else but->ofs = 0;
-
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- while (but->strwidth > okwidth) {
-
- /* textbut exception, clip right when... */
- if (but->editstr && but->pos >= 0) {
+ while (but->strwidth > okwidth) {
float width;
char buf[UI_MAX_DRAW_STR];
-
+
/* copy draw string */
BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf));
/* string position of cursor */
buf[but->pos] = 0;
width = BLF_width(fstyle->uifont_id, buf + but->ofs);
-
+
/* if cursor is at 20 pixels of right side button we clip left */
- if (width > okwidth - 20)
+ if (width > okwidth - 20) {
ui_text_clip_give_next_off(but);
+ }
else {
int len, bytes;
/* shift string to the left */
@@ -1016,25 +1045,30 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
but->drawstr[len - bytes] = 0;
}
- }
- else
- ui_text_clip_give_next_off(but);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- if (but->strwidth < 10) break;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+
+ if (but->strwidth < 10) break;
+ }
}
-
- if (fstyle->kerning == 1)
+
+ if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
-static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
+/**
+ * Cut off the end of text to fit into the width of \a rect.
+ *
+ * \note deals with ': ' especially for number buttons
+ */
+static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = BLI_RCT_SIZE_X(rect) - border;
+ int okwidth = BLI_rcti_size_x(rect) - border;
char *cpoin = NULL;
- char *cpend = but->drawstr + strlen(but->drawstr);
+ int drawstr_len = strlen(but->drawstr);
+ char *cpend = but->drawstr + drawstr_len;
/* need to set this first */
uiStyleFontSet(fstyle);
@@ -1045,6 +1079,13 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs = 0;
+
+ /* First shorten num-buttopns eg,
+ * Translucency: 0.000
+ * becomes
+ * Trans: 0.000
+ */
+
/* find the space after ':' separator */
cpoin = strrchr(but->drawstr, ':');
@@ -1057,8 +1098,11 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
int bytes = cp2 - prev_utf8;
/* shift the text after and including cp2 back by 1 char, +1 to include null terminator */
- memmove(cp2 - bytes, cp2, strlen(cp2) + 1);
+ memmove(cp2 - bytes, cp2, drawstr_len + 1);
cp2 -= bytes;
+
+ drawstr_len -= bytes;
+ // BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
@@ -1074,14 +1118,17 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
}
+
+ /* Now just remove trailing chars */
/* once the label's gone, chop off the least significant digits */
while (but->strwidth > okwidth) {
- int len = strlen(but->drawstr);
- int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
+ int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + drawstr_len));
if (bytes < 0)
bytes = 1;
- but->drawstr[len - bytes] = 0;
+ drawstr_len -= bytes;
+ but->drawstr[drawstr_len] = 0;
+ // BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
@@ -1229,30 +1276,31 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* draws text and icons for buttons */
static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
{
-
- if (but == NULL) return;
+ if (but == NULL) {
+ return;
+ }
/* clip but->drawstr to fit in available space */
if (but->editstr && but->pos >= 0) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_cursor(fstyle, but, rect);
}
else if (ELEM4(but->type, NUM, NUMABS, NUMSLI, SLI)) {
- ui_text_label_rightclip(fstyle, but, rect);
+ ui_text_clip_right_label(fstyle, but, rect);
}
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_left(fstyle, but, rect);
}
else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
- ui_text_leftclip(fstyle, but, rect);
+ ui_text_clip_left(fstyle, but, rect);
}
else but->ofs = 0;
-
+
/* check for button text label */
if (but->type == ICONTEXTROW) {
widget_draw_icon(but, (BIFIconID) (but->icon + but->iconadd), 1.0f, rect);
}
else {
-
+
if (but->type == BUT_TOGDUAL) {
int dualset = 0;
if (but->pointype == UI_BUT_POIN_SHORT) {
@@ -1261,30 +1309,30 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if (but->pointype == UI_BUT_POIN_INT) {
dualset = UI_BITBUT_TEST(*(((int *)but->poin) + 1), but->bitnr);
}
-
+
widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect);
}
else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
int tmp = rect->xmin;
- rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1;
+ rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
rect->xmin = tmp;
}
-
+
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
* and offset the text label to accommodate it */
-
+
if (but->flag & UI_HAS_ICON) {
widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect);
-
+
rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC);
-
- if (but->editstr || (but->flag & UI_TEXT_LEFT))
+
+ if (but->editstr || (but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
}
- else if ((but->flag & UI_TEXT_LEFT))
+ else if ((but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
-
+
/* always draw text for textbutton cursor */
widget_draw_text(fstyle, wcol, but, rect);
@@ -1761,8 +1809,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
float quad_strip[WIDGET_SIZE_MAX * 2][2];
/* prevent tooltips to not show round shadow */
- if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1))
- rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1);
+ if (2.0f * radout > 0.2f * BLI_rcti_size_y(&rect1))
+ rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
else
rect1.ymax -= 2.0f * radout;
@@ -1844,14 +1892,14 @@ static void ui_hsv_cursor(float x, float y)
void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my)
{
/* duplication of code... well, simple is better now */
- float centx = BLI_RCT_CENTER_X_FL(rect);
- float centy = BLI_RCT_CENTER_Y_FL(rect);
+ float centx = BLI_rcti_cent_x_fl(rect);
+ float centy = BLI_rcti_cent_y_fl(rect);
float radius, dist;
- if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
- radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
+ if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect))
+ radius = (float)BLI_rcti_size_y(rect) / 2;
else
- radius = (float)BLI_RCT_SIZE_X(rect) / 2;
+ radius = (float)BLI_rcti_size_x(rect) / 2;
mx -= centx;
my -= centy;
@@ -1874,30 +1922,33 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
int color_profile = but->block->color_profile;
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
radstep = 2.0f * (float)M_PI / (float)tot;
- centx = BLI_RCT_CENTER_X_FL(rect);
- centy = BLI_RCT_CENTER_Y_FL(rect);
+ centx = BLI_rcti_cent_x_fl(rect);
+ centy = BLI_rcti_cent_y_fl(rect);
- if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
- radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
+ if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect))
+ radius = (float)BLI_rcti_size_y(rect) / 2;
else
- radius = (float)BLI_RCT_SIZE_X(rect) / 2;
+ radius = (float)BLI_rcti_size_x(rect) / 2;
/* color */
ui_get_but_vectorf(but, rgb);
- copy_v3_v3(hsv, ui_block_hsv_get(but->block));
+ /* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */
+
+ rgb_to_hsv_compat_v(rgb, hsvo);
+
+ if (color_profile)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_compat_v(rgb, hsv);
- copy_v3_v3(hsvo, hsv);
/* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
if (but->flag & UI_BUT_COLOR_LOCK)
hsv[2] = 1.f;
- else if (color_profile)
- hsv[2] = linearrgb_to_srgb(hsv[2]);
hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
@@ -2059,10 +2110,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
}
/* rect */
- sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect);
- sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect);
+ sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
+ sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect);
sy = rect->ymin;
- dy = BLI_RCT_SIZE_Y(rect) / 3.0;
+ dy = BLI_rcti_size_y(rect) / 3.0;
glBegin(GL_QUADS);
for (a = 0; a < 3; a++, sy += dy) {
@@ -2117,8 +2168,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
}
/* cursor */
- x = rect->xmin + x * BLI_RCT_SIZE_X(rect);
- y = rect->ymin + y * BLI_RCT_SIZE_Y(rect);
+ x = rect->xmin + x * BLI_rcti_size_x(rect);
+ y = rect->ymin + y * BLI_rcti_size_y(rect);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
@@ -2133,21 +2184,22 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
{
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_X(rect);
+ float rad = 0.5f * BLI_rcti_size_x(rect);
float x, y;
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
ui_get_but_vectorf(but, rgb);
+
+ if (color_profile)
+ ui_block_to_display_space_v3(but->block, rgb);
+
rgb_to_hsv_v(rgb, hsv);
v = hsv[2];
- if (color_profile)
- v = linearrgb_to_srgb(v);
-
/* map v from property range to [0,1] */
range = but->softmax - but->softmin;
v = (v - but->softmin) / range;
@@ -2167,8 +2219,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
widgetbase_draw(&wtb, &wcol_tmp);
/* cursor */
- x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect);
- y = rect->ymin + v * BLI_RCT_SIZE_Y(rect);
+ x = rect->xmin + 0.5f * BLI_rcti_size_x(rect);
+ y = rect->ymin + v * BLI_rcti_size_y(rect);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
ui_hsv_cursor(x, y);
@@ -2179,7 +2231,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
/* ************ separator, for menus etc ***************** */
static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
{
- int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1;
+ int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1;
unsigned char col[4];
col[0] = wcol->text[0];
@@ -2198,7 +2250,7 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ float rad = 0.5f * BLI_rcti_size_y(rect);
float textofs = rad * 0.75f;
if (state & UI_SELECT)
@@ -2279,12 +2331,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widget_init(&wtb);
/* determine horizontal/vertical */
- horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
+ horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
if (horizontal)
- rad = 0.5f * BLI_RCT_SIZE_Y(rect);
+ rad = 0.5f * BLI_rcti_size_y(rect);
else
- rad = 0.5f * BLI_RCT_SIZE_X(rect);
+ rad = 0.5f * BLI_rcti_size_x(rect);
wtb.shadedir = (horizontal) ? 1 : 0;
@@ -2296,7 +2348,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widgetbase_draw(&wtb, wcol);
/* slider */
- if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) {
+ if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) {
/* pass */
}
else {
@@ -2362,17 +2414,17 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
rect1 = *rect;
/* determine horizontal/vertical */
- horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
+ horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
if (horizontal) {
- fac = BLI_RCT_SIZE_X(rect) / size;
+ fac = BLI_rcti_size_x(rect) / size;
rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min = BLI_RCT_SIZE_Y(rect);
+ min = BLI_rcti_size_y(rect);
- if (BLI_RCT_SIZE_X(&rect1) < min) {
+ if (BLI_rcti_size_x(&rect1) < min) {
rect1.xmax = rect1.xmin + min;
if (rect1.xmax > rect->xmax) {
@@ -2382,14 +2434,14 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
}
else {
- fac = BLI_RCT_SIZE_Y(rect) / size;
+ fac = BLI_rcti_size_y(rect) / size;
rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin));
rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min = BLI_RCT_SIZE_X(rect);
+ min = BLI_rcti_size_x(rect);
- if (BLI_RCT_SIZE_Y(&rect1) < min) {
+ if (BLI_rcti_size_y(&rect1) < min) {
rect1.ymax = rect1.ymin + min;
if (rect1.ymax > rect->ymax) {
@@ -2417,10 +2469,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
rect_prog.ymax = rect_prog.ymin + 4;
rect_bar.ymax = rect_bar.ymin + 4;
- w = value * BLI_RCT_SIZE_X(&rect_prog);
+ w = value * BLI_rcti_size_x(&rect_prog);
/* ensure minimium size */
- min = BLI_RCT_SIZE_Y(&rect_prog);
+ min = BLI_rcti_size_y(&rect_prog);
w = MAX2(w, min);
rect_bar.xmax = rect_bar.xmin + w;
@@ -2440,8 +2492,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in
UI_ThemeColor(TH_TEXT_HI);
- rectlink.xmin = BLI_RCT_CENTER_X(rect);
- rectlink.ymin = BLI_RCT_CENTER_Y(rect);
+ rectlink.xmin = BLI_rcti_cent_x(rect);
+ rectlink.ymin = BLI_rcti_cent_y(rect);
rectlink.xmax = but->linkto[0];
rectlink.ymax = but->linkto[1];
@@ -2463,7 +2515,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
/* backdrop first */
/* fully rounded */
- offs = 0.5f * BLI_RCT_SIZE_Y(rect);
+ offs = 0.5f * BLI_rcti_size_y(rect);
toffs = offs * 0.75f;
round_box_edges(&wtb, roundboxalign, rect, offs);
@@ -2484,7 +2536,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
rect1 = *rect;
value = ui_get_but_val(but);
- fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin);
+ fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
/* left part of slider, always rounded */
rect1.xmax = rect1.xmin + ceil(offs + 1.0f);
@@ -2531,7 +2583,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = BLI_PR_NONE;
+ color_profile = FALSE;
if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) {
col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
@@ -2559,7 +2611,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
if (color_profile)
- linearrgb_to_srgb_v3_v3(col, col);
+ ui_block_to_display_space_v3(but->block, col);
rgba_float_to_uchar((unsigned char *)wcol->inner, col);
@@ -2617,7 +2669,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmax -= BLI_RCT_SIZE_Y(rect);
+ rect->xmax -= BLI_rcti_size_y(rect);
}
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2660,7 +2712,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
{
if (state & UI_ACTIVE) {
uiWidgetBase wtb;
- float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */
+ float rad = 0.5f * BLI_rcti_size_y(rect); /* 4.0f */
widget_init(&wtb);
@@ -2706,10 +2758,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widget_init(&wtb);
/* square */
- recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp);
+ recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
/* smaller */
- delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8;
+ delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
recttemp.xmin += delta;
recttemp.ymin += delta;
recttemp.xmax -= delta;
@@ -2726,7 +2778,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta;
+ rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
}
@@ -2788,7 +2840,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
uiWidgetBase wtb;
- float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */
+ float rad = 5.0f; /* 0.5f * BLI_rcti_size_y(rect); */
widget_init(&wtb);
@@ -3271,12 +3323,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
if (block->flag & UI_BLOCK_CLIPTOP) {
/* XXX no scaling for UI here yet */
glColor3ubv((unsigned char *)wt->wcol.text);
- UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't');
+ UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't');
}
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
/* XXX no scaling for UI here yet */
glColor3ubv((unsigned char *)wt->wcol.text);
- UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v');
+ UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v');
}
}
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 0f1d1a24dcb..47bee92be62 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -96,11 +96,11 @@ static void view2d_masks(View2D *v2d)
/* check size if: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
- if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur))
+ if (BLI_rctf_size_x(&v2d->tot) <= BLI_rcti_size_x(&v2d->cur))
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
if (v2d->scroll & V2D_SCROLL_VERTICAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
- if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_SIZE_Y(&v2d->cur))
+ if (BLI_rctf_size_y(&v2d->tot) <= BLI_rctf_size_y(&v2d->cur))
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
#endif
scroll = view2d_scroll_mapped(v2d->scroll);
@@ -328,8 +328,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
rctf *cur, *tot;
/* use mask as size of region that View2D resides in, as it takes into account scrollbars already */
- winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ 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;
@@ -347,10 +347,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
* - firstly, we calculate the sizes of the rects
* - curwidth and curheight are saved as reference... modify width and height values here
*/
- totwidth = BLI_RCT_SIZE_X(tot);
- totheight = BLI_RCT_SIZE_Y(tot);
- curwidth = width = BLI_RCT_SIZE_X(cur);
- curheight = height = BLI_RCT_SIZE_Y(cur);
+ totwidth = BLI_rctf_size_x(tot);
+ totheight = BLI_rctf_size_y(tot);
+ 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)
@@ -499,16 +499,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
/* resize from centerpoint, unless otherwise specified */
if (width != curwidth) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
- cur->xmax += width - BLI_RCT_SIZE_X(cur);
+ cur->xmax += width - BLI_rctf_size_x(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
if (v2d->align & V2D_ALIGN_NO_POS_X)
- cur->xmin -= width - BLI_RCT_SIZE_X(cur);
+ cur->xmin -= width - BLI_rctf_size_x(cur);
else
- cur->xmax += width - BLI_RCT_SIZE_X(cur);
+ cur->xmax += width - BLI_rctf_size_x(cur);
}
else {
- temp = BLI_RCT_CENTER_X(cur);
+ temp = BLI_rctf_cent_x(cur);
dh = width * 0.5f;
cur->xmin = temp - dh;
@@ -517,16 +517,16 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
if (height != curheight) {
if (v2d->keepofs & V2D_LOCKOFS_Y) {
- cur->ymax += height - BLI_RCT_SIZE_Y(cur);
+ cur->ymax += height - BLI_rctf_size_y(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
if (v2d->align & V2D_ALIGN_NO_POS_Y)
- cur->ymin -= height - BLI_RCT_SIZE_Y(cur);
+ cur->ymin -= height - BLI_rctf_size_y(cur);
else
- cur->ymax += height - BLI_RCT_SIZE_Y(cur);
+ cur->ymax += height - BLI_rctf_size_y(cur);
}
else {
- temp = BLI_RCT_CENTER_Y(cur);
+ temp = BLI_rctf_cent_y(cur);
dh = height * 0.5f;
cur->ymin = temp - dh;
@@ -540,8 +540,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
float temp, diff;
/* recalculate extents of cur */
- curwidth = BLI_RCT_SIZE_X(cur);
- curheight = BLI_RCT_SIZE_Y(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))) {
@@ -592,7 +592,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
- temp = BLI_RCT_CENTER_X(tot);
+ temp = BLI_rctf_cent_x(tot);
diff = curheight * 0.5f;
cur->xmin = temp - diff;
@@ -642,7 +642,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
- temp = BLI_RCT_CENTER_Y(tot);
+ temp = BLI_rctf_cent_y(tot);
diff = curheight * 0.5f;
cur->ymin = temp - diff;
@@ -791,8 +791,8 @@ 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_RCT_SIZE_X(&v2d->mask) + 1);
- height = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ 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)) {
@@ -851,7 +851,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, int resize
if (scroll & V2D_SCROLL_VERTICAL)
height -= V2D_SCROLL_HEIGHT;
- if (ELEM3(0, v2d, width, 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;
@@ -958,8 +958,8 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
*curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
- float dx = BLI_RCT_SIZE_X(&v2d->cur) / ((float)(BLI_RCT_SIZE_X(&v2d->mask) + 1));
- float dy = BLI_RCT_SIZE_Y(&v2d->cur) / ((float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1));
+ float dx = BLI_rctf_size_x(&v2d->cur) / ((float)(BLI_rcti_size_x(&v2d->mask) + 1));
+ float dy = BLI_rctf_size_y(&v2d->cur) / ((float)(BLI_rcti_size_y(&v2d->mask) + 1));
if (v2d->mask.xmin != 0)
curmasked->xmin -= dx * (float)v2d->mask.xmin;
@@ -985,14 +985,13 @@ void UI_view2d_view_ortho(View2D *v2d)
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
- xofs = 0.001f * BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
- yofs = 0.001f * BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
+ xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+ yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
-
- curmasked.xmin -= xofs; curmasked.xmax -= xofs;
- curmasked.ymin -= yofs; curmasked.ymax -= yofs;
+
+ BLI_rctf_translate(&curmasked, -xofs, -yofs);
/* XXX ton: this flag set by outliner, for icons */
if (v2d->flag & V2D_PIXELOFS_X) {
@@ -1044,8 +1043,8 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
void UI_view2d_view_restore(const bContext *C)
{
ARegion *ar = CTX_wm_region(C);
- int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ 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);
glLoadIdentity();
@@ -1117,7 +1116,8 @@ static void step_to_grid(float *step, int *power, int unit)
* - winx = width of region we're drawing to, note: not used but keeping for completeness.
* - winy = height of region we're drawing into
*/
-View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy)
+View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp, int UNUSED(winx), int winy)
{
View2DGrid *grid;
@@ -1140,8 +1140,8 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space = BLI_RCT_SIZE_X(&v2d->cur);
- pixels = (float)BLI_RCT_SIZE_X(&v2d->mask);
+ space = BLI_rctf_size_x(&v2d->cur);
+ pixels = (float)BLI_rcti_size_x(&v2d->mask);
if (pixels != 0.0f) {
grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels);
@@ -1158,7 +1158,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space = BLI_RCT_SIZE_Y(&v2d->cur);
+ space = BLI_rctf_size_y(&v2d->cur);
pixels = (float)winy;
grid->dy = U.v2d_min_gridsize * space / pixels;
@@ -1206,7 +1206,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec2[1] = v2d->cur.ymax;
/* minor gridlines */
- step = (BLI_RCT_SIZE_X(&v2d->mask) + 1) / U.v2d_min_gridsize;
+ step = (BLI_rcti_size_x(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a < step; a++) {
@@ -1240,7 +1240,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec1[0] = grid->startx;
vec2[0] = v2d->cur.xmax;
- step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize;
+ step = (BLI_rcti_size_y(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a <= step; a++) {
@@ -1414,7 +1414,8 @@ struct View2DScrollers {
};
/* Calculate relevant scroller properties */
-View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp)
+View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d,
+ short xunits, short xclamp, short yunits, short yclamp)
{
View2DScrollers *scrollers;
rcti vert, hor;
@@ -1457,8 +1458,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* horizontal scrollers */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
- totsize = BLI_RCT_SIZE_X(&v2d->tot);
- scrollsize = (float)BLI_RCT_SIZE_X(&hor);
+ totsize = BLI_rctf_size_x(&v2d->tot);
+ scrollsize = (float)BLI_rcti_size_x(&hor);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
@@ -1498,8 +1499,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
- totsize = BLI_RCT_SIZE_Y(&v2d->tot);
- scrollsize = (float)BLI_RCT_SIZE_Y(&vert);
+ totsize = BLI_rctf_size_y(&v2d->tot);
+ scrollsize = (float)BLI_rcti_size_y(&vert);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
@@ -1547,7 +1548,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
xunits, xclamp, yunits, yclamp,
- BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert));
+ BLI_rcti_size_x(&hor), BLI_rcti_size_y(&vert));
}
/* return scrollers */
@@ -1631,7 +1632,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
- (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE))
+ (BLI_rcti_size_x(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1651,11 +1652,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - fac is x-coordinate to draw to
* - dfac is gap between scale markings
*/
- fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor);
+ 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_RCT_SIZE_X(&v2d->cur);
- dfac = dfac * BLI_RCT_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_ThemeColor(TH_TEXT);
@@ -1742,7 +1743,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
- (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
+ (BLI_rcti_size_y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1765,11 +1766,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - these involve a correction for horizontal scrollbar
* NOTE: it's assumed that that scrollbar is there if this is involved!
*/
- fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
- fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert);
+ 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_RCT_SIZE_Y(&v2d->cur);
- dfac = dfac * BLI_RCT_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 */
UI_ThemeColor(TH_TEXT);
@@ -1823,7 +1824,9 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers)
* - column, row = the 2d-coordinates (in 2D-view / 'tot' rect space) the cell exists at
* - rect = coordinates of the cell (passed as single var instead of 4 separate, as it's more useful this way)
*/
-void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, rctf *rect)
+void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowheight,
+ float startx, float starty,
+ int column, int row, rctf *rect)
{
/* sanity checks */
if (ELEM(NULL, v2d, rect)) {
@@ -1927,17 +1930,17 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *
float div, ofs;
if (r_viewx) {
- div = (float)BLI_RCT_SIZE_X(&v2d->mask);
+ div = (float)BLI_rcti_size_x(&v2d->mask);
ofs = (float)v2d->mask.xmin;
- *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div;
+ *r_viewx = v2d->cur.xmin + BLI_rctf_size_x(&v2d->cur) * ((float)x - ofs) / div;
}
if (r_viewy) {
- div = (float)BLI_RCT_SIZE_Y(&v2d->mask);
+ div = (float)BLI_rcti_size_y(&v2d->mask);
ofs = (float)v2d->mask.ymin;
- *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div;
+ *r_viewy = v2d->cur.ymin + BLI_rctf_size_y(&v2d->cur) * ((float)y - ofs) / div;
}
}
@@ -1956,15 +1959,15 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
*regiony = V2D_IS_CLIPPED;
/* express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ 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)) {
if (regionx)
- *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask));
+ *regionx = (int)(v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask));
if (regiony)
- *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask));
+ *regiony = (int)(v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask));
}
}
@@ -1977,12 +1980,12 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* step 1: express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
- y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
/* step 2: convert proportional distances to screen coordinates */
- x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
- y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
+ x = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
+ y = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
if (regionx) {
@@ -2035,8 +2038,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
*/
void UI_view2d_getscale(View2D *v2d, float *x, float *y)
{
- if (x) *x = BLI_RCT_SIZE_X(&v2d->mask) / BLI_RCT_SIZE_X(&v2d->cur);
- if (y) *y = BLI_RCT_SIZE_Y(&v2d->mask) / BLI_RCT_SIZE_Y(&v2d->cur);
+ 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);
}
/* Check if mouse is within scrollers
@@ -2142,7 +2145,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
const char *str = (const char *)(v2s + 1);
int xofs = 0, yofs;
- yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height));
+ yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height));
if (yofs < 1) yofs = 1;
if (col_pack_prev != v2s->col.pack) {
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 99313edc289..3d3f309a8d4 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -119,10 +119,10 @@ static int view_pan_init(bContext *C, wmOperator *op)
vpd->ar = ar;
/* calculate translation factor - based on size of view */
- winx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1);
- vpd->facx = (BLI_RCT_SIZE_X(&v2d->cur)) / winx;
- vpd->facy = (BLI_RCT_SIZE_Y(&v2d->cur)) / winy;
+ 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;
}
@@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "page")) {
ARegion *ar = CTX_wm_region(C);
- RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask));
+ RNA_int_set(op->ptr, "deltay", BLI_rcti_size_y(&ar->v2d.mask));
}
/* apply movement, then we're done */
@@ -590,12 +590,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
facy = RNA_float_get(op->ptr, "zoomfacy");
if (facx >= 0.0f) {
- dx = BLI_RCT_SIZE_X(&v2d->cur) * facx;
- dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy;
+ dx = BLI_rctf_size_x(&v2d->cur) * facx;
+ dy = BLI_rctf_size_y(&v2d->cur) * facy;
}
else {
- dx = (BLI_RCT_SIZE_X(&v2d->cur) / (1.0f + 2.0f * facx)) * facx;
- dy = (BLI_RCT_SIZE_Y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
+ dx = (BLI_rctf_size_x(&v2d->cur) / (1.0f + 2.0f * facx)) * facx;
+ dy = (BLI_rctf_size_y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
}
/* only resize view on an axis if change is allowed */
@@ -611,7 +611,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ 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);
@@ -636,7 +636,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ 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);
@@ -845,7 +845,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ 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);
@@ -864,7 +864,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
+ 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);
@@ -942,8 +942,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
* with magnify information that is stored in x axis
*/
fac = 0.01f * (event->x - event->prevx);
- dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f;
- dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f;
+ dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f;
+ dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f;
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
@@ -1009,14 +1009,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
float dist;
/* x-axis transform */
- dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f;
+ dist = BLI_rcti_size_x(&v2d->mask) / 2.0f;
dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f);
- dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur);
+ dx *= 0.5f * BLI_rctf_size_x(&v2d->cur);
/* y-axis transform */
- dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f;
+ dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f);
- dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur);
+ dy *= 0.5f * BLI_rctf_size_y(&v2d->cur);
}
else {
/* 'continuous' or 'dolly' */
@@ -1024,11 +1024,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* x-axis transform */
fac = 0.01f * (event->x - vzd->lastx);
- dx = fac * BLI_RCT_SIZE_X(&v2d->cur);
+ dx = fac * BLI_rctf_size_x(&v2d->cur);
/* y-axis transform */
fac = 0.01f * (event->y - vzd->lasty);
- dy = fac * BLI_RCT_SIZE_Y(&v2d->cur);
+ dy = fac * BLI_rctf_size_y(&v2d->cur);
#if 0
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
@@ -1161,17 +1161,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
/* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
- size = BLI_RCT_SIZE_X(&cur_new);
- zoom = size / BLI_RCT_SIZE_X(&rect);
- center = BLI_RCT_CENTER_X(&cur_new);
+ 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);
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
- size = BLI_RCT_SIZE_Y(&cur_new);
- zoom = size / BLI_RCT_SIZE_Y(&rect);
- center = BLI_RCT_CENTER_Y(&cur_new);
+ 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);
@@ -1221,14 +1221,14 @@ struct SmoothView2DStore {
*/
static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
{
- float size_a[2] = {BLI_RCT_SIZE_X(rect_a),
- BLI_RCT_SIZE_Y(rect_a)};
- float size_b[2] = {BLI_RCT_SIZE_X(rect_b),
- BLI_RCT_SIZE_Y(rect_b)};
- float cent_a[2] = {BLI_RCT_CENTER_X(rect_a),
- BLI_RCT_CENTER_Y(rect_a)};
- float cent_b[2] = {BLI_RCT_CENTER_X(rect_b),
- BLI_RCT_CENTER_Y(rect_b)};
+ float size_a[2] = {BLI_rctf_size_x(rect_a),
+ BLI_rctf_size_y(rect_a)};
+ float size_b[2] = {BLI_rctf_size_x(rect_b),
+ BLI_rctf_size_y(rect_b)};
+ float cent_a[2] = {BLI_rctf_cent_x(rect_a),
+ BLI_rctf_cent_y(rect_a)};
+ float cent_b[2] = {BLI_rctf_cent_x(rect_b),
+ BLI_rctf_cent_y(rect_b)};
float fac_max = 0.0f;
float tfac;
@@ -1501,8 +1501,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
- mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor);
- vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size;
+ mask_size = (float)BLI_rcti_size_x(&v2d->hor);
+ vsm->fac = BLI_rctf_size_x(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
@@ -1517,8 +1517,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
else {
/* vertical scroller - calculate adjustment factor first */
- mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert);
- vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size;
+ mask_size = (float)BLI_rcti_size_y(&v2d->vert);
+ vsm->fac = BLI_rctf_size_y(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
@@ -1798,8 +1798,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
int winx, winy;
/* zoom 1.0 */
- winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
- winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
+ winx = (float)(BLI_rcti_size_x(&v2d->mask) + 1);
+ winy = (float)(BLI_rcti_size_y(&v2d->mask) + 1);
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 0e6b8f77528..0ec99325752 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -54,6 +54,8 @@
#include "../../collada/collada.h"
+#include "io_collada.h"
+
static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -121,32 +123,32 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
- if (collada_export(
- CTX_data_scene(C),
- filepath,
- apply_modifiers,
- export_mesh_type,
- selected,
- include_children,
- include_armatures,
- deform_bones_only,
-
- active_uv_only,
- include_uv_textures,
- include_material_textures,
- use_texture_copies,
-
- use_object_instantiation,
- sort_by_name,
- second_life)) {
+ if (collada_export(CTX_data_scene(C),
+ filepath,
+ apply_modifiers,
+ export_mesh_type,
+ selected,
+ include_children,
+ include_armatures,
+ deform_bones_only,
+
+ active_uv_only,
+ include_uv_textures,
+ include_material_textures,
+ use_texture_copies,
+
+ use_object_instantiation,
+ sort_by_name,
+ second_life)) {
return OPERATOR_FINISHED;
}
else {
+ BKE_report(op->reports, RPT_WARNING, "Export file not created.");
return OPERATOR_CANCELLED;
}
}
-void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
+static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
{
uiLayout *box, *row, *col, *split;
@@ -233,7 +235,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
ot->name = "Export COLLADA";
ot->description = "Save a Collada file";
ot->idname = "WM_OT_collada_export";
-
+
ot->invoke = wm_collada_export_invoke;
ot->exec = wm_collada_export_exec;
ot->poll = WM_operator_winactive;
@@ -241,7 +243,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
ot->flag |= OPTYPE_PRESET;
ot->ui = wm_collada_export_draw;
-
+
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
@@ -296,7 +298,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
static int wm_collada_import_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
-
+
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
@@ -304,9 +306,9 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filename);
if (collada_import(C, filename)) return OPERATOR_FINISHED;
-
+
BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log.");
-
+
return OPERATOR_FINISHED;
}
@@ -315,11 +317,11 @@ void WM_OT_collada_import(wmOperatorType *ot)
ot->name = "Import COLLADA";
ot->description = "Load a Collada file";
ot->idname = "WM_OT_collada_import";
-
+
ot->invoke = WM_operator_filesel;
ot->exec = wm_collada_import_exec;
ot->poll = WM_operator_winactive;
-
+
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE,
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c
index d2b0ddd4e7e..f2a0532932d 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -34,6 +34,8 @@
#include "WM_types.h"
#include "WM_api.h"
+#include "io_ops.h" /* own include */
+
void ED_operatortypes_io(void)
{
#ifdef WITH_COLLADA
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 7fe1ac09df6..a254a6a9278 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -64,7 +64,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
MaskLayer *masklay, *point_masklay;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
- float dist, co[2];
+ float dist = FLT_MAX, co[2];
int width, height;
float u;
float scalex, scaley;
@@ -125,7 +125,7 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
cur_dist = dist_to_line_segment_v2(co, a, b);
- if (point == NULL || cur_dist < dist) {
+ if (cur_dist < dist) {
if (tangent)
sub_v2_v2v2(tangent, &diff_points[2 * i + 2], &diff_points[2 * i]);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 655458bd4cb..fe6567424b6 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -520,12 +520,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
- /* w = BLI_RCT_SIZE_X(&v2d->tot); */
- /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/
+ /* w = BLI_rctf_size_x(&v2d->tot); */
+ /* h = BLI_rctf_size_y(&v2d->tot);/*/
- zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur));
- zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur));
+ zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / BLI_rctf_size_x(&ar->v2d.cur);
+ zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / BLI_rctf_size_y(&ar->v2d.cur);
if (do_scale_applied) {
zoomx /= width;
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 6124947e3b9..561ad004a1d 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -48,6 +48,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
+#include "ED_mask.h" /* own include */
/* ***************************************** */
/* NOTE ABOUT THIS FILE:
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 94e10b53b29..a677f1272a3 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -533,8 +533,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
char *selar;
int a, index;
- int sx = BLI_RCT_SIZE_X(rect) + 1;
- int sy = BLI_RCT_SIZE_Y(rect) + 1;
+ int sx = BLI_rcti_size_x(rect) + 1;
+ int sy = BLI_rcti_size_y(rect) + 1;
me = BKE_mesh_from_object(ob);
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 8b032bb1a3d..fdaddec5246 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -55,9 +55,9 @@
/* ********* add primitive operators ************* */
-static void make_prim_init(bContext *C, const char *idname,
- float *dia, float mat[][4],
- int *state, const float loc[3], const float rot[3], const unsigned int layer)
+static Object *make_prim_init(bContext *C, const char *idname,
+ float *dia, float mat[][4],
+ int *state, const float loc[3], const float rot[3], const unsigned int layer)
{
Object *obedit = CTX_data_edit_object(C);
@@ -74,11 +74,12 @@ static void make_prim_init(bContext *C, const char *idname,
}
*dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
+
+ return obedit;
}
-static void make_prim_finish(bContext *C, int *state, int enter_editmode)
+static void make_prim_finish(bContext *C, Object *obedit, int *state, int enter_editmode)
{
- Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
/* Primitive has all verts selected, use vert select flush
@@ -104,9 +105,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -115,7 +114,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -148,9 +147,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) {
@@ -158,7 +155,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
}
/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -200,9 +197,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -213,7 +208,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -257,9 +252,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -274,7 +267,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -320,9 +313,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
cap_tri = (cap_end == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -334,7 +325,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -379,9 +370,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -393,7 +382,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -436,16 +425,14 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
if (!view_aligned)
rot[0] += (float)M_PI / 2.0f;
- make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) {
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -477,9 +464,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(em, op, "vertout",
@@ -490,7 +475,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
@@ -531,9 +516,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
- make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer);
-
- obedit = CTX_data_edit_object(C);
+ obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer);
em = BMEdit_FromObject(obedit);
if (!EDBM_op_call_and_selectf(
@@ -545,7 +528,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- make_prim_finish(C, &state, enter_editmode);
+ make_prim_finish(C, obedit, &state, enter_editmode);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index 0b7d396b696..c249d764ac1 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -309,7 +309,7 @@ static void vertsearchcallback(void *userdata, int index, const float *UNUSED(co
}
}
-BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
+BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], const float maxdist)
{
BVHTreeNearest hit;
@@ -325,7 +325,7 @@ BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, const float co[3], float maxdist)
float dist, curdist = tree->maxdist, v[3];
int cur = 0, i;
- maxdist = tree->maxdist;
+ /* maxdist = tree->maxdist; */ /* UNUSED */
for (i = 0; i < 3; i++) {
sub_v3_v3v3(v, hit.co, ls[i]->v->co);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 7ecfb712c18..1dcbf574b44 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -29,7 +29,9 @@
* \ingroup edmesh
*/
-#define _USE_MATH_DEFINES
+#ifdef _MSC_VER
+# define _USE_MATH_DEFINES
+#endif
#include "MEM_guardedalloc.h"
@@ -222,7 +224,7 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd)
static void knife_project_v3(KnifeTool_OpData *kcd, const float co[3], float sco[3])
{
- ED_view3d_project_float_v3(kcd->ar, co, sco, kcd->projmat);
+ ED_view3d_project_float_v3_m4(kcd->ar, co, sco, kcd->projmat);
}
static void knife_pos_data_clear(KnifePosData *kpd)
@@ -1203,7 +1205,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
}
knife_project_v3(kcd, p, sp);
- view3d_unproject(mats, view, sp[0], sp[1], 0.0f);
+ ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f);
mul_m4_v3(kcd->ob->imat, view);
if (kcd->cut_through) {
@@ -1386,7 +1388,7 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2],
mval[1] = (float)mval_i[1];
/* unproject to find view ray */
- view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
+ ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f);
if (kcd->is_ortho) {
negate_v3_v3(r_ray, kcd->vc.rv3d->viewinv[2]);
@@ -1753,6 +1755,9 @@ static int knife_update_active(KnifeTool_OpData *kcd)
return 1;
}
+#define SCANFILL_CUTS 0
+#if SCANFILL_CUTS
+
#define MARK 4
#define DEL 8
#define VERT_ON_EDGE 16
@@ -1761,9 +1766,6 @@ static int knife_update_active(KnifeTool_OpData *kcd)
#define BOUNDARY 128
#define FACE_NEW 256
-#define SCANFILL_CUTS 0
-#if SCANFILL_CUTS
-
typedef struct facenet_entry {
struct facenet_entry *next, *prev;
KnifeEdge *kfe;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 60c5244ddbc..8b13cc61d3e 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -29,7 +29,9 @@
*/
#include <float.h>
-#define _USE_MATH_DEFINES
+#ifdef _MSC_VER
+# define _USE_MATH_DEFINES
+#endif
#include <math.h>
#include <string.h>
#include <ctype.h>
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 4d4a890300f..53b877f2a6e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -61,8 +61,8 @@ static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4],
{
float vec1[3], vec2[3];
- ED_view3d_project_float_v2(ar, co1, vec1, mat);
- ED_view3d_project_float_v2(ar, co2, vec2, mat);
+ ED_view3d_project_float_v2_m4(ar, co1, vec1, mat);
+ ED_view3d_project_float_v2_m4(ar, co2, vec2, mat);
/* TODO: use dist_squared_to_line_segment_v2() looks like we only ever use for comparison */
return dist_to_line_segment_v2(mvalf, vec1, vec2);
@@ -97,11 +97,11 @@ static float edbm_rip_edge_side_measure(BMEdge *e, BMLoop *e_l,
mid_v3_v3v3(cent, v1_other->co, v2_other->co);
mid_v3_v3v3(mid, e->v1->co, e->v2->co);
- ED_view3d_project_float_v2(ar, cent, cent, projectMat);
- ED_view3d_project_float_v2(ar, mid, mid, projectMat);
+ ED_view3d_project_float_v2_m4(ar, cent, cent, projectMat);
+ ED_view3d_project_float_v2_m4(ar, mid, mid, projectMat);
- ED_view3d_project_float_v2(ar, e->v1->co, e_v1_co, projectMat);
- ED_view3d_project_float_v2(ar, e->v2->co, e_v2_co, projectMat);
+ ED_view3d_project_float_v2_m4(ar, e->v1->co, e_v1_co, projectMat);
+ ED_view3d_project_float_v2_m4(ar, e->v2->co, e_v2_co, projectMat);
sub_v2_v2v2(vec, cent, mid);
normalize_v2(vec);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index de9b3c5ba05..f6ae661a369 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -487,7 +487,6 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int
vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]);
vec[1] = eed->v1->co[1] + labda * (eed->v2->co[1] - eed->v1->co[1]);
vec[2] = eed->v1->co[2] + labda * (eed->v2->co[2] - eed->v1->co[2]);
- mul_m4_v3(data->vc.obedit->obmat, vec);
if (ED_view3d_clipping_test(data->vc.rv3d, vec, TRUE) == 0) {
data->dist = distance;
@@ -531,7 +530,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, int *dist)
data.closest = NULL;
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
- mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, 2);
+ mesh_foreachScreenEdge(vc, findnearestedge__doClosest, &data, V3D_CLIP_TEST_REGION);
*dist = data.dist;
return data.closest;
@@ -1058,8 +1057,8 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
/* We can't be sure this has already been set... */
ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
- project_float_noclip(vc.ar, eed->v1->co, v1_co);
- project_float_noclip(vc.ar, eed->v2->co, v2_co);
+ ED_view3d_project_float_noclip(vc.ar, eed->v1->co, v1_co);
+ ED_view3d_project_float_noclip(vc.ar, eed->v2->co, v2_co);
#if 0
printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co),
len_squared_v2v2(mvalf, v2_co));
@@ -1087,7 +1086,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
float co[2], tdist;
BM_face_calc_center_mean(f, cent);
- project_float_noclip(vc.ar, cent, co);
+ ED_view3d_project_float_noclip(vc.ar, cent, co);
tdist = len_squared_v2v2(mvalf, co);
if (tdist < best_dist) {
/* printf("Best face: %p (%f)\n", f, tdist);*/
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c
index 86ea5bc8651..bd1d13f3528 100644
--- a/source/blender/editors/mesh/editmesh_slide.c
+++ b/source/blender/editors/mesh/editmesh_slide.c
@@ -388,10 +388,10 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2])
edge = vso->edge_frame[i];
mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co);
- project_float_noclip(vso->active_region, v1_proj, v1_proj);
+ ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj);
mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co);
- project_float_noclip(vso->active_region, v2_proj, v2_proj);
+ ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj);
dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj);
if (dist < min_dist) {
@@ -455,10 +455,10 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event)
/* Project points onto screen and do interpolation in 2D */
mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co);
- project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
+ ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj);
mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co);
- project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
+ ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj);
closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 9e83742a909..7c700cc9731 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -163,7 +163,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes
float mval[2], vec[3], no_dummy[3];
int dist_dummy;
mul_v3_m4v3(vec, obedit->obmat, eve->co);
- project_float_noclip(ar, vec, mval);
+ ED_view3d_project_float_noclip(ar, vec, mval);
if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) {
mul_v3_m4v3(eve->co, obedit->imat, vec);
}
@@ -761,8 +761,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
float co1[3], co2[3];
mul_v3_m4v3(co1, vc.obedit->obmat, eed->v1->co);
mul_v3_m4v3(co2, vc.obedit->obmat, eed->v2->co);
- project_float_noclip(vc.ar, co1, co1);
- project_float_noclip(vc.ar, co2, co2);
+ ED_view3d_project_float_noclip(vc.ar, co1, co1);
+ ED_view3d_project_float_noclip(vc.ar, co2, co2);
/* 2D rotate by 90d while adding.
* (x, y) = (y, -x)
@@ -2526,12 +2526,6 @@ void MESH_OT_solidify(wmOperatorType *ot)
RNA_def_property_ui_range(prop, -10, 10, 0.1, 4);
}
-#define TRAIL_POLYLINE 1 /* For future use, They don't do anything yet */
-#define TRAIL_FREEHAND 2
-#define TRAIL_MIXED 3 /* (1|2) */
-#define TRAIL_AUTO 4
-#define TRAIL_MIDPOINTS 8
-
typedef struct CutCurve {
float x;
float y;
@@ -2776,7 +2770,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
copy_v3_v3(co, bv->co);
co[3] = 1.0f;
mul_m4_v4(obedit->obmat, co);
- project_float(ar, co, scr);
+ ED_view3d_project_float(ar, co, scr);
BLI_ghash_insert(gh, bv, scr);
}
@@ -2858,9 +2852,6 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old)
{
Base *base_new;
- BMIter iter;
- BMVert *v;
- BMEdge *e;
Object *obedit = base_old->object;
BMesh *bm_new;
@@ -2886,15 +2877,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh
BMO_op_callf(bm_old, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
"delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES);
- /* deselect loose data - this used to get deleted */
- BM_ITER_MESH (e, &iter, bm_old, BM_EDGES_OF_MESH) {
- BM_edge_select_set(bm_old, e, FALSE);
- }
-
- /* clean up any loose verts */
- BM_ITER_MESH (v, &iter, bm_old, BM_VERTS_OF_MESH) {
- BM_vert_select_set(bm_old, v, FALSE);
- }
+ /* deselect loose data - this used to get deleted,
+ * we could de-select edges and verts only, but this turns out to be less complicated
+ * since de-selecting all skips selection flushing logic */
+ BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
BM_mesh_normals_update(bm_new, FALSE);
@@ -2908,7 +2894,10 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh
static int mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old)
{
- /* tag -> select */
+ /* we may have tags from previous operators */
+ BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, FALSE);
+
+ /* sel -> tag */
BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, TRUE, BM_ELEM_SELECT);
return mesh_separate_tagged(bmain, scene, base_old, bm_old);
@@ -4721,7 +4710,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
- factor = -len_v2(mdiff) / opdata->initial_length + 1.0f;
+ factor = opdata->initial_length / -len_v2(mdiff) + 1.0f;
/* Fake shift-transform... */
if (event->shift) {
@@ -5085,9 +5074,9 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
mdiff[1] = opdata->mcenter[1] - event->mval[1];
if (opdata->modify_depth)
- amount = opdata->old_depth + len_v2(mdiff) / opdata->initial_length - 1.0f;
+ amount = opdata->old_depth + opdata->initial_length / len_v2(mdiff) - 1.0f;
else
- amount = opdata->old_thickness - len_v2(mdiff) / opdata->initial_length + 1.0f;
+ amount = opdata->old_thickness - opdata->initial_length / len_v2(mdiff) + 1.0f;
/* Fake shift-transform... */
if (opdata->shift)
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 03e2f2691a8..b844ba0baa2 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -535,6 +535,16 @@ static void *getEditMesh(bContext *C)
typedef struct UndoMesh {
Mesh me;
int selectmode;
+
+ /** \note
+ * this isn't a prefect solution, if you edit keys and change shapes this works well (fixing [#32442]),
+ * but editing shape keys, going into object mode, removing or changing their order,
+ * then go back into editmode and undo will give issues - where the old index will be out of sync
+ * with the new object index.
+ *
+ * There are a few ways this could be made to work but for now its a known limitation with mixing
+ * object and editmode operations - Campbell */
+ int shapenr;
} UndoMesh;
/* undo simply makes copies of a bmesh */
@@ -546,13 +556,14 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata)
UndoMesh *um = MEM_callocN(sizeof(UndoMesh), "undo Mesh");
/* make sure shape keys work */
- um->me.key = obme->key ? copy_key_nolib(obme->key) : NULL;
+ um->me.key = obme->key ? BKE_key_copy_nolib(obme->key) : NULL;
/* BM_mesh_validate(em->bm); */ /* for troubleshooting */
BM_mesh_bm_to_me(em->bm, &um->me, FALSE);
um->selectmode = em->selectmode;
+ um->shapenr = em->bm->shapenr;
return um;
}
@@ -564,7 +575,7 @@ static void undoMesh_to_editbtMesh(void *umv, void *em_v, void *UNUSED(obdata))
UndoMesh *um = umv;
BMesh *bm;
- ob->shapenr = em->bm->shapenr;
+ ob->shapenr = em->bm->shapenr = um->shapenr;
EDBM_mesh_free(em);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 09d89a961e4..a52c8d47ecd 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -47,6 +47,8 @@
#include "BLI_array.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
+#include "BLI_linklist.h"
+#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -74,6 +76,64 @@
#include "mesh_intern.h"
+static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
+{
+ CustomData *data;
+ BMesh *bm = (me->edit_btmesh) ? me->edit_btmesh->bm : NULL;
+ int tot;
+
+ /* this */
+ switch (htype) {
+ case BM_VERT:
+ if (bm) {
+ data = &bm->vdata;
+ tot = bm->totvert;
+ }
+ else {
+ data = &me->vdata;
+ tot = me->totvert;
+ }
+ break;
+ case BM_EDGE:
+ if (bm) {
+ data = &bm->edata;
+ tot = bm->totedge;
+ }
+ else {
+ data = &me->edata;
+ tot = me->totedge;
+ }
+ break;
+ case BM_LOOP:
+ if (bm) {
+ data = &bm->ldata;
+ tot = bm->totloop;
+ }
+ else {
+ data = &me->ldata;
+ tot = me->totloop;
+ }
+ break;
+ case BM_FACE:
+ if (bm) {
+ data = &bm->pdata;
+ tot = bm->totface;
+ }
+ else {
+ data = &me->pdata;
+ tot = me->totpoly;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ tot = 0;
+ data = NULL;
+ }
+
+ *r_tot = tot;
+ return data;
+}
+
#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer)
{
@@ -85,24 +145,10 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
int i, actindex, rndindex, cloneindex, stencilindex, tot;
if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) {
- if (me->edit_btmesh) {
- data = &me->edit_btmesh->bm->ldata;
- tot = me->edit_btmesh->bm->totloop;
- }
- else {
- data = &me->ldata;
- tot = me->totloop;
- }
+ data = mesh_customdata_get_type(me, BM_LOOP, &tot);
}
else {
- if (me->edit_btmesh) {
- data = &me->edit_btmesh->bm->pdata;
- tot = me->edit_btmesh->bm->totface;
- }
- else {
- data = &me->pdata;
- tot = me->totpoly;
- }
+ data = mesh_customdata_get_type(me, BM_FACE, &tot);
}
index = CustomData_get_layer_index(data, type);
@@ -701,22 +747,20 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/*********************** sticky operators ************************/
+/* *** CustomData clear functions, we need an operator for each *** */
-static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
+static int mesh_customdata_clear_exec__internal(bContext *C,
+ char htype, int type)
{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- Object *ob = ED_object_context(C);
- Mesh *me = ob->data;
+ Object *obedit = ED_object_context(C);
+ Mesh *me = obedit->data;
- /* why is this commented out? */
-#if 0
- if (me->msticky)
- return OPERATOR_CANCELLED;
-#endif
+ int tot;
+ CustomData *data = mesh_customdata_get_type(me, htype, &tot);
- RE_make_sticky(scene, v3d);
+ BLI_assert(CustomData_layertype_is_singleton(type) == TRUE);
+
+ CustomData_free_layers(data, type, tot);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
@@ -724,48 +768,79 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void MESH_OT_sticky_add(wmOperatorType *ot)
+/* Clear Mask */
+static int mesh_customdata_clear_mask_poll(bContext *C)
+{
+ Object *ob = ED_object_context(C);
+ if (ob && ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+
+ /* special case - can't run this if we're in sculpt mode */
+ if (ob->mode & OB_MODE_SCULPT) {
+ return FALSE;
+ }
+
+ if (me->id.lib == NULL) {
+ CustomData *data = GET_CD_DATA(me, vdata);
+ if (CustomData_has_layer(data, CD_PAINT_MASK)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_PAINT_MASK);
+}
+
+void MESH_OT_customdata_clear_mask(wmOperatorType *ot)
{
+
/* identifiers */
- ot->name = "Add Sticky";
- ot->description = "Add sticky UV texture layer";
- ot->idname = "MESH_OT_sticky_add";
-
+ ot->name = "Clear Sculpt-Mask Data";
+ ot->idname = "MESH_OT_customdata_clear_mask";
+ ot->description = "Clear vertex sculpt masking data from the mesh";
+
/* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_sticky_add_exec;
+ ot->exec = mesh_customdata_clear_mask_exec;
+ ot->poll = mesh_customdata_clear_mask_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
+/* Clear Skin */
+static int mesh_customdata_clear_skin_poll(bContext *C)
{
Object *ob = ED_object_context(C);
- Mesh *me = ob->data;
- if (!me->msticky)
- return OPERATOR_CANCELLED;
-
- CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
- me->msticky = NULL;
-
- DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
-
- return OPERATOR_FINISHED;
+ if (ob && ob->type == OB_MESH) {
+ Mesh *me = ob->data;
+ if (me->id.lib == NULL) {
+ CustomData *data = GET_CD_DATA(me, vdata);
+ if (CustomData_has_layer(data, CD_MVERT_SKIN)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ return mesh_customdata_clear_exec__internal(C, BM_VERT, CD_MVERT_SKIN);
}
-void MESH_OT_sticky_remove(wmOperatorType *ot)
+void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Sticky";
- ot->description = "Remove sticky UV texture layer";
- ot->idname = "MESH_OT_sticky_remove";
-
+ ot->name = "Clear Skin Data";
+ ot->idname = "MESH_OT_customdata_clear_skin";
+ ot->description = "Clear vertex skin layer";
+
/* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_sticky_remove_exec;
+ ot->exec = mesh_customdata_clear_skin_exec;
+ ot->poll = mesh_customdata_clear_skin_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index aed57141c2a..b68c1836992 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -189,8 +189,10 @@ void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
-void MESH_OT_sticky_add(struct wmOperatorType *ot);
-void MESH_OT_sticky_remove(struct wmOperatorType *ot);
+/* no create_mask yet */
+void MESH_OT_customdata_clear_mask(struct wmOperatorType *ot);
+void MESH_OT_customdata_clear_skin(struct wmOperatorType *ot);
+
void MESH_OT_drop_named_image(struct wmOperatorType *ot);
/* ************* bmesh_tools.c ***********/
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 7f73851f2a8..ccf91958e08 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -136,7 +136,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_vertices_smooth);
WM_operatortype_append(MESH_OT_noise);
WM_operatortype_append(MESH_OT_flip_normals);
- //WM_operatortype_append(MESH_OT_knife_cut);
WM_operatortype_append(MESH_OT_rip);
WM_operatortype_append(MESH_OT_blend_from_shape);
WM_operatortype_append(MESH_OT_shape_propagate_to_all);
@@ -145,8 +144,8 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_uv_texture_remove);
WM_operatortype_append(MESH_OT_vertex_color_add);
WM_operatortype_append(MESH_OT_vertex_color_remove);
- WM_operatortype_append(MESH_OT_sticky_add);
- WM_operatortype_append(MESH_OT_sticky_remove);
+ WM_operatortype_append(MESH_OT_customdata_clear_mask);
+ WM_operatortype_append(MESH_OT_customdata_clear_skin);
WM_operatortype_append(MESH_OT_drop_named_image);
WM_operatortype_append(MESH_OT_edgering_select);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index a7467ee4c79..f2b7a2e9c22 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -104,7 +104,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
MLoop *mloop = NULL;
Key *key, *nkey = NULL;
KeyBlock *kb, *okb, *kbn;
- float imat[4][4], cmat[4][4], *fp1, *fp2, curpos;
+ float imat[4][4], cmat[4][4], *fp1, *fp2;
int a, b, totcol, totmat = 0, totedge = 0, totvert = 0, ok = 0;
int totloop = 0, totpoly = 0, vertofs, *matmap = NULL;
int i, j, index, haskey = 0, edgeofs, loopofs, polyofs;
@@ -196,7 +196,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
else if (haskey) {
/* add a new key-block and add to the mesh */
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
}
@@ -243,29 +243,29 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* if this mesh has shapekeys, check if destination mesh already has matching entries too */
if (me->key && key) {
- for (kb = me->key->block.first; kb; kb = kb->next) {
+ /* for remapping KeyBlock.relative */
+ int *index_map = MEM_mallocN(sizeof(int) * me->key->totkey, __func__);
+ KeyBlock **kb_map = MEM_mallocN(sizeof(KeyBlock *) * me->key->totkey, __func__);
+
+ for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) {
+ BLI_assert(i < me->key->totkey);
+
+ kbn = BKE_keyblock_find_name(key, kb->name);
/* if key doesn't exist in destination mesh, add it */
- if (key_get_named_keyblock(key, kb->name) == NULL) {
- /* copy this existing one over to the new shapekey block */
- kbn = MEM_dupallocN(kb);
- kbn->prev = kbn->next = NULL;
-
+ if (kbn) {
+ index_map[i] = BLI_findindex(&key->block, kbn);
+ }
+ else {
+ index_map[i] = key->totkey;
+
+ kbn = BKE_keyblock_add(key, kb->name);
+
+ BKE_keyblock_copy_settings(kbn, kb);
+
/* adjust settings to fit (allocate a new data-array) */
kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
- kbn->totelem = totvert;
- kbn->weights = NULL;
-
- okb = key->block.last;
- curpos = (okb) ? okb->pos : -0.1f;
- if (key->type == KEY_RELATIVE)
- kbn->pos = curpos + 0.1f;
- else
- kbn->pos = curpos;
-
- BLI_addtail(&key->block, kbn);
- key->totkey++;
- if (key->totkey == 1) key->refkey = kbn;
-
+ kbn->totelem = totvert;
+
/* XXX 2.5 Animato */
#if 0
/* also, copy corresponding ipo-curve to ipo-block if applicable */
@@ -275,13 +275,26 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
#endif
}
+
+ kb_map[i] = kbn;
}
+
+ /* remap relative index values */
+ for (kb = me->key->block.first, i = 0; kb; kb = kb->next, i++) {
+ if (LIKELY(kb->relative < me->key->totkey)) { /* sanity check, should always be true */
+ kb_map[i]->relative = index_map[kb->relative];
+ }
+ }
+
+ MEM_freeN(index_map);
+ MEM_freeN(kb_map);
}
}
}
}
CTX_DATA_END;
-
+
+
/* setup new data for destination mesh */
memset(&vdata, 0, sizeof(vdata));
memset(&edata, 0, sizeof(edata));
@@ -356,7 +369,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this mesh has such a shapekey */
- okb = key_get_named_keyblock(me->key, kb->name);
+ okb = me->key ? BKE_keyblock_find_name(me->key, kb->name) : NULL;
+
if (okb) {
/* copy this mesh's shapekey to the destination shapekey (need to transform first) */
fp2 = ((float *)(okb->data));
@@ -386,7 +400,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this was one of the original shapekeys */
- okb = key_get_named_keyblock(nkey, kb->name);
+ okb = BKE_keyblock_find_name(nkey, kb->name);
if (okb) {
/* copy this mesh's shapekey to the destination shapekey */
fp2 = ((float *)(okb->data));
@@ -427,8 +441,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
if ((mmd = get_multires_modifier(scene, base->object, TRUE))) {
ED_object_iter_other(bmain, base->object, TRUE,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
}
}
@@ -548,6 +562,12 @@ int join_mesh_exec(bContext *C, wmOperator *op)
MEM_freeN(nkey);
}
+ /* ensure newly inserted keys are time sorted */
+ if (key && (key->type != KEY_RELATIVE)) {
+ BKE_key_sort(key);
+ }
+
+
DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call
#if 0
@@ -607,12 +627,12 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
if (key == NULL) {
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
/* first key added, so it was the basis. initialize it with the existing mesh */
- kb = add_keyblock(key, NULL);
- mesh_to_key(me, kb);
+ kb = BKE_keyblock_add(key, NULL);
+ BKE_key_convert_from_mesh(me, kb);
}
/* now ready to add new keys from selected meshes */
@@ -628,7 +648,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
if (!dm) continue;
- kb = add_keyblock(key, base->object->id.name + 2);
+ kb = BKE_keyblock_add(key, base->object->id.name + 2);
DM_to_meshkey(dm, me, kb);
@@ -709,9 +729,9 @@ static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const
float fx, fy, fz;
int vx, vy, vz;
- if (!finite(co[0]) ||
- !finite(co[1]) ||
- !finite(co[2]))
+ if ((finite(co[0]) == FALSE) ||
+ (finite(co[1]) == FALSE) ||
+ (finite(co[2]) == FALSE))
{
return;
}
@@ -940,9 +960,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
intptr_t poinval;
/* ignore nan verts */
- if (!finite(co[0]) ||
- !finite(co[1]) ||
- !finite(co[2]))
+ if ((finite(co[0]) == FALSE) ||
+ (finite(co[1]) == FALSE) ||
+ (finite(co[2]) == FALSE))
{
return NULL;
}
@@ -1217,7 +1237,7 @@ int ED_mesh_pick_face_vert(bContext *C, Mesh *me, Object *ob, const int mval[2],
const int v_idx = me->mloop[mp->loopstart + fidx].v;
dm->getVertCo(dm, v_idx, co);
mul_m4_v3(ob->obmat, co);
- project_float_noclip(ar, co, sco);
+ ED_view3d_project_float_noclip(ar, co, sco);
len = len_squared_v2v2(mval_f, sco);
if (len < len_best) {
len_best = len;
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 50d5569c483..22ccd7bbed8 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -98,9 +98,8 @@ void load_editMball(Object *UNUSED(obedit))
}
/* Add metaelem primitive to metaball object (which is in edit mode) */
-MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname))
+MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[4][4], int type, int UNUSED(newname))
{
- Object *obedit = CTX_data_edit_object(C);
MetaBall *mball = (MetaBall *)obedit->data;
MetaElem *ml;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index d90735ca5ac..4942b9e4390 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -198,7 +198,7 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
/********************* Add Object Operator ********************/
-void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr)
+static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(scene), struct PointerRNA *ptr)
{
RNA_struct_idprops_unset(ptr, "rotation");
}
@@ -439,7 +439,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
((Curve *)ob->data)->flag |= CU_PATH | CU_3D;
ED_object_enter_editmode(C, 0);
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
- BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_PATH, 1));
+ BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1));
if (!enter_editmode)
ED_object_exit_editmode(C, EM_FREEDATA);
@@ -574,7 +574,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
- /* elem= (MetaElem *) */ add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob);
+ /* elem= (MetaElem *) */ add_metaball_primitive(C, obedit, mat, RNA_enum_get(op->ptr, "type"), newob);
/* userdef */
if (newob && !enter_editmode) {
@@ -1826,7 +1826,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
/* check if obdata is copied */
if (didit) {
- Key *key = ob_get_key(obn);
+ Key *key = BKE_key_from_object(obn);
if (dupflag & USER_DUP_ACT) {
bActuator *act;
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index f9b73a56403..0ea2f78a415 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -69,6 +69,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "GPU_draw.h" /* GPU_free_image */
@@ -685,7 +686,7 @@ static void apply_heights_data(void *bake_data)
}
}
- ibuf->userflags = IB_RECT_INVALID;
+ ibuf->userflags = IB_RECT_INVALID | IB_DISPLAY_BUFFER_INVALID;
}
static void free_heights_data(void *bake_data)
@@ -769,6 +770,8 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
char *rrgb = (char *)ibuf->rect + pixel * 4;
rrgb[3] = 255;
}
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
/* MultiresBake callback for normals' baking
@@ -826,6 +829,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
rgb_float_to_uchar(rrgb, vec);
rrgb[3] = 255;
}
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
static void count_images(MultiresBakeRender *bkr)
@@ -895,7 +900,7 @@ static void finish_images(MultiresBakeRender *bkr)
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
- ibuf->userflags |= IB_BITMAPDIRTY;
+ ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;;
if (ibuf->rect_float)
ibuf->userflags |= IB_RECT_INVALID;
@@ -1324,11 +1329,12 @@ static int test_bake_internal(bContext *C, ReportList *reports)
static void init_bake_internal(BakeRender *bkr, bContext *C)
{
Scene *scene = CTX_data_scene(C);
+ bScreen *sc = CTX_wm_screen(C);
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
- bkr->sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */
+ bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */
bkr->main = CTX_data_main(C);
bkr->scene = scene;
bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL;
@@ -1369,6 +1375,7 @@ static void finish_bake_internal(BakeRender *bkr)
if (ima->ok == IMA_OK_LOADED) {
if (ibuf) {
if (ibuf->userflags & IB_BITMAPDIRTY) {
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
GPU_free_image(ima);
imb_freemipmapImBuf(ibuf);
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index aa885320b37..f95a186990e 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -649,11 +649,11 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
for (base = FIRSTBASE; base; base = base->next) {
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
if (nr == 1) { /* replace */
- copy_properties(&base->object->prop, &ob->prop);
+ BKE_bproperty_copy_list(&base->object->prop, &ob->prop);
}
else {
for (prop = ob->prop.first; prop; prop = prop->next) {
- set_ob_property(base->object, prop);
+ BKE_bproperty_object_set(base->object, prop);
}
}
}
@@ -665,7 +665,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
if (prop) {
for (base = FIRSTBASE; base; base = base->next) {
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
- set_ob_property(base->object, prop);
+ BKE_bproperty_object_set(base->object, prop);
}
}
}
@@ -1585,7 +1585,7 @@ static int game_property_new(bContext *C, wmOperator *op)
char name[MAX_NAME];
int type = RNA_enum_get(op->ptr, "type");
- prop = new_property(type);
+ prop = BKE_bproperty_new(type);
BLI_addtail(&ob->prop, prop);
RNA_string_get(op->ptr, "name", name);
@@ -1593,7 +1593,7 @@ static int game_property_new(bContext *C, wmOperator *op)
BLI_strncpy(prop->name, name, sizeof(prop->name));
}
- unique_property(NULL, prop, 0); // make_unique_prop_names(prop->name);
+ BKE_bproperty_unique(NULL, prop, 0); // make_unique_prop_names(prop->name);
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -1631,7 +1631,7 @@ static int game_property_remove(bContext *C, wmOperator *op)
if (prop) {
BLI_remlink(&ob->prop, prop);
- free_property(prop);
+ BKE_bproperty_free(prop);
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -1711,7 +1711,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
{
if (ob != ob_iter)
- set_ob_property(ob_iter, prop);
+ BKE_bproperty_object_set(ob_iter, prop);
} CTX_DATA_END;
}
}
@@ -1721,12 +1721,12 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
{
if (ob != ob_iter) {
if (type == COPY_PROPERTIES_REPLACE) {
- copy_properties(&ob_iter->prop, &ob->prop);
+ BKE_bproperty_copy_list(&ob_iter->prop, &ob->prop);
}
else {
/* merge - the default when calling with no argument */
for (prop = ob->prop.first; prop; prop = prop->next) {
- set_ob_property(ob_iter, prop);
+ BKE_bproperty_object_set(ob_iter, prop);
}
}
}
@@ -1763,7 +1763,7 @@ static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
{
- free_properties(&ob_iter->prop);
+ BKE_bproperty_free_list(&ob_iter->prop);
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 7c8386d55dc..a6afe6b2d04 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -585,13 +585,11 @@ void OBJECT_OT_hook_add_newobj(wmOperatorType *ot)
static int object_hook_remove_exec(bContext *C, wmOperator *op)
{
int num = RNA_enum_get(op->ptr, "modifier");
- Object *ob = NULL;
+ Object *ob = CTX_data_edit_object(C);
HookModifierData *hmd = NULL;
- ob = CTX_data_edit_object(C);
hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
-
- if (!ob || !hmd) {
+ if (!hmd) {
BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 89f9f5de311..1f7be0bf9a6 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -92,9 +92,9 @@ void make_editLatt(Object *obedit)
free_editLatt(obedit);
- actkey = ob_get_keyblock(obedit);
+ actkey = BKE_keyblock_from_object(obedit);
if (actkey)
- key_to_latt(actkey, lt);
+ BKE_key_convert_to_lattice(actkey, lt);
lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt");
lt->editlatt->latt = MEM_dupallocN(lt);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 4858fdf1c35..6fe7ad05a70 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -565,15 +565,15 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
}
if (key == NULL) {
- key = me->key = add_key((ID *)me);
+ key = me->key = BKE_key_add((ID *)me);
key->type = KEY_RELATIVE;
/* if that was the first key block added, then it was the basis.
* Initialize it with the mesh, and add another for the modifier */
- kb = add_keyblock(key, NULL);
- mesh_to_key(me, kb);
+ kb = BKE_keyblock_add(key, NULL);
+ BKE_key_convert_from_mesh(me, kb);
}
- kb = add_keyblock(key, md->name);
+ kb = BKE_keyblock_add(key, md->name);
DM_to_meshkey(dm, me, kb);
dm->release(dm);
@@ -1692,11 +1692,9 @@ static void skin_armature_bone_create(Object *skin_ob,
v = (e->v1 == parent_v ? e->v2 : e->v1);
- bone = MEM_callocN(sizeof(EditBone),
- "skin_armature_bone_create EditBone");
+ bone = ED_armature_edit_bone_add(arm, "Bone");
bone->parent = parent_bone;
- bone->layer = 1;
bone->flag |= BONE_CONNECTED;
copy_v3_v3(bone->head, mvert[parent_v].co);
@@ -1704,8 +1702,6 @@ static void skin_armature_bone_create(Object *skin_ob,
bone->rad_head = bone->rad_tail = 0.25;
BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx);
- BLI_addtail(arm->edbo, bone);
-
/* add bDeformGroup */
if ((dg = ED_vgroup_add_name(skin_ob, bone->name))) {
ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
@@ -1770,16 +1766,13 @@ static Object *modifier_skin_armature_create(struct Scene *scene,
* a fake root bone (have it going off in the Y direction
* (arbitrary) */
if (emap[v].count > 1) {
- bone = MEM_callocN(sizeof(EditBone), "EditBone");
+ bone = ED_armature_edit_bone_add(arm, "Bone");
copy_v3_v3(bone->head, me->mvert[v].co);
copy_v3_v3(bone->tail, me->mvert[v].co);
- bone->layer = 1;
bone->head[1] = 1.0f;
bone->rad_head = bone->rad_tail = 0.25;
-
- BLI_addtail(arm->edbo, bone);
}
if (emap[v].count >= 1) {
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 7eb8cc01db9..ff7f33f6107 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -723,7 +723,7 @@ static short objects_share_gameprop(Object *a, Object *b)
/*make a copy of all its properties*/
for (prop = a->prop.first; prop; prop = prop->next) {
- if (get_ob_property(b, prop->name) )
+ if (BKE_bproperty_object_get(b, prop->name) )
return 1;
}
return 0;
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 40b653a62fd..cfd4945688b 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -78,7 +78,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int f
{
KeyBlock *kb;
if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) {
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
/* for absolute shape keys, new keys may not be added last */
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
@@ -95,7 +95,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
Key *key;
//IpoCurve *icu;
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key == NULL)
return 0;
@@ -115,14 +115,14 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
/* apply new basis key on original data */
switch (ob->type) {
case OB_MESH:
- key_to_mesh(key->refkey, ob->data);
+ BKE_key_convert_to_mesh(key->refkey, ob->data);
break;
case OB_CURVE:
case OB_SURF:
- key_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data));
+ BKE_key_convert_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data));
break;
case OB_LATTICE:
- key_to_latt(key->refkey, ob->data);
+ BKE_key_convert_to_lattice(key->refkey, ob->data);
break;
}
}
@@ -155,7 +155,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
KeyBlock *kb;
Key *key;
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key == NULL)
return 0;
@@ -323,8 +323,8 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
if (!key || !kb)
return OPERATOR_CANCELLED;
@@ -357,8 +357,8 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- Key *key = ob_get_key(ob);
- KeyBlock *kb = ob_get_keyblock(ob);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
float cfra = 0.0f;
if (!key || !kb)
@@ -419,7 +419,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
int type = RNA_enum_get(op->ptr, "type");
- Key *key = ob_get_key(ob);
+ Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb, *kb_other;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index b7ce32aa10a..72bbcda2b5e 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -409,7 +409,7 @@ static int key_test_depth(PEData *data, const float co[3])
if ((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0)
return 1;
- project_short(data->vc.ar, co, wco);
+ ED_view3d_project_short(data->vc.ar, co, wco);
if (wco[0] == IS_CLIPPED)
return 0;
@@ -447,7 +447,7 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float *
float dx, dy, dist;
int sco[2];
- project_int(data->vc.ar, co, sco);
+ ED_view3d_project_int(data->vc.ar, co, sco);
if (sco[0] == IS_CLIPPED)
return 0;
@@ -473,7 +473,7 @@ static int key_inside_rect(PEData *data, const float co[3])
{
int sco[2];
- project_int(data->vc.ar, co, sco);
+ ED_view3d_project_int(data->vc.ar, co, sco);
if (sco[0] == IS_CLIPPED)
return 0;
@@ -1666,7 +1666,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
LOOP_KEYS {
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- project_int(ar, co, vertco);
+ ED_view3d_project_int(ar, co, vertco);
if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
@@ -1686,7 +1686,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- project_int(ar, co, vertco);
+ ED_view3d_project_int(ar, co, vertco);
if (BLI_lasso_is_point_inside(mcords, moves, vertco[0], vertco[1], IS_CLIPPED) &&
key_test_depth(&data, co))
{
@@ -2802,7 +2802,7 @@ static void brush_cut(PEData *data, int pa_index)
cut=0;
- project_int_noclip(ar, key->co, vertco);
+ ED_view3d_project_int_noclip(ar, key->co, vertco);
x0= (float)vertco[0];
x1= (float)vertco[1];
@@ -2820,7 +2820,7 @@ static void brush_cut(PEData *data, int pa_index)
else {
/* calculate path time closest to root that was inside the circle */
for (k=1, key++; k<=keys; k++, key++) {
- project_int_noclip(ar, key->co, vertco);
+ ED_view3d_project_int_noclip(ar, key->co, vertco);
if (key_test_depth(data, key->co) == 0) {
x0= (float)vertco[0];
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index f95b07bd71e..099d868a0ad 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -782,7 +782,7 @@ static void fluidbake_endjob(void *customdata)
}
}
-int runSimulationCallback(void *data, int status, int frame)
+static int runSimulationCallback(void *data, int status, int frame)
{
FluidBakeJob *fb = (FluidBakeJob *)data;
elbeemSimulationSettings *settings = fb->settings;
@@ -1095,7 +1095,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
return 1;
}
-void fluidsimFreeBake(Object *UNUSED(ob))
+static void UNUSED_FUNCTION(fluidsimFreeBake)(Object *UNUSED(ob))
{
/* not implemented yet */
}
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index b236b555850..c08ea2b6429 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -61,6 +61,7 @@
#include "ED_object.h"
#include "RE_pipeline.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -78,8 +79,8 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
{
float *rectf = NULL;
int ymin, ymax, xmin, xmax;
- int rymin, rxmin, predivide, profile_from;
- unsigned char *rectc;
+ int rymin, rxmin;
+ /* unsigned char *rectc; */ /* UNUSED */
/* if renrect argument, we only refresh scanlines */
if (renrect) {
@@ -123,8 +124,14 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
if (rr->rectf)
rectf = rr->rectf;
else {
- if (rr->rect32)
+ if (rr->rect32) {
+ /* special case, currently only happens with sequencer rendering,
+ * which updates the whole frame, so we can only mark display buffer
+ * as invalid here (sergey)
+ */
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
return;
+ }
else {
if (rr->renlay == NULL || rr->renlay->rectf == NULL) return;
rectf = rr->renlay->rectf;
@@ -136,20 +143,11 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
imb_addrectImBuf(ibuf);
rectf += 4 * (rr->rectx * ymin + xmin);
- rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin);
-
- if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- profile_from = IB_PROFILE_LINEAR_RGB;
- predivide = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
- }
- else {
- profile_from = IB_PROFILE_SRGB;
- predivide = 0;
- }
+ /* rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin); */ /* UNUSED */
- IMB_buffer_byte_from_float(rectc, rectf,
- 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
- xmax, ymax, ibuf->x, rr->rectx);
+ IMB_partial_display_buffer_update(ibuf, rectf, NULL, rr->rectx, rxmin, rymin,
+ &scene->view_settings, &scene->display_settings,
+ rxmin, rymin, rxmin + xmax, rymin + ymax);
}
/* ****************************** render invoking ***************** */
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 55df1caf3eb..d9618e89b68 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -63,6 +63,7 @@
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -143,22 +144,30 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
ibuf = BKE_sequencer_give_ibuf(context, CFRA, chanshown);
if (ibuf) {
+ ImBuf *linear_ibuf;
+
BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y));
- if (ibuf->rect_float == NULL) {
- /* internally sequencer working in sRGB space and stores both bytes and float
- * buffers in sRGB space, but if byte->float onversion doesn't happen in sequencer
- * (e.g. when adding image sequence/movie into sequencer) there'll be only
- * byte buffer and profile will still indicate sRGB->linear space conversion is needed
- * here we're ensure there'll be no conversion happen and float buffer would store
- * linear frame (sergey) */
- ibuf->profile = IB_PROFILE_NONE;
- IMB_float_from_rect(ibuf);
+ linear_ibuf = IMB_dupImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
+
+ if (linear_ibuf->rect_float == NULL) {
+ /* internally sequencer working in display space and stores both bytes and float buffers in that space.
+ * It is possible that byte->float onversion didn't happen in sequencer (e.g. when adding image sequence/movie
+ * into sequencer) there'll be only byte buffer. Create float buffer from existing byte buffer, making it linear
+ */
+
+ IMB_float_from_rect(linear_ibuf);
+ }
+ else {
+ /* ensure float buffer is in linear space, not in display space */
+ BKE_sequencer_imbuf_from_sequencer_space(scene, linear_ibuf);
}
- memcpy(rr->rectf, ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
- IMB_freeImBuf(ibuf);
+ memcpy(rr->rectf, linear_ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
+
+ IMB_freeImBuf(linear_ibuf);
}
}
else if (view_context) {
@@ -181,7 +190,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
if ((scene->r.mode & R_OSA) == 0) {
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf);
}
else {
@@ -195,7 +204,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
BLI_jitter_init(jit_ofs[0], scene->r.osa);
/* first sample buffer, also initializes 'rv3d->persmat' */
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer);
/* skip the first sample */
@@ -205,7 +214,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
(jit_ofs[j][0] * 2.0f) / sizex,
(jit_ofs[j][1] * 2.0f) / sizey);
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE, FALSE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_tmp);
add_vn_vn(accum_buffer, accum_tmp, sizex * sizey * sizeof(float));
}
@@ -221,7 +230,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
else {
/* shouldnt suddenly give errors mid-render but possible */
char err_out[256] = "unknown";
- ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out);
+ ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, FALSE, err_out);
camera = scene->camera;
if (ibuf_view) {
@@ -233,27 +242,27 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
}
- /* rr->rectf is now filled with image data */
-
- if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
- BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
-
/* note on color management:
*
* OpenGL renders into sRGB colors, but render buffers are expected to be
- * linear if color management is enabled. So we convert to linear here, so
- * the conversion back to bytes using the color management flag can make it
- * sRGB again, and so that e.g. openexr saving also saves the correct linear
- * float buffer. */
+ * linear So we convert to linear here, so the conversion back to bytes can make it
+ * sRGB (or other display space) again, and so that e.g. openexr saving also saves the
+ * correct linear float buffer.
+ */
- if (oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
- int predivide = 0; /* no alpha */
+ if (!oglrender->is_sequencer) {
+ /* sequencer has got tricker ocnversion happened above */
IMB_buffer_float_from_float(rr->rectf, rr->rectf,
- 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
+ 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, FALSE,
oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
}
+ /* rr->rectf is now filled with image data */
+
+ if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
+ BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
+
RE_ReleaseResult(oglrender->re);
/* update byte from float buffer */
@@ -536,12 +545,28 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
if (ibuf) {
+ int needs_free = FALSE;
+
+ if (is_movie || !BKE_imtype_supports_float(scene->r.im_format.imtype)) {
+ ImBuf *colormanage_ibuf = IMB_dupImBuf(ibuf);
+
+ IMB_display_buffer_to_imbuf_rect(colormanage_ibuf, &scene->view_settings, &scene->display_settings);
+ imb_freerectfloatImBuf(colormanage_ibuf);
+
+ // IMB_freeImBuf(ibuf); /* owned by the image */
+ ibuf = colormanage_ibuf;
+ needs_free = TRUE;
+ }
+
/* color -> grayscale */
/* editing directly would alter the render view */
if (scene->r.im_format.planes == R_IMF_PLANES_BW) {
- ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
+ ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
IMB_color_to_bw(ibuf_bw);
- // IMB_freeImBuf(ibuf); /* owned by the image */
+
+ if (needs_free)
+ IMB_freeImBuf(ibuf);
+
ibuf = ibuf_bw;
}
else {
@@ -551,6 +576,13 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
ibuf_cpy->rect = ibuf->rect;
ibuf_cpy->rect_float = ibuf->rect_float;
ibuf_cpy->zbuf_float = ibuf->zbuf_float;
+
+ if (needs_free) {
+ ibuf_cpy->mall = ibuf->mall;
+ ibuf->mall = 0;
+ IMB_freeImBuf(ibuf);
+ }
+
ibuf = ibuf_cpy;
}
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 068a7aaa50a..6b6018e51d2 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -64,6 +64,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
+#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -75,11 +76,13 @@
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_object.h"
+#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_world.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -115,7 +118,8 @@ ImBuf *get_brush_icon(Brush *brush)
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
BLI_path_abs(path, G.main->name);
- brush->icon_imbuf = IMB_loadiffname(path, flags);
+ /* use default colorspaces for brushes */
+ brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
// otherwise lets try to find it in other directories
if (!(brush->icon_imbuf)) {
@@ -123,8 +127,10 @@ ImBuf *get_brush_icon(Brush *brush)
BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
- if (path[0])
- brush->icon_imbuf = IMB_loadiffname(path, flags);
+ if (path[0]) {
+ /* use fefault color spaces */
+ brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
+ }
}
if (brush->icon_imbuf)
@@ -254,6 +260,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
+ BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings);
+
+ BKE_color_managed_view_settings_free(&sce->view_settings);
+ BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings);
/* prevent overhead for small renders and icons (32) */
if (id && sp->sizex < 40)
@@ -263,7 +273,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
/* exception: don't color manage texture previews or icons */
if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE)
- sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT;
+ BKE_scene_disable_color_management(sce);
if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
sce->r.alphamode = R_ALPHAPREMUL;
@@ -475,13 +485,13 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
char name[32];
int do_gamma_correct = FALSE, do_predivide = FALSE;
int offx = 0;
- int newx = BLI_RCT_SIZE_X(rect);
- int newy = BLI_RCT_SIZE_Y(rect);
+ int newx = BLI_rcti_size_x(rect);
+ int newy = BLI_rcti_size_y(rect);
if (id && GS(id->name) != ID_TE) {
/* exception: don't color manage texture previews - show the raw values */
if (sce) {
- do_gamma_correct = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ do_gamma_correct = TRUE;
do_predivide = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE;
}
}
@@ -514,15 +524,25 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
/* temporary conversion to byte for drawing */
float fx = rect->xmin + offx;
float fy = rect->ymin;
- int profile_from = (do_gamma_correct) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
int dither = 0;
unsigned char *rect_byte;
rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect");
- IMB_buffer_byte_from_float(rect_byte, rres.rectf,
- 4, dither, IB_PROFILE_SRGB, profile_from, do_predivide,
- rres.rectx, rres.recty, rres.rectx, rres.rectx);
+ if (do_gamma_correct) {
+ IMB_display_buffer_transform_apply(rect_byte, rres.rectf, rres.rectx, rres.recty, 4,
+ &sce->view_settings, &sce->display_settings, do_predivide);
+
+ }
+ else {
+ /* OCIO_TODO: currently seems an exception for textures (came fro mlegacish time),
+ * but is it indeed expected behavior, or textures should be
+ * color managed as well?
+ */
+ IMB_buffer_byte_from_float(rect_byte, rres.rectf,
+ 4, dither, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, do_predivide,
+ rres.rectx, rres.recty, rres.rectx, rres.rectx);
+ }
glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte);
@@ -549,8 +569,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
SpaceButs *sbuts = sa->spacedata.first;
rcti newrect;
int ok;
- int newx = BLI_RCT_SIZE_X(rect);
- int newy = BLI_RCT_SIZE_Y(rect);
+ int newx = BLI_rcti_size_x(rect);
+ int newy = BLI_rcti_size_y(rect);
newrect.xmin = rect->xmin;
newrect.xmax = rect->xmin;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0bfe5d04e5e..d14514546f5 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -104,8 +104,8 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct)
void ED_region_pixelspace(ARegion *ar)
{
- int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ int width = BLI_rcti_size_x(&ar->winrct) + 1;
+ int height = BLI_rcti_size_y(&ar->winrct) + 1;
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
@@ -901,10 +901,10 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
static int rct_fits(rcti *rect, char dir, int size)
{
if (dir == 'h') {
- return BLI_RCT_SIZE_X(rect) - size;
+ return BLI_rcti_size_x(rect) - size;
}
else { /* 'v' */
- return BLI_RCT_SIZE_Y(rect) - size;
+ return BLI_rcti_size_y(rect) - size;
}
}
@@ -1010,7 +1010,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if (alignment == RGN_ALIGN_HSPLIT) {
if (rct_fits(remainder, 'h', prefsizex) > 4) {
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
remainder->xmin = ar->winrct.xmax + 1;
}
else {
@@ -1019,7 +1019,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
else {
if (rct_fits(remainder, 'v', prefsizey) > 4) {
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
remainder->ymin = ar->winrct.ymax + 1;
}
else {
@@ -1051,20 +1051,20 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
if (quad) {
if (quad == 1) { /* left bottom */
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
}
else if (quad == 2) { /* left top */
- ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
- ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
+ ar->winrct.xmax = BLI_rcti_cent_x(remainder);
+ ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
}
else if (quad == 3) { /* right bottom */
- ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
- ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
+ ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
+ ar->winrct.ymax = BLI_rcti_cent_y(remainder);
}
else { /* right top */
- ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
- ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
+ ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
+ ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
BLI_rcti_init(remainder, 0, 0, 0, 0);
}
@@ -1073,8 +1073,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
/* for speedup */
- ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
/* set winrect for azones */
if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
@@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if (ar->alignment & RGN_SPLIT_PREV) {
if (ar->prev) {
remainder = remainder_prev;
- ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1;
- ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1;
+ ar->prev->winx = BLI_rcti_size_x(&ar->prev->winrct) + 1;
+ ar->prev->winy = BLI_rcti_size_y(&ar->prev->winrct) + 1;
}
}
@@ -1133,8 +1133,8 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
else sa->totrct.ymax = sa->v2->vec.y;
/* for speedup */
- sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1;
- sa->winy = BLI_RCT_SIZE_Y(&sa->totrct) + 1;
+ sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
+ sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
}
@@ -1268,8 +1268,8 @@ void ED_region_init(bContext *C, ARegion *ar)
/* refresh can be called before window opened */
region_subwindow(CTX_wm_window(C), ar);
- ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
/* UI convention */
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
@@ -1574,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
newcontext = UI_view2d_tab_set(v2d, contextnr);
if (vertical) {
- w = BLI_RCT_SIZE_X(&v2d->cur);
+ w = BLI_rctf_size_x(&v2d->cur);
em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y;
}
else {
@@ -1769,7 +1769,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
}
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_RCT_SIZE_Y(&ar->v2d.tot));
+ UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_rctf_size_y(&ar->v2d.tot));
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -1798,16 +1798,16 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
/* background box */
rect = ar->winrct;
rect.xmin = 0;
- rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height;
+ rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height;
if (block) {
- rect.xmax = BLI_RCT_SIZE_X(&ar->winrct);
+ rect.xmax = BLI_rcti_size_x(&ar->winrct);
}
else {
rect.xmax = rect.xmin + BLF_width(fontid, text) + 24;
}
- rect.ymax = BLI_RCT_SIZE_Y(&ar->winrct);
+ rect.ymax = BLI_rcti_size_y(&ar->winrct);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index c93f4156eeb..24053d76672 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -669,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
void glaDefine2DArea(rcti *screen_rect)
{
- const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1;
- const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1;
+ const int sc_w = BLI_rcti_size_x(screen_rect) + 1;
+ const int sc_h = BLI_rcti_size_y(screen_rect) + 1;
glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
@@ -714,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
di->world_rect = *rect;
- sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
- sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
- wo_w = BLI_RCT_SIZE_X(&di->world_rect);
- wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
+ sc_w = BLI_rcti_size_x(&di->screen_rect);
+ sc_h = BLI_rcti_size_y(&di->screen_rect);
+ wo_w = BLI_rcti_size_x(&di->world_rect);
+ wo_h = BLI_rcti_size_y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;
@@ -745,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
di->world_rect.ymax = di->screen_rect.ymax;
}
- sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
- sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
- wo_w = BLI_RCT_SIZE_X(&di->world_rect);
- wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
+ sc_w = BLI_rcti_size_x(&di->screen_rect);
+ sc_h = BLI_rcti_size_y(&di->screen_rect);
+ wo_w = BLI_rcti_size_x(&di->world_rect);
+ wo_h = BLI_rcti_size_y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 11d32e11cd0..2e1723027b8 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -40,6 +40,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -704,10 +705,6 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
/* *********************** DRAWING **************************************** */
-
-#define SCR_BACK 0.55
-#define SCR_ROUND 12
-
/* draw vertical shape visualizing future joining (left as well
* right direction of future joining) */
static void draw_horizontal_join_shape(ScrArea *sa, char dir)
@@ -1506,6 +1503,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene)
CTX_data_scene_set(C, scene);
BKE_scene_set_background(bmain, scene);
+ DAG_on_visible_update(bmain, FALSE);
ED_render_engine_changed(bmain);
ED_update_for_newframe(bmain, scene, 1);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 50a210e5d7c..c64a4a37f3a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -372,6 +372,21 @@ int ED_operator_posemode_exclusive(bContext *C)
return 0;
}
+/* allows for pinned pose objects to be used in the object buttons
+ * and the the non-active pose object to be used in the 3D view */
+int ED_operator_posemode_context(bContext *C)
+{
+ Object *obpose = ED_pose_object_from_context(C);
+
+ if (obpose && !(obpose->mode & OB_MODE_EDIT)) {
+ if (BKE_object_pose_context_check(obpose)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int ED_operator_posemode(bContext *C)
{
Object *obact = CTX_data_active_object(C);
@@ -1196,9 +1211,6 @@ static void SCREEN_OT_area_move(wmOperatorType *ot)
* call exit() or cancel() and remove handler
*/
-#define SPLIT_STARTED 1
-#define SPLIT_PROGRESS 2
-
typedef struct sAreaSplitData {
int x, y; /* last used mouse position */
@@ -1635,10 +1647,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
int dist;
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
- dist = BLI_RCT_SIZE_X(&sa->totrct);
+ dist = BLI_rcti_size_x(&sa->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
- dist = BLI_RCT_SIZE_Y(&sa->totrct);
+ dist = BLI_rcti_size_y(&sa->totrct);
}
/* subtractwidth of regions on opposite side
@@ -2850,35 +2862,40 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot)
}
/* ************** header tools operator ***************************** */
-
-static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- uiPopupMenu *pup;
- uiLayout *layout;
-
- pup = uiPupMenuBegin(C, "Header", ICON_NONE);
- layout = uiPupMenuLayout(pup);
-
- // XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator
+
+ /* XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator. */
if (ar->alignment == RGN_ALIGN_TOP)
- uiItemO(layout, "Flip to Bottom", ICON_NONE, "SCREEN_OT_header_flip");
+ uiItemO(layout, IFACE_("Flip to Bottom"), ICON_NONE, "SCREEN_OT_header_flip");
else
- uiItemO(layout, "Flip to Top", ICON_NONE, "SCREEN_OT_header_flip");
-
+ uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip");
+
uiItemS(layout);
-
+
/* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
if (sa->spacetype != SPACE_FILE) {
if (sa->full)
- uiItemO(layout, "Tile Area", ICON_NONE, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
else
- uiItemO(layout, "Maximize Area", ICON_NONE, "SCREEN_OT_screen_full_area");
+ uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
}
-
+}
+
+static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
+{
+ uiPopupMenu *pup;
+ uiLayout *layout;
+
+ pup = uiPupMenuBegin(C, N_("Header"), ICON_NONE);
+ layout = uiPupMenuLayout(pup);
+
+ ED_screens_header_tools_menu_create(C, layout, NULL);
+
uiPupMenuEnd(C, pup);
-
+
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 4e71c49465f..aeae79aa9d0 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -149,8 +149,8 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
{
unsigned int *to = ibuf->rect;
unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin;
- int crop_x = BLI_RCT_SIZE_X(&crop);
- int crop_y = BLI_RCT_SIZE_Y(&crop);
+ int crop_x = BLI_rcti_size_x(&crop);
+ int crop_y = BLI_rcti_size_y(&crop);
int y;
if (crop_x > 0 && crop_y > 0) {
@@ -245,7 +245,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
- uiTemplateImageSettings(layout, &ptr);
+ uiTemplateImageSettings(layout, &ptr, FALSE);
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8616d4e66eb..e14266c83a7 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -322,8 +322,8 @@ static int project_brush_radius(ViewContext *vc,
add_v3_v3v3(offset, location, ortho);
/* project the center of the brush, and the tangent point to the view onto the screen */
- project_float(vc->ar, location, p1);
- project_float(vc->ar, offset, p2);
+ ED_view3d_project_float(vc->ar, location, p1);
+ ED_view3d_project_float(vc->ar, offset, p2);
/* the distance between these points is the size of the projected brush in pixels */
return len_v2v2(p1, p2);
@@ -441,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
else {
quad.xmin = 0;
quad.ymin = 0;
- quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct);
- quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct);
+ quad.xmax = BLI_rcti_size_x(&vc->ar->winrct);
+ quad.ymax = BLI_rcti_size_y(&vc->ar->winrct);
}
/* set quad color */
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index e809267d076..2970bdfb5a4 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -251,7 +251,7 @@ static void clip_planes_from_rect(bContext *C,
view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc);
view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
- ED_view3d_calc_clipping(&bb, clip_planes, &mats, rect);
+ ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
mul_m4_fl(clip_planes, -1.0f);
}
@@ -388,7 +388,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
ot->modal = WM_border_select_modal;
ot->exec = hide_show_exec;
/* sculpt-only for now */
- ot->poll = sculpt_mode_poll;
+ ot->poll = sculpt_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7c3f376df91..b8e365c4c8e 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -104,6 +104,8 @@
#include "GPU_draw.h"
#include "GPU_extensions.h"
+#include "IMB_colormanagement.h"
+
#include "paint_intern.h"
/* Defines and Structs */
@@ -139,7 +141,7 @@
#define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS)
#define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS)
-static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
+static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
typedef struct ImagePaintState {
@@ -153,7 +155,6 @@ typedef struct ImagePaintState {
Image *image;
ImBuf *canvas;
ImBuf *clonecanvas;
- short clonefreefloat;
char *warnpackedfile;
char *warnmultifile;
@@ -239,8 +240,6 @@ typedef struct ImagePaintRegion {
/* vert flags */
#define PROJ_VERT_CULL 1
-#define PI_80_DEG ((M_PI_2 / 9) * 8)
-
/* This is mainly a convenience struct used so we can keep an array of images we use
* Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread
* because 'partRedrawRect' and 'touch' values would not be thread safe */
@@ -510,7 +509,7 @@ static void image_undo_restore(bContext *C, ListBase *lb)
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
-
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
IMB_freeImBuf(tmpibuf);
@@ -3137,7 +3136,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->is_ortho = params.is_ortho;
}
- /* same as view3d_get_object_project_mat */
+ /* same as #ED_view3d_ob_project_mat_get */
mult_m4_m4m4(vmat, viewmat, ps->ob->obmat);
mult_m4_m4m4(ps->projectMat, winmat, vmat);
}
@@ -3615,7 +3614,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps)
pr = &(projIma->partRedrawRect[i]);
if (pr->x2 != -1) { /* TODO - use 'enabled' ? */
imapaintpartial = *pr;
- imapaint_image_update(NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/
+ imapaint_image_update(NULL, NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/
redraw = 1;
}
}
@@ -3945,7 +3944,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma->touch = 1;
is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
- use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
+ use_color_correction = TRUE;
}
/* end copy */
@@ -4028,7 +4027,7 @@ static void *do_projectpaint_thread(void *ph_v)
last_projIma->touch = 1;
is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
- use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
+ use_color_correction = TRUE;
}
/* end copy */
@@ -4244,10 +4243,17 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
IMB_freeImBuf(tmpibuf);
}
-static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
+static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
{
- if (ibuf->rect_float)
- ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
+ if (scene) {
+ IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, ibuf->x, 0, 0,
+ &scene->view_settings, &scene->display_settings,
+ imapaintpartial.x1, imapaintpartial.y1,
+ imapaintpartial.x2, imapaintpartial.y2);
+ }
+ else {
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -4257,7 +4263,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s
int w = imapaintpartial.x2 - imapaintpartial.x1;
int h = imapaintpartial.y2 - imapaintpartial.y1;
/* Testing with partial update in uv editor too */
- GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint);
+ GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); //!texpaint);
}
}
@@ -4571,15 +4577,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
/* temporarily add float rect for cloning */
if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
- short profile = IB_PROFILE_NONE;
-
- /* Don't want to color manage, but don't disturb existing profiles */
- SWAP(short, s->clonecanvas->profile, profile);
-
IMB_float_from_rect(s->clonecanvas);
- s->clonefreefloat = 1;
-
- SWAP(short, s->clonecanvas->profile, profile);
}
else if (!s->canvas->rect_float && !s->clonecanvas->rect)
IMB_rect_from_float(s->clonecanvas);
@@ -4588,28 +4586,32 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
return 1;
}
-static void imapaint_canvas_free(ImagePaintState *s)
+static void imapaint_canvas_free(ImagePaintState *UNUSED(s))
{
- if (s->clonefreefloat)
- imb_freerectfloatImBuf(s->clonecanvas);
}
static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure)
{
ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL);
float pos[2];
+ int is_data;
if (!ibuf)
return 0;
+ is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
+
pos[0] = uv[0] * ibuf->x;
pos[1] = uv[1] * ibuf->y;
BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
- if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) {
+ /* OCIO_TODO: float buffers are now always linear, so always use color correction
+ * this should probably be changed when texture painting color space is supported
+ */
+ if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) {
if (update)
- imapaint_image_update(s->sima, image, ibuf, texpaint);
+ imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint);
return 1;
}
else return 0;
@@ -5257,7 +5259,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
-int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
+static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -5884,7 +5886,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (w > maxsize) w = maxsize;
if (h > maxsize) h = maxsize;
- ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out);
+ ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, FALSE, err_out);
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
/* but could be other reasons. Should be handled in the future. nazgul */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index cc71be4938e..39a95300d5d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -602,7 +602,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
}
}
-void paint_partial_visibility_keys(wmKeyMap *keymap)
+static void paint_partial_visibility_keys(wmKeyMap *keymap)
{
wmKeyMapItem *kmi;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index b53edeadb51..7fabaf7f23d 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -254,7 +254,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
pressure = event_tablet_data(event, NULL);
if (pressure > FLT_EPSILON) {
- scale = (BKE_brush_size_get(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length;
+ /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel
+ * causing very high step sizes, hanging blender [#32381] */
+ const float size_clamp = maxf(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure);
+ scale = (size_clamp * stroke->brush->spacing / 50.0f) / length;
if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);
@@ -521,8 +524,10 @@ int paint_poll(bContext *C)
{
Paint *p = paint_get_active_from_context(C);
Object *ob = CTX_data_active_object(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
return p && ob && paint_brush(p) &&
- CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
- CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
+ (sa && sa->spacetype == SPACE_VIEW3D) &&
+ (ar && ar->regiontype == RGN_TYPE_WINDOW);
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index df64e1c9d90..29a59651cf7 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -98,7 +98,7 @@ int paint_convert_bb_to_rect(rcti *rect,
vec[1] = j ? bb_min[1] : bb_max[1];
vec[2] = k ? bb_min[2] : bb_max[2];
/* convert corner to screen space */
- ED_view3d_project_float_v2(ar, vec, proj, projection_mat);
+ ED_view3d_project_float_v2_m4(ar, vec, proj, projection_mat);
/* expand 2D rectangle */
/* we could project directly to int? */
@@ -137,7 +137,7 @@ void paint_calc_redraw_planes(float planes[4][4],
rect.ymin -= 2;
rect.ymax += 2;
- ED_view3d_calc_clipping(&bb, planes, &mats, &rect);
+ ED_view3d_clipping_calc(&bb, planes, &mats, &rect);
mul_m4_fl(planes, -1.0f);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index ba440e98290..8aed92df3af 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -134,7 +134,7 @@ int vertex_paint_poll(bContext *C)
paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
{
ScrArea *sa = CTX_wm_area(C);
- if (sa->spacetype == SPACE_VIEW3D) {
+ if (sa && sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW)
return 1;
@@ -257,7 +257,7 @@ static void do_shared_vertex_tesscol(Mesh *me)
MEM_freeN(scolmain);
}
-void do_shared_vertexcol(Mesh *me, int do_tessface)
+static void do_shared_vertexcol(Mesh *me, int do_tessface)
{
const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK);
MPoly *mp;
@@ -850,7 +850,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n
float dist_squared;
float vertco[2], delta[2];
- project_float_noclip(vc->ar, vert_nor, vertco);
+ ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco);
sub_v2_v2v2(delta, mval, vertco);
dist_squared = dot_v2v2(delta, delta); /* len squared */
if (dist_squared > brush_size_pressure * brush_size_pressure) {
@@ -2227,19 +2227,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if (indexar[0]) totindex = 1;
else totindex = 0;
}
-
- if (wp->flag & VP_COLINDEX) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1);
-
- if (mpoly->mat_nr != ob->actcol - 1) {
- indexar[index] = 0;
- }
- }
- }
- }
-
+
if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) {
for (index = 0; index < totindex; index++) {
if (indexar[index] && indexar[index] <= me->totpoly) {
@@ -2639,52 +2627,13 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
return 1;
}
-#if 0
-static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
- const unsigned int index, const float mval[2],
- const float brush_size_pressure, const float brush_alpha_pressure,
- int UNUSED(flip))
+static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol)
{
- ViewContext *vc = &vpd->vc;
- Brush *brush = paint_brush(&vp->paint);
- Mesh *me = BKE_mesh_from_object(ob);
- MFace *mface = &me->mface[index];
- unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index;
- unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index;
- float alpha;
- int i;
-
- int brush_alpha_pressure_i;
-
- if ((vp->flag & VP_COLINDEX && mface->mat_nr != ob->actcol - 1) ||
- ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
- return;
-
- if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- unsigned int fcol1 = mcol_blend(mcol[0], mcol[1], 128);
- if (mface->v4) {
- unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128);
- vpd->paintcol = mcol_blend(fcol1, fcol2, 128);
- }
- else {
- vpd->paintcol = mcol_blend(mcol[2], fcol1, 170);
- }
- }
-
- brush_alpha_pressure_i = (int)(brush_alpha_pressure * 255.0f);
-
- for (i = 0; i < (mface->v4 ? 4 : 3); ++i) {
- alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos + 6 * (&mface->v1)[i],
- mval, brush_size_pressure, brush_alpha_pressure);
- if (alpha) {
- const int alpha_i = (int)(alpha * 255.0f);
- mcol[i] = vpaint_blend(vp, mcol[i], mcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i);
- }
- }
+ mcol->a = lcol->a;
+ mcol->r = lcol->r;
+ mcol->g = lcol->g;
+ mcol->b = lcol->b;
}
-#endif
-
-/* BMESH version of vpaint_paint_face (commented above) */
static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
const unsigned int index, const float mval[2],
@@ -2744,33 +2693,22 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob,
}
if (vpd->use_fast_update) {
-
-#ifdef CPYCOL
-# undef CPYCOL
-#endif
-#define CPYCOL(c, l) (c)->a = (l)->a, (c)->r = (l)->r, (c)->g = (l)->g, (c)->b = (l)->b
-
/* update vertex colors for tessellations incrementally,
* rather then regenerating the tessellation altogether */
for (e = vpd->polyfacemap[index].first; e; e = e->next) {
- mf = me->mface + e->facenr;
- mc = me->mcol + e->facenr * 4;
+ mf = &me->mface[e->facenr];
+ mc = &me->mcol[e->facenr * 4];
ml = me->mloop + mpoly->loopstart;
mlc = me->mloopcol + mpoly->loopstart;
for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) {
- if (ml->v == mf->v1)
- CPYCOL(mc, mlc);
- else if (ml->v == mf->v2)
- CPYCOL(mc + 1, mlc);
- else if (ml->v == mf->v3)
- CPYCOL(mc + 2, mlc);
- else if (mf->v4 && ml->v == mf->v4)
- CPYCOL(mc + 3, mlc);
+ if (ml->v == mf->v1) copy_lcol_to_mcol(mc + 0, mlc);
+ else if (ml->v == mf->v2) copy_lcol_to_mcol(mc + 1, mlc);
+ else if (ml->v == mf->v3) copy_lcol_to_mcol(mc + 2, mlc);
+ else if (mf->v4 && ml->v == mf->v4) copy_lcol_to_mcol(mc + 3, mlc);
}
}
-#undef CPYCOL
}
}
@@ -2804,7 +2742,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
mval[0] -= vc->ar->winrct.xmin;
mval[1] -= vc->ar->winrct.ymin;
-
+
/* which faces are involved */
if (vp->flag & VP_AREA) {
totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);
@@ -2814,19 +2752,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if (indexar[0]) totindex = 1;
else totindex = 0;
}
-
-
- if (vp->flag & VP_COLINDEX) {
- for (index = 0; index < totindex; index++) {
- if (indexar[index] && indexar[index] <= me->totpoly) {
- MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1);
-
- if (mpoly->mat_nr != ob->actcol - 1) {
- indexar[index] = 0;
- }
- }
- }
- }
if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) {
for (index = 0; index < totindex; index++) {
@@ -2835,15 +2760,13 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if ((mpoly->flag & ME_FACE_SEL) == 0)
indexar[index] = 0;
- }
+ }
}
}
swap_m4m4(vc->rv3d->persmat, mat);
-
for (index = 0; index < totindex; index++) {
-
if (indexar[index] && indexar[index] <= me->totpoly) {
vpaint_paint_poly(vp, vpd, ob, indexar[index] - 1, mval, brush_size_pressure, brush_alpha_pressure);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 210477e3e5a..05b5b90344c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -771,7 +771,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
if (ss->cache->radial_symmetry_pass)
mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point);
- ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
+ ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
/* keep coordinates relative to mouse */
@@ -2649,7 +2649,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
}
if (is_basis) {
- ofs = key_to_vertcos(ob, kb);
+ ofs = BKE_key_convert_to_vertcos(ob, kb);
/* calculate key coord offsets (from previous location) */
for (a = 0; a < me->totvert; a++) {
@@ -2662,7 +2662,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
int apply_offset = ((currkey != kb) && (ob->shapenr - 1 == currkey->relative));
if (apply_offset)
- offset_to_key(ob, currkey, ofs);
+ BKE_key_convert_from_offset(ob, currkey, ofs);
currkey = currkey->next;
}
@@ -2683,7 +2683,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
}
/* apply new coords on active key block */
- vertcos_to_key(ob, kb, vertCos);
+ BKE_key_convert_from_vertcos(ob, kb, vertCos);
}
static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
@@ -3074,7 +3074,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
/* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */
BKE_mesh_tessface_ensure(me);
- if (!mmd) ss->kb = ob_get_keyblock(ob);
+ if (!mmd) ss->kb = BKE_keyblock_from_object(ob);
else ss->kb = NULL;
/* needs to be called after we ensure tessface */
@@ -3109,7 +3109,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
free_sculptsession_deformMats(ss);
- ss->orig_cos = (ss->kb) ? key_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL);
+ ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL);
crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
@@ -3123,7 +3123,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
/* if pbvh is deformed, key block is already applied to it */
if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) {
- float (*vertCos)[3] = key_to_vertcos(ob, ss->kb);
+ float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb);
if (vertCos) {
/* apply shape keys coordinates to PBVH */
@@ -3139,6 +3139,11 @@ int sculpt_mode_poll(bContext *C)
return ob && ob->mode & OB_MODE_SCULPT;
}
+int sculpt_mode_poll_view3d(bContext *C)
+{
+ return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C));
+}
+
int sculpt_poll(bContext *C)
{
return sculpt_mode_poll(C) && paint_poll(C);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index f4467dc22fc..5e79616b0b0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -56,6 +56,7 @@ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct
void sculpt(struct Sculpt *sd);
int sculpt_mode_poll(struct bContext *C);
+int sculpt_mode_poll_view3d(struct bContext *C);
int sculpt_poll(struct bContext *C);
void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob, int need_pmap);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index c62dc687c73..bb2b4b8c743 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -107,8 +107,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) {
/* shape key has been changed before calling undo operator */
- Key *key = ob_get_key(ob);
- KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName);
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_find_name(key, unode->shapeName);
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
@@ -127,7 +127,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (ss->kb) {
float (*vertCos)[3];
- vertCos = key_to_vertcos(ob, ss->kb);
+ vertCos = BKE_key_convert_to_vertcos(ob, ss->kb);
for (i = 0; i < unode->totvert; i++) {
if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index fdce8ec04a4..0bcccd9479c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -156,8 +156,8 @@ typedef struct Temp_UvData {
-void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2],
- float alpha, float radius, float aspectRatio)
+static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2],
+ float alpha, float radius, float aspectRatio)
{
Temp_UVData *tmp_uvdata;
float diff[2];
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 878fd20b27e..10adeb3e721 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
* start of list offset, and the second is as a correction for the scrollers.
*/
height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2));
- if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
+ if (height > BLI_rcti_size_y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index c95f1dba31d..7635f85a37e 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -365,13 +365,13 @@ static int actkeys_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
+ v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 9ab79d73e76..5da348b2a84 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -309,7 +309,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
mode = ACTKEYS_BORDERSEL_FRAMERANGE;
else
mode = ACTKEYS_BORDERSEL_CHANNELS;
@@ -912,9 +912,6 @@ void ACTION_OT_select_leftright(wmOperatorType *ot)
* selection mode between replacing the selection (without) and inverting the selection (with).
*/
-/* sensitivity factor for frame-selections */
-#define FRAME_CLICK_THRESH 0.1f
-
/* ------------------- */
/* option 1) select keyframe directly under mouse */
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index 4bcd4a933ed..ebba7d92819 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
uiBlockEndAlign(block);
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot));
+ UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_rctf_size_y(&ar->v2d.tot));
uiEndBlock(C, block);
uiDrawBlock(C, block);
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index e66faa88b93..969b0e25928 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -119,6 +119,8 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL);
if (clip) {
+ uiLayout *col;
+
row = uiLayoutRow(layout, FALSE);
block = uiLayoutGetBlock(row);
uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, "");
@@ -129,6 +131,9 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE);
uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload");
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiTemplateColorspaceSettings(col, &clipptr, "colorspace_settings");
}
}
@@ -169,7 +174,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->track_preview_height =
(scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height;
- uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect),
+ uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_rctf_size_x(&rect),
scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
}
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 5d890155e25..cc1b8d444bc 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -274,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
dopesheet = &tracking->dopesheet;
height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
- if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
+ if (height > BLI_rcti_size_y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 2353f8f8c12..b22c9a60bdc 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -42,6 +42,7 @@
#include "BKE_tracking.h"
#include "BKE_mask.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -246,14 +247,7 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
ED_region_info_draw(ar, str, block, 0.6f);
}
-static void verify_buffer_float(ImBuf *ibuf)
-{
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) {
- IMB_rect_from_float(ibuf);
- }
-}
-
-static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
+static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
int width, int height, float zoomx, float zoomy)
{
int x, y;
@@ -267,13 +261,16 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
glRectf(x, y, x + zoomx * width, y + zoomy * height);
}
else {
- verify_buffer_float(ibuf);
+ unsigned char *display_buffer;
+ void *cache_handle;
+
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- if (ibuf->rect) {
+ if (display_buffer) {
int need_fallback = 1;
if (ED_space_clip_texture_buffer_supported(sc)) {
- if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) {
+ if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
glPushMatrix();
glTranslatef(x, y, 0.0f);
glScalef(zoomx, zoomy, 1.0f);
@@ -299,12 +296,14 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
/* set zoom */
glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
/* reset zoom */
glPixelZoom(1.0f, 1.0f);
}
}
+
+ IMB_display_buffer_release(cache_handle);
}
/* draw boundary border for frame if stabilization is enabled */
@@ -958,12 +957,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
{
/* express given coordinates as proportional values */
- x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur);
- y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur);
+ x = -v2d->cur.xmin / BLI_rctf_size_x(&v2d->cur);
+ y = -v2d->cur.ymin / BLI_rctf_size_y(&v2d->cur);
/* convert proportional distances to screen coordinates */
- *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
- *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
+ *regionx = v2d->mask.xmin + x * BLI_rcti_size_x(&v2d->mask);
+ *regiony = v2d->mask.ymin + y * BLI_rcti_size_y(&v2d->mask);
}
static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
@@ -1461,7 +1460,7 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
}
if (ibuf) {
- draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy);
+ draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy);
IMB_freeImBuf(ibuf);
}
else {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 08ad6aac970..32f91671daf 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -149,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo
ED_space_clip_get_size(sc, &width, &height);
- *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
- *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
+ *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (BLI_rctf_size_x(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (BLI_rctf_size_y(&ar->v2d.cur) * height);
}
void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
@@ -277,13 +277,7 @@ int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- /* IB_PROFILE_NONE is default but infact its linear */
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -394,8 +388,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
ED_space_clip_get_aspect(sc, &aspx, &aspy);
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
zoomx = (float)width / w / aspx;
zoomy = (float)height / h / aspy;
@@ -583,12 +577,15 @@ typedef struct SpaceClipDrawContext {
GLuint texture; /* OGL texture ID */
short texture_allocated; /* flag if texture was allocated by glGenTextures */
struct ImBuf *texture_ibuf; /* image buffer for which texture was created */
+ const unsigned char *display_buffer; /* display buffer for which texture was created */
int image_width, image_height; /* image width and height for which texture was created */
unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */
/* fields to check if cache is still valid */
int framenr, start_frame, frame_offset;
short render_size, render_flag;
+
+ char colorspace[64];
} SpaceClipDrawContext;
int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
@@ -613,7 +610,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
return context->buffers_supported;
}
-int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
+int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsigned char *display_buffer)
{
SpaceClipDrawContext *context = sc->draw_context;
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -625,12 +622,22 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
* assuming displaying happens of footage frames only on which painting doesn't heppen.
* so not changed image buffer pointer means unchanged image content */
need_rebind |= context->texture_ibuf != ibuf;
+ need_rebind |= context->display_buffer != display_buffer;
need_rebind |= context->framenr != sc->user.framenr;
need_rebind |= context->render_size != sc->user.render_size;
need_rebind |= context->render_flag != sc->user.render_flag;
need_rebind |= context->start_frame != clip->start_frame;
need_rebind |= context->frame_offset != clip->frame_offset;
+ if (!need_rebind) {
+ /* OCIO_TODO: not entirely nice, but currently it seems to be easiest way
+ * to deal with changing input color space settings
+ * pointer-based check could fail due to new buffers could be
+ * be allocated on on old memory
+ */
+ need_rebind = strcmp(context->colorspace, clip->colorspace_settings.name) != 0;
+ }
+
if (need_rebind) {
int width = ibuf->x, height = ibuf->y;
int need_recreate = 0;
@@ -670,16 +677,12 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
glBindTexture(GL_TEXTURE_2D, context->texture);
}
- if (ibuf->rect_float) {
- if (ibuf->rect == NULL)
- IMB_rect_from_float(ibuf);
- }
-
- if (ibuf->rect)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ if (display_buffer)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
/* store settings */
context->texture_allocated = 1;
+ context->display_buffer = display_buffer;
context->texture_ibuf = ibuf;
context->image_width = ibuf->x;
context->image_height = ibuf->y;
@@ -688,6 +691,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
context->render_flag = sc->user.render_flag;
context->start_frame = clip->start_frame;
context->frame_offset = clip->frame_offset;
+
+ strcpy(context->colorspace, clip->colorspace_settings.name);
}
else {
/* displaying exactly the same image which was loaded t oa texture,
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 91501971d9d..7b070fde6ba 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -94,7 +94,7 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack
glVertex2f(scene_framenr, val);
}
-void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
+static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
{
static float colors[2][3] = {{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f}};
@@ -116,7 +116,7 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co
glBegin(GL_LINE_STRIP);
}
-void tracking_segment_end_cb(void *UNUSED(userdata))
+static void tracking_segment_end_cb(void *UNUSED(userdata))
{
glEnd();
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 71dcd326887..fa235bd2997 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -130,7 +130,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack
copy_v2_v2(data->prev_co, co);
}
-void find_nearest_tracking_segment_end_cb(void *userdata)
+static void find_nearest_tracking_segment_end_cb(void *userdata)
{
MouseSelectUserData *data = userdata;
@@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
}
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
- extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_y(&v2d->cur);
v2d->cur.ymin -= extra;
v2d->cur.ymax += extra;
@@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot)
void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar)
{
View2D *v2d = &ar->v2d;
- float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f;
+ float extra = BLI_rctf_size_x(&v2d->cur) / 2.0f;
/* set extents of view to start/end frames */
v2d->cur.xmin = (float)CFRA - extra;
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index aa2cadbd2d3..5c338f3e6f1 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -90,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
if ((width < 4) && (height < 4))
sc->zoom = oldzoom;
- else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom)
+ else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
- else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom)
+ else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
}
@@ -726,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op)
h = h * aspy;
/* check if the image will fit in the image with zoom == 1 */
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
if (fit_view) {
const int margin = 5; /* margin from border */
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 7f43c404095..3f925df30c7 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar)
if (clip)
h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
- winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ winy = BLI_rcti_size_y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index a4f7e30ed7b..b7ef278275e 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -142,7 +142,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
/* always keep the bottom part of the view aligned, less annoying */
if (prev_y_min != ar->v2d.cur.ymin) {
- const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ const float cur_y_range = BLI_rctf_size_y(&ar->v2d.cur);
ar->v2d.cur.ymin = prev_y_min;
ar->v2d.cur.ymax = prev_y_min + cur_y_range;
}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index a07a560328c..e5c6a839380 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -66,6 +66,7 @@ void FILE_OT_select_border(struct wmOperatorType *ot);
void FILE_OT_select_bookmark(struct wmOperatorType *ot);
void FILE_OT_bookmark_add(struct wmOperatorType *ot);
void FILE_OT_delete_bookmark(struct wmOperatorType *ot);
+void FILE_OT_reset_recent(wmOperatorType *ot);
void FILE_OT_hidedot(struct wmOperatorType *ot);
void FILE_OT_execute(struct wmOperatorType *ot);
void FILE_OT_cancel(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 040f276940d..fcbeb064e4d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -64,11 +64,6 @@
#include <stdio.h>
#include <ctype.h>
-/* for events */
-#define NOTACTIVEFILE 0
-#define ACTIVATE 1
-#define INACTIVATE 2
-
/* ---------- FILE SELECTION ------------ */
static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect)
{
@@ -459,7 +454,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op))
if (params->dir[0] != '\0') {
char name[FILE_MAX];
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, FS_INSERT_SAVE);
BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
}
@@ -515,6 +510,35 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot)
RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000);
}
+static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ScrArea *sa = CTX_wm_area(C);
+ char name[FILE_MAX];
+ struct FSMenu *fsmenu = fsmenu_get();
+
+ while (fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) {
+ fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0);
+ }
+ BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
+ fsmenu_write_file(fsmenu, name);
+ ED_area_tag_redraw(sa);
+
+ return OPERATOR_FINISHED;
+}
+
+void FILE_OT_reset_recent(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Reset Recent";
+ ot->description = "Reset Recent files";
+ ot->idname = "FILE_OT_reset_recent";
+
+ /* api callbacks */
+ ot->exec = reset_recent_exec;
+ ot->poll = ED_operator_file_active;
+
+}
+
int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
{
View2D *v2d = &ar->v2d;
@@ -770,8 +794,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
file_sfile_to_operator(op, sfile, filepath);
- if (BLI_exists(sfile->params->dir))
- fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
+ if (BLI_exists(sfile->params->dir)) {
+ fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE | FS_INSERT_FIRST);
+ }
BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu_get(), filepath);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 51bd660e126..a7054909aaa 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -67,14 +67,14 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v))
WM_operator_properties_free(&ptr);
}
-static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse)
+static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete)
{
SpaceFile *sfile = CTX_wm_space_file(C);
uiBlock *block;
uiBut *but;
uiLayout *box, *col;
struct FSMenu *fsmenu = fsmenu_get();
- int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category);
+ int i, nentries = fsmenu_get_nentries(fsmenu, category);
/* reset each time */
*nr = -1;
@@ -89,13 +89,11 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
box = uiLayoutBox(pa->layout);
col = uiLayoutColumn(box, TRUE);
- for (i_iter = 0; i_iter < nentries; ++i_iter) {
+ for (i = 0; i < nentries; ++i) {
char dir[FILE_MAX];
char temp[FILE_MAX];
uiLayout *layout = uiLayoutRow(col, FALSE);
char *entry;
-
- i = reverse ? nentries - (i_iter + 1) : i_iter;
entry = fsmenu_get_entry(fsmenu, category, i);
@@ -134,7 +132,7 @@ static void file_panel_system(const bContext *C, Panel *pa)
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile)
- file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0);
+ file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0);
}
static void file_panel_bookmarks(const bContext *C, Panel *pa)
@@ -147,17 +145,22 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa)
uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add");
uiItemL(row, NULL, ICON_NONE);
- file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1, 0);
+ file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1);
}
}
static void file_panel_recent(const bContext *C, Panel *pa)
{
SpaceFile *sfile = CTX_wm_space_file(C);
+ uiLayout *row;
if (sfile) {
if (!(U.uiflag & USER_HIDE_RECENT) ) {
- file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1);
+ row = uiLayoutRow(pa->layout, FALSE);
+ uiItemO(row, IFACE_("Reset"), ICON_X, "file.reset_recent");
+ uiItemL(row, NULL, ICON_NONE);
+
+ file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0);
}
}
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 4abe41d5714..699cb9b4feb 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -389,7 +389,7 @@ void filelist_init_icons(void)
#ifdef WITH_HEADLESS
bbuf = NULL;
#else
- bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, "<splash>");
+ bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
#endif
if (bbuf) {
for (y = 0; y < SPECIAL_IMG_ROWS; y++) {
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 09231efd367..1fa89e5db9a 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -270,12 +270,12 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar)
int numfiles;
if (layout->flag & FILE_LAYOUT_HOR) {
- int width = (int)(BLI_RCT_SIZE_X(&ar->v2d.cur) - 2 * layout->tile_border_x);
+ int width = (int)(BLI_rctf_size_x(&ar->v2d.cur) - 2 * layout->tile_border_x);
numfiles = (int)((float)width / (float)layout->tile_w + 0.5f);
return numfiles * layout->rows;
}
else {
- int height = (int)(BLI_RCT_SIZE_Y(&ar->v2d.cur) - 2 * layout->tile_border_y);
+ int height = (int)(BLI_rctf_size_y(&ar->v2d.cur) - 2 * layout->tile_border_y);
numfiles = (int)((float)height / (float)layout->tile_h + 0.5f);
return numfiles * layout->columns;
}
@@ -503,7 +503,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_y = 6;
layout->tile_w = layout->prv_w + 2 * layout->prv_border_x;
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
- layout->width = (int)(BLI_RCT_SIZE_X(&v2d->cur) - 2 * layout->tile_border_x);
+ layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
if (layout->columns > 0)
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
@@ -522,7 +522,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_x = 0;
layout->prv_border_y = 0;
layout->tile_h = textheight * 3 / 2;
- layout->height = (int)(BLI_RCT_SIZE_Y(&v2d->cur) - 2 * layout->tile_border_y);
+ layout->height = (int)(BLI_rctf_size_y(&v2d->cur) - 2 * layout->tile_border_y);
layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y);
column_widths(sfile->files, layout);
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index a127e2ca2bc..66cda3082ea 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -97,84 +97,94 @@ FSMenu *fsmenu_get(void)
static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsms = NULL;
+ FSMenuEntry *fsm_head = NULL;
switch (category) {
case FS_CATEGORY_SYSTEM:
- fsms = fsmenu->fsmenu_system;
+ fsm_head = fsmenu->fsmenu_system;
break;
case FS_CATEGORY_BOOKMARKS:
- fsms = fsmenu->fsmenu_bookmarks;
+ fsm_head = fsmenu->fsmenu_bookmarks;
break;
case FS_CATEGORY_RECENT:
- fsms = fsmenu->fsmenu_recent;
+ fsm_head = fsmenu->fsmenu_recent;
break;
}
- return fsms;
+ return fsm_head;
}
-static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsms)
+static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_head)
{
switch (category) {
case FS_CATEGORY_SYSTEM:
- fsmenu->fsmenu_system = fsms;
+ fsmenu->fsmenu_system = fsm_head;
break;
case FS_CATEGORY_BOOKMARKS:
- fsmenu->fsmenu_bookmarks = fsms;
+ fsmenu->fsmenu_bookmarks = fsm_head;
break;
case FS_CATEGORY_RECENT:
- fsmenu->fsmenu_recent = fsms;
+ fsmenu->fsmenu_recent = fsm_head;
break;
}
}
int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
int count = 0;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter; fsm_iter = fsm_iter->next) {
count++;
+ }
return count;
}
char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) {
idx--;
+ }
- return fsme ? fsme->path : NULL;
+ return fsm_iter ? fsm_iter->path : NULL;
}
short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *fsme;
+ FSMenuEntry *fsm_iter;
- for (fsme = fsmenu_get_category(fsmenu, category); fsme && idx; fsme = fsme->next)
+ for (fsm_iter = fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) {
idx--;
+ }
- return fsme ? fsme->save : 0;
+ return fsm_iter ? fsm_iter->save : 0;
}
-void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save)
+void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, FSMenuInsert flag)
{
- FSMenuEntry *prev;
- FSMenuEntry *fsme;
- FSMenuEntry *fsms;
+ FSMenuEntry *fsm_prev;
+ FSMenuEntry *fsm_iter;
+ FSMenuEntry *fsm_head;
- fsms = fsmenu_get_category(fsmenu, category);
- prev = fsme = fsms;
+ fsm_head = fsmenu_get_category(fsmenu, category);
+ fsm_prev = fsm_head; /* this is odd and not really correct? */
- for (; fsme; prev = fsme, fsme = fsme->next) {
- if (fsme->path) {
- const int cmp_ret = BLI_path_cmp(path, fsme->path);
+ for (fsm_iter = fsm_head; fsm_iter; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
+ if (fsm_iter->path) {
+ const int cmp_ret = BLI_path_cmp(path, fsm_iter->path);
if (cmp_ret == 0) {
+ if (flag & FS_INSERT_FIRST) {
+ if (fsm_iter != fsm_head) {
+ fsm_prev->next = fsm_iter->next;
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
+ }
+ }
return;
}
- else if (sorted && cmp_ret < 0) {
+ else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
break;
}
}
@@ -182,78 +192,82 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c
/* if we're bookmarking this, file should come
* before the last separator, only automatically added
* current dir go after the last sep. */
- if (save) {
+ if (flag & FS_INSERT_SAVE) {
break;
}
}
}
- fsme = MEM_mallocN(sizeof(*fsme), "fsme");
- fsme->path = BLI_strdup(path);
- fsme->save = save;
+ fsm_iter = MEM_mallocN(sizeof(*fsm_iter), "fsme");
+ fsm_iter->path = BLI_strdup(path);
+ fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
- if (prev) {
- fsme->next = prev->next;
- prev->next = fsme;
+ if (fsm_prev) {
+ if (flag & FS_INSERT_FIRST) {
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
+ }
+ else {
+ fsm_iter->next = fsm_prev->next;
+ fsm_prev->next = fsm_iter;
+ }
}
else {
- fsme->next = fsms;
- fsmenu_set_category(fsmenu, category, fsme);
+ fsm_iter->next = fsm_head;
+ fsmenu_set_category(fsmenu, category, fsm_iter);
}
}
void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
{
- FSMenuEntry *prev = NULL, *fsme = NULL;
- FSMenuEntry *fsms = fsmenu_get_category(fsmenu, category);
+ FSMenuEntry *fsm_prev = NULL;
+ FSMenuEntry *fsm_iter;
+ FSMenuEntry *fsm_head;
+
+ fsm_head = fsmenu_get_category(fsmenu, category);
- for (fsme = fsms; fsme && idx; prev = fsme, fsme = fsme->next)
+ for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
idx--;
- if (fsme) {
+ if (fsm_iter) {
/* you should only be able to remove entries that were
* not added by default, like windows drives.
* also separators (where path == NULL) shouldn't be removed */
- if (fsme->save && fsme->path) {
+ if (fsm_iter->save && fsm_iter->path) {
/* remove fsme from list */
- if (prev) {
- prev->next = fsme->next;
+ if (fsm_prev) {
+ fsm_prev->next = fsm_iter->next;
}
else {
- fsms = fsme->next;
- fsmenu_set_category(fsmenu, category, fsms);
+ fsm_head = fsm_iter->next;
+ fsmenu_set_category(fsmenu, category, fsm_head);
}
/* free entry */
- MEM_freeN(fsme->path);
- MEM_freeN(fsme);
+ MEM_freeN(fsm_iter->path);
+ MEM_freeN(fsm_iter);
}
}
}
void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
{
- FSMenuEntry *fsme = NULL;
- int nskip = 0;
+ FSMenuEntry *fsm_iter = NULL;
+ int nwritten = 0;
FILE *fp = BLI_fopen(filename, "w");
if (!fp) return;
fprintf(fp, "[Bookmarks]\n");
- for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsme; fsme = fsme->next) {
- if (fsme->path && fsme->save) {
- fprintf(fp, "%s\n", fsme->path);
+ for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter; fsm_iter = fsm_iter->next) {
+ if (fsm_iter->path && fsm_iter->save) {
+ fprintf(fp, "%s\n", fsm_iter->path);
}
}
fprintf(fp, "[Recent]\n");
- nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX;
- /* skip first entries if list too long */
- for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsme && (nskip > 0); fsme = fsme->next, --nskip) {
- /* pass */
- }
- for (; fsme; fsme = fsme->next) {
- if (fsme->path && fsme->save) {
- fprintf(fp, "%s\n", fsme->path);
+ for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); fsm_iter = fsm_iter->next, ++nwritten) {
+ if (fsm_iter->path && fsm_iter->save) {
+ fprintf(fp, "%s\n", fsm_iter->path);
}
}
fclose(fp);
@@ -288,7 +302,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
if (BLI_exists(line))
#endif
{
- fsmenu_insert_entry(fsmenu, category, line, 0, 1);
+ fsmenu_insert_entry(fsmenu, category, line, FS_INSERT_SAVE);
}
}
}
@@ -315,16 +329,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
tmps[2] = '\\';
tmps[3] = 0;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, FS_INSERT_SORTED);
}
}
/* Adding Desktop and My Documents */
if (read_bookmarks) {
SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -347,7 +361,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
FSRefMakePath(&dir, path, FILE_MAX);
if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) {
/* /net and /home are meaningless on OSX, home folders are stored in /Users */
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
}
}
@@ -357,26 +371,26 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
home = getenv("HOME");
if (read_bookmarks && home) {
BLI_snprintf(line, 256, "%s/", home);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
BLI_snprintf(line, 256, "%s/Desktop/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Documents/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Pictures/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Music/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
BLI_snprintf(line, 256, "%s/Movies/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
#else
@@ -409,7 +423,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
CFRelease(pathString);
CFRelease(cfURL);
@@ -436,7 +450,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
FSRefMakePath(&dir, path, FILE_MAX);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
}
/* Finally get user favorite places */
@@ -459,7 +473,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
CFRelease(pathString);
CFRelease(cfURL);
@@ -477,10 +491,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
if (read_bookmarks && home) {
BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
if (BLI_exists(line)) {
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
}
}
@@ -505,10 +519,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
len = strlen(mnt->mnt_dir);
if (len && mnt->mnt_dir[len - 1] != '/') {
BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
+ }
+ else {
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, FS_INSERT_SORTED);
}
- else
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
found = 1;
}
@@ -520,7 +535,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
/* fallback */
if (!found)
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", FS_INSERT_SORTED);
}
}
#endif
@@ -530,15 +545,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
static void fsmenu_free_category(struct FSMenu *fsmenu, FSMenuCategory category)
{
- FSMenuEntry *fsme = fsmenu_get_category(fsmenu, category);
+ FSMenuEntry *fsm_iter = fsmenu_get_category(fsmenu, category);
- while (fsme) {
- FSMenuEntry *n = fsme->next;
+ while (fsm_iter) {
+ FSMenuEntry *fsm_next = fsm_iter->next;
- if (fsme->path) MEM_freeN(fsme->path);
- MEM_freeN(fsme);
+ if (fsm_iter->path) {
+ MEM_freeN(fsm_iter->path);
+ }
+ MEM_freeN(fsm_iter);
- fsme = n;
+ fsm_iter = fsm_next;
}
}
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index d7576d71933..30730578085 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -43,6 +43,12 @@ typedef enum FSMenuCategory {
FS_CATEGORY_RECENT
} FSMenuCategory;
+typedef enum FSMenuInsert {
+ FS_INSERT_SORTED = (1 << 0),
+ FS_INSERT_SAVE = (1 << 1),
+ FS_INSERT_FIRST = (1 << 2) /* moves the item to the front of the list when its not already there */
+} FSMenuInsert;
+
struct FSMenu;
struct FSMenu *fsmenu_get(void);
@@ -59,7 +65,7 @@ char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index
* Duplicate entries are not added.
* \param sorted Should entry be inserted in sorted order?
*/
-void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save);
+void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const FSMenuInsert flag);
/** Return whether the entry was created by the user and can be saved and deleted */
short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 4b568b43695..7f39545258d 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -386,6 +386,7 @@ static void file_operatortypes(void)
WM_operatortype_append(FILE_OT_bookmark_toggle);
WM_operatortype_append(FILE_OT_bookmark_add);
WM_operatortype_append(FILE_OT_delete_bookmark);
+ WM_operatortype_append(FILE_OT_reset_recent);
WM_operatortype_append(FILE_OT_hidedot);
WM_operatortype_append(FILE_OT_filenum);
WM_operatortype_append(FILE_OT_directory_new);
@@ -537,7 +538,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* scrolling here is just annoying, disable it */
- ar->v2d.cur.ymax = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur);
ar->v2d.cur.ymin = 0;
/* set view2d view matrix for scrolling (without scrollers) */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index efe62eaf495..0d56b02e086 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -69,12 +69,6 @@
#include "graph_intern.h" // own include
-/* XXX */
-
-/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
-#define UI_FLT_MAX 10000.0f
-
-
/* ******************* graph editor space & buttons ************** */
#define B_REDR 1
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index e4bda15bc7d..ef2e56afca0 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -88,7 +88,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
FCM_EnvelopeData *fed;
- const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
+ const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
/* draw two black lines showing the standard reference levels */
@@ -137,7 +137,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
{
BezTriple *bezt = fcu->bezt;
- const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
+ const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur);
int i;
/* we use bgl points not standard gl points, to workaround vertex
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index f01d64b46b8..7107a6a2369 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -229,11 +229,11 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
&cur_new.ymin, &cur_new.ymax,
do_sel_only, include_handles);
- extra = 0.1f * BLI_RCT_SIZE_X(&cur_new);
+ extra = 0.1f * BLI_rctf_size_x(&cur_new);
cur_new.xmin -= extra;
cur_new.xmax += extra;
- extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new);
+ extra = 0.1f * BLI_rctf_size_y(&cur_new);
cur_new.ymin -= extra;
cur_new.ymax += extra;
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 633f2b72cf6..e2fc1657379 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -325,7 +325,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_SIZE_Y(&rect)))
+ if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect)))
mode = BEZT_OK_FRAMERANGE;
else
mode = BEZT_OK_VALUERANGE;
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 40f0683a852..0b904f36a8c 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -71,28 +71,6 @@
#include "image_intern.h"
-#define B_REDR 1
-#define B_IMAGECHANGED 2
-#define B_NOP 0
-#define B_TWINANIM 5
-#define B_SIMAGETILE 6
-#define B_IDNAME 10
-#define B_FACESEL_PAINT_TEST 11
-#define B_SIMA_RECORD 12
-#define B_SIMA_PLAY 13
-
-#define B_SIMANOTHING 16
-#define B_SIMABRUSHCHANGE 17
-#define B_SIMABRUSHBROWSE 18
-#define B_SIMABRUSHLOCAL 19
-#define B_SIMABRUSHDELETE 20
-#define B_KEEPDATA 21
-#define B_SIMABTEXBROWSE 22
-#define B_SIMABTEXDELETE 23
-#define B_VPCOLSLI 24
-#define B_SIMACLONEBROWSE 25
-#define B_SIMACLONEDELETE 26
-
/* proto */
static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str)
@@ -169,47 +147,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
/* ************ panel stuff ************* */
-/* is used for both read and write... */
-
-static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt))
-{
- SpaceImage *sima = CTX_wm_space_image(C);
- ImBuf *ibuf;
- void *lock;
- int result;
-
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
- result = ibuf && ibuf->rect_float;
- ED_space_image_release_buffer(sima, lock);
-
- return result;
-}
-
-static void image_panel_curves(const bContext *C, Panel *pa)
-{
- bScreen *sc = CTX_wm_screen(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- ImBuf *ibuf;
- PointerRNA simaptr;
- int levels;
- void *lock;
-
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
-
- if (ibuf) {
- if (sima->cumap == NULL)
- sima->cumap = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
-
- /* curvemap black/white levels only works for RGBA */
- levels = (ibuf->channels == 4);
-
- RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr);
- uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0);
- }
-
- ED_space_image_release_buffer(sima, lock);
-}
-
#if 0
/* 0: disable preview
* otherwise refresh preview
@@ -234,6 +171,7 @@ void image_preview_event(int event)
}
if (exec && G.scene->nodetree) {
+ Scene *scene = G.scene;
/* should work when no node editor in screen..., so we execute right away */
ntreeCompositTagGenerators(G.scene->nodetree);
@@ -244,7 +182,7 @@ void image_preview_event(int event)
BIF_store_spare();
- ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1); /* 1 is do_previews */
+ ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */
G.scene->nodetree->timecursor = NULL;
G.scene->nodetree->test_break = NULL;
@@ -268,13 +206,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
int mval[2];
if (G.scene->r.mode & R_BORDER) {
- winx *= BLI_RCT_SIZE_X(&G.scene->r.border);
- winy *= BLI_RCT_SIZE_Y(&G.scene->r.border);
+ winx *= BLI_rcti_size_x(&G.scene->r.border);
+ winy *= BLI_rctf_size_y(&G.scene->r.border);
}
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */
- BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f);
+ BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f);
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
/* correction for gla draw */
@@ -611,6 +549,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiLayout *row, *split, *col;
uiBlock *block;
char str[128];
+
void *lock;
if (!ptr->data)
@@ -728,7 +667,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiItemL(layout, str, ICON_NONE);
}
}
-
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
+ uiItemR(col, &imaptr, "view_as_render", 0, NULL, ICON_NONE);
+
if (ima->source != IMA_SRC_GENERATED) {
if (compact == 0) { /* background image view doesnt need these */
uiItemS(layout);
@@ -794,15 +737,18 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
MEM_freeN(cb);
}
-void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
+void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_management)
{
ImageFormatData *imf = imfptr->data;
ID *id = imfptr->id.data;
+ PointerRNA display_settings_ptr;
+ PropertyRNA *prop;
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
/* some settings depend on this being a scene thats rendered */
const short is_render_out = (id && GS(id->name) == ID_SCE);
uiLayout *col, *row, *split, *sub;
+ int show_preview = FALSE;
col = uiLayoutColumn(layout, FALSE);
@@ -843,6 +789,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
}
if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) {
+ show_preview = TRUE;
uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE);
}
@@ -864,6 +811,22 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
#endif
}
+
+ /* color management */
+ if (color_management &&
+ (!BKE_imtype_supports_float(imf->imtype) ||
+ (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG)))
+ {
+ prop = RNA_struct_find_property(imfptr, "display_settings");
+ display_settings_ptr = RNA_property_pointer_get(imfptr, prop);
+
+ col = uiLayoutColumn(layout, FALSE);
+ uiItemL(col, IFACE_("Color Management"), ICON_NONE);
+
+ uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
+
+ uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings");
+ }
}
void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
@@ -886,14 +849,6 @@ void image_buttons_register(ARegionType *art)
{
PanelType *pt;
- pt = MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
- strcpy(pt->idname, "IMAGE_PT_curves");
- strcpy(pt->label, "Curves");
- pt->draw = image_panel_curves;
- pt->poll = image_panel_poll;
- pt->flag |= PNL_DEFAULT_CLOSED;
- BLI_addtail(&art->paneltypes, pt);
-
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
strcpy(pt->idname, "IMAGE_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index e293264c021..749ba75cfa1 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -51,6 +51,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -70,34 +71,13 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "WM_api.h"
+#include "WM_types.h"
#include "RE_pipeline.h"
#include "image_intern.h"
-#define HEADER_HEIGHT 18
-
-static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
-{
- /* detect if we need to redo the curve map.
- * ibuf->rect is zero for compositor and render results after change
- * convert to 32 bits always... drawing float rects isn't supported well (atis)
- *
- * NOTE: if float buffer changes, we have to manually remove the rect
- */
-
- if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
- if (color_manage) {
- if (ima && ima->source == IMA_SRC_VIEWER)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- }
- else
- ibuf->profile = IB_PROFILE_NONE;
-
- IMB_rect_from_float(ibuf);
- }
-}
-
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
RenderResult *rr;
@@ -112,7 +92,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
}
/* used by node view too */
-void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
+void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
{
char str[256];
@@ -136,7 +116,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
/* noisy, high contrast make impossible to read if lower alpha is used. */
glColor4ub(0, 0, 0, 190);
- glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20);
+ glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, 20);
glDisable(GL_BLEND);
BLF_size(blf_mono_font, 11, 72);
@@ -209,6 +189,20 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
}
+
+ if (color_manage && channels == 4) {
+ float pixel[4];
+
+ if (use_default_view)
+ IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, NULL, &scene->display_settings);
+ else
+ IMB_colormanagement_pixel_to_display_space_v4(pixel, fp, &scene->view_settings, &scene->display_settings);
+
+ BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
}
/* color rectangle */
@@ -252,11 +246,15 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
}
if (color_manage) {
- linearrgb_to_srgb_v4(finalcol, col);
+ if (use_default_view)
+ IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings);
+ else
+ IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings);
}
else {
copy_v4_v4(finalcol, col);
}
+
glDisable(GL_BLEND);
glColor3fv(finalcol);
dx += 5;
@@ -418,10 +416,9 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
MEM_freeN(rectf);
}
-static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
+static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
int x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
/* set zoom */
glPixelZoom(zoomx, zoomy);
@@ -445,6 +442,9 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
}
else {
+ unsigned char *display_buffer;
+ void *cache_handle;
+
if (sima->flag & SI_USE_ALPHA) {
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
@@ -452,17 +452,17 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- /* we don't draw floats buffers directly but
- * convert them, and optionally apply curves */
- image_verify_buffer_float(ima, ibuf, color_manage);
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- if (ibuf->rect)
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ if (display_buffer)
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
#if 0
else
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
#endif
-
+
+ IMB_display_buffer_release(cache_handle);
+
if (sima->flag & SI_USE_ALPHA)
glDisable(GL_BLEND);
}
@@ -471,14 +471,14 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
glPixelZoom(1.0f, 1.0f);
}
-static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
+static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy)
{
unsigned int *rt, *rp, *rectmain;
short y, heigth, len;
/* the right offset in rectot */
- rt = ibuf->rect + (starty * ibuf->x + startx);
+ rt = buffer + (starty * width + startx);
len = (endx - startx);
heigth = (endy - starty);
@@ -487,7 +487,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
for (y = 0; y < heigth; y++) {
memcpy(rp, rt, len * 4);
- rt += ibuf->x;
+ rt += width;
rp += len;
}
return rectmain;
@@ -495,28 +495,34 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
{
+ unsigned char *display_buffer;
unsigned int *rect;
int dx, dy, sx, sy, x, y;
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ void *cache_handle;
/* verify valid values, just leave this a while */
if (ima->xrep < 1) return;
if (ima->yrep < 1) return;
-
+
+ if (ima->flag & IMA_VIEW_AS_RENDER)
+ display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
+ else
+ display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle);
+
+ if (!display_buffer)
+ return;
+
glPixelZoom(zoomx, zoomy);
if (sima->curtile >= ima->xrep * ima->yrep)
sima->curtile = ima->xrep * ima->yrep - 1;
- /* create char buffer from float if needed */
- image_verify_buffer_float(ima, ibuf, color_manage);
-
/* retrieve part of image buffer */
dx = ibuf->x / ima->xrep;
dy = ibuf->y / ima->yrep;
sx = (sima->curtile % ima->xrep) * dx;
sy = (sima->curtile / ima->xrep) * dy;
- rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy);
+ rect = get_part_from_buffer((unsigned int*)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
/* draw repeated */
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
@@ -529,10 +535,12 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
glPixelZoom(1.0f, 1.0f);
+ IMB_display_buffer_release(cache_handle);
+
MEM_freeN(rect);
}
-static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
+static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
{
const double time_current = PIL_check_seconds_timer();
@@ -549,7 +557,7 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce
if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
else
- draw_image_buffer(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
/* only draw until running out of time */
if ((PIL_check_seconds_timer() - time_current) > 0.25)
@@ -632,22 +640,35 @@ static void draw_image_view_tool(Scene *scene)
}
#endif
-static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height)
+static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height)
{
Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
ImBuf *ibuf;
unsigned int size, alpha;
+ unsigned char *display_buffer;
unsigned char *rect, *cp;
+ void *cache_handle;
if (!brush || !brush->clone.image)
return NULL;
ibuf = BKE_image_get_ibuf(brush->clone.image, NULL);
- if (!ibuf || !ibuf->rect)
+ if (!ibuf)
return NULL;
- rect = MEM_dupallocN(ibuf->rect);
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (!display_buffer) {
+ IMB_display_buffer_release(cache_handle);
+
+ return NULL;
+ }
+
+ rect = MEM_dupallocN(display_buffer);
+
+ IMB_display_buffer_release(cache_handle);
+
if (!rect)
return NULL;
@@ -666,7 +687,7 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh
return rect;
}
-static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, float zoomy)
+static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy)
{
Brush *brush;
int x, y, w, h;
@@ -677,7 +698,7 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
* drawing with alpha */
- clonerect = get_alpha_clone_image(scene, &w, &h);
+ clonerect = get_alpha_clone_image(C, scene, &w, &h);
if (clonerect) {
UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
@@ -698,8 +719,10 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo
/* draw main image area */
-void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
+void draw_image_main(const bContext *C, ARegion *ar)
{
+ SpaceImage *sima = CTX_wm_space_image(C);
+ Scene *scene = CTX_data_scene(C);
Image *ima;
ImBuf *ibuf;
float zoomx, zoomy;
@@ -748,15 +771,15 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
if (ibuf == NULL)
ED_region_grid_draw(ar, zoomx, zoomy);
else if (sima->flag & SI_DRAW_TILE)
- draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy);
+ draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy);
else if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
else
- draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+ draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
/* paint helpers */
if (sima->mode == SI_MODE_PAINT)
- draw_image_paint_helpers(ar, scene, zoomx, zoomy);
+ draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
/* XXX integrate this code */
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 79d01491df7..92433449985 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -161,8 +161,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
*height = (scene->r.ysch * scene->r.size) / 100;
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
- *width *= BLI_RCT_SIZE_X(&scene->r.border);
- *height *= BLI_RCT_SIZE_Y(&scene->r.border);
+ *width *= BLI_rctf_size_x(&scene->r.border);
+ *height *= BLI_rctf_size_y(&scene->r.border);
}
}
@@ -204,8 +204,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float
ED_space_image_get_size(sima, &width, &height);
- *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
- *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
+ *zoomx = (float)(BLI_rcti_size_x(&ar->winrct) + 1) / (float)(BLI_rctf_size_x(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_rcti_size_y(&ar->winrct) + 1) / (float)(BLI_rctf_size_y(&ar->v2d.cur) * height);
}
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index 0d3a7614f10..f86e59c41a8 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -52,7 +52,7 @@ struct ARegion *image_has_scope_region(struct ScrArea *sa);
extern const char *image_context_dir[]; /* doc access */
/* image_draw.c */
-void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
+void draw_image_main(const struct bContext *C, struct ARegion *ar);
void draw_image_grease_pencil(struct bContext *C, short onlyv2d);
void draw_image_sample_line(struct SpaceImage *sima);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 86722c5158e..16c9405e098 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -55,6 +55,7 @@
#include "BKE_report.h"
#include "BKE_screen.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -98,9 +99,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if ((width < 4) && (height < 4))
sima->zoom = oldzoom;
- else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom)
+ else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
- else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom)
+ else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
}
@@ -191,7 +192,7 @@ int space_image_main_area_poll(bContext *C)
}
/* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */
-int space_image_main_area_not_uv_brush_poll(bContext *C)
+static int space_image_main_area_not_uv_brush_poll(bContext *C)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
@@ -581,8 +582,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
h = height * aspy;
/* check if the image will fit in the image with (zoom == 1) */
- width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ width = BLI_rcti_size_x(&ar->winrct) + 1;
+ height = BLI_rcti_size_y(&ar->winrct) + 1;
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
/* find the zoom value that will fit the image in the image space */
@@ -1168,6 +1169,10 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
}
BLI_path_abs(simopts->filepath, G.main->name);
}
+
+ /* color management */
+ BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings, &scene->display_settings);
+ BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, &scene->view_settings);
}
ED_space_image_release_buffer(sima, lock);
@@ -1178,6 +1183,8 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
+ BKE_color_managed_view_settings_free(&simopts->im_format.view_settings);
+
simopts->im_format = *(ImageFormatData *)op->customdata;
}
@@ -1190,12 +1197,47 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op
static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
+ BKE_color_managed_view_settings_free(&((ImageFormatData *)op->customdata)->view_settings);
+
*(ImageFormatData *)op->customdata = simopts->im_format;
}
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
+static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, int save_as_render, void **cache_handle)
+{
+ ImageFormatData *imf = &simopts->im_format;
+ ImBuf *colormanaged_ibuf;
+ int do_colormanagement;
+
+ *cache_handle = NULL;
+ do_colormanagement = save_as_render && !BKE_imtype_supports_float(imf->imtype);
+
+ if (do_colormanagement) {
+ unsigned char *display_buffer;
+
+ display_buffer = IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle);
+
+ if (*cache_handle) {
+ colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
+ colormanaged_ibuf->rect = (unsigned int *) display_buffer;
+ }
+ else {
+ /* no cache handle means color management didn't run transformation
+ * or performed transformation to image's byte buffer which doesn't
+ * require allocating new image buffer
+ */
+ colormanaged_ibuf = ibuf;
+ }
+ }
+ else {
+ colormanaged_ibuf = ibuf;
+ }
+
+ return colormanaged_ibuf;
+}
+
/* assumes name is FILE_MAX */
/* ima->name and ibuf->name should end up the same */
static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
@@ -1205,9 +1247,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
+ void *cache_handle;
+ ImBuf *colormanaged_ibuf;
const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
+ const short save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render"));
short ok = FALSE;
/* old global to ensure a 2nd save goes to same dir */
@@ -1231,7 +1276,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24;
}
}
-
+
+ colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, save_as_render, &cache_handle);
+
if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
Scene *scene = CTX_data_scene(C);
RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
@@ -1245,7 +1292,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
+ if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy))
+ {
ok = TRUE;
}
}
@@ -1284,6 +1332,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (relative) {
BLI_path_rel(ima->name, relbase); /* only after saving */
}
+
+ IMB_colormanagment_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
}
}
else {
@@ -1294,6 +1344,13 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
WM_cursor_wait(0);
+
+ if (cache_handle) {
+ colormanaged_ibuf->rect = NULL;
+ IMB_freeImBuf(colormanaged_ibuf);
+
+ IMB_display_buffer_release(cache_handle);
+ }
}
ED_space_image_release_buffer(sima, lock);
@@ -1302,6 +1359,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
static void image_save_as_free(wmOperator *op)
{
if (op->customdata) {
+ ImageFormatData *im_format = (ImageFormatData *)op->customdata;
+ BKE_color_managed_view_settings_free(&im_format->view_settings);
+
MEM_freeN(op->customdata);
op->customdata = NULL;
}
@@ -1354,6 +1414,11 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
RNA_boolean_set(op->ptr, "copy", TRUE);
}
+ if (ima->source == IMA_SRC_VIEWER || (ima->flag & IMA_VIEW_AS_RENDER))
+ RNA_boolean_set(op->ptr, "save_as_render", TRUE);
+ else
+ RNA_boolean_set(op->ptr, "save_as_render", FALSE);
+
op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__);
memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format));
@@ -1389,7 +1454,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &ptr);
- uiTemplateImageSettings(layout, &ptr);
+ uiTemplateImageSettings(layout, &ptr, FALSE);
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
@@ -1417,6 +1482,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ RNA_def_boolean(ot->srna, "save_as_render", 0, "Save As Render", "Apply render part of display transform when saving byte image");
RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE,
@@ -1601,8 +1667,10 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "color", color);
alpha = RNA_boolean_get(op->ptr, "alpha");
- if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ if (!floatbuf) {
+ /* OCIO_TODO: perhaps we need to convert to display space, not just to sRGB */
linearrgb_to_srgb_v3_v3(color, color);
+ }
if (!alpha)
color[3] = 1.0f;
@@ -1938,14 +2006,18 @@ typedef struct ImageSampleInfo {
float *zfp;
int draw;
+ int color_manage;
+ int use_default_view;
} ImageSampleInfo;
-static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
+static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
{
ImageSampleInfo *info = arg_info;
if (info->draw) {
- /* no color management needed for images (color_manage=0) */
- ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
+ Scene *scene = CTX_data_scene(C);
+
+ ED_image_draw_info(scene, ar, info->color_manage, info->use_default_view, info->channels,
+ info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
}
}
@@ -1975,13 +2047,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
-
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -2003,7 +2069,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
ImageSampleInfo *info = op->customdata;
float fx, fy;
-
+ Scene *scene = CTX_data_scene(C);
+ CurveMapping *curve_mapping = scene->view_settings.curve_mapping;
+
if (ibuf == NULL) {
ED_space_image_release_buffer(sima, lock);
info->draw = 0;
@@ -2016,6 +2084,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
float *fp;
unsigned char *cp;
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
+ Image *image = ED_space_image(sima);
CLAMP(x, 0, ibuf->x - 1);
CLAMP(y, 0, ibuf->y - 1);
@@ -2029,7 +2098,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colfp = NULL;
info->zp = NULL;
info->zfp = NULL;
-
+
+ info->use_default_view = (image->flag & IMA_VIEW_AS_RENDER) ? FALSE : TRUE;
+
if (ibuf->rect) {
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
@@ -2044,6 +2115,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -2053,6 +2126,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = fp[2];
info->colf[3] = fp[3];
info->colfp = info->colf;
+
+ info->color_manage = TRUE;
}
if (ibuf->zbuf) {
@@ -2063,25 +2138,21 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->zf = ibuf->zbuf_float[y * ibuf->x + x];
info->zfp = &info->zf;
}
-
- if (sima->cumap && ibuf->channels == 4) {
+
+ if (curve_mapping && ibuf->channels == 4) {
/* we reuse this callback for set curves point operators */
if (RNA_struct_find_property(op->ptr, "point")) {
int point = RNA_enum_get(op->ptr, "point");
if (point == 1) {
- curvemapping_set_black_white(sima->cumap, NULL, info->colfp);
- if (ibuf->rect_float)
- curvemapping_do_ibuf(sima->cumap, ibuf);
+ curvemapping_set_black_white(curve_mapping, NULL, info->colfp);
}
else if (point == 0) {
- curvemapping_set_black_white(sima->cumap, info->colfp, NULL);
- if (ibuf->rect_float)
- curvemapping_do_ibuf(sima->cumap, ibuf);
+ curvemapping_set_black_white(curve_mapping, info->colfp, NULL);
}
}
}
-
+
// XXX node curve integration ..
#if 0
{
@@ -2211,7 +2282,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
hist->co[1][0] = x2f;
hist->co[1][1] = y2f;
- BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
+ BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings);
/* reset y zoom */
hist->ymax = 1.0f;
@@ -2306,7 +2377,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
- ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
+ ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra,
+ &scene->view_settings, &scene->display_settings); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 91a0cba2555..abe8dfb751b 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -195,9 +195,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
static void image_free(SpaceLink *sl)
{
SpaceImage *simage = (SpaceImage *) sl;
-
- if (simage->cumap)
- curvemapping_free(simage->cumap);
+
scopes_free(&simage->scopes);
}
@@ -217,8 +215,6 @@ static SpaceLink *image_duplicate(SpaceLink *sl)
SpaceImage *simagen = MEM_dupallocN(sl);
/* clear or remove stuff from old */
- if (simagen->cumap)
- simagen->cumap = curvemapping_copy(simagen->cumap);
scopes_new(&simagen->scopes);
@@ -442,7 +438,12 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
break;
case ND_MODE:
+ if (wmn->subtype == NS_EDITMODE_MESH)
+ ED_area_tag_refresh(sa);
+ ED_area_tag_redraw(sa);
+ break;
case ND_RENDER_RESULT:
+ case ND_RENDER_OPTIONS:
case ND_COMPO_RESULT:
if (ED_space_image_show_render(sima))
image_scopes_tag_refresh(sa);
@@ -561,8 +562,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
if (ima)
h *= ima->aspy / ima->aspx;
- winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
- winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
+ winx = BLI_rcti_size_x(&ar->winrct) + 1;
+ winy = BLI_rcti_size_y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
@@ -652,7 +653,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
image_main_area_set_view2d(sima, ar);
/* we draw image in pixelspace */
- draw_image_main(sima, ar, scene);
+ draw_image_main(C, ar);
/* and uvs in 0.0-1.0 space */
UI_view2d_view_ortho(v2d);
@@ -776,9 +777,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
if (!sima->scopes.ok) {
- BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
}
- scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
}
ED_space_image_release_buffer(sima, lock);
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 4ffa99319c4..5e5e0c87feb 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -368,7 +368,7 @@ static void stats_string(Scene *scene)
s += sprintf(s, "%s | ", versionstr);
if (scene->obedit) {
- if (ob_get_keyblock(scene->obedit))
+ if (BKE_keyblock_from_object(scene->obedit))
s += sprintf(s, "(Key) ");
if (scene->obedit->type == OB_MESH) {
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index abffb955405..abdfa0ef4dd 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
int i, b;
rcti rectlink;
- rectlink.xmin = (int)BLI_RCT_CENTER_X(&line->from->rect);
- rectlink.ymin = (int)BLI_RCT_CENTER_Y(&line->from->rect);
- rectlink.xmax = (int)BLI_RCT_CENTER_X(&line->to->rect);
- rectlink.ymax = (int)BLI_RCT_CENTER_Y(&line->to->rect);
+ rectlink.xmin = (int)BLI_rctf_cent_x(&line->from->rect);
+ rectlink.ymin = (int)BLI_rctf_cent_y(&line->from->rect);
+ rectlink.xmax = (int)BLI_rctf_cent_x(&line->to->rect);
+ rectlink.ymax = (int)BLI_rctf_cent_y(&line->to->rect);
if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) {
for (i=0; i<tot-1; i++)
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 6ffac1dcd34..5d7ff77e032 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -72,10 +72,7 @@
#include "logic_intern.h"
-
-#define MAX_RENDER_PASS 100
#define B_REDR 1
-#define B_IDNAME 2
#define B_ADD_SENS 2703
#define B_CHANGE_SENS 2704
@@ -91,7 +88,6 @@
#define B_SOUNDACT_BROWSE 2712
-#define B_SETSECTOR 2713
#define B_SETPROP 2714
#define B_SETACTOR 2715
#define B_SETMAINACTOR 2716
@@ -187,178 +183,6 @@ void make_unique_prop_names(bContext *C, char *str)
MEM_freeN(names);
}
-static void make_unique_prop_names_cb(bContext *C, void *strv, void *UNUSED(redraw_view3d_flagv))
-{
- char *str= strv;
-// int redraw_view3d_flag= GET_INT_FROM_POINTER(redraw_view3d_flagv);
-
- make_unique_prop_names(C, str);
-}
-
-
-static void old_sca_move_sensor(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bSensor *sens_to_delete= datav;
- int val;
- Base *base;
- bSensor *sens, *tmp;
-
- // val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- sens= base->object->sensors.first;
- while (sens) {
- if (sens == sens_to_delete) break;
- sens= sens->next;
- }
-
- if (sens) {
- if ( val==1 && sens->prev) {
- for (tmp=sens->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlinkbefore(&base->object->sensors, tmp, sens);
- }
- }
- else if ( val==2 && sens->next) {
- for (tmp=sens->next; tmp; tmp=tmp->next) {
- if (tmp->flag & SENS_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->sensors, sens);
- BLI_insertlink(&base->object->sensors, tmp, sens);
- }
- }
- ED_undo_push(C, "Move sensor");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
-static void old_sca_move_controller(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bController *controller_to_del= datav;
- int val;
- Base *base;
- bController *cont, *tmp;
-
- //val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- cont= base->object->controllers.first;
- while (cont) {
- if (cont == controller_to_del) break;
- cont= cont->next;
- }
-
- if (cont) {
- if ( val==1 && cont->prev) {
- /* locate the controller that has the same state mask but is earlier in the list */
- tmp = cont->prev;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->prev;
- }
- if (tmp) {
- BLI_remlink(&base->object->controllers, cont);
- BLI_insertlinkbefore(&base->object->controllers, tmp, cont);
- }
- }
- else if ( val==2 && cont->next) {
- tmp = cont->next;
- while (tmp) {
- if (tmp->state_mask & cont->state_mask)
- break;
- tmp = tmp->next;
- }
- BLI_remlink(&base->object->controllers, cont);
- BLI_insertlink(&base->object->controllers, tmp, cont);
- }
- ED_undo_push(C, "Move controller");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
-static void old_sca_move_actuator(bContext *C, void *datav, void *move_up)
-{
- /* deprecated, no longer using it (moved to sca.c) */
- Scene *scene= CTX_data_scene(C);
- bActuator *actuator_to_move= datav;
- int val;
- Base *base;
- bActuator *act, *tmp;
-
- //val= pupmenu("Move up%x1|Move down %x2");
- val = move_up ? 1:2;
-
- if (val>0) {
- /* now find out which object has this ... */
- base= FIRSTBASE;
- while (base) {
-
- act= base->object->actuators.first;
- while (act) {
- if (act == actuator_to_move) break;
- act= act->next;
- }
-
- if (act) {
- if ( val==1 && act->prev) {
- /* locate the first visible actuators before this one */
- for (tmp = act->prev; tmp; tmp=tmp->prev) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlinkbefore(&base->object->actuators, tmp, act);
- }
- }
- else if ( val==2 && act->next) {
- for (tmp=act->next; tmp; tmp=tmp->next) {
- if (tmp->flag & ACT_VISIBLE)
- break;
- }
- if (tmp) {
- BLI_remlink(&base->object->actuators, act);
- BLI_insertlink(&base->object->actuators, tmp, act);
- }
- }
- ED_undo_push(C, "Move actuator");
- break;
- }
-
- base= base->next;
- }
- }
-}
-
static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
{
Main *bmain= CTX_data_main(C);
@@ -631,14 +455,6 @@ static const char *sensor_name(int type)
return "unknown";
}
-static const char *sensor_pup(void)
-{
- /* the number needs to match defines in DNA_sensor_types.h */
- return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|"
- "Touch %x1|Collision %x6|Near %x2|Radar %x7|"
- "Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12|Armature %x14";
-}
-
static const char *controller_name(int type)
{
switch (type) {
@@ -662,11 +478,6 @@ static const char *controller_name(int type)
return "unknown";
}
-static const char *controller_pup(void)
-{
- return "Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3";
-}
-
static const char *actuator_name(int type)
{
switch (type) {
@@ -718,36 +529,6 @@ static const char *actuator_name(int type)
return "unknown";
}
-
-
-
-static const char *actuator_pup(Object *owner)
-{
- switch (owner->type) {
- case OB_ARMATURE:
- return ("Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- break;
-
- case OB_MESH:
- return ("Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- break;
-
- default:
- return ("Actuators %t|Motion %x0|Constraint %x9|Ipo %x1"
- "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
- "|Scene %x11|Random %x13|Message %x14|Game %x17"
- "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22");
- }
-}
-
-
-
static void set_sca_ob(Object *ob)
{
bController *cont;
@@ -935,151 +716,6 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
return idar;
}
-
-static int get_col_sensor(int type)
-{
- /* XXX themecolors not here */
-
- switch (type) {
- case SENS_ALWAYS: return TH_PANEL;
- case SENS_DELAY: return TH_PANEL;
- case SENS_TOUCH: return TH_PANEL;
- case SENS_COLLISION: return TH_PANEL;
- case SENS_NEAR: return TH_PANEL;
- case SENS_KEYBOARD: return TH_PANEL;
- case SENS_PROPERTY: return TH_PANEL;
- case SENS_ARMATURE: return TH_PANEL;
- case SENS_ACTUATOR: return TH_PANEL;
- case SENS_MOUSE: return TH_PANEL;
- case SENS_RADAR: return TH_PANEL;
- case SENS_RANDOM: return TH_PANEL;
- case SENS_RAY: return TH_PANEL;
- case SENS_MESSAGE: return TH_PANEL;
- case SENS_JOYSTICK: return TH_PANEL;
- default: return TH_PANEL;
- }
-}
-static void set_col_sensor(int type, int medium)
-{
- int col= get_col_sensor(type);
- UI_ThemeColorShade(col, medium?30:0);
-}
-
-
-static void verify_logicbutton_func(bContext *UNUSED(C), void *data1, void *data2)
-{
- bSensor *sens= (bSensor*)data1;
-
- if (sens->level && sens->tap) {
- if (data2 == &(sens->level))
- sens->tap= 0;
- else
- sens->level= 0;
- }
-}
-
-static void test_scriptpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->text, name, offsetof(ID, name) + 2);
-}
-
-static void test_actionpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->action, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-
-static void test_obpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_lib_extern(*idpp); /* checks lib data, sets correct flag for saving then */
-}
-
-static void test_meshpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->mesh, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_matpoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->mat, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_scenepoin_but(struct bContext *C, const char *name, ID **idpp)
-{
- *idpp= BLI_findstring(&CTX_data_main(C)->scene, name, offsetof(ID, name) + 2);
- if (*idpp)
- id_us_plus(*idpp);
-}
-
-static void test_keyboard_event(struct bContext *UNUSED(C), void *arg_ks, void *UNUSED(arg))
-{
- bKeyboardSensor *ks= (bKeyboardSensor*)arg_ks;
-
- if (!ISKEYBOARD(ks->key))
- ks->key= 0;
- if (!ISKEYBOARD(ks->qual))
- ks->qual= 0;
- if (!ISKEYBOARD(ks->qual2))
- ks->qual2= 0;
-}
-
-/**
- * Draws a toggle for pulse mode, a frequency field and a toggle to invert
- * the value of this sensor. Operates on the shared data block of sensors.
- */
-static void draw_default_sensor_header(bSensor *sens,
- uiBlock *block,
- short x,
- short y,
- short w)
-{
- uiBut *but;
-
- /* Pulsing and frequency */
- uiBlockBeginAlign(block);
- uiDefIconButBitS(block, TOG, SENS_PULSE_REPEAT, 1, ICON_DOTSUP,
- (short)(x + 10 + 0.0 * (w - 20)), (short)(y - 21), (short)(0.1 * (w - 20)), 19,
- &sens->pulse, 0.0, 0.0, 0, 0,
- "Activate TRUE level triggering (pulse mode)");
-
- uiDefIconButBitS(block, TOG, SENS_NEG_PULSE_MODE, 1, ICON_DOTSDOWN,
- (short)(x + 10 + 0.1 * (w-20)), (short)(y - 21), (short)(0.1 * (w-20)), 19,
- &sens->pulse, 0.0, 0.0, 0, 0,
- "Activate FALSE level triggering (pulse mode)");
- uiDefButS(block, NUM, 1, "f:",
- (short)(x + 10 + 0.2 * (w-20)), (short)(y - 21), (short)(0.275 * (w-20)), 19,
- &sens->freq, 0.0, 10000.0, 0, 0,
- "Delay between repeated pulses (in logic tics, 0 = no delay)");
- uiBlockEndAlign(block);
-
- /* value or shift? */
- uiBlockBeginAlign(block);
- but = uiDefButS(block, TOG, 1, "Level",
- (short)(x + 10 + 0.5 * (w-20)), (short)(y - 21), (short)(0.20 * (w-20)), 19,
- &sens->level, 0.0, 0.0, 0, 0,
- "Level detector, trigger controllers of new states (only applicable upon logic state transition)");
- uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->level));
- but = uiDefButS(block, TOG, 1, "Tap",
- (short)(x + 10 + 0.702 * (w-20)), (short)(y - 21), (short)(0.12 * (w-20)), 19,
- &sens->tap, 0.0, 0.0, 0, 0,
- "Trigger controllers only for an instant, even while the sensor remains true");
- uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->tap));
- uiBlockEndAlign(block);
-
- uiDefButS(block, TOG, 1, "Inv",
- (short)(x + 10 + 0.85 * (w-20)), (short)(y - 21), (short)(0.15 * (w-20)), 19,
- &sens->invert, 0.0, 0.0, 0, 0,
- "Invert the level (output) of this sensor");
-}
-
static void get_armature_bone_constraint(Object *ob, const char *posechannel, const char *constraint_name, bConstraint **constraint)
{
/* check that bone exist in the active object */
@@ -1094,1848 +730,6 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co
}
/* didn't find any */
}
-static void check_armature_bone_constraint(Object *ob, char *posechannel, char *constraint)
-{
- /* check that bone exist in the active object */
- if (ob->type == OB_ARMATURE && ob->pose) {
- bPoseChannel *pchan;
- bPose *pose = ob->pose;
- for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
- if (!strcmp(pchan->name, posechannel)) {
- /* found it, now look for constraint channel */
- bConstraint *con;
- for (con=pchan->constraints.first; con; con=con->next) {
- if (!strcmp(con->name, constraint)) {
- /* found it, all ok */
- return;
- }
- }
- /* didn't find constraint, make empty */
- constraint[0] = 0;
- return;
- }
- }
- }
- /* didn't find any */
- posechannel[0] = 0;
- constraint[0] = 0;
-}
-
-static void check_armature_sensor(bContext *C, void *arg1_but, void *arg2_sens)
-{
- bArmatureSensor *sens = arg2_sens;
- uiBut *but = arg1_but;
- Object *ob= CTX_data_active_object(C);
-
- /* check that bone exist in the active object */
- but->retval = B_REDR;
- check_armature_bone_constraint(ob, sens->posechannel, sens->constraint);
-}
-
-static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short xco, short yco, short width)
-{
- bNearSensor *ns = NULL;
- bTouchSensor *ts = NULL;
- bKeyboardSensor *ks = NULL;
- bPropertySensor *ps = NULL;
- bArmatureSensor *arm = NULL;
- bMouseSensor *ms = NULL;
- bCollisionSensor *cs = NULL;
- bRadarSensor *rs = NULL;
- bRandomSensor *randomSensor = NULL;
- bRaySensor *raySens = NULL;
- bMessageSensor *mes = NULL;
- bJoystickSensor *joy = NULL;
- bActuatorSensor *as = NULL;
- bDelaySensor *ds = NULL;
- uiBut *but;
- short ysize;
- const char *str;
-
- /* yco is at the top of the rect, draw downwards */
-
- set_col_sensor(sens->type, 0);
-
- switch (sens->type) {
- case SENS_ALWAYS:
- {
- ysize= 24;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- yco-= ysize;
-
- break;
- }
- case SENS_TOUCH:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- ts= sens->data;
-
- // uiDefBut(block, TEX, 1, "Property:", xco, yco-22, width, 19, &ts->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property");
- uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:", (short)(xco + 10), (short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material");
- // uiDefButF(block, NUM, 1, "Margin:", xco+width/2, yco-44, width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity");
- yco-= ysize;
- break;
- }
- case SENS_COLLISION:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- cs= sens->data;
-
- /* The collision sensor will become a generic collision (i.e. it */
- /* absorb the old touch sensor). */
-
- uiDefButBitS(block, TOG, SENS_COLLISION_PULSE, B_REDR, "Pulse", (short)(xco + 10), (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0,
- "Changes to the set of colliding objects generated pulses");
-
- uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P", (short)(xco + 10 + (0.20 * (width-20))), (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0,
- "Toggle collision on material or property");
-
- if (cs->mode & SENS_COLLISION_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)),
- (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44),
- (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
- }
-
- /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90, yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */
-
- yco-= ysize;
- break;
- }
- case SENS_NEAR:
- {
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ns= sens->data;
-
- uiDefBut(block, TEX, 1, "Property:", (short)(10+xco), (short)(yco-44), (short)(width-20), 19,
- &ns->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property");
- uiDefButF(block, NUM, 1, "Dist", (short)(10+xco), (short)(yco-68), (short)((width-22)/2), 19,
- &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance");
- uiDefButF(block, NUM, 1, "Reset", (short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19,
- &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance");
- yco-= ysize;
- break;
- }
- case SENS_RADAR:
- {
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- rs= sens->data;
-
- uiDefBut(block, TEX, 1, "Prop:",
- (short)(10+xco), (short)(yco-44), (short)(0.7 * (width-20)), 19,
- &rs->name, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
-
- str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5";
- uiDefButS(block, MENU, B_REDR, str,
- (short)(10+xco+0.7 * (width-20)), (short)(yco-44), (short)(0.3 * (width-22)), 19,
- &rs->axis, 2.0, 31, 0, 0,
- "Specify along which axis the radar cone is cast");
-
- uiDefButF(block, NUM, 1, "Ang:",
- (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19,
- &rs->angle, 0.0, 179.9, 10, 0,
- "Opening angle of the radar cone");
- uiDefButF(block, NUM, 1, "Dist:",
- (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19,
- &rs->range, 0.01, 10000.0, 100, 0,
- "Depth of the radar cone");
- yco-= ysize;
- break;
- }
- case SENS_KEYBOARD:
- {
- ks= sens->data;
-
- /* 5 lines: 120 height */
- ysize= (ks->type&1) ? 96:120;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* header line */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* part of line 1 */
- uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, "");
- uiDefButBitS(block, TOG, 1, B_REDR, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19,
- &ks->type, 0, 0, 0, 0, "");
-
-
- if ((ks->type&1)==0) { /* is All Keys option off? */
- /* line 2: hotkey and allkeys toggle */
- but = uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
-
- /* line 3: two key modifyers (qual1, qual2) */
- uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, "");
- but = uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
- but = uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code");
- uiButSetFunc(but, test_keyboard_event, ks, NULL);
- }
-
- /* line 4: toggle property for string logging mode */
- uiDefBut(block, TEX, 1, "LogToggle: ",
- xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19,
- ks->toggleName, 0, MAX_NAME, 0, 0,
- "Property that indicates whether to log "
- "keystrokes as a string");
-
- /* line 5: target property for string logging mode */
- uiDefBut(block, TEX, 1, "Target: ",
- xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19,
- ks->targetName, 0, MAX_NAME, 0, 0,
- "Property that receives the keystrokes in case "
- "a string is logged");
-
- yco-= ysize;
- break;
- }
- case SENS_PROPERTY:
- {
- ysize= 96;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ps= sens->data;
-
- str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3";
- /* str= "Type %t|Equal %x0|Not Equal %x1"; */
- uiDefButI(block, MENU, B_REDR, str, xco+30, yco-44, width-60, 19,
- &ps->type, 0, 31, 0, 0, "Type");
-
- if (ps->type != SENS_PROP_EXPRESSION) {
- uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-68, width-60, 19,
- ps->name, 0, MAX_NAME, 0, 0, "Property name");
- }
-
- if (ps->type == SENS_PROP_INTERVAL) {
- uiDefBut(block, TEX, 1, "Min: ", xco, yco-92, width/2, 19,
- ps->value, 0, MAX_NAME, 0, 0, "check for min value");
- uiDefBut(block, TEX, 1, "Max: ", xco+width/2, yco-92, width/2, 19,
- ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value");
- }
- else if (ps->type == SENS_PROP_CHANGED) {
- /* pass */
- }
- else {
- uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-92, width-60, 19,
- ps->value, 0, MAX_NAME, 0, 0, "check for value");
- }
-
- yco-= ysize;
- break;
- }
- case SENS_ARMATURE:
- {
- ysize= 70;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- arm= sens->data;
-
- if (ob->type == OB_ARMATURE) {
- uiBlockBeginAlign(block);
- but = uiDefBut(block, TEX, 1, "Bone: ",
- (xco+10), (yco-44), (width-20)/2, 19,
- arm->posechannel, 0, MAX_NAME, 0, 0,
- "Bone on which you want to check a constraint");
- uiButSetFunc(but, check_armature_sensor, but, arm);
- but = uiDefBut(block, TEX, 1, "Cons: ",
- (xco+10)+(width-20)/2, (yco-44), (width-20)/2, 19,
- arm->constraint, 0, MAX_NAME, 0, 0,
- "Name of the constraint you want to control");
- uiButSetFunc(but, check_armature_sensor, but, arm);
- uiBlockEndAlign(block);
-
- str= "Type %t|State changed %x0|Lin error below %x1|Lin error above %x2|Rot error below %x3|Rot error above %x4";
-
- uiDefButI(block, MENU, B_REDR, str, xco+10, yco-66, 0.4*(width-20), 19,
- &arm->type, 0, 31, 0, 0, "Type");
-
- if (arm->type != SENS_ARM_STATE_CHANGED) {
- uiDefButF(block, NUM, 1, "Value: ", xco+10+0.4*(width-20), yco-66, 0.6*(width-20), 19,
- &arm->value, -10000.0, 10000.0, 100, 0, "Test the error against this value");
- }
- }
- yco-= ysize;
- break;
- }
- case SENS_ACTUATOR:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- as= sens->data;
-
- uiDefBut(block, TEX, 1, "Act: ", xco+30, yco-44, width-60, 19,
- as->name, 0, MAX_NAME, 0, 0, "Actuator name, actuator active state modifications will be detected");
- yco-= ysize;
- break;
- }
- case SENS_DELAY:
- {
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- ds = sens->data;
-
- uiDefButS(block, NUM, 0, "Delay", (short)(10+xco), (short)(yco-44), (short)((width-22)*0.4+10), 19,
- &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of logic tics before the positive trigger (default 60 per second)");
- uiDefButS(block, NUM, 0, "Dur", (short)(10+xco+(width-22)*0.4+10), (short)(yco-44), (short)((width-22)*0.4-10), 19,
- &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of logic tics before the negative trigger following the positive trigger");
- uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP", (short)(xco + 10 + (width-22)*0.8), (short)(yco - 44),
- (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0,
- "Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics");
- yco-= ysize;
- break;
- }
- case SENS_MOUSE:
- {
- ms= sens->data;
- /* Two lines: 48 pixels high. */
- ysize = 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* line 1: header */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* Line 2: type selection. The number are a bit mangled to get
- * proper compatibility with older .blend files. */
-
- /* Any sensor type default is 0 but the ms enum starts in 1.
- * Therefore the mouse sensor is initialized to 1 in sca.c */
- str= "Type %t|Left button %x1|Middle button %x2|"
- "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, (width*0.8f)-20, 19,
- &ms->type, 0, 31, 0, 0,
- "Specify the type of event this mouse sensor should trigger on");
-
- if (ms->type==32) {
- uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse", (short)(xco + 10) + (width*0.8f)-20, (short)(yco - 44),
- (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0,
- "Moving the mouse over a different object generates a pulse");
- }
-
- yco-= ysize;
- break;
- }
- case SENS_RANDOM:
- {
- ysize = 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- randomSensor = sens->data;
- /* some files were wrongly written, avoid crash now */
- if (randomSensor) {
- uiDefButI(block, NUM, 1, "Seed: ", xco+10, yco-44, (width-20), 19,
- &randomSensor->seed, 0, 1000, 0, 0,
- "Initial seed of the generator. (Choose 0 for not random)");
- }
- yco-= ysize;
- break;
- }
- case SENS_RAY:
- {
- ysize = 72;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- draw_default_sensor_header(sens, block, xco, yco, width);
- raySens = sens->data;
-
- /* 1. property or material */
- uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P",
- xco + 10, yco - 44, 0.20 * (width-20), 19,
- &raySens->mode, 0.0, 0.0, 0, 0,
- "Toggle collision on material or property");
-
- if (raySens->mode & SENS_COLLISION_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19,
- &raySens->matname, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19,
- &raySens->propname, 0, MAX_NAME, 0, 0,
- "Only look for Objects with this property");
- }
-
- /* X-Ray option */
- uiDefButBitS(block, TOG, SENS_RAY_XRAY, 1, "X",
- xco + 10, yco - 68, 0.10 * (width-20), 19,
- &raySens->mode, 0.0, 0.0, 0, 0,
- "Toggle X-Ray option (see through objects that don't have the property)");
- /* 2. sensing range */
- uiDefButF(block, NUM, 1, "Range", xco+10 + 0.10 * (width-20), yco-68, 0.5 * (width-20), 19,
- &raySens->range, 0.01, 10000.0, 100, 0,
- "Sense objects no farther than this distance");
-
- /* 3. axis choice */
- str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5";
- uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &raySens->axisflag, 2.0, 31, 0, 0,
- "Specify along which axis the ray is cast");
-
- yco-= ysize;
- break;
- }
- case SENS_MESSAGE:
- {
- mes = sens->data;
- ysize = 2 * 24; /* total number of lines * 24 pixels/line */
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- /* line 1: header line */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- /* line 2: Subject filter */
- uiDefBut(block, TEX, 1, "Subject: ",
- (xco+10), (yco-44), (width-20), 19,
- mes->subject, 0, MAX_NAME, 0, 0,
- "Optional subject filter: only accept messages with this subject"
- ", or empty for all");
-
- yco -= ysize;
- break;
- }
- case SENS_JOYSTICK:
- {
-
- ysize = 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* line 1: header */
- draw_default_sensor_header(sens, block, xco, yco, width);
-
- joy= sens->data;
-
- uiDefButC(block, NUM, 1, "Index:", xco+10, yco-44, 0.33 * (width-20), 19,
- &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0,
- "Specify which joystick to use");
-
- str= "Type %t|Button %x0|Axis %x1|Single Axis %x3|Hat%x2";
- uiDefButC(block, MENU, B_REDR, str, xco+87, yco-44, 0.26 * (width-20), 19,
- &joy->type, 0, 31, 0, 0,
- "The type of event this joystick sensor is triggered on");
-
- if (joy->type != SENS_JOY_AXIS_SINGLE) {
- if (joy->flag & SENS_JOY_ANY_EVENT) {
- switch (joy->type) {
- case SENS_JOY_AXIS:
- str = "All Axis Events";
- break;
- case SENS_JOY_BUTTON:
- str = "All Button Events";
- break;
- default:
- str = "All Hat Events";
- break;
- }
- }
- else {
- str = "All";
- }
-
- uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str,
- xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19,
- &joy->flag, 0, 0, 0, 0,
- "Triggered by all events on this joysticks current type (axis/button/hat)");
- }
- if (joy->type == SENS_JOY_BUTTON) {
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->button, 0, 18, 100, 0,
- "Specify which button to use");
- }
- }
- else if (joy->type == SENS_JOY_AXIS) {
- uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->axis, 1, 8.0, 100, 0,
- "Specify which axis pair to use, 1 is useually the main direction input");
-
- uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19,
- &joy->precision, 0, 32768.0, 100, 0,
- "Specify the precision of the axis");
-
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- str = "Type %t|Up Axis %x1 |Down Axis %x3|Left Axis %x2|Right Axis %x0";
- uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->axisf, 2.0, 31, 0, 0,
- "The direction of the axis, use 'All Events' to receive events on any direction");
- }
- }
- else if (joy->type == SENS_JOY_HAT) {
- uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->hat, 1, 4.0, 100, 0,
- "Specify which hat to use");
-
- if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
- str = "Direction%t|Up%x1|Down%x4|Left%x8|Right%x2|%l|Up/Right%x3|Down/Left%x12|Up/Left%x9|Down/Right%x6";
- uiDefButI(block, MENU, 0, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
- &joy->hatf, 2.0, 31, 0, 0,
- "The direction of the hat, use 'All Events' to receive events on any direction");
- }
- }
- else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/
- uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19,
- &joy->axis_single, 1, 16.0, 100, 0,
- "Specify a single axis (verticle/horizontal/other) to detect");
-
- uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20), yco-44, 0.4 * (width-20), 19,
- &joy->precision, 0, 32768.0, 100, 0,
- "Specify the precision of the axis");
- }
- yco-= ysize;
- break;
- }
- }
-
- return yco-4;
-}
-
-
-
-static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width)
-{
- bExpressionCont *ec;
- bPythonCont *pc;
- short ysize;
-
- switch (cont->type) {
- case CONT_EXPRESSION:
- ysize= 28;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* uiDefBut(block, LABEL, 1, "Not yet...", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, ""); */
- ec= cont->data;
- /* uiDefBut(block, BUT, 1, "Variables", xco, yco-24, 80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */
- uiDefBut(block, TEX, 1, "Exp:", xco + 10, yco-21, width-20, 19,
- ec->str, 0, sizeof(ec->str), 0, 0,
- "Expression");
-
- yco-= ysize;
- break;
- case CONT_PYTHON:
- ysize= 28;
-
- if (cont->data==NULL) init_controller(cont);
- pc= cont->data;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
-
- uiBlockBeginAlign(block);
- uiDefButI(block, MENU, B_REDR, "Execution Method%t|Script%x0|Module%x1", xco+4, yco-23, 66, 19, &pc->mode, 0, 0, 0, 0, "Python script type (textblock or module - faster)");
- if (pc->mode==0)
- uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70, yco-23, width-74, 19, &pc->text, "Blender textblock to run as a script");
- else {
- uiDefBut(block, TEX, 1, "", xco+70, yco-23, (width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used");
- uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting");
- }
- uiBlockEndAlign(block);
-
- yco-= ysize;
- break;
-
- default:
- ysize= 4;
-
- UI_ThemeColor(TH_PANEL);
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- yco-= ysize;
- }
-
- return yco;
-}
-
-static int get_col_actuator(int type)
-{
- switch (type) {
- case ACT_ACTION: return TH_PANEL;
- case ACT_SHAPEACTION: return TH_PANEL;
- case ACT_OBJECT: return TH_PANEL;
- case ACT_IPO: return TH_PANEL;
- case ACT_PROPERTY: return TH_PANEL;
- case ACT_SOUND: return TH_PANEL;
- case ACT_CAMERA: return TH_PANEL;
- case ACT_EDIT_OBJECT: return TH_PANEL;
- case ACT_GROUP: return TH_PANEL;
- case ACT_RANDOM: return TH_PANEL;
- case ACT_SCENE: return TH_PANEL;
- case ACT_MESSAGE: return TH_PANEL;
- case ACT_GAME: return TH_PANEL;
- case ACT_VISIBILITY: return TH_PANEL;
- case ACT_CONSTRAINT: return TH_PANEL;
- case ACT_STATE: return TH_PANEL;
- case ACT_ARMATURE: return TH_PANEL;
- case ACT_STEERING: return TH_PANEL;
- default: return TH_PANEL;
- }
-}
-static void set_col_actuator(int item, int medium)
-{
- int col= get_col_actuator(item);
- UI_ThemeColorShade(col, medium?30:10);
-
-}
-
-static void change_object_actuator(bContext *UNUSED(C), void *act, void *UNUSED(arg))
-{
- bObjectActuator *oa = act;
-
- if (oa->type != oa->otype) {
- switch (oa->type) {
- case ACT_OBJECT_NORMAL:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_FORCE_LOCAL|ACT_TORQUE_LOCAL|ACT_DLOC_LOCAL|ACT_DROT_LOCAL;
- oa->type = ACT_OBJECT_NORMAL;
- break;
-
- case ACT_OBJECT_SERVO:
- memset(oa, 0, sizeof(bObjectActuator));
- oa->flag = ACT_LIN_VEL_LOCAL;
- oa->type = ACT_OBJECT_SERVO;
- oa->forcerot[0] = 30.0f;
- oa->forcerot[1] = 0.5f;
- oa->forcerot[2] = 0.0f;
- break;
- }
- }
-}
-
-static void change_ipo_actuator(bContext *UNUSED(C), void *arg1_but, void *arg2_ia)
-{
- bIpoActuator *ia = arg2_ia;
- uiBut *but = arg1_but;
-
- if (but->retval & ACT_IPOFORCE)
- ia->flag &= ~ACT_IPOADD;
- else if (but->retval & ACT_IPOADD)
- ia->flag &= ~ACT_IPOFORCE;
- but->retval = B_REDR;
-}
-
-static void update_object_actuator_PID(bContext *UNUSED(C), void *act, void *UNUSED(arg))
-{
- bObjectActuator *oa = act;
- oa->forcerot[0] = 60.0f*oa->forcerot[1];
-}
-
-static char *get_state_name(Object *ob, short bit)
-{
- bController *cont;
- unsigned int mask;
-
- mask = (1<<bit);
- cont = ob->controllers.first;
- while (cont) {
- if (cont->state_mask & mask) {
- return cont->name;
- }
- cont = cont->next;
- }
- return (char*)"";
-}
-
-static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask)
-{
- wmWindow *win= CTX_wm_window(C);
- int shift= win->eventstate->shift;
- unsigned int *cont_mask = arg2_mask;
- uiBut *but = arg1_but;
-
- if (*cont_mask == 0 || !(shift))
- *cont_mask = (1<<but->retval);
- but->retval = B_REDR;
-}
-
-static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act)
-{
- bArmatureActuator *act = arg2_act;
- uiBut *but = arg1_but;
- Object *ob= CTX_data_active_object(C);
-
- /* check that bone exist in the active object */
- but->retval = B_REDR;
- check_armature_bone_constraint(ob, act->posechannel, act->constraint);
-}
-
-
-static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
-{
- bSoundActuator *sa = NULL;
- bObjectActuator *oa = NULL;
- bIpoActuator *ia = NULL;
- bPropertyActuator *pa = NULL;
- bCameraActuator *ca = NULL;
- bEditObjectActuator *eoa = NULL;
- bConstraintActuator *coa = NULL;
- bSceneActuator *sca = NULL;
- bGroupActuator *ga = NULL;
- bRandomActuator *randAct = NULL;
- bMessageActuator *ma = NULL;
- bActionActuator *aa = NULL;
- bGameActuator *gma = NULL;
- bVisibilityActuator *visAct = NULL;
- bTwoDFilterActuator *tdfa = NULL;
- bParentActuator *parAct = NULL;
- bStateActuator *staAct = NULL;
- bArmatureActuator *armAct = NULL;
-
- float *fp;
- short ysize = 0, wval;
- const char *str;
- int myline, stbit;
- uiBut *but;
-
-
- /* yco is at the top of the rect, draw downwards */
- set_col_actuator(act->type, 0);
-
- switch (act->type) {
- case ACT_OBJECT:
- {
- oa = act->data;
- wval = (width-100)/3;
- if (oa->type == ACT_OBJECT_NORMAL) {
- if (ob->gameflag & OB_DYNAMIC) {
- ysize= 175;
- }
- else {
- ysize= 72;
- }
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiBlockBeginAlign(block);
- uiDefBut(block, LABEL, 0, "Loc", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "Sets the location");
- uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Rot", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the rotation");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
-
- if (ob->gameflag & OB_DYNAMIC) {
- uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
- }
-
- if (ob->gameflag & OB_DYNAMIC) {
- uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "AngV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
-
- uiDefBut(block, LABEL, 0, "Damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity");
- uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, "");
-
- uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
-
- uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "use_additive", xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV");
- }
- }
- else if (oa->type == ACT_OBJECT_SERVO) {
- ysize= 195;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefBut(block, LABEL, 0, "Ref", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "");
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+45, yco-45, wval*3, 19, &(oa->reference), "Reference object for velocity calculation, leave empty for world reference");
- uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, NULL, 0, 0, 0, 0, "Sets the target relative linear velocity, it will be achieved by automatic application of force. Null velocity is a valid target");
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, "");
- uiBlockEndAlign(block);
- uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-68, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Velocity is defined in local coordinates");
-
- uiDefBut(block, LABEL, 0, "Limit", xco, yco-91, 45, 19, NULL, 0, 0, 0, 0, "Select if the force needs to be limited along certain axis (local or global depending on LinV Local flag)");
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_X, B_REDR, "X", xco+45, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the X axis");
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Y, B_REDR, "Y", xco+45+wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Y axis");
- uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Z, B_REDR, "Z", xco+45+2*wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Z axis");
- uiBlockEndAlign(block);
- uiDefBut(block, LABEL, 0, "Max", xco, yco-110, 45, 19, NULL, 0, 0, 0, 0, "Set the upper limit for force");
- uiDefBut(block, LABEL, 0, "Min", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Set the lower limit for force");
- if (oa->flag & ACT_SERVO_LIMIT_X) {
- uiDefButF(block, NUM, 0, "", xco+45, yco-110, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, "");
- }
- if (oa->flag & ACT_SERVO_LIMIT_Y) {
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-110, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, "");
- }
- if (oa->flag & ACT_SERVO_LIMIT_Z) {
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-110, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, "");
- }
- uiDefBut(block, LABEL, 0, "Servo", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Coefficients of the PID servo controller");
- uiDefButF(block, NUMSLI, B_REDR, "P: ", xco+45, yco-152, wval*3, 19, oa->forcerot, 0.00, 200.0, 100, 0, "Proportional coefficient, typical value is 60x Integral coefficient");
- uiDefBut(block, LABEL, 0, "Slow", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response");
- but = uiDefButF(block, NUMSLI, B_REDR, " I : ", xco+45, yco-171, wval*3, 19, oa->forcerot+1, 0.0, 3.0, 1, 0, "Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response");
- uiButSetFunc(but, update_object_actuator_PID, oa, NULL);
- uiDefBut(block, LABEL, 0, "Fast", xco+45+3*wval, yco-171, 45, 19, NULL, 0, 0, 0, 0, "High value of I coefficient correspond to fast response");
- uiDefButF(block, NUMSLI, B_REDR, "D: ", xco+45, yco-190, wval*3, 19, oa->forcerot+2, -100.0, 100.0, 100, 0, "Derivate coefficient, not required, high values can cause instability");
- }
- str= "Motion Type %t|Simple motion %x0|Servo Control %x1";
- but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &oa->type, 0.0, 0.0, 0, 0, "");
- oa->otype = oa->type;
- uiButSetFunc(but, change_object_actuator, oa, NULL);
- yco-= ysize;
- break;
- }
- case ACT_ACTION:
- case ACT_SHAPEACTION:
- {
- /* DrawAct */
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- ysize = 112;
-#else
- ysize= 92;
-#endif
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- aa = act->data;
- wval = (width-60)/3;
-
- // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7";
-#else
- str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-#endif
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type");
- uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name");
-
- uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19,
- &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time");
-
-
- if (aa->type == ACT_ACTION_FROM_PROP) {
- uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position");
- }
- else {
- uiDefButF(block, NUM, 0, "Sta: ", xco+10, yco-44, (width-20)/2, 19, &aa->sta, 1.0, MAXFRAMEF, 0, 0, "Start frame");
- uiDefButF(block, NUM, 0, "End: ", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 1.0, MAXFRAMEF, 0, 0, "End frame");
- }
-
- uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending");
- uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack");
-
- uiDefBut(block, TEX, 0, "FrameProp: ", xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property");
-
-
-#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
- if (aa->type == ACT_ACTION_MOTION) {
- uiDefButF(block, NUM, 0, "Cycle: ", xco+30, yco-84, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action");
- }
-#endif
-
-
-
- yco-=ysize;
- break;
- }
- case ACT_IPO:
- {
- ia= act->data;
-
- ysize= 72;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6";
-
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, (width-20)/2, 19, &ia->type, 0, 0, 0, 0, "");
-
- but = uiDefButBitS(block, TOG, ACT_IPOFORCE, ACT_IPOFORCE,
- "Force", xco+10+(width-20)/2, yco-24, (width-20)/4-10, 19,
- &ia->flag, 0, 0, 0, 0,
- "Apply Ipo as a global or local force depending on the local option (dynamic objects only)");
- uiButSetFunc(but, change_ipo_actuator, but, ia);
-
- but = uiDefButBitS(block, TOG, ACT_IPOADD, ACT_IPOADD,
- "Add", xco+3*(width-20)/4, yco-24, (width-20)/4-10, 19,
- &ia->flag, 0, 0, 0, 0,
- "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag");
- uiButSetFunc(but, change_ipo_actuator, but, ia);
-
- /* Only show the do-force-local toggle if force is requested */
- if (ia->flag & (ACT_IPOFORCE|ACT_IPOADD)) {
- uiDefButBitS(block, TOG, ACT_IPOLOCAL, 0,
- "L", xco+width-30, yco-24, 20, 19,
- &ia->flag, 0, 0, 0, 0,
- "Let the ipo acts in local coordinates, used in Force and Add mode");
- }
-
- if (ia->type==ACT_IPO_FROM_PROP) {
- uiDefBut(block, TEX, 0,
- "Prop: ", xco+10, yco-44, width-80, 19,
- ia->name, 0.0, MAX_NAME, 0, 0,
- "Use this property to define the Ipo position");
- }
- else {
- uiDefButF(block, NUM, 0,
- "Sta", xco+10, yco-44, (width-80)/2, 19,
- &ia->sta, 1.0, MAXFRAMEF, 0, 0,
- "Start frame");
- uiDefButF(block, NUM, 0,
- "End", xco+10+(width-80)/2, yco-44, (width-80)/2, 19,
- &ia->end, 1.0, MAXFRAMEF, 0, 0,
- "End frame");
- }
- uiDefButBitS(block, TOG, ACT_IPOCHILD, B_REDR,
- "Child", xco+10+(width-80), yco-44, 60, 19,
- &ia->flag, 0, 0, 0, 0,
- "Update IPO on all children Objects as well");
- uiDefBut(block, TEX, 0,
- "FrameProp: ", xco+10, yco-64, width-20, 19,
- ia->frameProp, 0.0, MAX_NAME, 0, 0,
- "Assign the action's current frame number to this property");
-
- yco-= ysize;
- break;
- }
- case ACT_PROPERTY:
- {
- ysize= 68;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- pa= act->data;
-
- str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3";
- uiDefButI(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &pa->type, 0, 31, 0, 0, "Type");
-
- uiDefBut(block, TEX, 1, "Prop: ", xco+30, yco-44, width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name");
-
-
- if (pa->type==ACT_PROP_TOGGLE) {
- /* no ui */
- ysize -= 22;
- }
- else if (pa->type==ACT_PROP_COPY) {
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object");
- uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property");
- }
- else {
- uiDefBut(block, TEX, 1, "Value: ", xco+30, yco-64, width-60, 19, pa->value, 0, MAX_NAME, 0, 0, "change with this value, use \"\" around strings");
- }
- yco-= ysize;
-
- break;
- }
- case ACT_SOUND:
- {
- sa = act->data;
- sa->sndnr = 0;
-
- if (sa->flag & ACT_SND_3D_SOUND)
- ysize = 180;
- else
- ysize = 92;
-
- wval = (width-20)/2;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- if (bmain->sound.first) {
- IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr));
- /* reset this value, it is for handling the event */
- sa->sndnr = 0;
- uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10, yco-22, 20, 19, &(sa->sndnr), 0, 0, 0, 0, "");
- uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+wval+10, yco-22, wval, 19,
- "Load a sound file (remember to set caching on for small sounds that are played often)");
-
- if (sa->sound) {
- char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|"
- "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4";
- uiDefBut(block, TEX, B_IDNAME, "SO:", xco+30, yco-22, wval-20, 19,
- ((ID *)sa->sound)->name+2, 0.0, MAX_ID_NAME-2, 0, 0, "");
- uiDefButS(block, MENU, 1, dummy_str, xco+10, yco-44, width-20, 19,
- &sa->type, 0.0, 0.0, 0, 0, "");
- uiDefButF(block, NUM, 0, "Volume:", xco+10, yco-66, wval, 19, &sa->volume,
- 0.0, 1.0, 0, 0, "Sets the volume of this sound");
- uiDefButF(block, NUM, 0, "Pitch:", xco+wval+10, yco-66, wval, 19, &sa->pitch, -12.0,
- 12.0, 0, 0, "Sets the pitch of this sound");
- uiDefButS(block, TOG | UI_BUT_POIN_BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19,
- &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space");
- if (sa->flag & ACT_SND_3D_SOUND) {
- uiDefButF(block, NUM, 0, "Minimum Gain: ", xco+10, yco-110, wval, 19,
- &sa->sound3D.min_gain, 0.0, 1.0, 0.0, 0.0,
- "The minimum gain of the sound, no matter how far it is away");
- uiDefButF(block, NUM, 0, "Maximum Gain: ", xco+10, yco-132, wval, 19,
- &sa->sound3D.max_gain, 0.0, 1.0, 0.0, 0.0,
- "The maximum gain of the sound, no matter how near it is");
- uiDefButF(block, NUM, 0, "Reference Distance: ", xco+10, yco-154, wval, 19,
- &sa->sound3D.reference_distance, 0.0, FLT_MAX, 0.0, 0.0,
- "The reference distance is the distance where the sound has a gain of 1.0");
- uiDefButF(block, NUM, 0, "Maximum Distance: ", xco+10, yco-176, wval, 19,
- &sa->sound3D.max_distance, 0.0, FLT_MAX, 0.0, 0.0,
- "The maximum distance at which you can hear the sound");
- uiDefButF(block, NUM, 0, "Rolloff: ", xco+wval+10, yco-110, wval, 19,
- &sa->sound3D.rolloff_factor, 0.0, 5.0, 0.0, 0.0,
- "The rolloff factor defines the influence factor on volume depending on distance");
- uiDefButF(block, NUM, 0, "Cone Outer Gain: ", xco+wval+10, yco-132, wval, 19,
- &sa->sound3D.cone_outer_gain, 0.0, 1.0, 0.0, 0.0,
- "The gain outside the outer cone. The gain in the outer cone will be "
- "interpolated between this value and the normal gain in the inner cone");
- uiDefButF(block, NUM, 0, "Cone Outer Angle: ", xco+wval+10, yco-154, wval,
- 19, &sa->sound3D.cone_outer_angle, 0.0, 360.0, 0.0, 0.0,
- "The angle of the outer cone");
- uiDefButF(block, NUM, 0, "Cone Inner Angle: ", xco+wval+10, yco-176, wval,
- 19, &sa->sound3D.cone_inner_angle, 0.0, 360.0, 0.0, 0.0,
- "The angle of the inner cone");
- }
- }
- MEM_freeN((void *)str);
- }
- else {
- uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+10, yco-22, width-20, 19, "Load a sound file");
- }
-
- yco-= ysize;
-
- break;
- }
- case ACT_CAMERA:
-
- ysize= 48;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- ca= act->data;
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object");
- uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, "");
-
- uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, "");
-
- if (ca->axis==0) ca->axis= 'x';
- uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis");
- uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis");
-
- uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, "");
-
- yco-= ysize;
-
- break;
-
- case ACT_EDIT_OBJECT:
-
- eoa= act->data;
-
- if (eoa->type==ACT_EDOB_ADD_OBJECT) {
- ysize = 92;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)");
- uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives");
-
- wval= (width-60)/3;
- uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19,
- NULL, 0, 0, 0, 0,
- "Velocity upon creation");
- uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19,
- eoa->linVelocity, -100.0, 100.0, 10, 0,
- "Velocity upon creation, x component");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19,
- eoa->linVelocity+1, -100.0, 100.0, 10, 0,
- "Velocity upon creation, y component");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19,
- eoa->linVelocity+2, -100.0, 100.0, 10, 0,
- "Velocity upon creation, z component");
- uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_LINV, 0, "L", xco+45+3*wval, yco-68, 15, 19,
- &eoa->localflag, 0.0, 0.0, 0, 0,
- "Apply the transformation locally");
-
-
- uiDefBut(block, LABEL, 0, "AngV", xco, yco-90, 45, 19,
- NULL, 0, 0, 0, 0,
- "Angular velocity upon creation");
- uiDefButF(block, NUM, 0, "", xco+45, yco-90, wval, 19,
- eoa->angVelocity, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, x component");
- uiDefButF(block, NUM, 0, "", xco+45+wval, yco-90, wval, 19,
- eoa->angVelocity+1, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, y component");
- uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-90, wval, 19,
- eoa->angVelocity+2, -10000.0, 10000.0, 10, 0,
- "Angular velocity upon creation, z component");
- uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_ANGV, 0, "L", xco+45+3*wval, yco-90, 15, 19,
- &eoa->localflag, 0.0, 0.0, 0, 0,
- "Apply the rotation locally");
-
-
- }
- else if (eoa->type==ACT_EDOB_END_OBJECT) {
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
- else if (eoa->type==ACT_EDOB_REPLACE_MESH) {
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, 1, "ME:", xco+40, yco-44, (width-80)/2, 19, &(eoa->me), "replace the existing, when left blank 'Phys' will remake the existing physics mesh");
-
- uiDefButBitS(block, TOGN, ACT_EDOB_REPLACE_MESH_NOGFX, 0, "Gfx", xco+40 + (width-80)/2, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the display mesh");
- uiDefButBitS(block, TOG, ACT_EDOB_REPLACE_MESH_PHYS, 0, "Phys", xco+40 + (width-80)/2 +(width-80)/4, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the physics mesh (triangle bounds only. compound shapes not supported)");
- }
- else if (eoa->type==ACT_EDOB_TRACK_TO) {
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object");
- uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes");
- uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking");
- }
- else if (eoa->type==ACT_EDOB_DYNAMICS) {
- ysize= 69;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3|Set Mass %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-44, (width-80), 19, &(eoa->dyn_operation), 0.0, 0.0, 0, 0, "");
- if (eoa->dyn_operation==4) {
- uiDefButF(block, NUM, 0, "", xco+40, yco-63, width-80, 19,
- &eoa->mass, 0.0, 10000.0, 10, 0,
- "Mass for object");
- }
- }
- str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3|Dynamics %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
-
- break;
-
- case ACT_CONSTRAINT:
- coa= act->data;
-
- if (coa->type == ACT_CONST_TYPE_LOC) {
- ysize= 69;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- /* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */
- /* coa->flag &= ~(63); */
- str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4";
- coa->flag &= 7;
- coa->time = 0;
- uiDefButS(block, MENU, 1, str, xco+10, yco-65, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, "");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "Min", xco+80, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, "");
-
- if (coa->flag & ACT_CONST_LOCX) fp= coa->minloc;
- else if (coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1;
- else if (coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2;
- else if (coa->flag & ACT_CONST_ROTX) fp= coa->minrot;
- else if (coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1;
- else fp= coa->minrot+2;
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, "");
- uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-65, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, "");
- }
- else if (coa->type == ACT_CONST_TYPE_DIST) {
- ysize= 106;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "Range", xco+80, yco-45, (width-115)/2, 19, NULL, 0.0, 0.0, 0, 0, "Set the maximum length of ray");
- uiDefButBitS(block, TOG, ACT_CONST_DISTANCE, B_REDR, "Dist", xco+80+(width-115)/2, yco-45, (width-115)/2, 19, &coa->flag, 0.0, 0.0, 0, 0, "Force distance of object to point of impact of ray");
- uiDefButBitS(block, TOG, ACT_CONST_LOCAL, 0, "L", xco+80+(width-115), yco-45, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Set ray along object's axis or global axis");
-
- if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc;
- else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1;
- else fp= coa->minloc+2;
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/2, 19, fp+3, 0.0, 2000.0, 10, 0, "Maximum length of ray");
- if (coa->flag & ACT_CONST_DISTANCE)
- uiDefButF(block, NUM, 0, "", xco+80+(width-115)/2, yco-65, (width-115)/2, 19, fp, -2000.0, 2000.0, 10, 0, "Keep this distance to target");
- uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Set object axis along (local axis) or parallel (global axis) to the normal at hit position");
- uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property");
- if (coa->flag & ACT_CONST_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detects only Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detect only Objects with this property");
- }
- uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target");
- uiDefButS(block, NUM, 0, "time", xco+50, yco-103, (width-60)/2, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButS(block, NUM, 0, "rotDamp", xco+50+(width-60)/2, yco-103, (width-60)/2, 19, &(coa->rotdamp), 0.0, 100.0, 0, 0, "Use a different damping for orientation");
- }
- else if (coa->type == ACT_CONST_TYPE_ORI) {
- ysize= 87;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Select the axis to be aligned along the reference direction");
-
- uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter");
- uiDefBut(block, LABEL, 0, "X", xco+80, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Y", xco+80+(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Z", xco+80+2*(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, "");
-
- uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/3, 19, &coa->maxrot[0], -2000.0, 2000.0, 10, 0, "X component of reference direction");
- uiDefButF(block, NUM, 0, "", xco+80+(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[1], -2000.0, 2000.0, 10, 0, "Y component of reference direction");
- uiDefButF(block, NUM, 0, "", xco+80+2*(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[2], -2000.0, 2000.0, 10, 0, "Z component of reference direction");
-
- uiDefButS(block, NUM, 0, "time", xco+10, yco-84, 70, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButF(block, NUM, 0, "min", xco+80, yco-84, (width-115)/2, 19, &(coa->minloc[0]), 0.0, 180.0, 10, 1, "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max");
- uiDefButF(block, NUM, 0, "max", xco+80+(width-115)/2, yco-84, (width-115)/2, 19, &(coa->maxloc[0]), 0.0, 180.0, 10, 1, "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max");
- }
- else if (coa->type == ACT_CONST_TYPE_FH) {
- ysize= 106;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32";
- uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray (in world coordinate)");
-
- if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc;
- else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1;
- else fp= coa->minloc+2;
-
- uiDefButF(block, NUM, 0, "damp", xco+10, yco-45, (width-70)/2, 19, &coa->maxrot[0], 0.0, 1.0, 1, 0, "Damping factor of the Fh spring force");
- uiDefButF(block, NUM, 0, "dist", xco+10+(width-70)/2, yco-45, (width-70)/2, 19, fp, 0.010, 2000.0, 10, 0, "Height of the Fh area");
- uiDefButBitS(block, TOG, ACT_CONST_DOROTFH, 0, "Rot Fh", xco+10+(width-70), yco-45, 50, 19, &coa->flag, 0.0, 0.0, 0, 0, "Keep object axis parallel to normal");
-
- uiDefButF(block, NUMSLI, 0, "Fh ", xco+80, yco-65, (width-115), 19, fp+3, 0.0, 1.0, 0, 0, "Spring force within the Fh area");
- uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes");
- uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property");
- if (coa->flag & ACT_CONST_MATERIAL) {
- uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detects only Objects with this material");
- }
- else {
- uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19,
- coa->matprop, 0, MAX_NAME, 0, 0,
- "Ray detect only Objects with this property");
- }
- uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19,
- &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target");
- uiDefButS(block, NUM, 0, "time", xco+50, yco-103, 90, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited");
- uiDefButF(block, NUM, 0, "rotDamp", xco+140, yco-103, (width-150), 19, &coa->maxrot[1], 0.0, 1.0, 1, 0, "Use a different damping for rotation");
- }
- str= "Constraint Type %t|Location %x0|Distance %x1|Orientation %x2|Force field %x3";
- but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &coa->type, 0.0, 0.0, 0, 0, "");
- yco-= ysize;
- break;
-
- case ACT_SCENE:
- sca= act->data;
-
- if (sca->type==ACT_SCENE_RESTART) {
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
- else if (sca->type==ACT_SCENE_CAMERA) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object");
- }
- else if (sca->type==ACT_SCENE_SET) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene");
- }
- else if (sca->type==ACT_SCENE_ADD_FRONT) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene");
- }
- else if (sca->type==ACT_SCENE_ADD_BACK) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene");
- }
- else if (sca->type==ACT_SCENE_REMOVE) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene");
- }
- else if (sca->type==ACT_SCENE_SUSPEND) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene");
- }
- else if (sca->type==ACT_SCENE_RESUME) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene");
- }
-
- str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
- break;
- case ACT_GAME:
- {
- gma = act->data;
- if (gma->type == ACT_GAME_LOAD) {
- //ysize = 68;
- ysize = 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file");
- // uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation");
- }
-#if 0
- else if (gma->type == ACT_GAME_START) {
- ysize = 68;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44, width-20, 19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this file");
- uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64, width-20, 19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation");
- }
-#endif
- else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) {
- ysize = 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
-
- //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3";
- str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save bge.logic.globalDict %x4|Load bge.logic.globalDict %x5";
- uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, "");
-
- yco -= ysize;
- break;
- }
- case ACT_GROUP:
- ga= act->data;
-
- ysize= 52;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5";
-
- uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, "");
- if (ga->type==ACT_GROUP_SET) {
- uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set");
- uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame");
- }
- else if (ga->type==ACT_GROUP_FROM_PROP) {
- uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position");
- }
- else {
- uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame");
- uiDefButI(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame");
- }
- yco-= ysize;
- break;
-
- case ACT_VISIBILITY:
- ysize = 24;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- visAct = act->data;
-
- uiBlockBeginAlign(block);
- uiDefButBitI(block, TOGN, ACT_VISIBILITY_INVISIBLE, B_REDR,
- "Visible",
- xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)");
- uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR,
- "Occlusion",
- xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Set the object to occlude objects behind it. Initialized from the object type in physics button");
- uiBlockEndAlign(block);
-
- uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, 0,
- "Children",
- xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag,
- 0.0, 0.0, 0, 0,
- "Sets all the children of this object to the same visibility/occlusion recursively");
-
- yco-= ysize;
-
- break;
-
- case ACT_STATE:
- ysize = 34;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- staAct = act->data;
-
- str= "Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3";
-
- uiDefButI(block, MENU, B_REDR, str,
- xco + 10, yco - 24, 65, 19, &staAct->type,
- 0.0, 0.0, 0, 0,
- "Select the bit operation on object state mask");
-
- for (wval=0; wval<15; wval+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, TOG, 1<<(stbit+wval), stbit+wval, "", (short)(xco+85+12*stbit+13*wval), yco-17, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval)));
- uiButSetFunc(but, check_state_mask, but, &(staAct->mask));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, TOG, 1<<(stbit+wval+15), stbit+wval+15, "", (short)(xco+85+12*stbit+13*wval), yco-29, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval+15)));
- uiButSetFunc(but, check_state_mask, but, &(staAct->mask));
- }
- }
- uiBlockEndAlign(block);
-
- yco-= ysize;
-
- break;
-
- case ACT_RANDOM:
- ysize = 69;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco,
- (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- randAct = act->data;
-
- /* 1. seed */
- uiDefButI(block, NUM, 1, "Seed: ", (xco+10), yco-24, 0.4 *(width-20), 19,
- &randAct->seed, 0, 1000, 0, 0,
- "Initial seed of the random generator. Use Python for more freedom. "
- " (Choose 0 for not random)");
-
- /* 2. distribution type */
- /* One pick per distribution. These numbers MUST match the #defines */
- /* in game.h !!! */
- str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1"
- "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4"
- "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7"
- "|Float Normal %x8|Float Neg. Exp. %x9";
- uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19,
- &randAct->distribution, 0.0, 0.0, 0, 0,
- "Choose the type of distribution");
-
- /* 3. property */
- uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19,
- &randAct->propname, 0, MAX_NAME, 0, 0,
- "Assign the random value to this property");
-
- /*4. and 5. arguments for the distribution*/
- switch (randAct->distribution) {
- case ACT_RANDOM_BOOL_CONST:
- uiDefButBitI(block, TOG, 1, 1, "Always true", (xco+10), yco-64, (width-20), 19,
- &randAct->int_arg_1, 2.0, 1, 0, 0,
- "Always false or always true");
- break;
- case ACT_RANDOM_BOOL_UNIFORM:
- uiDefBut(block, LABEL, 0, " Do a 50-50 pick", (xco+10), yco-64, (width-20), 19,
- NULL, 0, 0, 0, 0,
- "Choose between true and false, 50% chance each");
- break;
- case ACT_RANDOM_BOOL_BERNOUILLI:
- uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.0, 1.0, 0, 0,
- "Pick a number between 0 and 1. Success if you stay "
- "below this value");
- break;
- case ACT_RANDOM_INT_CONST:
- uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19,
- &randAct->int_arg_1, -1000, 1000, 0, 0,
- "Always return this number");
- break;
- case ACT_RANDOM_INT_UNIFORM:
- uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->int_arg_1, -1000, 1000, 0, 0,
- "Choose a number from a range. "
- "Lower boundary of the range");
- uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->int_arg_2, -1000, 1000, 0, 0,
- "Choose a number from a range. "
- "Upper boundary of the range");
- break;
- case ACT_RANDOM_INT_POISSON:
- uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.01, 100.0, 0, 0,
- "Expected mean value of the distribution");
- break;
- case ACT_RANDOM_FLOAT_CONST:
- uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.0, 1.0, 0, 0,
- "Always return this number");
- break;
- case ACT_RANDOM_FLOAT_UNIFORM:
- uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->float_arg_1, -10000.0, 10000.0, 0, 0,
- "Choose a number from a range"
- "Lower boundary of the range");
- uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->float_arg_2, -10000.0, 10000.0, 0, 0,
- "Choose a number from a range"
- "Upper boundary of the range");
- break;
- case ACT_RANDOM_FLOAT_NORMAL:
- uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19,
- &randAct->float_arg_1, -10000.0, 10000.0, 0, 0,
- "A normal distribution. Mean of the distribution");
- uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19,
- &randAct->float_arg_2, 0.0, 10000.0, 0, 0,
- "A normal distribution. Standard deviation of the "
- "distribution");
- break;
- case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL:
- uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19,
- &randAct->float_arg_1, 0.001, 10000.0, 0, 0,
- "Negative exponential dropoff");
- break;
- default:
- ; /* don't know what this distro is... can be useful for testing */
- /* though :) */
- }
-
- yco-= ysize;
- break;
- case ACT_MESSAGE:
- ma = act->data;
-
- ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize,
- (float)xco+width, (float)yco, 1);
-
- myline=1;
-
- /* line 1: To */
- uiDefBut(block, TEX, 1, "To: ",
- (xco+10), (yco-(myline++*24)), (width-20), 19,
- &ma->toPropName, 0, MAX_NAME, 0, 0,
- "Optional send message to objects with this name only, or empty to broadcast");
-
- /* line 2: Message Subject */
- uiDefBut(block, TEX, 1, "Subject: ",
- (xco+10), (yco-(myline++*24)), (width-20), 19,
- &ma->subject, 0, MAX_NAME, 0, 0,
- "Optional message subject. This is what can be filtered on");
-
- /* line 3: Text/Property */
- uiDefButBitS(block, TOG, 1, B_REDR, "T/P",
- (xco+10), (yco-(myline*24)), (0.20 * (width-20)), 19,
- &ma->bodyType, 0.0, 0.0, 0, 0,
- "Toggle message type: either Text or a PropertyName");
-
- if (ma->bodyType == ACT_MESG_MESG) {
- /* line 3: Message Body */
- uiDefBut(block, TEX, 1, "Body: ",
- (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19,
- &ma->body, 0, MAX_NAME, 0, 0,
- "Optional message body Text");
- }
- else {
- /* line 3: Property body (set by property) */
- uiDefBut(block, TEX, 1, "Propname: ",
- (xco+10+(0.20*(width-20))), (yco-(myline++*24)), (0.8*(width-20)), 19,
- &ma->body, 0, MAX_NAME, 0, 0,
- "The message body will be set by the Property Value");
- }
-
- yco -= ysize;
- break;
- case ACT_2DFILTER:
- tdfa = act->data;
-
- ysize = 50;
- if (tdfa->type == ACT_2DFILTER_CUSTOMFILTER) {
- ysize +=20;
- }
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- switch (tdfa->type) {
- case ACT_2DFILTER_MOTIONBLUR:
- if (!tdfa->flag) {
- uiDefButS(block, TOG, B_REDR, "D", xco+30, yco-44, 19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur");
- uiDefButF(block, NUM, B_REDR, "Value:", xco+52, yco-44, width-82, 19, &tdfa->float_arg, 0.0, 1.0, 0.0, 0.0, "Set motion blur value");
- }
- else {
- uiDefButS(block, TOG, B_REDR, "Disabled", xco+30, yco-44, width-60, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Enable Motion Blur");
- }
- break;
- case ACT_2DFILTER_BLUR:
- case ACT_2DFILTER_SHARPEN:
- case ACT_2DFILTER_DILATION:
- case ACT_2DFILTER_EROSION:
- case ACT_2DFILTER_LAPLACIAN:
- case ACT_2DFILTER_SOBEL:
- case ACT_2DFILTER_PREWITT:
- case ACT_2DFILTER_GRAYSCALE:
- case ACT_2DFILTER_SEPIA:
- case ACT_2DFILTER_INVERT:
- case ACT_2DFILTER_NOFILTER:
- case ACT_2DFILTER_DISABLED:
- case ACT_2DFILTER_ENABLED:
- uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order");
- break;
- case ACT_2DFILTER_CUSTOMFILTER:
- uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30, yco-44, width-60, 19, &tdfa->int_arg, 0.0, MAX_RENDER_PASS-1, 0.0, 0.0, "Set filter order");
- uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30, yco-64, width-60, 19, &tdfa->text, "");
- break;
- }
-
- str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
- "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|"
- "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|";
- uiDefButS(block, MENU, B_REDR, str, xco+30, yco-24, width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type");
-
- yco -= ysize;
- break;
- case ACT_PARENT:
- parAct = act->data;
-
- if (parAct->type==ACT_PARENT_SET) {
-
- ysize= 48;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent");
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR,
- "Compound",
- xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag,
- 0.0, 0.0, 0, 0,
- "Add this object shape to the parent shape (only if the parent shape is already compound)");
- uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR,
- "Ghost",
- xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag,
- 0.0, 0.0, 0, 0,
- "Make this object ghost while parented (only if not compound)");
- uiBlockEndAlign(block);
- }
- else if (parAct->type==ACT_PARENT_REMOVE) {
-
- ysize= 28;
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- }
-
- str= "Parent %t|Set Parent %x0|Remove Parent %x1";
- uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, "");
-
- yco-= ysize;
- break;
- case ACT_ARMATURE:
- armAct = act->data;
-
- if (ob->type == OB_ARMATURE) {
- str= "Constraint %t|Run armature %x0|Enable %x1|Disable %x2|Set target %x3|Set weight %x4";
- uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, (width-10)*0.35, 19, &armAct->type, 0.0, 0.0, 0, 0, "");
-
- switch (armAct->type) {
- case ACT_ARM_RUN:
- ysize = 28;
- break;
- default:
- uiBlockBeginAlign(block);
- but = uiDefBut(block, TEX, 1, "Bone: ",
- (xco+5), (yco-44), (width-10)/2, 19,
- armAct->posechannel, 0, MAX_NAME, 0, 0,
- "Bone on which the constraint is defined");
- uiButSetFunc(but, check_armature_actuator, but, armAct);
- but = uiDefBut(block, TEX, 1, "Cons: ",
- (xco+5)+(width-10)/2, (yco-44), (width-10)/2, 19,
- armAct->constraint, 0, MAX_NAME, 0, 0,
- "Name of the constraint you want to control");
- uiButSetFunc(but, check_armature_actuator, but, armAct);
- uiBlockEndAlign(block);
- ysize = 48;
- switch (armAct->type) {
- case ACT_ARM_SETTARGET:
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Target: ", xco+5, yco-64, (width-10), 19, &(armAct->target), "Set this object as the target of the constraint");
- uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "Secondary Target: ", xco+5, yco-84, (width-10), 19, &(armAct->subtarget), "Set this object as the secondary target of the constraint (only IK polar target at the moment)");
- ysize += 40;
- break;
- case ACT_ARM_SETWEIGHT:
- uiDefButF(block, NUM, B_REDR, "Weight:", xco+5+(width-10)*0.35, yco-24, (width-10)*0.65, 19, &armAct->weight, 0.0, 1.0, 0.0, 0.0, "Set weight of this constraint");
- break;
- }
- }
- }
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
- yco-= ysize;
- break;
-
- default:
- ysize= 4;
-
- glRects(xco, yco-ysize, xco+width, yco);
- uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-
- yco-= ysize;
- break;
- }
-
- uiBlockSetEmboss(block, UI_EMBOSS);
-
- return yco-4;
-}
static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event)
{
@@ -3084,8 +878,6 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg))
return block;
}
-
-
static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, void *arg2_mask)
{
unsigned int *cont_mask = arg2_mask;
@@ -3096,17 +888,6 @@ static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, voi
but->retval = B_REDR;
}
-static int first_bit(unsigned int mask)
-{
- int bit;
-
- for (bit=0; bit<32; bit++) {
- if (mask & (1<<bit))
- return bit;
- }
- return -1;
-}
-
static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont)
{
uiBlock *block;
@@ -3139,44 +920,6 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c
return block;
}
-static void do_object_state_menu(bContext *UNUSED(C), void *arg, int event)
-{
- Object *ob = arg;
-
- switch (event) {
- case 0:
- ob->state = 0x3FFFFFFF;
- break;
- case 1:
- ob->state = ob->init_state;
- if (!ob->state)
- ob->state = 1;
- break;
- case 2:
- ob->init_state = ob->state;
- break;
- }
-}
-
-static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj)
-{
- uiBlock *block;
- short xco = 0;
-
- block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP);
- uiBlockSetButmFunc(block, do_object_state_menu, arg_obj);
-
- uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, "");
- uiDefBut(block, BUTM, 1, "Recall init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, "");
- uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefBut(block, BUTM, 1, "Store init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, "");
-
- uiBlockSetDirection(block, UI_TOP);
- uiEndBlock(C, block);
-
- return block;
-}
-
static int is_sensor_linked(uiBlock *block, bSensor *sens)
{
bController *cont;
@@ -4458,14 +2201,13 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C)
}
}
-static void logic_buttons_new(bContext *C, ARegion *ar)
+void logic_buttons(bContext *C, ARegion *ar)
{
SpaceLogic *slogic= CTX_wm_space_logic(C);
Object *ob= CTX_data_active_object(C);
- Object *act_ob= ob;
ID **idar;
- PointerRNA logic_ptr, settings_ptr;
+ PointerRNA logic_ptr, settings_ptr, object_ptr;
uiLayout *layout, *row, *box;
uiBlock *block;
@@ -4558,8 +2300,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
row = uiLayoutRow(split, TRUE);
uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE);
+
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+ uiLayoutSetContextPointer(row, "object", &object_ptr);
+ uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE);
if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
@@ -4574,9 +2318,9 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
col = uiLayoutColumn(subsplit, FALSE);
row = uiLayoutRow(col, FALSE);
uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE);
- uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0);
+ uiTemplateGameStates(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0);
row = uiLayoutRow(col, FALSE);
- uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0);
+ uiTemplateGameStates(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0);
col = uiLayoutColumn(subsplit, FALSE);
uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
@@ -4653,8 +2397,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
row = uiLayoutRow(layout, TRUE);
uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE);
+
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+ uiLayoutSetContextPointer(row, "object", &object_ptr);
+ uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE);
if ((ob->scaflag & OB_SHOWSENS) == 0) continue;
@@ -4721,8 +2467,10 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
row = uiLayoutRow(layout, TRUE);
uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators");
- if (ob == act_ob)
- uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE);
+
+ RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr);
+ uiLayoutSetContextPointer(row, "object", &object_ptr);
+ uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE);
if ((ob->scaflag & OB_SHOWACT) == 0) continue;
@@ -4773,377 +2521,3 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
if (idar) MEM_freeN(idar);
}
-void logic_buttons(bContext *C, ARegion *ar)
-{
- Main *bmain= CTX_data_main(C);
- SpaceLogic *slogic= CTX_wm_space_logic(C);
- Object *ob= CTX_data_active_object(C);
- ID **idar;
- bSensor *sens;
- bController *cont;
- bActuator *act;
- uiBlock *block;
- uiBut *but;
- PointerRNA logic_ptr;
- int a, iact, stbit, offset;
- int xco, yco, width, ycoo;
- short count;
- char numstr[32];
- /* pin is a bool used for actuator and sensor drawing with states
- * pin so changing states dosnt hide the logic brick */
- char pin;
-
- if (G.debug_value == 0) {
- logic_buttons_new(C, ar);
- return;
- }
-
- if (ob==NULL) return;
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar);
- block= uiBeginBlock(C, ar, numstr, UI_EMBOSS);
- uiBlockSetHandleFunc(block, do_logic_buts, NULL);
-
- RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
-
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
- /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
- * we can determine which is actually linked/visible */
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
- act= ob->actuators.first;
- while (act) {
- act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
- act = act->next;
- }
- /* same for sensors */
- sens= ob->sensors.first;
- while (sens) {
- sens->flag &= ~(SENS_VISIBLE);
- sens = sens->next;
- }
- }
-
- /* start with the controller because we need to know which one is visible */
- /* ******************************* */
- xco= 400; yco= 170; width= 300;
-
- uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator");
- uiBlockEndAlign(block);
-
- for (a=0; a<count; a++) {
- unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */
-
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if ((ob->scavisflag & OB_VIS_CONT) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->controllers.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Active Object name");
-// if (ob->controllers.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller");
- uiBlockEndAlign(block);
- yco-=20;
-
- /* mark all actuators linked to these controllers */
- /* note that some of these actuators could be from objects that are not in the display list.
- * It's ok because those actuators will not be displayed here */
- cont= ob->controllers.first;
- while (cont) {
- for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
- if (act)
- act->flag |= ACT_LINKED;
- }
- controller_state_mask |= cont->state_mask;
- cont = cont->next;
- }
-
- if (ob->scaflag & OB_SHOWCONT) {
-
- /* first show the state */
- uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state");
-
- if (!ob->state)
- ob->state = 1;
- for (offset=0; offset<15; offset+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- }
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, OB_ALLSTATE, B_SET_STATE_BIT, "All", (short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
- uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini", (short)(xco+248), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
- uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D", (short)(xco+270), yco-10, 15, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
- uiBlockEndAlign(block);
-
- yco-=35;
-
- /* display only the controllers that match the current state */
- offset = 0;
- for (stbit=0; stbit<32; stbit++) {
- if (!(ob->state & (1<<stbit)))
- continue;
- /* add a separation between controllers of different states */
- if (offset) {
- offset = 0;
- yco -= 6;
- }
- cont= ob->controllers.first;
- while (cont) {
- if (cont->state_mask & (1<<stbit)) {
- /* this controller is visible, mark all its actuator */
- for (iact=0; iact<cont->totlinks; iact++) {
- act = cont->links[iact];
- if (act)
- act->flag |= ACT_VISIBLE;
- }
- uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Delete Controller");
- uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Controller settings");
- uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)");
-
- sprintf(numstr, "%d", first_bit(cont->state_mask)+1);
- uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)");
-
- if (cont->flag & CONT_SHOW) {
- cont->otype= cont->type;
- uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(), (short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name");
- uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0);
-
- ycoo= yco;
- yco= draw_controllerbuttons(cont, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- cpack(0x999999);
- glRecti(xco+22, yco, xco+width-22, yco+19);
- but = uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 70, UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller type");
- //uiButSetFunc(but, old_sca_move_controller, cont, NULL);
- but = uiDefBut(block, LABEL, 0, cont->name, (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont, 0, 0, 0, 0, "Controller name");
- //uiButSetFunc(but, old_sca_move_controller, cont, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(110+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_controller, cont, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(88+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_controller, cont, (void *)FALSE);
- uiBlockEndAlign(block);
-
- ycoo= yco;
- }
-
- but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR);
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco-19), ycoo, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, "");
- /* offset is >0 if at least one controller was displayed */
- offset++;
- yco-=20;
- }
- cont= cont->next;
- }
-
- }
- yco-= 6;
- }
- }
-
- /* ******************************* */
- xco= 10; yco= 170; width= 300;
-
- uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
- uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states");
- uiBlockEndAlign(block);
-
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- if ((ob->scavisflag & OB_VIS_SENS) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->sensors.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors");
-// if (ob->sensors.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor");
- uiBlockEndAlign(block);
- yco-=20;
-
- if (ob->scaflag & OB_SHOWSENS) {
-
- sens= ob->sensors.first;
- while (sens) {
- if (!(slogic->scaflag & BUTS_SENS_STATE) ||
- (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
- (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
- (is_sensor_linked(block, sens))
- ) {
- /* should we draw the pin? - for now always draw when there is a state */
- pin = (slogic->scaflag & BUTS_SENS_STATE && (sens->flag & SENS_SHOW || sens->flag & SENS_PIN)) ? 1 : 0;
-
- sens->flag |= SENS_VISIBLE;
- uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Delete Sensor");
- if (pin)
- uiDefIconButBitS(block, ICONTOG, SENS_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
-
- uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &sens->flag, 0, 0, 0, 0, "Sensor settings");
-
- ycoo= yco;
- if (sens->flag & SENS_SHOW) {
- uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, UI_UNIT_Y, &sens->type, 0, 0, 0, 0, "Sensor type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, MAX_NAME, 0, 0, "Sensor name");
- uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0);
-
- sens->otype= sens->type;
- yco= draw_sensorbuttons(ob, sens, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- set_col_sensor(sens->type, 1);
- glRecti(xco + 22, yco, xco + width - 22, yco + 19);
- but = uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, UI_UNIT_Y, sens, 0, 0, 0, 0, "");
- //uiButSetFunc(but, old_sca_move_sensor, sens, NULL);
- but = uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, MAX_NAME, 0, 0, "");
- //uiButSetFunc(but, old_sca_move_sensor, sens, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_sensor, sens, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_sensor, sens, (void *)FALSE);
- uiBlockEndAlign(block);
- }
-
- but = uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER);
-
- yco-=20;
- }
- sens= sens->next;
- }
- yco-= 6;
- }
- }
- /* ******************************* */
- xco= 800; yco= 170; width= 300;
- uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, UI_UNIT_Y, "");
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects");
- uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show active Object");
- uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller");
- uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states");
- uiBlockEndAlign(block);
- for (a=0; a<count; a++) {
- ob= (Object *)idar[a];
-// uiClearButLock();
-// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if ((ob->scavisflag & OB_VIS_ACT) == 0) {
- continue;
- }
-
- /* presume it is only objects for now */
- uiBlockBeginAlign(block);
-// if (ob->actuators.first) uiSetCurFont(block, UI_HELVB);
- uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators");
-// if (ob->actuators.first) uiSetCurFont(block, UI_HELV);
- uiDefButBitS(block, TOG, OB_ADDACT, B_ADD_ACT, "Add", (short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator");
- uiBlockEndAlign(block);
- yco-=20;
-
- if (ob->scaflag & OB_SHOWACT) {
-
- act= ob->actuators.first;
- while (act) {
- if (!(slogic->scaflag & BUTS_ACT_STATE) ||
- !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
- (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
- (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE))
- {
- pin = (slogic->scaflag & BUTS_ACT_STATE && (act->flag & SENS_SHOW || act->flag & SENS_PIN)) ? 1 : 0;
-
- act->flag |= ACT_VISIBLE; /* mark the actuator as visible to help implementing the up/down action */
- uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Delete Actuator");
- if (pin)
- uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller");
- uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display the actuator");
-
- if (act->flag & ACT_SHOW) {
- act->otype= act->type;
- uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type");
- but = uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name");
- uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
-
- ycoo= yco;
- yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width);
- if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
- }
- else {
- set_col_actuator(act->type, 1);
- glRecti((short)(xco+22), yco, (short)(xco+width-22), (short)(yco+19));
- /* but= */ uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator type");
- // uiButSetFunc(but, old_sca_move_actuator, act, NULL);
- /* but= */ uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator name");
- // uiButSetFunc(but, old_sca_move_actuator, act, NULL);
-
- uiBlockBeginAlign(block);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_UP, (short)(xco+width-(66+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick up");
- uiButSetFunc(but, old_sca_move_actuator, act, (void *)TRUE);
- but = uiDefIconBut(block, BUT, B_REDR, ICON_TRIA_DOWN, (short)(xco+width-(44+5)), yco, 22, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Move this logic brick down");
- uiButSetFunc(but, old_sca_move_actuator, act, (void *)FALSE);
- uiBlockEndAlign(block);
-
- ycoo= yco;
- }
-
- uiDefIconBut(block, INLINK, 0, ICON_INLINK, (short)(xco - 19), ycoo, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, "");
-
- yco-=20;
- }
- act= act->next;
- }
- yco-= 6;
- }
- }
-
- uiComposeLinks(block);
-
- uiEndBlock(C, block);
- uiDrawBlock(C, block);
-
- if (idar) MEM_freeN(idar);
-}
-
-
-
-
-
-
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 9b0e342505b..badc4dbb533 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -67,9 +67,6 @@
/* ******************* nla editor space & buttons ************** */
-#define B_NOP 1
-#define B_REDR 2
-
/* -------------- */
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event)
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 775dd5445c3..950060dde5f 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -304,13 +304,13 @@ static int nlaedit_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
+ v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
@@ -1170,7 +1170,8 @@ static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
-void NLA_OT_bake(wmOperatorType *ot)
+/* why isn't this used? */
+static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake Strips";
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 222c2414fcb..79be0d0a194 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -309,7 +309,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
mode = NLA_BORDERSEL_FRAMERANGE;
else
mode = NLA_BORDERSEL_CHANNELS;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 5ebcef1d9a7..3bba02f4fc8 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -63,14 +63,12 @@
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "node_intern.h" /* own include */
-/* XXX interface.h */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
-
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
@@ -199,25 +197,22 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
{
SpaceNode *snode = CTX_wm_space_node(C);
- float slen;
- int ofs = 0;
const char *ui_name = IFACE_(name);
- int len = strlen(ui_name);
+ float slen;
+
UI_ThemeColor(TH_TEXT);
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
- while (slen > node->width && ofs < len) {
- ofs++;
- slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
+ while (slen > node->width && *ui_name) {
+ ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
+ slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
}
-
- if (ofs < len) {
- uiDefBut(block, LABEL, 0, ui_name + ofs,
- (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
- (short)(node->width - NODE_DY), (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+
+ if (*ui_name) {
+ uiDefBut(block, LABEL, 0, ui_name,
+ (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
+ (short)slen, (short)NODE_DY,
+ NULL, 0, 0, 0, 0, "");
}
-
- (void)snode;
}
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
@@ -386,7 +381,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "",
(int)butr->xmin, (int)butr->xmin,
- (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr),
+ (short)BLI_rctf_size_x(butr), (short)BLI_rctf_size_x(butr),
nor, 0.0f, 1.0f, 0, 0, "");
uiButSetFunc(bt, node_normal_cb, ntree, node);
}
@@ -522,7 +517,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
rect->ymax += NODE_DY;
/* input sockets */
- dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
+ dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
gsock = ngroup->inputs.first;
sock = gnode->inputs.first;
while (gsock || sock) {
@@ -570,7 +565,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
}
/* output sockets */
- dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
+ dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
gsock = ngroup->outputs.first;
sock = gnode->outputs.first;
while (gsock || sock) {
@@ -645,13 +640,13 @@ static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v
}
static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock,
- int in_out, float xoffset, float yoffset)
+ int in_out, float xoffset, float yoffset, short width, short height)
{
if (sock->flag & SOCK_DYNAMIC) {
bNodeTree *ngroup = (bNodeTree *)gnode->id;
uiBut *but;
but = uiDefBut(gnode->block, TEX, 0, "",
- sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
+ sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
sock->name, 0, sizeof(sock->name), 0, 0, "");
if (in_out == SOCK_IN)
uiButSetFunc(but, update_group_input_cb, snode, ngroup);
@@ -661,7 +656,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
else {
const char *ui_name = IFACE_(sock->name);
uiDefBut(gnode->block, LABEL, 0, ui_name,
- sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
+ sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
NULL, 0, 0, 0, 0, "");
}
}
@@ -669,23 +664,26 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
{
+ const float dpi_fac = U.dpi / 72.0f;
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
uiBut *bt;
float offset;
int draw_value;
- float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72;
- float socket_size = NODE_SOCKSIZE * U.dpi / 72;
- float arrowbutw = 0.8f * UI_UNIT_X;
+ const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
+ const float socket_size = NODE_SOCKSIZE * dpi_fac;
+ const float arrowbutw = 0.8f * UI_UNIT_X;
+ const short co_text_w = 72 * dpi_fac;
+ const float co_margin = 6.0f * dpi_fac;
/* layout stuff for buttons on group left frame */
- float colw = 0.6f * node_group_frame;
- float col1 = 6 - node_group_frame;
- float col2 = col1 + colw + 6;
- float col3 = -arrowbutw - 6;
+ const float colw = 0.6f * node_group_frame;
+ const float col1 = co_margin - node_group_frame;
+ const float col2 = col1 + colw + co_margin;
+ const float col3 = -arrowbutw - co_margin;
/* layout stuff for buttons on group right frame */
- float cor1 = 6;
- float cor2 = cor1 + arrowbutw + 6;
- float cor3 = cor2 + arrowbutw + 6;
+ const float cor1 = co_margin;
+ const float cor2 = cor1 + arrowbutw;
+ const float cor3 = cor2 + arrowbutw + co_margin;
/* node and group socket circles */
if (sock)
@@ -715,13 +713,13 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
if (draw_value) {
/* both name and value buttons */
if (gsock) {
- draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0);
+ draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0, co_text_w, NODE_DY);
if (stype->buttonfunc)
stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "",
gsock->locx + offset, gsock->locy - NODE_DY, colw);
}
else {
- draw_group_socket_name(snode, gnode, sock, in_out, offset, 0);
+ draw_group_socket_name(snode, gnode, sock, in_out, offset, 0, co_text_w, NODE_DY);
if (stype->buttonfunc)
stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "",
sock->locx + offset, sock->locy - NODE_DY, colw);
@@ -730,9 +728,9 @@ static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
else {
/* only name, no value button */
if (gsock)
- draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS);
+ draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
else
- draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS);
+ draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
}
if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
@@ -836,7 +834,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
- mini((int)(BLI_RCT_SIZE_X(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
+ mini((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
uiBlockLayoutResolve(gnode->block, NULL, NULL);
@@ -892,7 +890,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
}
-void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
}
@@ -978,7 +976,7 @@ static void node_draw_frame_label(bNode *node, const float aspect)
ascender = BLF_ascender(fontid);
/* 'x' doesn't need aspect correction */
- x = BLI_RCT_CENTER_X(rct) - (0.5f * width);
+ x = BLI_rctf_cent_x(rct) - (0.5f * width);
y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
BLF_position(fontid, x, y, 0);
@@ -2023,7 +2021,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
node_composit_buts_file_output(layout, C, ptr);
- uiTemplateImageSettings(layout, &imfptr);
+ uiTemplateImageSettings(layout, &imfptr, TRUE);
uiItemS(layout);
@@ -2082,7 +2080,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C
col = uiLayoutColumn(layout, FALSE);
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
- uiTemplateImageSettings(col, &imfptr);
+ uiTemplateImageSettings(col, &imfptr, TRUE);
}
}
}
@@ -2387,7 +2385,7 @@ static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C),
uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
}
-void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
// node_composit_backdrop_canvas(snode, backdrop, node, x, y);
if (node->custom1 == 0) {
@@ -2407,7 +2405,7 @@ void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *nod
}
}
-void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
NodeBoxMask *boxmask = node->storage;
const float backdropWidth = backdrop->x;
@@ -2448,7 +2446,7 @@ void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *no
glEnd();
}
-void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
+static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
NodeEllipseMask *ellipsemask = node->storage;
const float backdropWidth = backdrop->x;
@@ -2608,7 +2606,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN
uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
if (node->custom1 == 2) {
- uiItemR(layout, ptr, "relative_frame", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
}
}
}
@@ -3051,7 +3049,7 @@ void ED_node_init_butfuncs(void)
/* ************** Generic drawing ************** */
-void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
+void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
{
if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
@@ -3059,7 +3057,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
void *lock;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
+ SpaceNode *snode = CTX_wm_space_node(C);
float x, y;
+ unsigned char *display_buffer;
+ void *cache_handle;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -3078,15 +3079,10 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
- if (!ibuf->rect) {
- if (color_manage)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_NONE;
- IMB_rect_from_float(ibuf);
- }
- if (ibuf->rect) {
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (display_buffer) {
if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
int ofs;
@@ -3104,7 +3100,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
/* swap bytes, so alpha is most significant one, then just draw it as luminance int */
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
- ((unsigned char *)ibuf->rect) + ofs);
+ display_buffer + ofs);
glPixelZoom(1.0f, 1.0f);
}
@@ -3114,7 +3110,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
#ifdef __BIG_ENDIAN__
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
#endif
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
#ifdef __BIG_ENDIAN__
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
@@ -3126,7 +3122,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glPixelZoom(1.0f, 1.0f);
glDisable(GL_BLEND);
@@ -3134,12 +3130,14 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
else {
glPixelZoom(snode->zoom, snode->zoom);
- glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glPixelZoom(1.0f, 1.0f);
}
}
+ IMB_display_buffer_release(cache_handle);
+
/** @note draw selected info on backdrop */
if (snode->edittree) {
bNode *node = snode->edittree->nodes.first;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f1a91df6f53..379e9987c4c 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -62,10 +62,8 @@
#include "node_intern.h" /* own include */
#include "COM_compositor.h"
-/* width of socket columns in group display */
-#define NODE_GROUP_FRAME 120
/* XXX interface.h */
-extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
+extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
/* XXX update functions for node editor are a mess, needs a clear concept */
void ED_node_tree_update(SpaceNode *snode, Scene *scene)
@@ -343,7 +341,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
}
else {
- float oldh = BLI_RCT_SIZE_Y(&node->prvr);
+ float oldh = BLI_rctf_size_y(&node->prvr);
if (oldh == 0.0f)
oldh = 0.6f * node->width - NODE_DY;
dy -= NODE_DYS / 2;
@@ -584,9 +582,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float
/* not a callback */
static void node_draw_preview(bNodePreview *preview, rctf *prv)
{
- float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize);
- float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize);
- float tile = BLI_RCT_SIZE_X(prv) / 10.0f;
+ float xscale = BLI_rctf_size_x(prv) / ((float)preview->xsize);
+ float yscale = BLI_rctf_size_y(prv) / ((float)preview->ysize);
+ float tile = BLI_rctf_size_x(prv) / 10.0f;
float x, y;
/* draw checkerboard backdrop to show alpha */
@@ -852,8 +850,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
{
bNodeSocket *sock;
rctf *rct = &node->totr;
- float dx, centy = BLI_RCT_CENTER_Y(rct);
- float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f;
+ float dx, centy = BLI_rctf_cent_y(rct);
+ float hiddenrad = BLI_rctf_size_y(rct) / 2.0f;
float socket_size = NODE_SOCKSIZE * U.dpi / 72;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 is used below */
@@ -932,7 +930,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
uiDefBut(node->block, LABEL, 0, showname,
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
- (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY,
+ (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
}
@@ -1091,8 +1089,6 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
{
View2DScrollers *scrollers;
SpaceNode *snode = CTX_wm_space_node(C);
- Scene *scene = CTX_data_scene(C);
- int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
bNodeLinkDrag *nldrag;
LinkData *linkdata;
@@ -1110,7 +1106,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
glEnable(GL_MAP1_VERTEX_3);
/* aspect+font, set each time */
- snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx;
+ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx;
snode->aspect_sqrt = sqrtf(snode->aspect);
// XXX snode->curfont= uiSetCurFont_ext(snode->aspect);
@@ -1118,7 +1114,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2);
/* backdrop */
- draw_nodespace_back_pix(ar, snode, color_manage);
+ draw_nodespace_back_pix(C, ar, snode);
/* nodes */
snode_set_context(snode, CTX_data_scene(C));
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 9e04bd36a1f..64a8d96a74f 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -148,8 +148,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
{
CompoJob *cj = cjv;
bNodeTree *ntree = cj->localtree;
+ Scene *scene = cj->scene;
- if (cj->scene->use_nodes == FALSE)
+ if (scene->use_nodes == FALSE)
return;
cj->stop = stop;
@@ -165,7 +166,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
// XXX BIF_store_spare();
- ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */
+ ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */
ntree->test_break = NULL;
ntree->stats_draw = NULL;
@@ -2066,8 +2067,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
/* calculate "barycenter" for placing on mouse cursor */
zero_v2(center);
for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) {
- center[0] += BLI_RCT_CENTER_X(&node->totr);
- center[1] += BLI_RCT_CENTER_Y(&node->totr);
+ center[0] += BLI_rctf_cent_x(&node->totr);
+ center[1] += BLI_rctf_cent_y(&node->totr);
}
mul_v2_fl(center, 1.0 / num_nodes);
diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c
index e17961b6c7c..5ab698cd415 100644
--- a/source/blender/editors/space_node/node_header.c
+++ b/source/blender/editors/space_node/node_header.c
@@ -100,7 +100,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
/* once this is called from an operator, this should be removed */
if (node_new) {
char undostr[BKE_UNDO_STR_MAX];
- BLI_snprintf(undostr, sizeof(BKE_UNDO_STR_MAX), "Add Node %s", nodeLabel(node_new));
+ BLI_snprintf(undostr, sizeof(undostr), "Add Node %s", nodeLabel(node_new));
BKE_write_undo(C, undostr);
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 2bb550d1a63..36ebddc8d22 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -125,7 +125,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3);
int node_link_bezier_points(View2D * v2d, SpaceNode * snode, bNodeLink * link, float coord_array[][2], int resol);
// void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
-void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage);
+void draw_nodespace_back_pix(const struct bContext *C, ARegion *ar, SpaceNode *snode);
/* node_add.c */
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index a56d76a3ef7..f7757ce49b4 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -555,8 +555,8 @@ static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short
/* do actual selection */
for (node = snode->edittree->nodes.first; node; node = node->next) {
int screen_co[2];
- const float cent[2] = {BLI_RCT_CENTER_X(&node->totr),
- BLI_RCT_CENTER_Y(&node->totr)};
+ const float cent[2] = {BLI_rctf_cent_x(&node->totr),
+ BLI_rctf_cent_y(&node->totr)};
/* marker in screen coords */
UI_view2d_view_to_region(&ar->v2d,
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 7881014ed54..3d93a6c14a1 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -230,7 +230,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
/****************************** Node Link Menu *******************************/
-#define UI_NODE_LINK_ADD 0
+// #define UI_NODE_LINK_ADD 0
#define UI_NODE_LINK_DISCONNECT -1
#define UI_NODE_LINK_REMOVE -2
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index e89e798a6fa..ccf5c4b540f 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -72,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
int tot = 0;
int has_frame = FALSE;
- oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur);
- oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur);
+ oldwidth = BLI_rctf_size_x(&ar->v2d.cur);
+ oldheight = BLI_rctf_size_y(&ar->v2d.cur);
BLI_rctf_init_minmax(&cur_new);
@@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
}
if (tot) {
- width = BLI_RCT_SIZE_X(&cur_new);
- height = BLI_RCT_SIZE_Y(&cur_new);
+ width = BLI_rctf_size_x(&cur_new);
+ height = BLI_rctf_size_y(&cur_new);
/* for single non-frame nodes, don't zoom in, just pan view,
* but do allow zooming out, this allows for big nodes to be zoomed out */
@@ -327,12 +327,12 @@ typedef struct ImageSampleInfo {
void *draw_handle;
int x, y;
int channels;
- int color_manage;
unsigned char col[4];
float colf[4];
int draw;
+ int color_manage;
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -341,7 +341,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
ImageSampleInfo *info = arg_info;
if (info->draw) {
- ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+ ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels,
info->x, info->y, info->col, info->colf,
NULL, NULL /* zbuf - unused for nodes */
);
@@ -358,6 +358,13 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float
float fx, fy, bufx, bufy;
int ret = FALSE;
+ if (snode->treetype != NTREE_COMPOSIT || (snode->flag & SNODE_BACKDRAW) == 0) {
+ /* use viewer image for color sampling only if we're in compositor tree
+ * with backdrop enabled
+ */
+ return FALSE;
+ }
+
ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
@@ -381,12 +388,7 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
/* IB_PROFILE_NONE is default but infact its linear */
- if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
- linearrgb_to_srgb_v3_v3(r_col, fp);
- }
- else {
- copy_v3_v3(r_col, fp);
- }
+ linearrgb_to_srgb_v3_v3(r_col, fp);
ret = TRUE;
}
else if (ibuf->rect) {
@@ -419,10 +421,6 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
}
if (!ibuf->rect) {
- if (info->color_manage)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- else
- ibuf->profile = IB_PROFILE_NONE;
IMB_rect_from_float(ibuf);
}
@@ -457,6 +455,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[1] = (float)cp[1] / 255.0f;
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -465,6 +465,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[1] = fp[1];
info->colf[2] = fp[2];
info->colf[3] = fp[3];
+
+ info->color_manage = TRUE;
}
ED_node_sample_set(info->colf);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 1522528a8ac..0601d7c105f 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -44,6 +44,7 @@
#include "BKE_screen.h"
#include "BKE_node.h"
+#include "ED_space_api.h"
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_node.h"
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 0874ddcb279..d7e180f982b 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -579,11 +579,11 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
te = outliner_find_id(so, &so->tree, (ID *)OBACT);
if (te) {
/* make te->ys center of view */
- ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2);
+ ytop = (int)(te->ys + BLI_rcti_size_y(&v2d->mask) / 2);
if (ytop > 0) ytop = 0;
v2d->cur.ymax = (float)ytop;
- v2d->cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&v2d->mask));
+ v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - v2d->cur.xmin);
@@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask);
+ int dy = BLI_rcti_size_y(&ar->v2d.mask);
int up = 0;
if (RNA_boolean_get(op->ptr, "up"))
@@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
tselem->flag |= TSE_SELECTED;
/* make te->ys center of view */
- ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2);
+ ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2);
if (ytop > 0) ytop = 0;
ar->v2d.cur.ymax = (float)ytop;
- ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask));
+ ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - ar->v2d.cur.xmin);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 8b7cf406642..823de61d044 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -433,8 +433,11 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
if (set) {
if (!(bone->flag & BONE_HIDDEN_P)) {
- if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag
- else ED_pose_deselectall(OBACT, 0);
+ Object *ob = OBACT;
+ if (ob) {
+ if (set == 2) ED_pose_deselectall(ob, 2); // 2 is clear active tag
+ else ED_pose_deselectall(ob, 0);
+ }
if (set == 2 && (bone->flag & BONE_SELECTED)) {
bone->flag &= ~BONE_SELECTED;
@@ -444,7 +447,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
arm->act_bone = bone;
}
- WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob);
}
}
else {
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 0c316450c29..f927e83cabe 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -52,6 +52,7 @@
#include "BKE_sound.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "BIF_gl.h"
@@ -68,6 +69,9 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "WM_api.h"
+#include "WM_types.h"
+
/* own include */
#include "sequencer_intern.h"
@@ -428,7 +432,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
+ pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
if (pixely <= 0) return; /* can happen when the view is split/resized */
@@ -721,7 +725,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
- drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx);
+ drawseqwave(scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
}
/* draw lock */
@@ -846,6 +850,50 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int
return ibuf;
}
+static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf)
+{
+ if (scopes->reference_ibuf != ibuf) {
+ if (scopes->zebra_ibuf) {
+ IMB_freeImBuf(scopes->zebra_ibuf);
+ scopes->zebra_ibuf = NULL;
+ }
+
+ if (scopes->waveform_ibuf) {
+ IMB_freeImBuf(scopes->waveform_ibuf);
+ scopes->waveform_ibuf = NULL;
+ }
+
+ if (scopes->sep_waveform_ibuf) {
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+ scopes->sep_waveform_ibuf = NULL;
+ }
+
+ if (scopes->vector_ibuf) {
+ IMB_freeImBuf(scopes->vector_ibuf);
+ scopes->vector_ibuf = NULL;
+ }
+
+ if (scopes->histogram_ibuf) {
+ IMB_freeImBuf(scopes->histogram_ibuf);
+ scopes->histogram_ibuf = NULL;
+ }
+ }
+}
+
+static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf))
+{
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+ ImBuf *scope;
+
+ IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+
+ scope = make_scope_cb(display_ibuf);
+
+ IMB_freeImBuf(display_ibuf);
+
+ return scope;
+}
+
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
{
struct Main *bmain = CTX_data_main(C);
@@ -859,6 +907,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
float col[3];
GLuint texid;
GLuint last_texid;
+ unsigned char *display_buffer;
+ void *cache_handle = NULL;
render_size = sseq->render_size;
if (render_size == 0) {
@@ -906,38 +956,64 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (ibuf->rect == NULL && ibuf->rect_float == NULL)
return;
-
- switch (sseq->mainb) {
- case SEQ_DRAW_IMG_IMBUF:
- if (sseq->zebra != 0) {
- scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra);
- }
- break;
- case SEQ_DRAW_IMG_WAVEFORM:
- if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
- scope = make_sep_waveform_view_from_ibuf(ibuf);
- }
- else {
- scope = make_waveform_view_from_ibuf(ibuf);
- }
- break;
- case SEQ_DRAW_IMG_VECTORSCOPE:
- scope = make_vectorscope_view_from_ibuf(ibuf);
- break;
- case SEQ_DRAW_IMG_HISTOGRAM:
- scope = make_histogram_view_from_ibuf(ibuf);
- break;
+
+ if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) {
+ SequencerScopes *scopes = &sseq->scopes;
+
+ sequencer_check_scopes(scopes, ibuf);
+
+ switch (sseq->mainb) {
+ case SEQ_DRAW_IMG_IMBUF:
+ if (!scopes->zebra_ibuf) {
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+
+ IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+ scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
+ IMB_freeImBuf(display_ibuf);
+ }
+ scope = scopes->zebra_ibuf;
+ break;
+ case SEQ_DRAW_IMG_WAVEFORM:
+ if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
+ if (!scopes->sep_waveform_ibuf)
+ scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
+ scope = scopes->sep_waveform_ibuf;
+ }
+ else {
+ if (!scopes->waveform_ibuf)
+ scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
+ scope = scopes->waveform_ibuf;
+ }
+ break;
+ case SEQ_DRAW_IMG_VECTORSCOPE:
+ if (!scopes->vector_ibuf)
+ scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
+ scope = scopes->vector_ibuf;
+ break;
+ case SEQ_DRAW_IMG_HISTOGRAM:
+ if (!scopes->histogram_ibuf)
+ scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
+ scope = scopes->histogram_ibuf;
+ break;
+ }
+
+ scopes->reference_ibuf = ibuf;
}
if (scope) {
IMB_freeImBuf(ibuf);
ibuf = scope;
- }
- if (ibuf->rect_float && ibuf->rect == NULL) {
- IMB_rect_from_float(ibuf);
+ if (ibuf->rect_float && ibuf->rect == NULL) {
+ IMB_rect_from_float(ibuf);
+ }
+
+ display_buffer = (unsigned char *)ibuf->rect;
}
-
+ else {
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+ }
+
/* setting up the view - actual drawing starts here */
UI_view2d_view_ortho(v2d);
@@ -950,16 +1026,16 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glBegin(GL_QUADS);
if (draw_overlay) {
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
rctf tot_clip;
- tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin);
- tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin);
- tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax);
- tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax);
+ tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
+ tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
+ tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
+ tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
@@ -1030,7 +1106,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
- IMB_freeImBuf(ibuf);
+ if (!scope)
+ IMB_freeImBuf(ibuf);
/* ortho at pixel level */
UI_view2d_view_restore(C);
@@ -1065,6 +1142,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
}
}
+ if (cache_handle)
+ IMB_display_buffer_release(cache_handle);
}
#if 0
@@ -1143,7 +1222,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
View2D *v2d = &ar->v2d;
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
- float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index f47eb339878..e7d964ba715 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
if (ed == NULL) return NULL;
- pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -2164,8 +2164,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
float winx = (int)(rd->size * rd->xsch) / 100;
float winy = (int)(rd->size * rd->ysch) / 100;
- float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx;
- float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy;
+ float facx = BLI_rcti_size_x(&v2d->mask) / winx;
+ float facy = BLI_rcti_size_y(&v2d->mask) / winy;
BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
@@ -2268,7 +2268,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ymax += ymargin;
ymin -= ymargin;
- orig_height = BLI_RCT_SIZE_Y(&cur_new);
+ orig_height = BLI_rctf_size_y(&cur_new);
cur_new.xmin = xmin;
cur_new.xmax = xmax;
@@ -2277,8 +2277,8 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
cur_new.ymax = ymax;
/* only zoom out vertically */
- if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) {
- ymid = BLI_RCT_CENTER_Y(&cur_new);
+ if (orig_height > BLI_rctf_size_y(&cur_new)) {
+ ymid = BLI_rctf_cent_y(&cur_new);
cur_new.ymin = ymid - (orig_height / 2);
cur_new.ymax = ymid + (orig_height / 2);
@@ -2800,11 +2800,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op)
if (ed == NULL)
return OPERATOR_CANCELLED;
- rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
- rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
+ rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot));
- rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
- rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
+ rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot));
rect.xmin += 0.5f;
rect.xmax += 0.5f;
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index aa6bacf8836..70b288a59e6 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -43,6 +43,7 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_sequencer.h"
#include "ED_markers.h"
#include "ED_transform.h" /* transform keymap */
@@ -77,6 +78,9 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_swap_data);
WM_operatortype_append(SEQUENCER_OT_rendersize);
+ WM_operatortype_append(SEQUENCER_OT_copy);
+ WM_operatortype_append(SEQUENCER_OT_paste);
+
WM_operatortype_append(SEQUENCER_OT_view_all);
WM_operatortype_append(SEQUENCER_OT_view_selected);
WM_operatortype_append(SEQUENCER_OT_view_all_preview);
@@ -109,10 +113,9 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
WM_operatortype_append(SEQUENCER_OT_image_strip_add);
WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
- WM_operatortype_append(SEQUENCER_OT_properties);
- WM_operatortype_append(SEQUENCER_OT_copy);
- WM_operatortype_append(SEQUENCER_OT_paste);
+ /* sequencer_buttons.c */
+ WM_operatortype_append(SEQUENCER_OT_properties);
/* sequencer_modifiers.c */
WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
@@ -131,7 +134,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
/* Common items ------------------------------------------------------------------ */
keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
-
+
+ WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.show_overlay");
@@ -140,9 +145,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
/* Strips Region --------------------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
-
- WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -152,12 +155,12 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_enum_set(kmi->ptr, "type", SEQ_CUT_SOFT);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", TRUE);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "unselected", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
@@ -178,7 +181,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
@@ -209,7 +212,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT);
RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0);
@@ -244,7 +247,7 @@ void sequencer_keymap(wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
@@ -292,14 +295,14 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
-
+
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
@@ -307,33 +310,32 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0);
-
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame");
RNA_int_set(kmi->ptr, "value", 0);
transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
-
+
/* special markers hotkeys for anim editors: see note in definition of this function */
ED_marker_keymap_animedit_conflictfree(keymap);
-
-
+
+
/* Preview Region ----------------------------------------------------------- */
keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0);
/* would prefer to use numpad keys for job */
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
-
+
/* Setting zoom levels is not that useful, except for back to zoom level 1, removing keymap because of conflicts for now */
#if 0
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
-
+
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 1655b3ec7bc..6ed34a79510 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -449,6 +449,8 @@ static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col)
}
}
+#define HIS_STEPS 512
+
static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
{
ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
@@ -456,22 +458,38 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
unsigned int n;
unsigned char *src = (unsigned char *) ibuf->rect;
- unsigned int bins[3][256];
+ unsigned int bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
+ #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256)
for (y = 0; y < ibuf->y; y++) {
+ unsigned int cur_bins[3][HIS_STEPS];
+
+ memset(cur_bins, 0, sizeof(cur_bins));
+
for (x = 0; x < ibuf->x; x++) {
- bins[0][*src++]++;
- bins[1][*src++]++;
- bins[2][*src++]++;
- src++;
+ unsigned char *pixel = src + (y * ibuf->x + x) * 4;
+
+ cur_bins[0][pixel[0]]++;
+ cur_bins[1][pixel[1]]++;
+ cur_bins[2][pixel[2]]++;
+ }
+
+ #pragma omp critical
+ {
+ int i;
+ for (i = 0; i < HIS_STEPS; i++) {
+ bins[0][i] += cur_bins[0][i];
+ bins[1][i] += cur_bins[1][i];
+ bins[2][i] += cur_bins[2][i];
+ }
}
}
n = 0;
for (c = 0; c < 3; c++) {
- for (x = 0; x < 256; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
@@ -479,7 +497,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
}
for (c = 0; c < 3; c++) {
- for (x = 0; x < 256; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
draw_histogram_bar(rval, x * 2 + 1, ((float) bins[c][x]) / n, c);
draw_histogram_bar(rval, x * 2 + 2, ((float) bins[c][x]) / n, c);
}
@@ -490,7 +508,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
return rval;
}
-static int get_bin_float(float f)
+BLI_INLINE int get_bin_float(float f)
{
if (f < -0.25f) {
return 0;
@@ -508,16 +526,32 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
int n, c, x, y;
float *src = ibuf->rect_float;
- unsigned int bins[3][512];
+ unsigned int bins[3][HIS_STEPS];
memset(bins, 0, sizeof(bins));
+ #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256)
for (y = 0; y < ibuf->y; y++) {
+ unsigned int cur_bins[3][HIS_STEPS];
+
+ memset(cur_bins, 0, sizeof(cur_bins));
+
for (x = 0; x < ibuf->x; x++) {
- bins[0][get_bin_float(*src++)]++;
- bins[1][get_bin_float(*src++)]++;
- bins[2][get_bin_float(*src++)]++;
- src++;
+ float *pixel = src + (y * ibuf->x + x) * 4;
+
+ cur_bins[0][get_bin_float(pixel[0])]++;
+ cur_bins[1][get_bin_float(pixel[1])]++;
+ cur_bins[2][get_bin_float(pixel[2])]++;
+ }
+
+ #pragma omp critical
+ {
+ int i;
+ for (i = 0; i < HIS_STEPS; i++) {
+ bins[0][i] += cur_bins[0][i];
+ bins[1][i] += cur_bins[1][i];
+ bins[2][i] += cur_bins[2][i];
+ }
}
}
@@ -526,14 +560,14 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
n = 0;
for (c = 0; c < 3; c++) {
- for (x = 0; x < 512; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
}
}
for (c = 0; c < 3; c++) {
- for (x = 0; x < 512; x++) {
+ for (x = 0; x < HIS_STEPS; x++) {
draw_histogram_bar(rval, x + 1, (float) bins[c][x] / n, c);
}
}
@@ -543,6 +577,8 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
return rval;
}
+#undef HIS_STEPS
+
ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf)
{
if (ibuf->rect_float) {
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index d500bef4f02..3c3489115a4 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -49,6 +49,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
#include "UI_view2d.h"
@@ -70,6 +71,7 @@ typedef struct ImageSampleInfo {
float *colfp;
int draw;
+int color_manage;
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
@@ -78,8 +80,8 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
ImageSampleInfo *info = arg_info;
if (info->draw) {
- ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
- info->x, info->y, info->col, info->colf, NULL, NULL);
+ ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels,
+ info->x, info->y, info->colp, info->colfp, NULL, NULL);
}
}
@@ -131,6 +133,8 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
+
+ info->color_manage = FALSE;
}
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
@@ -140,6 +144,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = fp[2];
info->colf[3] = fp[3];
info->colfp = info->colf;
+
+ /* sequencer's image buffers are in non-linear space, need to make them linear */
+ BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->colf);
+
+ info->color_manage = TRUE;
}
}
else {
@@ -202,7 +211,7 @@ static int sample_cancel(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
-int sample_poll(bContext *C)
+static int sample_poll(bContext *C)
{
return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL;
}
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index f7362aab7aa..8ac50a57b10 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -57,8 +57,19 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "IMB_imbuf.h"
+
#include "sequencer_intern.h" // own include
+/**************************** common state *****************************/
+
+static void sequencer_scopes_tag_refresh(ScrArea *sa)
+{
+ SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
+
+ sseq->scopes.reference_ibuf = NULL;
+}
+
/* ******************** manage regions ********************* */
ARegion *sequencer_has_buttons_region(ScrArea *sa)
@@ -183,12 +194,27 @@ static SpaceLink *sequencer_new(const bContext *C)
}
/* not spacelink itself */
-static void sequencer_free(SpaceLink *UNUSED(sl))
+static void sequencer_free(SpaceLink *sl)
{
-// SpaceSeq *sseq= (SpaceSequencer*) sl;
-
+ SpaceSeq *sseq= (SpaceSeq *) sl;
+ SequencerScopes *scopes = &sseq->scopes;
+
// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
+ if (scopes->zebra_ibuf)
+ IMB_freeImBuf(scopes->zebra_ibuf);
+
+ if (scopes->waveform_ibuf)
+ IMB_freeImBuf(scopes->waveform_ibuf);
+
+ if (scopes->sep_waveform_ibuf)
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+
+ if (scopes->vector_ibuf)
+ IMB_freeImBuf(scopes->vector_ibuf);
+
+ if (scopes->histogram_ibuf)
+ IMB_freeImBuf(scopes->histogram_ibuf);
}
@@ -290,7 +316,24 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
return (SpaceLink *)sseqn;
}
-
+static void sequencer_listener(ScrArea *sa, wmNotifier *wmn)
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_SEQUENCER:
+ sequencer_scopes_tag_refresh(sa);
+ break;
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER)
+ sequencer_scopes_tag_refresh(sa);
+ break;
+ }
+}
/* *********************** sequencer (main) region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
@@ -610,6 +653,7 @@ void ED_spacetype_sequencer(void)
st->context = sequencer_context;
st->dropboxes = sequencer_dropboxes;
st->refresh = sequencer_refresh;
+ st->listener = sequencer_listener;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 97eb5b41db7..5111d20b8ee 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1232,7 +1232,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);
uiSetRoundBox(UI_CNR_ALL);
- rad = 0.4f * mini(BLI_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll));
+ rad = 0.4f * mini(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
UI_GetThemeColor3ubv(TH_HILITE, col);
col[3] = 48;
glColor4ubv(col);
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index b0cd6aeaab4..7dc3ec1ac60 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -59,17 +59,12 @@
#include "WM_types.h"
-
-
-
#ifdef WITH_PYTHON
// XXX #include "BPY_menus.h"
#endif
#include "text_intern.h"
-#define HEADER_PATH_MAX 260
-
/* ************************ header area region *********************** */
/************************** properties ******************************/
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 5af44f93d06..75b8e2f218d 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -602,9 +602,12 @@ static int text_run_script(bContext *C, ReportList *reports)
/* Don't report error messages while live editing */
if (!is_live) {
- if (text->curl != curl_prev || curc_prev != text->curc) {
- text_update_cursor_moved(C);
- WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ /* text may have freed its self */
+ if (CTX_data_edit_text(C) == text) {
+ if (text->curl != curl_prev || curc_prev != text->curc) {
+ text_update_cursor_moved(C);
+ WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+ }
}
BKE_report(reports, RPT_ERROR, "Python script fail, look in the console for now...");
@@ -2409,8 +2412,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* jump scroll, works in v2d but needs to be added here too :S */
if (event->type == MIDDLEMOUSE) {
- tsc->old[0] = ar->winrct.xmin + BLI_RCT_CENTER_X(&st->txtbar);
- tsc->old[1] = ar->winrct.ymin + BLI_RCT_CENTER_Y(&st->txtbar);
+ tsc->old[0] = ar->winrct.xmin + BLI_rcti_cent_x(&st->txtbar);
+ tsc->old[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->txtbar);
tsc->delta[0] = 0;
tsc->delta[1] = 0;
diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c
index f980e19e9c8..966afe22e42 100644
--- a/source/blender/editors/space_text/text_python.c
+++ b/source/blender/editors/space_text/text_python.c
@@ -180,13 +180,9 @@ static void confirm_suggestion(Text *text, int skipleft)
}
// XXX
-#define L_MOUSE 0
-#define M_MOUSE 0
-#define R_MOUSE 0
#define LR_SHIFTKEY 0
#define LR_ALTKEY 0
#define LR_CTRLKEY 0
-#define LR_OSKEY 0
// XXX
static int doc_scroll = 0;
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index 733fd27135b..9067fb6933f 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -151,7 +151,7 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur.xmax = (float)PEFRA;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
+ extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index da93e07748a..f05c78e8512 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -179,7 +179,7 @@ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int i
return DM_DRAW_OPTION_SKIP;
}
-void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
+static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
{
drawMeshFaceSelect_userData data;
@@ -372,7 +372,15 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
Gtexdraw.ob = ob;
Gtexdraw.is_tex = is_tex;
- Gtexdraw.color_profile = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+
+ /* OCIO_TODO: for now assume OpenGL is always doing color management and working in sRGB space
+ * supporting for real display conversion could be nice here, but it's a bit challenging
+ * since all the shaders should be aware of such a transform
+ * perhaps this flag could be completely removed before release in separated commit and
+ * be re-implemented if real display transform would be needed
+ */
+ Gtexdraw.color_profile = TRUE;
+
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));
set_draw_settings_cached(1, NULL, NULL, Gtexdraw);
glShadeModel(GL_SMOOTH);
@@ -507,7 +515,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
finalCol[i * 4 + j].r = 255;
}
}
- else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
+ else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
for (j = 0; j < 4; j++) {
finalCol[i * 4 + j].b = 255;
finalCol[i * 4 + j].g = 0;
@@ -630,7 +638,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */
MLoopCol *lcol;
- bProperty *prop = get_ob_property(ob, "Text");
+ bProperty *prop = BKE_bproperty_object_get(ob, "Text");
GPUVertexAttribs gattribs;
int a, totpoly = me->totpoly;
@@ -706,7 +714,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
unsigned int j;
lcol = &mloopcol[mp->loopstart];
- for (j = 0; j <= totloop_clamp; j++, lcol++) {
+ for (j = 0; j < totloop_clamp; j++, lcol++) {
MESH_MLOOPCOL_TO_MCOL(lcol, &tmp_mcol[j]);
}
}
@@ -724,7 +732,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
/* The BM_FONT handling is in the gpu module, shared with the
* game engine, was duplicated previously */
- set_property_valstr(prop, string);
+ BKE_bproperty_set_valstr(prop, string);
characters = strlen(string);
if (!BKE_image_get_ibuf(mtpoly->tpage, NULL))
@@ -772,8 +780,8 @@ static int compareDrawOptionsEm(void *userData, int cur_index, int next_index)
return 1;
}
-void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
- Object *ob, DerivedMesh *dm, const int draw_flags)
+static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
+ Object *ob, DerivedMesh *dm, const int draw_flags)
{
Mesh *me = ob->data;
@@ -824,7 +832,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
}
/* draw game engine text hack */
- if (get_ob_property(ob, "Text"))
+ if (BKE_bproperty_object_get(ob, "Text"))
draw_mesh_text(scene, ob, 0);
draw_textured_end();
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 83bc094270b..8d58530765a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2092,7 +2092,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo
else {
float co2[2];
mul_v3_m4v3(co2, data->vc.obedit->obmat, co);
- project_short_noclip(data->vc.ar, co2, s);
+ ED_view3d_project_short_noclip(data->vc.ar, co2, s);
}
if (s[0] != IS_CLIPPED)
@@ -2169,8 +2169,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo
mul_v3_m4v3(v1_co, data->vc.obedit->obmat, v0co);
mul_v3_m4v3(v2_co, data->vc.obedit->obmat, v1co);
- project_short_noclip(data->vc.ar, v1_co, s[0]);
- project_short_noclip(data->vc.ar, v2_co, s[1]);
+ ED_view3d_project_short_noclip(data->vc.ar, v1_co, s[0]);
+ ED_view3d_project_short_noclip(data->vc.ar, v2_co, s[1]);
if (data->clipVerts == V3D_CLIP_TEST_REGION) {
/* make an int copy */
@@ -2225,7 +2225,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo
short s[2];
mul_v3_m4v3(cent2, data->vc.obedit->obmat, cent);
- project_short(data->vc.ar, cent2, s);
+ ED_view3d_project_short(data->vc.ar, cent2, s);
if (s[0] != IS_CLIPPED) {
data->func(data->userData, efa, s[0], s[1], index);
@@ -3335,7 +3335,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
}
- if (em) {
+
+ {
draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
if (me->drawflag & ME_DRAWNORMALS) {
@@ -3461,7 +3462,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
dm->drawFacesGLSL(dm, GPU_enable_material);
-// if (get_ob_property(ob, "Text"))
+// if (BKE_bproperty_object_get(ob, "Text"))
// XXX draw_mesh_text(ob, 1);
GPU_disable_material();
@@ -3649,7 +3650,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
if (obedit && ob != obedit && ob->data == obedit->data) {
- if (ob_get_key(ob) || ob_get_key(obedit)) {}
+ if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
else if (ob->modifiers.first || obedit->modifiers.first) {}
else drawlinked = 1;
}
@@ -6643,7 +6644,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* which wire color */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
- project_short(ar, ob->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, ob->obmat[3], &base->sx);
draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive);
ob_wire_col = _ob_wire_col;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index c819637fd04..c8aca5674a4 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -83,7 +83,6 @@
/* ******************* view3d space & buttons ************** */
-#define B_NOP 1
#define B_REDR 2
#define B_OBJECTPANELMEDIAN 1008
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 8a334423ab0..c0ea4173392 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -69,6 +69,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
@@ -558,7 +559,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
/* we don't want the clipping for cursor */
flag = v3d->flag;
v3d->flag = 0;
- project_int(ar, give_cursor(scene, v3d), co);
+ ED_view3d_project_int(ar, give_cursor(scene, v3d), co);
v3d->flag = flag;
mx = co[0];
@@ -900,7 +901,7 @@ static void draw_selected_name(Scene *scene, Object *ob)
/* try to display active shapekey too */
shapes[0] = '\0';
- key = ob_get_key(ob);
+ key = BKE_key_from_object(ob);
if (key) {
kb = BLI_findlink(&key->block, ob->shapenr - 1);
if (kb) {
@@ -972,10 +973,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV
rect_camera = params.viewplane;
/* get camera border within viewport */
- viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
- viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
- viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
- viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
+ viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
+ viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
+ viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
+ viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
}
void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2])
@@ -983,8 +984,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
rctf viewborder;
view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE);
- size_r[0] = BLI_RCT_SIZE_X(&viewborder);
- size_r[1] = BLI_RCT_SIZE_Y(&viewborder);
+ size_r[0] = BLI_rctf_size_x(&viewborder);
+ size_r[1] = BLI_rctf_size_y(&viewborder);
}
void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@@ -1340,7 +1341,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
glDisable(GL_MULTISAMPLE_ARB);
region_scissor_winrct(ar, &winrct);
- glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct));
+ glScissor(winrct.xmin, winrct.ymin, BLI_rcti_size_x(&winrct), BLI_rcti_size_y(&winrct));
glClearColor(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
@@ -1542,11 +1543,6 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
{
RegionView3D *rv3d = ar->regiondata;
BGpic *bgpic;
- Image *ima;
- MovieClip *clip;
- ImBuf *ibuf = NULL, *freeibuf;
- float vec[4], fac, asp, zoomx, zoomy;
- float x1, y1, x2, y2, cx, cy;
int fg_flag = do_foreground ? V3D_BGPIC_FOREGROUND : 0;
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
@@ -1559,6 +1555,13 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
(rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA)))
{
float image_aspect[2];
+ float fac, asp, zoomx, zoomy;
+ float x1, y1, x2, y2;
+
+ ImBuf *ibuf = NULL, *freeibuf;
+
+ Image *ima;
+ MovieClip *clip;
/* disable individual images */
if ((bgpic->flag & V3D_BGPIC_DISABLED))
@@ -1686,26 +1689,25 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
}
}
else {
+ float tvec[3];
float sco[2];
const float mval_f[2] = {1.0f, 0.0f};
/* calc window coord */
initgrabz(rv3d, 0.0, 0.0, 0.0);
- ED_view3d_win_to_delta(ar, mval_f, vec);
- fac = maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */
+ ED_view3d_win_to_delta(ar, mval_f, tvec);
+ fac = maxf(fabsf(tvec[0]), maxf(fabsf(tvec[1]), fabsf(tvec[2]))); /* largest abs axis */
fac = 1.0f / fac;
- asp = ( (float)ibuf->y) / (float)ibuf->x;
+ asp = (float)ibuf->y / (float)ibuf->x;
- zero_v3(vec);
- ED_view3d_project_float_v2(ar, vec, sco, rv3d->persmat);
- cx = sco[0];
- cy = sco[1];
+ zero_v3(tvec);
+ ED_view3d_project_float_v2_m4(ar, tvec, sco, rv3d->persmat);
- x1 = cx + fac * (bgpic->xof - bgpic->size);
- y1 = cy + asp * fac * (bgpic->yof - bgpic->size);
- x2 = cx + fac * (bgpic->xof + bgpic->size);
- y2 = cy + asp * fac * (bgpic->yof + bgpic->size);
+ x1 = sco[0] + fac * (bgpic->xof - bgpic->size);
+ y1 = sco[1] + asp * fac * (bgpic->yof - bgpic->size);
+ x2 = sco[0] + fac * (bgpic->xof + bgpic->size);
+ y2 = sco[1] + asp * fac * (bgpic->yof + bgpic->size);
}
/* complete clip? */
@@ -1771,8 +1773,9 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
glDepthMask(1);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
- if (freeibuf)
+ if (freeibuf) {
IMB_freeImBuf(freeibuf);
+ }
}
}
}
@@ -2044,8 +2047,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
x = rect->xmin;
y = rect->ymin;
- w = BLI_RCT_SIZE_X(rect);
- h = BLI_RCT_SIZE_Y(rect);
+ w = BLI_rcti_size_x(rect);
+ h = BLI_rcti_size_y(rect);
if (w <= 0 || h <= 0) {
if (d->depths)
@@ -2375,7 +2378,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
- ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE);
+ ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE, FALSE);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
v3d->drawtype = drawtype;
@@ -2514,7 +2517,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar,
void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
int winx, int winy, float viewmat[][4], float winmat[][4],
- int do_bgpic)
+ int do_bgpic, int colormanage_background)
{
RegionView3D *rv3d = ar->regiondata;
Base *base;
@@ -2553,10 +2556,25 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* set background color, fallback on the view background color
* (if active clip is set but frame is failed to load fallback to horizon color as background) */
if (scene->world) {
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ /* NOTE: currently OpenGL is supposed to always work in sRGB space and do not
+ * apply any tonemaps since it's really tricky to support for all features (GLSL, textures, etc)
+ * but due to compatibility issues background is being affected display transform, so we can
+ * emulate behavior of disabled colro management
+ * but this function is also used for sequencer's scene strips which shouldn't be affected by
+ * tonemaps now and should be purely sRGB, that's why we've got this colormanage_background
+ * we can drop this flag in cost of some compatibility loss -- background wouldn't be
+ * color managed in 3d viewport
+ * same goes to opengl rendering, where color profile should be applied as very final step
+ */
+
+ if (colormanage_background) {
+ IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
+ &scene->display_settings);
+ }
+ else {
linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
- else
- copy_v3_v3(backcol, &scene->world->horr);
+ }
+
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
}
else {
@@ -2661,7 +2679,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* utility func for ED_view3d_draw_offscreen */
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
- int sizex, int sizey, unsigned int flag, int draw_background, char err_out[256])
+ int sizex, int sizey, unsigned int flag, int draw_background,
+ int colormanage_background, char err_out[256])
{
RegionView3D *rv3d = ar->regiondata;
ImBuf *ibuf;
@@ -2686,10 +2705,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
BKE_camera_params_compute_viewplane(&params, sizex, sizey, scene->r.xasp, scene->r.yasp);
BKE_camera_params_compute_matrix(&params);
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background, colormanage_background);
}
else {
- ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background);
+ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL, draw_background, colormanage_background);
}
/* read in pixels & stamp */
@@ -2714,7 +2733,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar,
/* creates own 3d views, used by the sequencer */
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height,
- unsigned int flag, int drawtype, int draw_background, char err_out[256])
+ unsigned int flag, int drawtype, int draw_background,
+ int colormanage_background, char err_out[256])
{
View3D v3d = {NULL};
ARegion ar = {NULL};
@@ -2753,7 +2773,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w
mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
- return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, draw_background, err_out);
+ return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag,
+ draw_background, colormanage_background, err_out);
// seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
}
@@ -2860,10 +2881,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
- cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder);
- cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder);
- cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder);
- cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder);
+ cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
+ cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
+ cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder);
+ cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder);
cliprct.xmin += ar->winrct.xmin;
cliprct.xmax += ar->winrct.xmin;
@@ -2877,7 +2898,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
glGetIntegerv(GL_SCISSOR_BOX, scissor);
- glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct));
+ glScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct));
}
else
return 0;
@@ -2936,10 +2957,9 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
/* clear background */
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
- if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
- linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
- else
- copy_v3_v3(backcol, &scene->world->horr);
+ IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
+ &scene->display_settings);
+
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
}
else
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 7accdb0c0e4..744ce6f6209 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -375,17 +375,17 @@ typedef struct ViewOpsData {
#define TRACKBALLSIZE (1.1)
-static void calctrackballvec(rcti *rect, int mx, int my, float vec[3])
+static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3])
{
float x, y, radius, d, z, t;
radius = TRACKBALLSIZE;
/* normalize x and y */
- x = BLI_RCT_CENTER_X(rect) - mx;
- x /= (float)(BLI_RCT_SIZE_X(rect) / 4);
- y = BLI_RCT_CENTER_Y(rect) - my;
- y /= (float)(BLI_RCT_SIZE_Y(rect) / 2);
+ x = BLI_rcti_cent_x(rect) - mx;
+ x /= (float)(BLI_rcti_size_x(rect) / 4);
+ y = BLI_rcti_cent_y(rect) - my;
+ y /= (float)(BLI_rcti_size_y(rect) / 2);
d = sqrt(x * x + y * y);
if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */
@@ -1637,7 +1637,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
if (use_cam_zoom) {
float delta;
delta = (x - vod->origx + y - vod->origy) / 10.0f;
- vod->rv3d->camzoom = vod->camzoom0 - delta;
+ vod->rv3d->camzoom = vod->camzoom0 + (zoom_invert ? delta : -delta);
CLAMP(vod->rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
}
@@ -1666,8 +1666,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
int ctr[2], len1, len2;
/* method which zooms based on how far you move the mouse */
- ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct);
- ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct);
+ ctr[0] = BLI_rcti_cent_x(&vod->ar->winrct);
+ ctr[1] = BLI_rcti_cent_y(&vod->ar->winrct);
len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5;
len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5;
@@ -2619,10 +2619,10 @@ static int render_border_exec(bContext *C, wmOperator *op)
/* calculate range */
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
- scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb);
- scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
- scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb);
- scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
+ scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb);
+ scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_rctf_size_y(&vb);
+ scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_rctf_size_x(&vb);
+ scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_rctf_size_y(&vb);
/* actually set border */
CLAMP(scene->r.border.xmin, 0.0f, 1.0f);
@@ -2786,8 +2786,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
}
/* work out the ratios, so that everything selected fits when we zoom */
- xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]);
- yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]);
+ xscale = (BLI_rcti_size_x(&rect) / vb[0]);
+ yscale = (BLI_rcti_size_y(&rect) / vb[1]);
new_dist *= maxf(xscale, yscale);
/* zoom in as required, or as far as we can go */
@@ -3465,7 +3465,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op)
view3d_set_viewcontext(C, &vc);
view3d_get_transformation(vc.ar, vc.rv3d, NULL, &mats); /* NULL because we don't want it in object space */
- ED_view3d_calc_clipping(rv3d->clipbb, rv3d->clip, &mats, &rect);
+ ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, &mats, &rect);
return OPERATOR_FINISHED;
}
@@ -3529,7 +3529,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
// if (obedit && ctrl) lr_click= 1;
copy_v3_v3(oldcurs, fp);
- project_int_noclip(ar, fp, mval);
+ ED_view3d_project_int_noclip(ar, fp, mval);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
/* reset the depth based on the view offset */
@@ -3537,7 +3537,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
negate_v3_v3(fp, rv3d->ofs);
/* re initialize */
- project_int_noclip(ar, fp, mval);
+ ED_view3d_project_int_noclip(ar, fp, mval);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
(void)flip;
}
@@ -3837,10 +3837,12 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m
}
/**
- * Gets the view transformation from a camera
- * currently dosnt take camzoom into account
+ * Set the view transformation from a 4x4 matrix.
*
- * The dist is not modified for this function, if NULL its assumed zero
+ * \param mat The view 4x4 transformation matrix to assign.
+ * \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_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist)
{
@@ -3871,6 +3873,14 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist)
}
}
+/**
+ * Calculate the view transformation matrix from RegionView3D input.
+ * The resulting matrix is equivalent to RegionView3D.viewinv
+ * \param mat The view 4x4 transformation matrix to calculate.
+ * \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_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist)
{
float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]};
@@ -3881,8 +3891,14 @@ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], co
sub_v3_v3v3(mat[3], dvec, ofs);
}
-
-/* object -> view */
+/**
+ * Set the RegionView3D members from an objects transformation and optionally lens.
+ * \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)
{
ED_view3d_from_m4(ob->obmat, ofs, quat, dist);
@@ -3896,7 +3912,13 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
}
}
-/* view -> object */
+/**
+ * Set the object transformation from RegionView3D members.
+ * \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)
{
float mat[4][4];
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 855771b17a2..c743b88e889 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -346,7 +346,6 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event
/* check for flying ortho camera - which we cant support well
* we _could_ also check for an ortho camera but this is easier */
if ((fly->rv3d->persp == RV3D_CAMOB) &&
- (fly->v3d->camera != NULL) &&
(fly->rv3d->is_persp == FALSE))
{
((Camera *)fly->v3d->camera->data)->type = CAM_PERSP;
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index fd43333acfe..b2ae63df662 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -84,25 +84,10 @@
* This can be cleaned when I make some new 'mode' icons.
*/
-/* view3d handler codes */
-#define VIEW3D_HANDLER_BACKGROUND 1
-#define VIEW3D_HANDLER_PROPERTIES 2
-#define VIEW3D_HANDLER_OBJECT 3
-#define VIEW3D_HANDLER_PREVIEW 4
-#define VIEW3D_HANDLER_MULTIRES 5
-#define VIEW3D_HANDLER_TRANSFORM 6
-#define VIEW3D_HANDLER_GREASEPENCIL 7
-#define VIEW3D_HANDLER_BONESKETCH 8
-
/* end XXX ************* */
static void do_view3d_header_buttons(bContext *C, void *arg, int event);
-#define B_SCENELOCK 101
-#define B_FULL 102
-#define B_HOME 103
-#define B_VIEWBUT 104
-#define B_PERSP 105
#define B_MODESELECT 108
#define B_SEL_VERT 110
#define B_SEL_EDGE 111
@@ -110,10 +95,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
#define B_MAN_TRANS 116
#define B_MAN_ROT 117
#define B_MAN_SCALE 118
-#define B_NDOF 119
#define B_MAN_MODE 120
-#define B_REDR 122
-#define B_NOP 123
/* XXX quickly ported across */
static void handle_view3d_lock(bContext *C)
@@ -346,10 +328,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
/* watch it: if sa->win does not exist, check that when calling direct drawing routines */
switch (event) {
- case B_REDR:
- ED_area_tag_redraw(sa);
- break;
-
case B_MODESELECT:
WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
@@ -416,9 +394,6 @@ static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
}
ED_area_tag_redraw(sa);
break;
- case B_NDOF:
- ED_area_tag_redraw(sa);
- break;
case B_MAN_MODE:
ED_area_tag_redraw(sa);
break;
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 5712144caf1..e409ad4e81e 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -114,7 +114,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
mval_cpy[0] = mval[0];
mval_cpy[1] = mval[1];
- project_int_noclip(vc->ar, fp, mval_cpy);
+ ED_view3d_project_int_noclip(vc->ar, fp, mval_cpy);
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
@@ -319,11 +319,6 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2)
return 1;
}
-
-#define MOVES_GESTURE 50
-#define MOVES_LASSO 500
-
-
/* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN)
* and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK
*/
@@ -339,9 +334,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
- project_int(vc->ar, vec, sco1);
+ ED_view3d_project_int(vc->ar, vec, sco1);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
- project_int(vc->ar, vec, sco2);
+ ED_view3d_project_int(vc->ar, vec, sco2);
if (BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) {
if (select) pchan->bone->flag |= BONE_SELECTED;
@@ -376,7 +371,7 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move
for (base = vc->scene->base.first; base; base = base->next) {
if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
- project_short(vc->ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx);
if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) {
if (select) ED_base_object_select(base, BA_SELECT);
@@ -583,9 +578,9 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
didpoint = 0;
if (BLI_lasso_is_point_inside(mcords, moves, sco1[0], sco1[1], IS_CLIPPED)) {
@@ -637,7 +632,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves,
for (ml = mb->editelems->first; ml; ml = ml->next) {
mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x);
- project_short(vc->ar, vec, sco);
+ ED_view3d_project_short(vc->ar, vec, sco);
if (BLI_lasso_is_point_inside(mcords, moves, sco[0], sco[1], IS_CLIPPED)) {
if (select) ml->flag |= SELECT;
@@ -646,7 +641,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves,
}
}
-int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
+static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
{
Mesh *me;
MVert *mvert;
@@ -654,8 +649,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
int a, index;
char *selar;
- int sx = BLI_RCT_SIZE_X(rect) + 1;
- int sy = BLI_RCT_SIZE_Y(rect) + 1;
+ int sx = BLI_rcti_size_x(rect) + 1;
+ int sy = BLI_rcti_size_y(rect) + 1;
me = vc->obact->data;
@@ -1065,7 +1060,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
else {
int temp, dist = 15;
- project_short(vc->ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(vc->ar, base->object->obmat[3], &base->sx);
temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
if (temp < dist)
@@ -1346,7 +1341,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese
base = startbase;
while (base) {
if (BASE_SELECTABLE(v3d, base)) {
- project_short(ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, base->object->obmat[3], &base->sx);
temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]);
if (base == BASACT) temp += 10;
@@ -2383,11 +2378,11 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f
/* project head location to screenspace */
mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
/* project tail location to screenspace */
mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
/* check if the head and/or tail is in the circle
* - the call to check also does the selection already
@@ -2451,11 +2446,11 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2
/* project head location to screenspace */
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
- project_short(vc->ar, vec, sco1);
+ ED_view3d_project_short(vc->ar, vec, sco1);
/* project tail location to screenspace */
mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
- project_short(vc->ar, vec, sco2);
+ ED_view3d_project_short(vc->ar, vec, sco2);
/* check if the head and/or tail is in the circle
* - the call to check also does the selection already
@@ -2561,7 +2556,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
select = select ? BA_SELECT : BA_DESELECT;
for (base = FIRSTBASE; base; base = base->next) {
if (BASE_SELECTABLE(v3d, base)) {
- project_short(ar, base->object->obmat[3], &base->sx);
+ ED_view3d_project_short(ar, base->object->obmat[3], &base->sx);
if (base->sx != IS_CLIPPED) {
int dx = base->sx - x;
int dy = base->sy - y;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index c25bb80bfde..ff518e6ce5b 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -520,7 +520,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
/* ********************************** */
-void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
+void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
{
float modelview[4][4];
double xs, ys, p[3];
@@ -569,7 +569,18 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co
}
}
-/* create intersection coordinates in view Z direction at mouse coordinates */
+/**
+ * Calculate a 3d segment from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_end is a far point.
+ * ray_start and ray_end are clipped by the view near and far limits
+ * so points along this line are always in view.
+ * In orthographic view all resulting segments will be parallel.
+ * \param ar The region (used for the window width and height).
+ * \param v3d The 3d viewport (used for near and far clipping range).
+ * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * \param ray_start The world-space starting point of the segment.
+ * \param ray_end The world-space end point of the segment.
+ */
void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
{
RegionView3D *rv3d = ar->regiondata;
@@ -604,7 +615,17 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2]
}
}
-/* create intersection ray in view Z direction at mouse coordinates */
+/**
+ * Calculate a 3d viewpoint and direction vector from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_normal is the direction towards mval.
+ * ray_start is clipped by the view near limit so points in front of it are always in view.
+ * In orthographic view the resulting ray_normal will match the view vector.
+ * \param ar The region (used for the window width and height).
+ * \param v3d The 3d viewport (used for near clipping value).
+ * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * \param ray_start The world-space starting point of the segment.
+ * \param ray_normal The normalized world-space direction of towards mval.
+ */
void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
{
float ray_end[3];
@@ -614,6 +635,13 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r
normalize_v3(ray_normal);
}
+/**
+ * Calculate a normalized 3d direction vector from the viewpoint towards a global location.
+ * In orthographic view the resulting vector will match the view vector.
+ * \param rv3d The region (used for the window width and height).
+ * \param coord The world-space location.
+ * \param vec The resulting normalized vector.
+ */
void ED_view3d_global_to_vector(RegionView3D *rv3d, const float coord[3], float vec[3])
{
if (rv3d->is_persp) {
@@ -660,6 +688,13 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z)
return flip;
}
+/**
+ * Calculate a 3d location from 2d window coordinates.
+ * \param ar The region (used for the window width and height).
+ * \param depth_pt The reference location used to calculate the Z depth.
+ * \param mval The area relative location (such as event->mval converted to floats).
+ * \param out The resulting world-space location.
+ */
void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[2], float out[3])
{
RegionView3D *rv3d = ar->regiondata;
@@ -690,8 +725,14 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[
}
}
-/* always call initgrabz */
-/* only to detect delta motion */
+/**
+ * Calculate a 3d difference vector from 2d window offset.
+ * note that initgrabz() must be called first to determine
+ * the depth used to calculate the delta.
+ * \param ar The region (used for the window width and height).
+ * \param mval The area relative 2d difference (such as event->mval[0] - other_x).
+ * \param out The resulting world-space delta.
+ */
void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
{
RegionView3D *rv3d = ar->regiondata;
@@ -705,9 +746,19 @@ void ED_view3d_win_to_delta(ARegion *ar, const float mval[2], float out[3])
out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy);
}
-/* doesn't rely on initgrabz */
-/* for perspective view, get the vector direction to
- * the mouse cursor as a normalized vector */
+/**
+ * Calculate a 3d direction vector from 2d window coordinates.
+ * This direction vector starts and the view in the direction of the 2d window coordinates.
+ * In orthographic view all window coordinates yield the same vector.
+ *
+ * \note doesn't rely on initgrabz
+ * for perspective view, get the vector direction to
+ * the mouse cursor as a normalized vector.
+ *
+ * \param ar The region (used for the window width and height).
+ * \param mval The area relative 2d location (such as event->mval converted to floats).
+ * \param out The resulting normalized world-space direction vector.
+ */
void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3])
{
RegionView3D *rv3d = ar->regiondata;
@@ -754,7 +805,7 @@ void ED_view3d_ob_project_mat_get(RegionView3D *rv3d, Object *ob, float pmat[4][
/* Uses window coordinates (x,y) and depth component z to find a point in
* modelspace */
-void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, const float z)
+void ED_view3d_unproject(bglMats *mats, float out[3], const float x, const float y, const float z)
{
double ux, uy, uz;
@@ -766,44 +817,44 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y,
out[2] = uz;
}
-/* use view3d_get_object_project_mat to get projecting mat */
-void ED_view3d_project_float_v2(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4])
+/* use #ED_view3d_ob_project_mat_get to get projecting mat */
+void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4])
{
float vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- /* adr[0]= IS_CLIPPED; */ /* always overwritten */
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
mul_m4_v4(mat, vec4);
if (vec4[3] > FLT_EPSILON) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
}
else {
- adr[0] = adr[1] = 0.0f;
+ zero_v2(r_co);
}
}
-/* use view3d_get_object_project_mat to get projecting mat */
-void ED_view3d_project_float_v3(ARegion *ar, const float vec[3], float adr[3], float mat[4][4])
+/* use #ED_view3d_ob_project_mat_get to get projecting mat */
+void ED_view3d_project_float_v3_m4(ARegion *ar, const float vec[3], float r_co[3], float mat[4][4])
{
float vec4[4];
copy_v3_v3(vec4, vec);
vec4[3] = 1.0;
- /* adr[0]= IS_CLIPPED; */ /* always overwritten */
+ /* r_co[0] = IS_CLIPPED; */ /* always overwritten */
mul_m4_v4(mat, vec4);
if (vec4[3] > FLT_EPSILON) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
- adr[2] = vec4[2] / vec4[3];
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ r_co[2] = vec4[2] / vec4[3];
}
else {
- zero_v3(adr);
+ zero_v3(r_co);
}
}
@@ -842,24 +893,24 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
return 0;
}
-void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
+void ED_view3d_project_short(ARegion *ar, const float co[3], short r_co[2]) /* clips */
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
if (rv3d->rflag & RV3D_CLIPPING) {
- if (ED_view3d_clipping_test(rv3d, vec, FALSE)) {
+ if (ED_view3d_clipping_test(rv3d, co, FALSE)) {
return;
}
}
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > 0 && fx < ar->winx) {
@@ -867,44 +918,44 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > 0.0f && fy < (float)ar->winy) {
- adr[0] = (short)floor(fx);
- adr[1] = (short)floor(fy);
+ r_co[0] = (short)floor(fx);
+ r_co[1] = (short)floor(fy);
}
}
}
}
-void project_int(ARegion *ar, const float vec[3], int adr[2])
+void ED_view3d_project_int(ARegion *ar, const float co[3], int r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = (int)2140000000.0f;
+ r_co[0] = (int)2140000000.0f;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > -2140000000.0f && fx < 2140000000.0f) {
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > -2140000000.0f && fy < 2140000000.0f) {
- adr[0] = (int)floor(fx);
- adr[1] = (int)floor(fy);
+ r_co[0] = (int)floor(fx);
+ r_co[1] = (int)floor(fy);
}
}
}
}
-void project_int_noclip(ARegion *ar, const float vec[3], int adr[2])
+void ED_view3d_project_int_noclip(ARegion *ar, const float co[3], int r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
@@ -913,27 +964,27 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2])
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
- adr[0] = (int)floor(fx);
- adr[1] = (int)floor(fy);
+ r_co[0] = (int)floor(fx);
+ r_co[1] = (int)floor(fy);
}
else {
- adr[0] = ar->winx / 2;
- adr[1] = ar->winy / 2;
+ r_co[0] = ar->winx / 2;
+ r_co[1] = ar->winy / 2;
}
}
-void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
+void ED_view3d_project_short_noclip(ARegion *ar, const float co[3], short r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float fx, fy, vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
mul_m4_v4(rv3d->persmat, vec4);
- if (vec4[3] > (float)BL_NEAR_CLIP) { /* 0.001 is the NEAR clipping cutoff for picking */
+ if (vec4[3] > (float)BL_NEAR_CLIP) {
fx = (ar->winx / 2) * (1 + vec4[0] / vec4[3]);
if (fx > -32700 && fx < 32700) {
@@ -941,53 +992,48 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
fy = (ar->winy / 2) * (1 + vec4[1] / vec4[3]);
if (fy > -32700.0f && fy < 32700.0f) {
- adr[0] = (short)floor(fx);
- adr[1] = (short)floor(fy);
+ r_co[0] = (short)floor(fx);
+ r_co[1] = (short)floor(fy);
}
}
}
}
-void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[3], float adr[2])
+void ED_view3d_project_float(ARegion *ar, const float co[3], float r_co[2])
{
+ RegionView3D *rv3d = ar->regiondata;
+
float vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
- adr[0] = IS_CLIPPED;
+ r_co[0] = IS_CLIPPED;
- mul_m4_v4(persmat, vec4);
+ mul_m4_v4(rv3d->persmat, vec4);
if (vec4[3] > (float)BL_NEAR_CLIP) {
- adr[0] = (float)(winx / 2.0f) + (winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(winy / 2.0f) + (winy / 2.0f) * vec4[1] / vec4[3];
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
}
}
-void project_float(ARegion *ar, const float vec[3], float adr[2])
-{
- RegionView3D *rv3d = ar->regiondata;
-
- apply_project_float(rv3d->persmat, ar->winx, ar->winy, vec, adr);
-}
-
-void project_float_noclip(ARegion *ar, const float vec[3], float adr[2])
+void ED_view3d_project_float_noclip(ARegion *ar, const float co[3], float r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
float vec4[4];
- copy_v3_v3(vec4, vec);
+ copy_v3_v3(vec4, co);
vec4[3] = 1.0;
mul_m4_v4(rv3d->persmat, vec4);
if (fabs(vec4[3]) > BL_NEAR_CLIP) {
- adr[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
- adr[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
+ r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3];
+ r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3];
}
else {
- adr[0] = ar->winx / 2.0f;
- adr[1] = ar->winy / 2.0f;
+ r_co[0] = ar->winx / 2.0f;
+ r_co[1] = ar->winy / 2.0f;
}
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index dccd0c27234..ee5d50c7aba 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -126,11 +126,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx;
- r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy;
+ r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
+ r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
r_vec[2] = 0.0f;
}
@@ -139,11 +139,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
float divx, divy;
float mulx, muly;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- mulx = BLI_RCT_SIZE_X(&v2d->cur);
- muly = BLI_RCT_SIZE_Y(&v2d->cur);
+ mulx = BLI_rctf_size_x(&v2d->cur);
+ muly = BLI_rctf_size_y(&v2d->cur);
/* difference with convertViewVec2D */
/* clamp w/h, mask only */
@@ -226,7 +226,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype == SPACE_VIEW3D) {
if (t->ar->regiontype == RGN_TYPE_WINDOW)
- project_int_noclip(t->ar, vec, adr);
+ ED_view3d_project_int_noclip(t->ar, vec, adr);
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
@@ -344,7 +344,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
case SPACE_VIEW3D:
{
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- project_float_noclip(t->ar, vec, adr);
+ ED_view3d_project_float_noclip(t->ar, vec, adr);
return;
}
break;
@@ -2195,7 +2195,6 @@ static void constraintTransLim(TransInfo *t, TransData *td)
for (con = td->con; con; con = con->next) {
bConstraintTypeInfo *cti = NULL;
ListBase targets = {NULL, NULL};
- float tmat[4][4];
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
@@ -2221,8 +2220,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
/* skip... incompatable spacetype */
@@ -2237,9 +2235,8 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
/* free targets list */
@@ -2287,18 +2284,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
bConstraintOb cob;
bConstraint *con;
int do_limit = FALSE;
-
+
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data = con->data;
- float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
@@ -2312,12 +2308,11 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
constraintob_from_transdata(&cob, td);
do_limit = TRUE;
}
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
/* do constraint */
@@ -2325,9 +2320,8 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
@@ -2382,7 +2376,6 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data = con->data;
- float tmat[4][4];
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
@@ -2391,11 +2384,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
- /* skip... incompatable spacetype */
+ /* skip... incompatible spacetype */
continue;
}
@@ -2404,13 +2396,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
-
+
/* copy results from cob->matrix */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
@@ -2420,7 +2411,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
mat4_to_size(td->ext->size, cob.matrix);
}
}
@@ -2852,11 +2843,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) {
float obsizemat[3][3];
- // Reorient the size mat to fit the oriented object.
+ /* Reorient the size mat to fit the oriented object. */
mul_m3_m3m3(obsizemat, tmat, td->axismtx);
- //print_m3("obsizemat", obsizemat);
+ /* print_m3("obsizemat", obsizemat); */
TransMat3ToSize(obsizemat, td->axismtx, fsize);
- //print_v3("fsize", fsize);
+ /* print_v3("fsize", fsize); */
}
else {
mat3_to_size(fsize, tmat);
@@ -2864,7 +2855,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
protectedSizeBits(td->protectflag, fsize);
- if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't resize objects itself */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
*td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
@@ -4100,9 +4091,9 @@ void initMaskShrinkFatten(TransInfo *t)
int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
+ TransData *td;
float ratio;
- int i;
+ int i, initial_feather = FALSE;
char str[50];
ratio = t->values[0];
@@ -4116,13 +4107,30 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
- sprintf(str, "Shrink/Fatten: %s", c);
+ sprintf(str, "Feather Shrink/Fatten: %s", c);
}
else {
- sprintf(str, "Shrink/Fatten: %3f", ratio);
+ sprintf(str, "Feather Shrink/Fatten: %3f", ratio);
}
- for (i = 0; i < t->total; i++, td++) {
+ /* detect if no points have feather yet */
+ if (ratio > 1.0f) {
+ initial_feather = TRUE;
+
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (td->ival >= 0.001f)
+ initial_feather = FALSE;
+ }
+ }
+
+ /* apply shrink/fatten */
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4130,7 +4138,11 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
continue;
if (td->val) {
- *td->val = td->ival * ratio;
+ if (initial_feather)
+ *td->val = td->ival + (ratio - 1.0f) * 0.01f;
+ else
+ *td->val = td->ival * ratio;
+
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
if (*td->val <= 0.0f) *td->val = 0.001f;
@@ -4774,7 +4786,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
sv->edge_len = len_v3v3(dw_p, up_p);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
- project_float_noclip(t->ar, v_proj, v_proj);
+ ED_view3d_project_float_noclip(t->ar, v_proj, v_proj);
dist = len_squared_v2v2(mval, v_proj);
if (dist < min_dist) {
@@ -5040,19 +5052,19 @@ static int createSlideVerts(TransInfo *t)
j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v));
if (sv_array[j].down) {
- ED_view3d_project_float_v3(ar, sv_array[j].down->co, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].down->co, vec1, projectMat);
}
else {
add_v3_v3v3(vec1, v->co, sv_array[j].downvec);
- ED_view3d_project_float_v3(ar, vec1, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec1, vec1, projectMat);
}
if (sv_array[j].up) {
- ED_view3d_project_float_v3(ar, sv_array[j].up->co, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].up->co, vec2, projectMat);
}
else {
add_v3_v3v3(vec2, v->co, sv_array[j].upvec);
- ED_view3d_project_float_v3(ar, vec2, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec2, vec2, projectMat);
}
/* global direction */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 181f9fe6036..022e9177a4a 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1773,9 +1773,6 @@ void flushTransParticles(TransInfo *t)
/* ********************* mesh ****************** */
-/* proportional distance based on connectivity */
-#define THRESHOLDFACTOR (1.0f - 0.0001f)
-
/* I did this wrong, it should be a breadth-first search
* but instead it's a depth-first search, fudged
* to report shortest distances. I have no idea how fast
@@ -5170,7 +5167,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- if (ob->pose || ob_get_key(ob))
+ if (ob->pose || BKE_key_from_object(ob))
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
else
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -5554,8 +5551,8 @@ static void createTransObject(bContext *C, TransInfo *t)
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
{
/* hold original location */
- float locxy[2] = {BLI_RCT_CENTER_X(&node->totr),
- BLI_RCT_CENTER_Y(&node->totr)};
+ float locxy[2] = {BLI_rctf_cent_x(&node->totr),
+ BLI_rctf_cent_y(&node->totr)};
copy_v2_v2(td2d->loc, locxy);
td2d->loc[2] = 0.0f;
@@ -5722,10 +5719,9 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
unit_m3(td->smtx);
}
-static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
+static void trackToTransData(const int framenr, TransData *td, TransData2D *td2d,
TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy)
{
- int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
tdt->flag = marker->flag;
@@ -5777,7 +5773,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
- MovieTrackingMarker *marker;
TransDataTracking *tdt;
int framenr = ED_space_clip_get_clip_frame_number(sc);
float aspx, aspy;
@@ -5788,8 +5783,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
t->total++; /* offset */
if (track->flag & SELECT)
@@ -5820,9 +5813,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
- trackToTransData(sc, td, td2d, tdt, track, aspx, aspy);
+ trackToTransData(framenr, td, td2d, tdt, track, aspx, aspy);
/* offset */
td++;
@@ -5845,12 +5836,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
td += 2;
td2d += 2;
tdt += 2;
-
- if (marker->flag & MARKER_DISABLED) {
- td += 3;
- td2d += 3;
- tdt += 3;
- };
}
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index b88ae68e00b..1d75be05534 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -315,7 +315,7 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- project_float(t->ar, iloc, mval);
+ ED_view3d_project_float(t->ar, iloc, mval);
if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
@@ -601,7 +601,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int dx, dy;
int dist;
- project_int(t->ar, p->co, screen_loc);
+ ED_view3d_project_int(t->ar, p->co, screen_loc);
dx = t->mval[0] - screen_loc[0];
dy = t->mval[1] - screen_loc[1];
@@ -960,8 +960,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
if (t->spacetype == SPACE_NODE && td != NULL) {
bNode *node = td->extra;
char border = t->tsnap.snapNodeBorder;
- float width = BLI_RCT_SIZE_X(&node->totr);
- float height = BLI_RCT_SIZE_Y(&node->totr);
+ float width = BLI_rctf_size_x(&node->totr);
+ float height = BLI_rctf_size_y(&node->totr);
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.5f * width;
@@ -1164,7 +1164,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
if (new_dist <= *dist && new_depth < *depth) {
@@ -1232,7 +1232,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
/* 10% threshold if edge is closer but a bit further
@@ -1289,7 +1289,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
if (new_dist <= *r_dist && new_depth < *r_depth) {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 5008c35e46a..06da1c8bfea 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2836,7 +2836,7 @@ static int uv_lasso_select_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
}
-void UV_OT_select_lasso(wmOperatorType *ot)
+static void UV_OT_select_lasso(wmOperatorType *ot)
{
ot->name = "Lasso Select UV";
ot->description = "Select UVs using lasso selection";
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index c95b2e85248..7c06fbd2a9d 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -242,7 +242,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
key = (ParamKey)efa;
- tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
+ // tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); // UNUSED
if (efa->len == 3 || efa->len == 4) {
/* for quads let parametrize split, it can make better decisions