diff options
Diffstat (limited to 'source/blender/editors')
130 files changed, 3121 insertions, 1943 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 837230d9719..16168888573 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3067,9 +3067,9 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float break; } } - + /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; @@ -3461,7 +3461,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) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { + if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 3cc39238713..3255bc47148 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -125,7 +125,7 @@ void ANIM_id_update(Scene *UNUSED(scene), ID *id) */ /* perform syncing updates for Action Groups */ -static void animchan_sync_group(bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGroup **active_agrp) { bActionGroup *agrp = (bActionGroup *)ale->data; ID *owner_id = ale->id; @@ -143,22 +143,50 @@ static void animchan_sync_group(bAnimContext *UNUSED(ac), bAnimListElem *ale) /* 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; - /* if one matches, sync the selection status */ if (pchan) { - if (pchan->bone && pchan->bone->flag & BONE_SELECTED) + bActionGroup *bgrp; + + /* if one matches, sync the selection status */ + if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) agrp->flag |= AGRP_SELECTED; else agrp->flag &= ~AGRP_SELECTED; + + /* also sync active group status */ + if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { + /* if no previous F-Curve has active flag, then we're the first and only one to get it */ + if (*active_agrp == NULL) { + agrp->flag |= AGRP_ACTIVE; + *active_agrp = agrp; + } + else { + /* someone else has already taken it - set as not active */ + agrp->flag &= ~AGRP_ACTIVE; + } + } + else { + /* this can't possibly be active now */ + agrp->flag &= ~AGRP_ACTIVE; + } + + /* sync group colors */ + bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1)); + if (bgrp) { + agrp->customCol = bgrp->customCol; + action_group_colors_sync(agrp, bgrp); + } } } } } /* perform syncing updates for F-Curves */ -static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **active_fcurve) { FCurve *fcu = (FCurve *)ale->data; ID *owner_id = ale->id; @@ -168,12 +196,13 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) */ if (ELEM3(NULL, fcu, fcu->rna_path, owner_id)) return; - + if (GS(owner_id->name) == ID_OB) { Object *ob = (Object *)owner_id; /* only affect if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { + bArmature *arm = (bArmature *)ob->data; bPoseChannel *pchan; char *bone_name; @@ -184,10 +213,30 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) /* F-Curve selection depends on whether the bone is selected */ if ((pchan) && (pchan->bone)) { + /* F-Curve selection */ if (pchan->bone->flag & BONE_SELECTED) fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; + + /* Active F-Curve - it should be the first one for this bone on the + * active object to be considered as active + */ + if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { + /* if no previous F-Curve has active flag, then we're the first and only one to get it */ + if (*active_fcurve == NULL) { + fcu->flag |= FCURVE_ACTIVE; + *active_fcurve = fcu; + } + else { + /* someone else has already taken it - set as not active */ + fcu->flag &= ~FCURVE_ACTIVE; + } + } + else { + /* this can't possibly be active now */ + fcu->flag &= ~FCURVE_ACTIVE; + } } } } @@ -202,10 +251,10 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) /* get strip name, and check if this strip is selected */ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); - seq = BKE_sequwnce_get_by_name(ed->seqbasep, seq_name, FALSE); + seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); - /* can only add this F-Curve if it is selected */ + /* update selection status */ if (seq) { if (seq->flag & SELECT) fcu->flag |= FCURVE_SELECTED; @@ -227,12 +276,31 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); - /* can only add this F-Curve if it is selected */ + /* update selection/active status */ if (node) { + /* update selection status */ if (node->flag & NODE_SELECT) fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; + + /* update active status */ + /* XXX: this may interfere with setting bones as active if both exist at once; + * then again, if that's the case, production setups aren't likely to be animating + * nodes while working with bones? + */ + if (node->flag & NODE_ACTIVE) { + if (*active_fcurve == NULL) { + fcu->flag |= FCURVE_ACTIVE; + *active_fcurve = fcu; + } + else { + fcu->flag &= ~FCURVE_ACTIVE; + } + } + else { + fcu->flag &= ~FCURVE_ACTIVE; + } } } } @@ -248,25 +316,30 @@ void ANIM_sync_animchannels_to_data(const bContext *C) bAnimListElem *ale; int filter; + bActionGroup *active_agrp = NULL; + 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; /* filter data */ - /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed */ - filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; + /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed + * However, don't include duplicates so that selection statuses don't override each other + */ + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* flush settings as appropriate depending on the types of the channels */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_GROUP: - animchan_sync_group(&ac, ale); + animchan_sync_group(&ac, ale, &active_agrp); break; case ANIMTYPE_FCURVE: - animchan_sync_fcurve(&ac, ale); + animchan_sync_fcurve(&ac, ale, &active_fcurve); break; } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index b1497712aed..a0acdd710e0 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -917,7 +917,7 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i /* get strip name, and check if this strip is selected */ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); - seq = BKE_sequwnce_get_by_name(ed->seqbasep, seq_name, FALSE); + seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); /* can only add this F-Curve if it is selected */ diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index a8daf852dda..95adaa01b94 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 = v2d->mask.ymax - v2d->mask.ymin; + ypixels = BLI_RCT_SIZE_Y(&v2d->mask); UI_view2d_getscale(v2d, &xscale, &yscale); glScalef(1.0f / xscale, 1.0f, 1.0f); @@ -773,8 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) if (hasNumInput(&mm->num)) break; - dx = v2d->mask.xmax - v2d->mask.xmin; - dx = (v2d->cur.xmax - v2d->cur.xmin) / dx; + dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_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 91cc602c838..e254fb7a3c4 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -229,7 +229,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) { uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); - /* set up new row for the next pair of coefficients*/ + /* set up new row for the next pair of coefficients */ row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } @@ -336,7 +336,7 @@ static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float f /* initialize exists-flag first */ *exists = 0; - /* sneaky optimisations (don't go through searching process if...): + /* sneaky optimizations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds * - keyframe to be added would replace one of the existing ones on bounds */ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 78ac729f16e..b277d0eccb5 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -505,7 +505,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { short ok = 0; - #define KEY_CHECK_OK(_index) BLI_in_rctf_v(ked->data, bezt->vec[_index]) + #define KEY_CHECK_OK(_index) BLI_rctf_isect_pt_v(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index dd2400ca302..738fdc229fb 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1585,7 +1585,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* properties s*/ + /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index bc154de9691..e2d15897233 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1938,7 +1938,7 @@ static void adduplicateflagNurb(Object *obedit, short flag) } else { - if (newu == 1) SWAP(short, newu, newv); + if (newu == 1) SWAP(int, newu, newv); newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); memcpy(newnu, nu, sizeof(Nurb)); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 949f92c68e9..5d67b63af18 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) * (subrect->xmax - subrect->xmin)) + subrect->xmin; - mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; + 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; } 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 fd98dd83a7d..e4bfbea75b0 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -300,8 +300,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) / ((p->subrect->xmax - p->subrect->xmin))) * 100; - out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; + 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; } } } @@ -819,13 +819,13 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor y0 = (int)(gps->points->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + 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; } } /* do boundbox check first */ - if (BLI_in_rcti(rect, x0, y0)) { + if (BLI_rcti_isect_pt(rect, x0, y0)) { /* only check if point is inside */ if ( ((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ @@ -866,15 +866,15 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor y1 = (int)(pt2->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; - x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + 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; } } /* check that point segment of the boundbox of the eraser stroke */ - if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(rect, x1, y1)) { + if (BLI_rcti_isect_pt(rect, x0, y0) || BLI_rcti_isect_pt(rect, x1, y1)) { /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant @@ -1480,7 +1480,7 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) float mousef[2]; int tablet = 0; - /* convert from window-space to area-space mouse coordintes + /* convert from window-space to area-space mouse coordinates * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... */ p->mval[0] = event->mval[0] + 1; @@ -1667,14 +1667,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) static int gpencil_area_exists(bContext *C, ScrArea *sa_test) { bScreen *sc = CTX_wm_screen(C); - ScrArea *sa; - - for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa == sa_test) - return 1; - } - - return 0; + return (BLI_findindex(&sc->areabase, sa_test) != -1); } static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 3a1d63574a6..13c3b180230 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -62,6 +62,8 @@ int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); +int ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]); + void ED_clip_update_frame(const struct Main *mainp, int cfra); int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index d291c500547..6f41bef81f4 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -46,6 +46,7 @@ void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, s struct Mask *ED_space_image_get_mask(struct SpaceImage *sima); void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask); +int ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *ar, int mval[2], float r_col[3]); struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r); void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock); int ED_space_image_has_buffer(struct SpaceImage *sima); diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index b6a1fd0f979..32baa8883e1 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -76,8 +76,11 @@ void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNod void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, struct Scene *scene_owner); -/* node ops.c */ +/* node_ops.c */ void ED_operatormacros_node(void); +/* node_view.c */ +int ED_space_node_color_sample(struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]); + #endif /* __ED_NODE_H__ */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0b0ad83ab21..f055c89235d 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -456,19 +456,19 @@ uiBut *uiDefBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, @@ -477,18 +477,18 @@ uiBut *uiDefIconBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip); uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, @@ -497,18 +497,18 @@ uiBut *uiDefIconTextBut(uiBlock *block, void *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip); /* for passing inputs to ButO buttons */ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); @@ -573,25 +573,25 @@ typedef void (*uiIDPoinFuncFP)(struct bContext *C, const char *str, struct ID ** typedef void (*uiIDPoinFunc)(struct bContext *C, struct ID *id, int event); uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, - int x1, int y1, short x2, short y2, void *idpp, const char *tip); + int x, int y, short width, short height, void *idpp, const char *tip); int uiIconFromID(struct ID *id); -uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip); -uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, const char *str, int x, int y, short width, short height, const char *tip); +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip); -uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip); +uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip); -uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip); +uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip); +uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip); -uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip); +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip); uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 9ab024a8b76..3a8f05a76f0 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -120,8 +120,8 @@ enum { /* Macros: */ /* test if mouse in a scrollbar (assume that scroller availability has been tested) */ -#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->vert, co)) -#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti_v(&v2d->hor, co)) +#define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co)) +#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->hor, co)) /* ------------------------------------------ */ /* Type definitions: */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7b1150669e8..afbabaaa8d7 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -99,8 +99,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 = ar->winrct.xmax - ar->winrct.xmin + 1; - getsizey = ar->winrct.ymax - ar->winrct.ymin + 1; + getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; + getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -137,10 +137,7 @@ void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti ui_block_to_window_fl(ar, block, &tmpr.xmin, &tmpr.ymin); ui_block_to_window_fl(ar, block, &tmpr.xmax, &tmpr.ymax); - winr->xmin = tmpr.xmin; - winr->ymin = tmpr.ymin; - winr->xmax = tmpr.xmax; - winr->ymax = tmpr.ymax; + BLI_rcti_rctf_copy(winr, &tmpr); } void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y) /* for mouse cursor */ @@ -148,8 +145,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 = ar->winrct.xmax - ar->winrct.xmin + 1; - getsizey = ar->winrct.ymax - ar->winrct.ymin + 1; + getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1; + getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1; sx = ar->winrct.xmin; sy = ar->winrct.ymin; @@ -196,19 +193,13 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y) void ui_block_translate(uiBlock *block, int x, int y) { - uiBut *bt; + uiBut *but; - for (bt = block->buttons.first; bt; bt = bt->next) { - bt->x1 += x; - bt->y1 += y; - bt->x2 += x; - bt->y2 += y; + for (but = block->buttons.first; but; but = but->next) { + BLI_rctf_translate(&but->rect, x, y); } - block->minx += x; - block->miny += y; - block->maxx += x; - block->maxy += y; + BLI_rctf_translate(&block->rect, x, y); } static void ui_text_bounds_block(uiBlock *block, float offset) @@ -227,26 +218,27 @@ static void ui_text_bounds_block(uiBlock *block, float offset) if (j > i) i = j; } - if (bt->next && bt->x1 < bt->next->x1) + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) lastcol++; } /* cope with multi collumns */ bt = block->buttons.first; while (bt) { - if (bt->next && bt->x1 < bt->next->x1) { + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) { nextcol = 1; col++; } else nextcol = 0; - bt->x1 = x1addval; - bt->x2 = bt->x1 + i + block->bounds; + bt->rect.xmin = x1addval; + bt->rect.xmax = bt->rect.xmin + i + block->bounds; - if (col == lastcol) - bt->x2 = MAX2(bt->x2, offset + block->minbounds); + if (col == lastcol) { + bt->rect.xmax = maxf(bt->rect.xmax, offset + block->minbounds); + } - ui_check_but(bt); // clips text again + ui_check_but(bt); /* clips text again */ if (nextcol) x1addval += i + block->bounds; @@ -262,43 +254,35 @@ void ui_bounds_block(uiBlock *block) if (block->buttons.first == NULL) { if (block->panel) { - block->minx = 0.0; block->maxx = block->panel->sizex; - block->miny = 0.0; block->maxy = block->panel->sizey; + block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex; + block->rect.ymin = 0.0; block->rect.ymax = block->panel->sizey; } } else { - block->minx = block->miny = 10000; - block->maxx = block->maxy = -10000; - - bt = block->buttons.first; - while (bt) { - if (bt->x1 < block->minx) block->minx = bt->x1; - if (bt->y1 < block->miny) block->miny = bt->y1; - - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; + BLI_rctf_init_minmax(&block->rect); - bt = bt->next; + for (bt = block->buttons.first; bt; bt = bt->next) { + BLI_rctf_union(&block->rect, &bt->rect); } - block->minx -= block->bounds; - block->miny -= block->bounds; - block->maxx += block->bounds; - block->maxy += block->bounds; + block->rect.xmin -= block->bounds; + block->rect.ymin -= block->bounds; + block->rect.xmax += block->bounds; + block->rect.ymax += block->bounds; } - block->maxx = block->minx + MAX2(block->maxx - block->minx, block->minbounds); + block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; if (bt && strncmp(bt->str, "ERROR", 5) == 0) xof = 10; else xof = 40; - block->safety.xmin = block->minx - xof; - block->safety.ymin = block->miny - xof; - block->safety.xmax = block->maxx + xof; - block->safety.ymax = block->maxy + xof; + block->safety.xmin = block->rect.xmin - xof; + block->safety.ymin = block->rect.ymin - xof; + block->safety.xmax = block->rect.xmax + xof; + block->safety.ymax = block->rect.ymax + xof; } static void ui_centered_bounds_block(const bContext *C, uiBlock *block) @@ -316,13 +300,13 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block) ui_bounds_block(block); - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = BLI_RCT_SIZE_X(&block->rect); + height = BLI_RCT_SIZE_Y(&block->rect); startx = (xmax * 0.5f) - (width * 0.5f); starty = (ymax * 0.5f) - (height * 0.5f); - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -341,14 +325,14 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ wm_window_get_size(window, &xmax, &ymax); - oldwidth = block->maxx - block->minx; - oldheight = block->maxy - block->miny; + oldwidth = BLI_RCT_SIZE_X(&block->rect); + oldheight = BLI_RCT_SIZE_Y(&block->rect); /* first we ensure wide enough text bounds */ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) { if (block->flag & UI_BLOCK_LOOP) { block->bounds = 50; - ui_text_bounds_block(block, block->minx); + ui_text_bounds_block(block, block->rect.xmin); } } @@ -357,8 +341,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ ui_bounds_block(block); /* and we adjust the position to fit within window */ - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = BLI_RCT_SIZE_X(&block->rect); + height = BLI_RCT_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); @@ -366,8 +350,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ /* offset block based on mouse position, user offset is scaled * along in case we resized the block in ui_text_bounds_block */ - startx = window->eventstate->x + block->minx + (block->mx * width) / oldwidth; - starty = window->eventstate->y + block->miny + (block->my * height) / oldheight; + startx = window->eventstate->x + block->rect.xmin + (block->mx * width) / oldwidth; + starty = window->eventstate->y + block->rect.ymin + (block->my * height) / oldheight; if (startx < 10) startx = 10; @@ -386,7 +370,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ starty = endy - height; } - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -436,10 +420,10 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval) void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy) { - block->minx = minx; - block->miny = miny; - block->maxx = maxx; - block->maxy = maxy; + block->rect.xmin = minx; + block->rect.ymin = miny; + block->rect.xmax = maxx; + block->rect.ymax = maxy; block->dobounds = 0; } @@ -504,10 +488,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) if (line->from == NULL || line->to == NULL) return; - rect.xmin = (line->from->x1 + line->from->x2) / 2.0f; - rect.ymin = (line->from->y1 + line->from->y2) / 2.0f; - rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; - rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; + 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); if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); @@ -526,18 +510,18 @@ static void ui_draw_links(uiBlock *block) /* Draw the inactive lines (lines with neither button being hovered over). * As we go, remember if we see any active or selected lines. */ - int foundselectline = 0; - int foundactiveline = 0; + int foundselectline = FALSE; + int foundactiveline = FALSE; for (but = block->buttons.first; but; but = but->next) { if (but->type == LINK && but->link) { for (line = but->link->lines.first; line; line = line->next) { if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, 0); else - foundactiveline = 1; + foundactiveline = TRUE; if ((line->from->flag & UI_SELECT) || (line->to->flag & UI_SELECT)) - foundselectline = 1; + foundselectline = TRUE; } } } @@ -653,8 +637,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *butpp = oldbut; /* still stuff needs to be copied */ - oldbut->x1 = but->x1; oldbut->y1 = but->y1; - oldbut->x2 = but->x2; oldbut->y2 = but->y2; + oldbut->rect = but->rect; oldbut->context = but->context; /* set by Layout */ /* typically the same pointers, but not on undo/redo */ @@ -697,28 +680,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but) { uiBlock *oldblock; uiBut *oldbut; - int activate = 0, found = 0, isactive = 0; + int activate = FALSE, found = FALSE, isactive = FALSE; oldblock = block->oldblock; if (!oldblock) - activate = 1; + activate = TRUE; else { for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) { if (ui_but_equals_old(oldbut, but)) { - found = 1; + found = TRUE; if (oldbut->active) - isactive = 1; + isactive = TRUE; break; } } } - if (activate || found == 0) { + if ((activate == TRUE) || (found == FALSE)) { ui_button_activate_do((bContext *)C, CTX_wm_region(C), but); } - else if (found && isactive == 0) { - + else if ((found == TRUE) && (isactive == FALSE)) { BLI_remlink(&block->buttons, but); ui_free_but(C, but); return 0; @@ -764,7 +746,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) int tot_missing = 0; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (pass = 0; pass < 2; pass++) { @@ -865,7 +847,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDProperty *prop_menu_name = NULL; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (but = block->buttons.first; but; but = but->next) { @@ -928,7 +910,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; } if (but->context) @@ -960,7 +942,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if (block->minx == 0.0f && block->maxx == 0.0f) uiBoundsBlock(block, 0); + if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) uiBoundsBlock(block, 0); if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock = 1; @@ -993,14 +975,14 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u getsizex = ar->winx; getsizey = ar->winy; - gx = (but ? but->x1 : block->minx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y1 : block->miny) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmin : block->rect.xmin) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymin : block->rect.ymin) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmin = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymin = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); - gx = (but ? but->x2 : block->maxx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y2 : block->maxy) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmax : block->rect.xmax) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymax : block->rect.ymax) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmax = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymax = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); @@ -1010,7 +992,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u /* uses local copy of style, to scale things down, and allow widgets to change stuff */ void uiDrawBlock(const bContext *C, uiBlock *block) { - uiStyle style = *UI_GetStyle(); // XXX pass on as arg + uiStyle style = *UI_GetStyle(); /* XXX pass on as arg */ ARegion *ar; uiBut *but; rcti rect; @@ -1084,9 +1066,12 @@ void uiDrawBlock(const bContext *C, uiBlock *block) static void ui_is_but_sel(uiBut *but, double *value) { - short is_push = 0, is_true = 1; + short is_push = 0; /* (0 == UNSELECT), (1 == SELECT), (2 == DO-NOHING) */ + short is_true = TRUE; - if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true = 0; + if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) { + is_true = FALSE; + } if (but->bit) { int lvalue; @@ -1215,14 +1200,14 @@ void uiComposeLinks(uiBlock *block) void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr) { if (val) { - block->lock = val ? 1 : 0; + block->lock = val ? TRUE : FALSE; block->lockstr = lockstr; } } void uiBlockClearButLock(uiBlock *block) { - block->lock = 0; + block->lock = FALSE; block->lockstr = NULL; } @@ -1369,7 +1354,7 @@ int ui_is_but_unit(uiBut *but) if (unit_type == PROP_UNIT_NONE) return 0; -#if 1 // removed so angle buttons get correct snapping +#if 1 /* removed so angle buttons get correct snapping */ if (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; #endif @@ -1532,10 +1517,15 @@ void ui_set_but_val(uiBut *but, double value) if (but->pointype == CHA) value = (char)floor(value + 0.5); else if (but->pointype == SHO) { - /* gcc 3.2.1 seems to have problems + /* gcc 3.2.1 seems to have problems * casting a double like 32772.0 to - * a short so we cast to an int, then - * to a short */ + * a short so we cast to an int, then + * to a short. + * + * Update: even in gcc.4.6 using intermediate int cast gives -32764, + * where as a direct cast from double to short gives -32768, + * if this difference isn't important we could remove this hack, + * since we dont support gcc3 anymore - Campbell */ int gcckludge; gcckludge = (int) floor(value + 0.5); value = (short)gcckludge; @@ -2112,7 +2102,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor block = MEM_callocN(sizeof(uiBlock), "uiBlock"); block->active = 1; block->dt = dt; - block->evil_C = (void *)C; // XXX + block->evil_C = (void *)C; /* XXX */ if (scn) { block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT); @@ -2221,7 +2211,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (but->x2 - but->x1); // UNUSED + // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED /* name: */ switch (but->type) { @@ -2229,7 +2219,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if (but->x2 - but->x1 > 24) { + if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) { UI_GET_BUT_VALUE_INIT(but, value); ui_set_name_menu(but, (int)value); } @@ -2373,8 +2363,8 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) { float dx, dy; - dx = fabs(but1->x2 - but2->x1); - dy = fabs(but1->y1 - but2->y2); + dx = fabs(but1->rect.xmax - but2->rect.xmin); + dy = fabs(but1->rect.ymin - but2->rect.ymax); if (dx > dy) return 0; return 1; @@ -2382,7 +2372,7 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) void uiBlockEndAlign(uiBlock *block) { - block->flag &= ~UI_BUT_ALIGN; // all 4 flags + block->flag &= ~UI_BUT_ALIGN; /* all 4 flags */ } int ui_but_can_align(uiBut *but) @@ -2492,32 +2482,32 @@ static void ui_block_do_align_but(uiBut *first, short nr) if (prev) { /* simple cases */ if (rows == 0) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; } else if (cols == 0) { - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; } else { if (buts_are_horiz(prev, but)) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; /* copy height too */ - but->y2 = prev->y2; + but->rect.ymax = prev->rect.ymax; } else if (prev->prev && buts_are_horiz(prev->prev, prev) == 0) { /* the previous button is a single one in its row */ - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; - but->x1 = prev->x1; + but->rect.xmin = prev->rect.xmin; if (next && buts_are_horiz(but, next) == 0) - but->x2 = prev->x2; + but->rect.xmax = prev->rect.xmax; } else { /* the previous button is not a single one in its row */ - but->y2 = prev->y1; + but->rect.ymax = prev->rect.ymin; } } } @@ -2549,13 +2539,16 @@ void ui_block_do_align(uiBlock *block) /** * \brief ui_def_but is the function that draws many button types * + * \param x,y The lower left hand corner of the button (X axis) + * \param width,height The size of the button. + * * for float buttons: * - \a a1 Click Step (how much to change the value each click) * - \a a2 Number of decimal point values to display. 0 defaults to 3 (0.000) * 1,2,3, and a maximum of 4, all greater values will be clamped to 4. */ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, - int x1, int y1, short x2, short y2, + int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; @@ -2586,10 +2579,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } memcpy(but->str, str, slen + 1); - but->x1 = x1; - but->y1 = y1; - but->x2 = (x1 + x2); - but->y2 = (y1 + y2); + but->rect.xmin = x; + but->rect.ymin = y; + but->rect.xmax = but->rect.xmin + width; + but->rect.ymax = but->rect.ymin + height; but->poin = poin; but->hardmin = but->softmin = min; @@ -2602,8 +2595,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->lockstr = block->lockstr; but->dt = block->dt; - but->aspect = 1.0f; //XXX block->aspect; - but->block = block; // pointer back, used for frontbuffer status, and picker + but->aspect = 1.0f; /* XXX block->aspect; */ + but->block = block; /* pointer back, used for frontbuffer status, and picker */ if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) but->alignnr = block->alignnr; @@ -2639,7 +2632,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->flag |= (block->flag & UI_BUT_ALIGN); - if (but->lock) { + if (but->lock == TRUE) { if (but->lockstr) { but->flag |= UI_BUT_DISABLED; } @@ -2682,7 +2675,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, - int x1, int y1, short x2, short y2, + int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { @@ -2794,7 +2787,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } /* now create button */ - but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); + but = ui_def_but(block, type, retval, str, x, y, width, height, NULL, min, max, a1, a2, tip); but->rnapoin = *ptr; but->rnaprop = prop; @@ -2830,16 +2823,16 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s return but; } -static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { PropertyRNA *prop = RNA_struct_find_property(ptr, propname); uiBut *but; if (prop) { - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); } else { - but = ui_def_but(block, type, retval, propname, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); + but = ui_def_but(block, type, retval, propname, x, y, width, height, NULL, min, max, a1, a2, tip); UI_DEF_BUT_RNA_DISABLE(but); } @@ -2847,7 +2840,7 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons return but; } -static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; @@ -2862,14 +2855,14 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * tip = RNA_struct_ui_description(ot->srna); } - but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip); + but = ui_def_but(block, type, -1, str, x, y, width, height, NULL, 0, 0, 0, 0, tip); but->optype = ot; but->opcontext = opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } @@ -2877,15 +2870,15 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * } #if 0 /* UNUSED */ -static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); if (str == NULL && ot == NULL) str = opname; - return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); } #endif -static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; wmOperatorType *ot; @@ -2901,23 +2894,23 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn tip = ot->description; } - but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + but = ui_def_but(block, type, -1, str, x, y, width, height, poin, min, max, a1, a2, tip); but->optype = ot; but->opcontext = opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ if (!ot) { but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } return but; } -uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but(but); @@ -3036,241 +3029,241 @@ static void ui_check_but_and_iconize(uiBut *but, int icon) ui_check_but(but); } -static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefBut(block, type | BIT | bitIdx, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefBut(block, type | BIT | bitIdx, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | FLO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | FLO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | FLO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | FLO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | INT, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | INT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | INT, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | INT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | SHO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | SHO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | SHO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | SHO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefBut(block, type | CHA, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefBut(block, type | CHA, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefButBit(block, type | CHA, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefButBit(block, type | CHA, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but(but); return but; } -uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but(but); return but; } -uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); ui_check_but(but); return but; } -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); if (str == NULL && ot == NULL) str = opname; - return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + return uiDefButO_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); } -uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but_operator_text(block, type, opname, opcontext, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but(but); return but; } /* if a1==1.0 then a2 is an extra icon blending factor (alpha 0.0 - 1.0) */ -uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, "", x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, "", x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | FLO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | FLO, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | FLO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | FLO, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | INT, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | INT, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | INT, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | INT, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | SHO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | SHO, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | SHO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | SHO, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconBut(block, type | CHA, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconBut(block, type | CHA, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconButBit(block, type | CHA, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconButBit(block, type | CHA, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, "", x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, "", x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, "", x, y, width, height, tip); ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip); + return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip); } /* Button containing both string label and icon */ -uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) +static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx = findBitIndex(bit); if (bitIdx == -1) { return NULL; } else { - return uiDefIconTextBut(block, type | BIT | bitIdx, retval, icon, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | BIT | bitIdx, retval, icon, str, x, y, width, height, poin, min, max, a1, a2, tip); } } -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | FLO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | FLO, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | FLO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | FLO, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | INT, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | INT, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | INT, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | INT, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | SHO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | SHO, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | SHO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | SHO, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextBut(block, type | CHA, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextBut(block, type | CHA, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip) { - return uiDefIconTextButBit(block, type | CHA, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip); + return uiDefIconTextButBit(block, type | CHA, bit, retval, icon, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) { uiBut *but; - but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); + but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); ui_check_but_and_iconize(but, icon); but->flag |= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); - return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x1, y1, x2, y2, tip); + return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip); } /* END Button containing both string label and icon */ @@ -3296,8 +3289,8 @@ int uiBlocksGetYMin(ListBase *lb) int min = 0; for (block = lb->first; block; block = block->next) - if (block == lb->first || block->miny < min) - min = block->miny; + if (block == lb->first || block->rect.ymin < min) + min = block->rect.ymin; return min; } @@ -3321,15 +3314,15 @@ void uiBlockFlipOrder(uiBlock *block) for (but = block->buttons.first; but; but = but->next) { if (but->flag & UI_BUT_ALIGN) return; - if (but->y1 < miny) miny = but->y1; - if (but->y2 > maxy) maxy = but->y2; + if (but->rect.ymin < miny) miny = but->rect.ymin; + if (but->rect.ymax > maxy) maxy = but->rect.ymax; } /* mirror trick */ centy = (miny + maxy) / 2.0f; for (but = block->buttons.first; but; but = but->next) { - but->y1 = centy - (but->y1 - centy); - but->y2 = centy - (but->y2 - centy); - SWAP(float, but->y1, but->y2); + but->rect.ymin = centy - (but->rect.ymin - centy); + but->rect.ymax = centy - (but->rect.ymax - centy); + SWAP(float, but->rect.ymin, but->rect.ymax); } /* also flip order in block itself, for example for arrowkey */ @@ -3522,9 +3515,9 @@ void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg) but->autofunc_arg = arg; } -uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, int x1, int y1, short x2, short y2, void *idpp, const char *tip) +uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, int x, int y, short width, short height, void *idpp, const char *tip) { - uiBut *but = ui_def_but(block, IDPOIN, retval, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, IDPOIN, retval, str, x, y, width, height, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->idpoin_func = func; but->idpoin_idpp = (ID **) idpp; ui_check_but(but); @@ -3535,17 +3528,17 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int return but; } -uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; if (but->func_argN) { MEM_freeN(but->func_argN); @@ -3556,25 +3549,25 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const } -uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->menu_create_func = func; ui_check_but(but); return but; } -uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3588,9 +3581,9 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in return but; } -uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, PULLDOWN, 0, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, PULLDOWN, 0, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3603,9 +3596,9 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic } /* Block button containing both string label and icon */ -uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, 0, str, x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); /* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */ if (icon != ICON_RIGHTARROW_THIN) { @@ -3622,9 +3615,9 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, } /* Block button containing icon */ -uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, const char *tip) { - uiBut *but = ui_def_but(block, BLOCK, retval, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, BLOCK, retval, "", x, y, width, height, arg, 0.0, 0.0, 0.0, 0.0, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3637,18 +3630,18 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int return but; } -uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip) +uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *spoin, const char *tip) { - uiBut *but = ui_def_but(block, KEYEVT | SHO, retval, str, x1, y1, x2, y2, spoin, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, KEYEVT | SHO, retval, str, x, y, width, height, spoin, 0.0, 0.0, 0.0, 0.0, tip); ui_check_but(but); return but; } /* short pointers hardcoded */ /* modkeypoin will be set to KM_SHIFT, KM_ALT, KM_CTRL, KM_OSKEY bits */ -uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip) +uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, int y, short width, short height, short *keypoin, short *modkeypoin, const char *tip) { - uiBut *but = ui_def_but(block, HOTKEYEVT | SHO, retval, str, x1, y1, x2, y2, keypoin, 0.0, 0.0, 0.0, 0.0, tip); + uiBut *but = ui_def_but(block, HOTKEYEVT | SHO, retval, str, x, y, width, height, keypoin, 0.0, 0.0, 0.0, 0.0, tip); but->modifier_key = *modkeypoin; ui_check_but(but); return but; @@ -3657,9 +3650,9 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, i /* arg is pointer to string/name, use uiButSetSearchFunc() below to make this work */ /* here a1 and a2, if set, control thumbnail preview rows/cols */ -uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip) +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip) { - uiBut *but = ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, a1, a2, tip); + uiBut *but = ui_def_but(block, SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip); but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; @@ -3828,7 +3821,9 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) + { tmp = BLI_strdup(buf); + } } } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f7eff2cb22b..77dbbc878a7 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -439,8 +439,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 = (rect->xmax - rect->xmin); - h = (rect->ymax - rect->ymin); + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_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 +493,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = abs(rect->xmax - rect->xmin); - height = abs(rect->ymax - rect->ymin); + width = abs(BLI_RCT_SIZE_X(rect)); + height = abs(BLI_RCT_SIZE_Y(rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -629,7 +629,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) } } -#endif // WITH_INTERNATIONAL +#endif /* WITH_INTERNATIONAL */ #endif static void draw_scope_end(rctf *rect, GLint *scissor) @@ -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 + (rect->xmax - rect->xmin) / 2 - SCOPE_RESIZE_PAD; - scaler_x2 = rect->xmin + (rect->xmax - rect->xmin) / 2 + SCOPE_RESIZE_PAD; + 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; 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 = rect.xmax - rect.xmin; - h = (rect.ymax - rect.ymin) * hist->ymax; + w = BLI_RCT_SIZE_X(&rect); + h = BLI_RCT_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 = rect.xmax - rect.xmin - 7; - h = (rect.ymax - rect.ymin) * scopes->wavefrm_yfac; - yofs = rect.ymin + (rect.ymax - rect.ymin - h) / 2.0f; + 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; 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 = rect.xmax - rect.xmin; - h = rect.ymax - rect.ymin; + w = BLI_RCT_SIZE_X(&rect); + h = BLI_RCT_SIZE_Y(&rect); centerx = rect.xmin + w / 2; centery = rect.ymin + h / 2; diam = (w < h) ? w : h; @@ -1262,12 +1262,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* transform to button */ glPushMatrix(); - glTranslatef(rect->xmin + 0.5f * (rect->xmax - rect->xmin), rect->ymin + 0.5f * (rect->ymax - rect->ymin), 0.0f); + glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f); - if (rect->xmax - rect->xmin < rect->ymax - rect->ymin) - size = (rect->xmax - rect->xmin) / 200.f; + if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect)) + size = BLI_RCT_SIZE_X(rect) / 200.f; else - size = (rect->ymax - rect->ymin) / 200.f; + size = BLI_RCT_SIZE_Y(rect) / 200.f; glScalef(size, size, size); @@ -1355,8 +1355,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect rcti scissor_new; int a; - cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin); - cuma = cumap->cm + cumap->cur; + if (but->editcumap) { + cumap = but->editcumap; + } + else { + cumap = (CurveMapping *)but->poin; + } + + cuma = &cumap->cm[cumap->cur]; /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); @@ -1365,11 +1371,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect scissor_new.xmax = ar->winrct.xmin + rect->xmax; scissor_new.ymax = ar->winrct.ymin + rect->ymax; BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new); - glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin); - + glScissor(scissor_new.xmin, + scissor_new.ymin, + BLI_RCT_SIZE_X(&scissor_new), + BLI_RCT_SIZE_Y(&scissor_new)); + /* calculate offset and zoom */ - zoomx = (rect->xmax - rect->xmin - 2.0f * but->aspect) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (rect->ymax - rect->ymin - 2.0f * but->aspect) / (cumap->curr.ymax - cumap->curr.ymin); + 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); offsx = cumap->curr.xmin - but->aspect / zoomx; offsy = cumap->curr.ymin - but->aspect / zoomy; @@ -1481,12 +1490,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glBegin(GL_LINE_STRIP); if (cuma->table == NULL) - curvemapping_changed(cumap, 0); /* 0 = no remove doubles */ + curvemapping_changed(cumap, FALSE); cmp = cuma->table; /* first point */ - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy)); + } else { fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]); fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]); @@ -1498,8 +1508,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glVertex2f(fx, fy); } /* last point */ - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy)); + } else { fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]); fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]); @@ -1514,7 +1525,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glPointSize(3.0f); bglBegin(GL_POINTS); for (a = 0; a < cuma->totpoint; a++) { - if (cmp[a].flag & SELECT) + if (cmp[a].flag & CUMA_SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); @@ -1545,8 +1556,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 = rect.xmax - rect.xmin + 1; - height = rect.ymax - rect.ymin; + width = BLI_RCT_SIZE_X(&rect) + 1; + height = BLI_RCT_SIZE_Y(&rect); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1621,8 +1632,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, - rect.xmax - rect.xmin, - rect.ymax - rect.ymin); + BLI_RCT_SIZE_X(&rect), + BLI_RCT_SIZE_Y(&rect)); for (a = 0; a < 2; a++) { if (a == 1) { @@ -1722,8 +1733,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE glEnable(GL_BLEND); - if (radius > (rct->ymax - rct->ymin - 10.0f) / 2.0f) - rad = (rct->ymax - rct->ymin - 10.0f) / 2.0f; + if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f) + rad = (BLI_RCT_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 90f8bb52826..ca52daa8cd2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -686,20 +686,19 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) ui_window_to_block(ar, but->block, &x, &y); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; + BLI_rcti_rctf_copy(&rect, &but->rect); if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { - rect.xmax = rect.xmin + (rect.ymax - rect.ymin); + rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect)); } else { - int delta = (rect.xmax - rect.xmin) - (rect.ymax - rect.ymin); + int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect); rect.xmin += delta / 2; rect.xmax -= delta / 2; } - return BLI_in_rcti(&rect, x, y); + return BLI_rcti_isect_pt(&rect, x, y); } static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) @@ -715,7 +714,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, but->x2 - but->x1, but->y2 - but->y1); + WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect)); return 1; } @@ -839,6 +838,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) /* (3) add a new controller */ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & 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... */ /* (4) link the sensor->controller->actuator */ tmp_but = MEM_callocN(sizeof(uiBut), "uiBut"); @@ -1140,8 +1140,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, static ColorBand but_copypaste_coba = {0}; char buf[UI_MAX_DRAW_STR + 1] = {0}; - if (mode == 'v' && but->lock) + if (mode == 'v' && but->lock == TRUE) { return; + } if (mode == 'v') { /* extract first line from clipboard in case of multi-line copies */ @@ -1282,7 +1283,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho { uiStyle *style = UI_GetStyle(); // XXX pass on as arg uiFontStyle *fstyle = &style->widget; - int startx = but->x1; + int startx = but->rect.xmin; char *origstr; uiStyleFontSet(fstyle); @@ -1296,7 +1297,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 * (but->y2 - but->y1)); + startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect))); else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) @@ -2537,11 +2538,11 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 1; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 1; } else if (event->val == KM_PRESS) { @@ -2611,7 +2612,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->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; @@ -2622,7 +2623,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->x1 + (2 * (but->x2 - but->x1) / 3) + 3)) { + else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; @@ -2637,7 +2638,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); } else { - if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - 0.01f * but->a1; @@ -2646,7 +2647,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->x1 + (2 * ((but->x2 - but->x1) / 3) + 3)) { + else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + 0.01f * but->a1; @@ -2674,14 +2675,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short softmax = but->softmax; softrange = softmax - softmin; - if (but->type == NUMSLI) deler = ((but->x2 - but->x1) - 5.0f * but->aspect); - else if (but->type == HSVSLI) deler = ((but->x2 - but->x1) / 2.0f - 5.0f * but->aspect); + 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); else if (but->type == SCROLL) { - int horizontal = (but->x2 - but->x1 > but->y2 - but->y1); - float size = (horizontal) ? (but->x2 - but->x1) : -(but->y2 - but->y1); + 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); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); } - else deler = (but->x2 - but->x1 - 5.0f * but->aspect); + else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect); f = (float)(mx - data->dragstartx) / deler + data->dragfstart; @@ -2750,11 +2751,11 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 2; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 2; } else if (event->val == KM_PRESS) { @@ -2764,12 +2765,12 @@ 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 = (but->x1 + but->x2) / 2; + int halfpos = BLI_RCT_CENTER_X(&but->rect); click = 2; if (mx < halfpos) - mx = but->x1; + mx = but->rect.xmin; else - mx = but->x2; + mx = but->rect.xmax; } else if (event->type == LEFTMOUSE) { data->dragstartx = mx; @@ -2831,12 +2832,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton #if 0 if (but->type == SLI) { - f = (float)(mx - but->x1) / (but->x2 - but->x1); /* same as below */ + f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */ } else #endif { - f = (float)(mx - but->x1) / (but->x2 - but->x1); + f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); } f = softmin + f * softrange; @@ -2877,7 +2878,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 = (but->x2 - but->x1 > but->y2 - but->y1); + int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect)); mx = event->x; my = event->y; @@ -2946,9 +2947,11 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm return WM_UI_HANDLER_BREAK; } else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) { - - if (event->type == WHEELDOWNMOUSE && event->alt) { - data->value = ui_step_name_menu(but, -1); + if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { + const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1; + + data->value = ui_step_name_menu(but, direction); + button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); @@ -2962,16 +2965,15 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm data->postbut = but; data->posttype = BUTTON_ACTIVATE_OVER; - return WM_UI_HANDLER_BREAK; - } - else if (event->type == WHEELUPMOUSE && event->alt) { - data->value = ui_step_name_menu(but, 1); - button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); - - /* why this is needed described above */ - data->postbut = but; - data->posttype = BUTTON_ACTIVATE_OVER; + /* without this, a new interface that draws as result of the menu change + * won't register that the mouse is over it, eg: + * Alt+MouseWheel over the render slots, without this, + * the slot menu fails to switch a second time. + * + * The active state of the button could be maintained some other way + * and remove this mousemove event. + */ + WM_event_add_mousemove(C); return WM_UI_HANDLER_BREAK; } @@ -3034,7 +3036,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 = (but->x2 - but->x1); + rad = BLI_RCT_SIZE_X(&but->rect); radsq = rad * rad; if (fp[2] > 0.0f) { @@ -3142,8 +3144,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ - x = ((float)mx_fl - but->x1) / (but->x2 - but->x1); - y = ((float)my_fl - but->y1) / (but->y2 - but->y1); + 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); CLAMP(x, 0.0f, 1.0f); CLAMP(y, 0.0f, 1.0f); @@ -3348,9 +3350,8 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; - + BLI_rcti_rctf_copy(&rect, &but->rect); + ui_get_but_vectorf(but, rgb); copy_v3_v3(hsv, ui_block_hsv_get(but->block)); rgb_to_hsv_compat_v(rgb, hsv); @@ -3541,7 +3542,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx if (data->draglastx == mx) return changed; - dx = ((float)(mx - data->draglastx)) / (but->x2 - but->x1); + dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); @@ -3570,7 +3571,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->x1)) / (but->x2 - but->x1); + float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect); colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3582,7 +3583,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->x1 + (cbd->pos * (but->x2 - but->x1)); + xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect)); xco = ABS(xco - mx); if (a == coba->cur) xco += 5; // selected one disadvantage if (xco < mindist) { @@ -3623,8 +3624,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 = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + 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); /* offsx= cumap->curr.xmin; */ /* offsy= cumap->curr.ymin; */ @@ -3649,7 +3650,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, fy *= mval_factor; for (a = 0; a < cuma->totpoint; a++) { - if (cmp[a].flag & SELECT) { + if (cmp[a].flag & CUMA_SELECT) { float origx = cmp[a].x, origy = cmp[a].y; cmp[a].x += fx; cmp[a].y += fy; @@ -3662,7 +3663,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, } } - curvemapping_changed(cumap, 0); /* no remove doubles */ + curvemapping_changed(cumap, FALSE); if (moved_point) { data->draglastx = mx; @@ -3719,25 +3720,25 @@ 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 = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + 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); offsx = cumap->curr.xmin; offsy = cumap->curr.ymin; if (event->ctrl) { - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; curvemap_insert(cuma, fx, fy); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); changed = 1; } /* check for selecting of a point */ cmp = cuma->curve; /* ctrl adds point, new malloc */ for (a = 0; a < cuma->totpoint; a++) { - fx = but->x1 + zoomx * (cmp[a].x - offsx); - fy = but->y1 + zoomy * (cmp[a].y - offsy); + fx = but->rect.xmin + zoomx * (cmp[a].x - offsx); + fy = but->rect.ymin + zoomy * (cmp[a].y - offsy); dist = (fx - mx) * (fx - mx) + (fy - my) * (fy - my); if (dist < mindist) { sel = a; @@ -3750,20 +3751,20 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* if the click didn't select anything, check if it's clicked on the * curve itself, and if so, add a point */ - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; cmp = cuma->table; /* loop through the curve segment table and find what's near the mouse. * 0.05 is kinda arbitrary, but seems to be what works nicely. */ for (i = 0; i <= CM_TABLE; i++) { - if ( (fabsf(fx - cmp[i].x) < 0.05f) && - (fabsf(fy - cmp[i].y) < 0.05f)) + if ((fabsf(fx - cmp[i].x) < 0.05f) && + (fabsf(fy - cmp[i].y) < 0.05f)) { curvemap_insert(cuma, fx, fy); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); changed = 1; @@ -3785,11 +3786,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* deselect all if this one is deselect. except if we hold shift */ if (event->shift == FALSE) { for (a = 0; a < cuma->totpoint; a++) - cmp[a].flag &= ~SELECT; - cmp[sel].flag |= SELECT; + cmp[a].flag &= ~CUMA_SELECT; + cmp[sel].flag |= CUMA_SELECT; } else - cmp[sel].flag ^= SELECT; + cmp[sel].flag ^= CUMA_SELECT; } else { /* move the view */ @@ -3824,12 +3825,13 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* deselect all, select one */ if (event->shift == FALSE) { for (a = 0; a < cuma->totpoint; a++) - cmp[a].flag &= ~SELECT; - cmp[data->dragsel].flag |= SELECT; + cmp[a].flag &= ~CUMA_SELECT; + cmp[data->dragsel].flag |= CUMA_SELECT; } } - else - curvemapping_changed(cumap, 1); /* remove doubles */ + else { + curvemapping_changed(cumap, TRUE); /* remove doubles */ + } } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -3846,8 +3848,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ - return (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->rect.xmax - SCOPE_RESIZE_PAD) && (y < but->rect.ymin + SCOPE_RESIZE_PAD); */ + return (y < but->rect.ymin + SCOPE_RESIZE_PAD); } static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) @@ -3857,15 +3859,14 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx int changed = 1; float /* dx, */ dy; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ - hist->height = (but->y2 - but->y1) + (data->dragstarty - my); + hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { /* scale histogram values (dy / 10 for better control) */ @@ -3941,8 +3942,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int changed = 1; float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3950,7 +3950,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 = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { /* scale waveform values */ @@ -4025,15 +4025,14 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int int changed = 1; /* float dx, dy; */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* BLI_rcti_rctf_copy(&rect, &but->rect); */ /* dx = mx - data->draglastx; */ /* dy = my - data->draglasty; */ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ - scopes->vecscope_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } data->draglastx = mx; @@ -4103,17 +4102,17 @@ 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(but->x2 - but->x1); - height = abs(but->y2 - but->y1); + width = abs(BLI_RCT_SIZE_X(&but->rect)); + height = abs(BLI_RCT_SIZE_Y(&but->rect)); butw = floor(width / 12); buth = floor(height / 6); /* Initialize variables */ - sx = but->x1; - ex = but->x1 + butw; - sy = but->y1 + height - buth; - ey = but->y1 + height; + sx = but->rect.xmin; + ex = but->rect.xmin + butw; + sy = but->rect.ymin + height - buth; + ey = but->rect.ymin + height; cs = G.charstart; @@ -4236,7 +4235,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 = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my); } else { if (!scopes->track_locked) { @@ -4244,8 +4243,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] / (but->block->maxx - but->block->minx); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->maxy - but->block->miny); + 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); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } @@ -4712,7 +4711,6 @@ static int ui_but_menu(bContext *C, uiBut *but) static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) { -// Scene *scene= CTX_data_scene(C); uiHandleButtonData *data; int retval; @@ -4796,7 +4794,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) /* verify if we can edit this button */ if (ELEM(event->type, LEFTMOUSE, RETKEY)) { /* this should become disabled button .. */ - if (but->lock) { + if (but->lock == TRUE) { if (but->lockstr) { BKE_report(NULL, RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -4879,7 +4877,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) retval = ui_do_but_BUT(C, but, data, event); break; case COL: - if (but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker + if (but->a1 == UI_GRAD_V_ALT) /* signal to prevent calling up color picker */ retval = ui_do_but_EXIT(C, but, data, event); else retval = ui_do_but_BLOCK(C, but, data, event); @@ -4921,7 +4919,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) static int ui_but_contains_pt(uiBut *but, int mx, int my) { - return ((but->x1 < mx && but->x2 >= mx) && (but->y1 < my && but->y2 >= my)); + return BLI_rctf_isect_pt(&but->rect, mx, my); } static uiBut *ui_but_find_activated(ARegion *ar) @@ -4997,7 +4995,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) uiBlock *block; /* check if the mouse is in the region */ - if (!BLI_in_rcti(&ar->winrct, x, y)) { + if (!BLI_rcti_isect_pt(&ar->winrct, x, y)) { for (block = ar->uiblocks.first; block; block = block->next) block->auto_open = FALSE; @@ -5020,10 +5018,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) ui_window_to_region(ar, &mx, &my); /* make a copy of the mask rect, and tweak accordingly for hidden scrollbars */ - mask_rct.xmin = v2d->mask.xmin; - mask_rct.xmax = v2d->mask.xmax; - mask_rct.ymin = v2d->mask.ymin; - mask_rct.ymax = v2d->mask.ymax; + mask_rct = v2d->mask; if (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE | V2D_SCROLL_VERTICAL_FULLR)) { if (v2d->scroll & V2D_SCROLL_LEFT) @@ -5039,7 +5034,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) } /* check if in the rect */ - if (!BLI_in_rcti(&mask_rct, mx, my)) + if (!BLI_rcti_isect_pt(&mask_rct, mx, my)) return 0; } @@ -5092,9 +5087,7 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if (block->minx <= mx && block->maxx >= mx && - block->miny <= my && block->maxy >= my) - { + if (BLI_rctf_isect_pt(&block->rect, mx, my)) { break; } } @@ -5290,8 +5283,13 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->wm = CTX_wm_manager(C); data->window = CTX_wm_window(C); data->region = ar; - if (ELEM(but->type, BUT_CURVE, SEARCH_MENU) ) ; // XXX curve is temp - else data->interactive = 1; + + if (ELEM(but->type, BUT_CURVE, SEARCH_MENU)) { + /* XXX curve is temp */ + } + else { + data->interactive = 1; + } data->state = BUTTON_STATE_INIT; @@ -5979,17 +5977,17 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men /* verify that we are moving towards one of the edges of the * menu block, in other words, in the triangle formed by the * initial mouse location and two edge points. */ - p1[0] = block->minx - 20; - p1[1] = block->miny - 20; + p1[0] = block->rect.xmin - 20; + p1[1] = block->rect.ymin - 20; - p2[0] = block->maxx + 20; - p2[1] = block->miny - 20; + p2[0] = block->rect.xmax + 20; + p2[1] = block->rect.ymin - 20; - p3[0] = block->maxx + 20; - p3[1] = block->maxy + 20; + p3[0] = block->rect.xmax + 20; + p3[1] = block->rect.ymax + 20; - p4[0] = block->minx - 20; - p4[1] = block->maxy + 20; + p4[0] = block->rect.xmin - 20; + p4[1] = block->rect.ymax + 20; oldp[0] = menu->towardsx; oldp[1] = menu->towardsy; @@ -6019,10 +6017,10 @@ static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { if (block->flag & UI_BLOCK_CLIPTOP) - if (my > block->maxy - 14) + if (my > block->rect.ymax - 14) return 't'; if (block->flag & UI_BLOCK_CLIPBOTTOM) - if (my < block->miny + 14) + if (my < block->rect.ymin + 14) return 'b'; } return 0; @@ -6053,25 +6051,25 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) if (test == 't') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = bnext->y1 - b1->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = bnext->rect.ymin - b1->rect.ymin; /* bottom button is last button */ else - dy = bprev->y1 - b2->y1; + dy = bprev->rect.ymin - b2->rect.ymin; } else if (test == 'b') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = b1->y1 - bnext->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = b1->rect.ymin - bnext->rect.ymin; /* bottom button is last button */ else - dy = b2->y1 - bprev->y1; + dy = b2->rect.ymin - bprev->rect.ymin; } if (dy) { for (b1 = block->buttons.first; b1; b1 = b1->next) { - b1->y1 -= dy; - b1->y2 -= dy; + b1->rect.ymin -= dy; + b1->rect.ymax -= dy; } /* set flags again */ ui_popup_block_scrolltest(block); @@ -6103,10 +6101,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle ui_window_to_block(ar, block, &mx, &my); /* check if mouse is inside block */ - inside = 0; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy >= my) - inside = 1; + inside = BLI_rctf_isect_pt(&block->rect, mx, my); /* if there's an active modal button, don't check events or outside, except for search menu */ but = ui_but_find_activated(ar); @@ -6355,7 +6350,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle uiSafetyRct *saferct = block->saferct.first; if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val == KM_PRESS) { - if (saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) { + if (saferct && !BLI_rctf_isect_pt(&saferct->parent, event->x, event->y)) { if (block->flag & (UI_BLOCK_OUT_1)) menu->menuretval = UI_RETURN_OK; else @@ -6388,9 +6383,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle * events we check all preceding block rects too to make * arrow keys navigation work */ if (event->type != MOUSEMOVE || saferct == block->saferct.first) { - if (BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y)) + if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y)) break; - if (BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y)) + if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y)) break; } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 2bfead708be..dd3c2e491a7 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -596,7 +596,7 @@ static void init_internal_icons(void) IMB_freeImBuf(bbuf); } -#endif // WITH_HEADLESS +#endif /* WITH_HEADLESS */ static void init_iconfile_list(struct ListBase *list) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index c6787b4c554..567109e26d0 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -158,7 +158,7 @@ struct uiBut { char strdata[UI_MAX_NAME_STR]; char drawstr[UI_MAX_DRAW_STR]; - float x1, y1, x2, y2; + rctf rect; char *poin; float hardmin, hardmax, softmin, softmax; @@ -176,7 +176,7 @@ struct uiBut { struct bContextStore *context; - /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */ + /* not used yet, was used in 2.4x for ui_draw_pulldown_round & friends */ #if 0 void (*embossfunc)(int, int, float, float, float, float, float, int); void (*sliderfunc)(int, float, float, float, float, float, float, int); @@ -264,8 +264,8 @@ struct uiBlock { char name[UI_MAX_NAME_STR]; float winmat[4][4]; - - float minx, miny, maxx, maxy; + + rctf rect; float aspect; int puphash; /* popup menu hash for memory */ @@ -303,27 +303,27 @@ struct uiBlock { const char *lockstr; char lock; - char active; // to keep blocks while drawing and free them afterwards - char tooltipdisabled; // to avoid tooltip after click - char endblock; // uiEndBlock done? - - float xofs, yofs; // offset to parent button - int dobounds, mx, my; // for doing delayed - int bounds, minbounds; // for doing delayed + char active; /* to keep blocks while drawing and free them afterwards */ + char tooltipdisabled; /* to avoid tooltip after click */ + char endblock; /* uiEndBlock done? */ + + float xofs, yofs; /* offset to parent button */ + int dobounds, mx, my; /* for doing delayed */ + int bounds, minbounds; /* for doing delayed */ - rctf safety; // pulldowns, to detect outside, can differ per case how it is created - ListBase saferct; // uiSafetyRct list + rctf safety; /* pulldowns, to detect outside, can differ per case how it is created */ + ListBase saferct; /* uiSafetyRct list */ - uiPopupBlockHandle *handle; // handle + uiPopupBlockHandle *handle; /* handle */ - struct wmOperator *ui_operator; // use so presets can find the operator, - // across menus and from nested popups which fail for operator context. + struct wmOperator *ui_operator; /* use so presets can find the operator, */ + /* across menus and from nested popups which fail for operator context. */ - void *evil_C; // XXX hack for dynamic operator enums + void *evil_C; /* XXX hack for dynamic operator enums */ - 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 + 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 */ }; typedef struct uiSafetyRct { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 10fde402acc..b68e14898d0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -238,8 +239,10 @@ 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 = bitem->but->x2 - bitem->but->x1; - if (r_h) *r_h = bitem->but->y2 - bitem->but->y1; + + + if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect); + if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect); } else { uiLayout *litem = (uiLayout *)item; @@ -254,8 +257,8 @@ static void ui_item_offset(uiItem *item, int *r_x, int *r_y) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_x) *r_x = bitem->but->x1; - if (r_y) *r_y = bitem->but->y1; + if (r_x) *r_x = bitem->but->rect.xmin; + if (r_y) *r_y = bitem->but->rect.ymin; } else { if (r_x) *r_x = 0; @@ -268,10 +271,10 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - bitem->but->x1 = x; - bitem->but->y1 = y; - bitem->but->x2 = x + w; - bitem->but->y2 = y + h; + bitem->but->rect.xmin = x; + bitem->but->rect.ymin = y; + bitem->but->rect.xmax = x + w; + bitem->but->rect.ymax = y + h; ui_check_but(bitem->but); /* for strlen */ } @@ -627,7 +630,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name) but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); but->flag |= UI_BUT_DISABLED; - but->lock = 1; + but->lock = TRUE; but->lockstr = ""; } @@ -1898,10 +1901,10 @@ static void ui_litem_layout_box(uiLayout *litem) /* roundbox around the sublayout */ but = box->roundbox; - but->x1 = litem->x; - but->y1 = litem->y; - but->x2 = litem->x + litem->w; - but->y2 = litem->y + litem->h; + but->rect.xmin = litem->x; + but->rect.ymin = litem->y; + but->rect.xmax = litem->x + litem->w; + but->rect.ymax = litem->y + litem->h; } /* multi-column layout, automatically flowing to the next */ @@ -2749,7 +2752,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem) uiBut *but = bitem->but; BLI_dynstr_appendf(ds, "'type':%d, ", but->type); /* see ~ UI_interface.h:200 */ BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr); - BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); // not exactly needed, rna has this + BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */ if (but->optype) { char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0); @@ -2811,7 +2814,7 @@ static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout) ui_intro_items(ds, &layout->items); } -static char *str = NULL; // XXX, constant re-freeing, far from ideal. +static char *str = NULL; /* XXX, constant re-freeing, far from ideal. */ const char *uiLayoutIntrospect(uiLayout *layout) { DynStr *ds = BLI_dynstr_new(); @@ -2848,8 +2851,10 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, i /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens * just fails silently */ if (!WM_operator_repeat_check(C, op)) { - uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo"); - uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); // XXX, could give some nicer feedback or not show redo panel at all? + uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator can't' redo"); + + /* XXX, could give some nicer feedback or not show redo panel at all? */ + uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); } /* menu */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index b76907bc3ba..67c0d04a79f 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -27,7 +27,6 @@ * \ingroup edinterface */ - #include <stdio.h> #include <math.h> #include <string.h> @@ -69,6 +68,9 @@ #include "BKE_main.h" #include "BLI_ghash.h" +#include "ED_image.h" /* for HDR color sampling */ +#include "ED_node.h" /* for HDR color sampling */ +#include "ED_clip.h" /* for HDR color sampling */ /* ********************************************************** */ @@ -126,9 +128,59 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) /* *** eyedropper_color_ helper functions *** */ -/* simply get the color from the screen */ -static void eyedropper_color_sample_fl(Eyedropper *UNUSED(eye), int mx, int my, float r_col[3]) +/** + * \brief get the color from the screen. + * + * Special check for image or nodes where we MAY have HDR pixels which don't display. + */ +static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int mx, int my, float r_col[3]) { + + /* we could use some clever */ + wmWindow *win = CTX_wm_window(C); + ScrArea *sa; + for (sa = win->screen->areabase.first; sa; sa = sa->next) { + if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { + if (sa->spacetype == SPACE_IMAGE) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceImage *sima = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_image_color_sample(sima, ar, mval, r_col)) { + return; + } + } + } + else if (sa->spacetype == SPACE_NODE) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceNode *snode = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_node_color_sample(snode, ar, mval, r_col)) { + return; + } + } + } + else if (sa->spacetype == SPACE_CLIP) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceClip *sc = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_clip_color_sample(sc, ar, mval, r_col)) { + return; + } + } + } + } + } + + /* fallback to simple opengl picker */ glReadBuffer(GL_FRONT); glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col); glReadBuffer(GL_BACK); @@ -167,14 +219,14 @@ static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) { float col[3]; - eyedropper_color_sample_fl(eye, mx, my, col); + eyedropper_color_sample_fl(C, eye, mx, my, col); eyedropper_color_set(C, eye, col); } -static void eyedropper_color_sample_accum(Eyedropper *eye, int mx, int my) +static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my) { float col[3]; - eyedropper_color_sample_fl(eye, mx, my, col); + eyedropper_color_sample_fl(C, eye, mx, my, col); /* delay linear conversion */ add_v3_v3(eye->accum_col, col); eye->accum_tot++; @@ -203,13 +255,13 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event) else if (event->val == KM_PRESS) { /* enable accum and make first sample */ eye->accum_start = TRUE; - eyedropper_color_sample_accum(eye, event->x, event->y); + eyedropper_color_sample_accum(C, eye, event->x, event->y); } break; case MOUSEMOVE: if (eye->accum_start) { /* button is pressed so keep sampling */ - eyedropper_color_sample_accum(eye, event->x, event->y); + eyedropper_color_sample_accum(C, eye, event->x, event->y); eyedropper_color_set_accum(C, eye); } break; @@ -217,7 +269,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->val == KM_RELEASE) { eye->accum_tot = 0; zero_v3(eye->accum_col); - eyedropper_color_sample_accum(eye, event->x, event->y); + eyedropper_color_sample_accum(C, eye, event->x, event->y); eyedropper_color_set_accum(C, eye); } break; @@ -689,10 +741,7 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) /* this just needs to be a 'good-enough' comparison so we can know beyond * reasonable doubt that these buttons are the same between redraws. * if this fails it only means edit-source fails - campbell */ - if ((but_a->x1 == but_b->x1) && - (but_a->x2 == but_b->x2) && - (but_a->y1 == but_b->y1) && - (but_a->y2 == but_b->y2) && + if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) && (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && @@ -1018,7 +1067,7 @@ void UI_buttons_operatortypes(void) WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_reset_default_button); WM_operatortype_append(UI_OT_copy_to_selected_button); - WM_operatortype_append(UI_OT_reports_to_textblock); // XXX: temp? + WM_operatortype_append(UI_OT_reports_to_textblock); /* XXX: temp? */ #ifdef WITH_PYTHON WM_operatortype_append(UI_OT_editsource); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d04c1af2769..fa3e04d1351 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -315,13 +315,13 @@ static void ui_offset_panel_block(uiBlock *block) ofsy = block->panel->sizey - style->panelspace; for (but = block->buttons.first; but; but = but->next) { - but->y1 += ofsy; - but->y2 += ofsy; + but->rect.ymin += ofsy; + but->rect.ymax += ofsy; } - block->maxx = block->panel->sizex; - block->maxy = block->panel->sizey; - block->minx = block->miny = 0.0; + block->rect.xmax = block->panel->sizex; + block->rect.ymax = block->panel->sizey; + block->rect.xmin = block->rect.ymin = 0.0; } /**************************** drawing *******************************/ @@ -360,11 +360,11 @@ void UI_DrawTriIcon(float x, float y, char dir) static void ui_draw_tria_rect(rctf *rect, char dir) { if (dir == 'h') { - float half = 0.5f * (rect->ymax - rect->ymin); + float half = 0.5f * BLI_RCT_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 * (rect->xmax - rect->xmin); + float half = 0.5f * BLI_RCT_SIZE_X(rect); ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin); } } @@ -422,7 +422,7 @@ static void ui_draw_panel_scalewidget(rcti *rect) glDisable(GL_BLEND); } -static void ui_draw_panel_dragwidget(rctf *rect) +static void ui_draw_panel_dragwidget(const rctf *rect) { float xmin, xmax, dx; float ymin, ymax, dy; @@ -483,8 +483,8 @@ static void rectf_scale(rctf *rect, float scale) { float centx = 0.5f * (rect->xmin + rect->xmax); float centy = 0.5f * (rect->ymin + rect->ymax); - float sizex = 0.5f * scale * (rect->xmax - rect->xmin); - float sizey = 0.5f * scale * (rect->ymax - rect->ymin); + float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect); + float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect); 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 - (headrect.ymax - headrect.ymin); + itemrect.xmin = itemrect.xmax - BLI_RCT_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 + (headrect.ymax - headrect.ymin); + itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; @@ -875,11 +875,11 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) /* consistency; are panels not made, whilst they have tabs */ for (panot = ar->panels.first; panot; panot = panot->next) { - if ((panot->runtime_flag & PNL_ACTIVE) == 0) { // not made + if ((panot->runtime_flag & PNL_ACTIVE) == 0) { /* not made */ for (panew = ar->panels.first; panew; panew = panew->next) { if ((panew->runtime_flag & PNL_ACTIVE)) { - if (panew->paneltab == panot) { // panew is tab in notmade pa + if (panew->paneltab == panot) { /* panew is tab in notmade pa */ break; } } @@ -893,7 +893,7 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) } panot->paneltab = panew; panew->paneltab = NULL; - ED_region_tag_redraw(ar); // the buttons panew were not made + ED_region_tag_redraw(ar); /* the buttons panew were not made */ } } } @@ -979,14 +979,14 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) short align = panel_aligned(sa, ar), dx = 0, dy = 0; /* first clip for window, no dragging outside */ - if (!BLI_in_rcti_v(&ar->winrct, &event->x)) + if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) return; dx = (event->x - data->startx) & ~(PNL_GRID - 1); dy = (event->y - data->starty) & ~(PNL_GRID - 1); - dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin) / (float)(ar->winrct.xmax - ar->winrct.xmin); - dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin) / (float)(ar->winrct.ymax - ar->winrct.ymin); + 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); if (data->state == PANEL_STATE_DRAG_SCALE) { panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX); @@ -1033,22 +1033,22 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else if (event == AKEY) button = 1; else if (block->panel->flag & PNL_CLOSEDX) { - if (my >= block->maxy) button = 1; + if (my >= block->rect.ymax) button = 1; } else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ - if (mx <= block->maxx - 8 - PNL_ICON) button = 2; - //else if (mx <= block->minx + 10 + 2 * PNL_ICON + 2) button = 1; + if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2; + //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1; } - else if (mx <= block->maxx - PNL_ICON - 12) { + else if (mx <= block->rect.xmax - PNL_ICON - 12) { button = 1; } if (button) { - if (button == 2) { // close + if (button == 2) { /* close */ ED_region_tag_redraw(ar); } - else { // collapse + else { /* collapse */ if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; /* snap back up so full panel aligns with screen edge */ @@ -1078,7 +1078,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else ED_region_tag_redraw(ar); } - else if (mx <= (block->maxx - PNL_ICON - 12) + PNL_ICON + 2) { + else if (mx <= (block->rect.xmax - PNL_ICON - 12) + PNL_ICON + 2) { panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } } @@ -1106,18 +1106,18 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (!pa || pa->paneltab != NULL) continue; - if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. + if (pa->type && pa->type->flag & PNL_NO_HEADER) /* XXX - accessed freed panels when scripts reload, need to fix. */ continue; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy + PNL_HEADER >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx) + if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my) inside = 1; if (inside && event->val == KM_PRESS) { if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { if (pa->flag & PNL_CLOSEDY) { - if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) + if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) ui_handle_panel_header(C, block, mx, my, event->type); } else @@ -1134,15 +1134,15 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (inside) { /* clicked at panel header? */ if (pa->flag & PNL_CLOSEDX) { - if (block->minx <= mx && block->minx + PNL_HEADER >= mx) + if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx) inside_header = 1; } - else if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) { + else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { inside_header = 1; } else if (pa->control & UI_PNL_SCALE) { - if (block->maxx - PNL_HEADER <= mx) - if (block->miny + PNL_HEADER >= my) + if (block->rect.xmax - PNL_HEADER <= mx) + if (block->rect.ymin + PNL_HEADER >= my) inside_scale = 1; } @@ -1177,7 +1177,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) #endif } else if (event->type == PADPLUSKEY || event->type == PADMINUS) { -#if 0 // XXX make float panel exception? +#if 0 /* XXX make float panel exception? */ int zoom = 0; /* if panel is closed, only zoom if mouse is over the header */ @@ -1275,7 +1275,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat * Aligorith, 2009Sep */ //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel - check_panel_overlap(ar, NULL); // clears + check_panel_overlap(ar, NULL); /* clears */ } pa->flag &= ~PNL_SELECT; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 70f2bf7b028..96c1b00d46d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -391,7 +391,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 * ((bbox.ymax - bbox.ymin) - data->toth); + bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth); bbox.ymin = bbox.ymax - data->lineh; for (i = 0; i < data->totline; i++) { @@ -420,8 +420,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* IDProperty *prop;*/ char buf[512]; float fonth, fontw, aspect = but->block->aspect; - float x1f, x2f, y1f, y2f; - int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a; + int winx, winy, ofsx, ofsy, w, h, a; + rctf rect_fl; + rcti rect_i; const int nbr_info = 6; uiStringInfo but_tip = {BUT_GET_TIP, NULL}; @@ -573,6 +574,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) char *str; opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ + /* so the context is passed to itemf functions (some py itemf functions use it) */ + WM_operator_properties_sanitize(opptr, FALSE); + str = WM_operator_pystring(C, but->optype, opptr, 0); /* operator info */ @@ -682,62 +686,59 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; ofsy = (but->block->panel) ? but->block->panel->ofsy : 0; - x1f = (but->x1 + but->x2) * 0.5f + ofsx - (TIP_BORDER_X * aspect); - x2f = x1f + fontw + (TIP_BORDER_X * aspect); - y2f = but->y1 + ofsy - (TIP_BORDER_Y * aspect); - y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect); + rect_fl.xmin = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect); + rect_fl.xmax = rect_fl.xmin + fontw + (TIP_BORDER_X * aspect); + rect_fl.ymax = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect); + rect_fl.ymin = rect_fl.ymax - fonth * aspect - (TIP_BORDER_Y * aspect); #undef TIP_MARGIN_Y #undef TIP_BORDER_X #undef TIP_BORDER_Y /* copy to int, gets projected if possible too */ - x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); if (butregion) { /* XXX temp, region v2ds can be empty still */ if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { - UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); - UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax); } - x1 += butregion->winrct.xmin; - x2 += butregion->winrct.xmin; - y1 += butregion->winrct.ymin; - y2 += butregion->winrct.ymin; + BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin); } wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if (x2 > winx) { + if (rect_i.xmax > winx) { /* super size */ - if (x2 > winx + x1) { - x2 = winx; - x1 = 0; + if (rect_i.xmax > winx + rect_i.xmin) { + rect_i.xmax = winx; + rect_i.xmin = 0; } else { - x1 -= x2 - winx; - x2 = winx; + rect_i.xmin -= rect_i.xmax - winx; + rect_i.xmax = winx; } } /* ensure at least 5 px above screen bounds * 25 is just a guess to be above the menu item */ - if (y1 < 5) { - y2 += (-y1) + 30; - y1 = 30; + if (rect_i.ymin < 5) { + rect_i.ymax += (-rect_i.ymin) + 30; + rect_i.ymin = 30; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ - ar->winrct.xmin = x1 - MENU_SHADOW_SIDE; - ar->winrct.xmax = x2 + MENU_SHADOW_SIDE; - ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = y2 + MENU_TOP; + ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = rect_i.ymax + MENU_TOP; /* adds subwindow */ ED_region_init(C, ar); @@ -864,8 +865,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) { /* thumbnail preview */ if (data->preview) { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / data->prv_rows; - int butw = (data->bbox.xmax - data->bbox.xmin) / data->prv_cols; + 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 row, col; *rect = data->bbox; @@ -881,7 +882,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } /* list view */ else { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / SEARCH_ITEMS; + int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS; *rect = data->bbox; rect->xmin = data->bbox.xmin + 3.0f; @@ -898,7 +899,7 @@ int ui_searchbox_inside(ARegion *ar, int x, int y) { uiSearchboxData *data = ar->regiondata; - return(BLI_in_rcti(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin)); + return(BLI_rcti_isect_pt(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin)); } /* string validated to be of correct length (but->hardmax) */ @@ -934,13 +935,13 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event) ui_searchbox_select(C, ar, but, 1); break; case MOUSEMOVE: - if (BLI_in_rcti(&ar->winrct, event->x, event->y)) { + if (BLI_rcti_isect_pt(&ar->winrct, event->x, event->y)) { rcti rect; int a; for (a = 0; a < data->items.totitem; a++) { ui_searchbox_butrect(&rect, data, a); - if (BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { + if (BLI_rcti_isect_pt(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { if (data->active != a + 1) { data->active = a + 1; ui_searchbox_select(C, ar, but, 0); @@ -1094,13 +1095,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((rect.xmax - rect.xmin) / 2, rect.ymin - 9, ICON_TRIA_DOWN); + UI_icon_draw((BLI_RCT_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((rect.xmax - rect.xmin) / 2, rect.ymax - 7, ICON_TRIA_UP); + UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP); glDisable(GL_BLEND); } } @@ -1131,8 +1132,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) ARegion *ar; uiSearchboxData *data; float aspect = but->block->aspect; - float x1f, x2f, y1f, y2f; - int x1, x2, y1, y2, winx, winy, ofsx, ofsy; + rctf rect_fl; + rcti rect_i; + int winx, winy, ofsx, ofsy; + int i; /* create area region */ ar = ui_add_temporary_region(CTX_wm_screen(C)); @@ -1173,82 +1176,78 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = (ar->winrct.xmax - ar->winrct.xmin) - MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ - if (but->y2 < (but->block->miny + but->block->maxy) / 2) { - data->bbox.ymin += (but->y2 - but->y1); + if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) { + data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect); } else { - data->bbox.ymax -= (but->y2 - but->y1); + data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect); } } else { - x1f = but->x1 - 5; /* align text with button */ - x2f = but->x2 + 5; /* symmetrical */ - y2f = but->y1; - y1f = y2f - uiSearchBoxhHeight(); + rect_fl.xmin = but->rect.xmin - 5; /* align text with button */ + rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */ + rect_fl.ymax = but->rect.ymin; + rect_fl.ymin = rect_fl.ymax - uiSearchBoxhHeight(); ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; ofsy = (but->block->panel) ? but->block->panel->ofsy : 0; - x1f += ofsx; - x2f += ofsx; - y1f += ofsy; - y2f += ofsy; + BLI_rctf_translate(&rect_fl, ofsx, ofsy); /* minimal width */ - if (x2f - x1f < 150) x2f = x1f + 150; // XXX arbitrary + if (BLI_RCT_SIZE_X(&rect_fl) < 150) { + rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */ + } /* copy to int, gets projected if possible too */ - x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { - UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); - UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin); + UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax); } - x1 += butregion->winrct.xmin; - x2 += butregion->winrct.xmin; - y1 += butregion->winrct.ymin; - y2 += butregion->winrct.ymin; + BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin); wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if (x2 > winx) { + if (rect_i.xmax > winx) { /* super size */ - if (x2 > winx + x1) { - x2 = winx; - x1 = 0; + if (rect_i.xmax > winx + rect_i.xmin) { + rect_i.xmax = winx; + rect_i.xmin = 0; } else { - x1 -= x2 - winx; - x2 = winx; + rect_i.xmin -= rect_i.xmax - winx; + rect_i.xmax = winx; } } - if (y1 < 0) { + if (rect_i.ymin < 0) { int newy1; - UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1); + UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; - y2 = y2 - y1 + newy1; - y1 = newy1; + rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1; + rect_i.ymin = newy1; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ - ar->winrct.xmin = x1 - MENU_SHADOW_SIDE; - ar->winrct.xmax = x2 + MENU_SHADOW_SIDE; - ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = y2; + ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = rect_i.ymax; } /* adds subwindow */ @@ -1269,8 +1268,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names"); data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers"); data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons"); - for (x1 = 0; x1 < data->items.maxitem; x1++) - data->items.names[x1] = MEM_callocN(but->hardmax + 1, "search pointers"); + for (i = 0; i < data->items.maxitem; i++) + data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers"); return ar; } @@ -1336,45 +1335,36 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, short dir1 = 0, dir2 = 0; /* transform to window coordinates, using the source button region/block */ - butrct.xmin = but->x1; butrct.xmax = but->x2; - butrct.ymin = but->y1; butrct.ymax = but->y2; + butrct = but->rect; ui_block_to_window_fl(butregion, but->block, &butrct.xmin, &butrct.ymin); ui_block_to_window_fl(butregion, but->block, &butrct.xmax, &butrct.ymax); /* calc block rect */ - if (block->minx == 0.0f && block->maxx == 0.0f) { + if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) { if (block->buttons.first) { - block->minx = block->miny = 10000; - block->maxx = block->maxy = -10000; - - bt = block->buttons.first; - while (bt) { - if (bt->x1 < block->minx) block->minx = bt->x1; - if (bt->y1 < block->miny) block->miny = bt->y1; + BLI_rctf_init_minmax(&block->rect); - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; - - bt = bt->next; + for (bt = block->buttons.first; bt; bt = bt->next) { + BLI_rctf_union(&block->rect, &bt->rect); } } else { /* we're nice and allow empty blocks too */ - block->minx = block->miny = 0; - block->maxx = block->maxy = 20; + block->rect.xmin = block->rect.ymin = 0; + block->rect.xmax = block->rect.ymax = 20; } } - /* aspect = (float)(block->maxx - block->minx + 4);*/ /*UNUSED*/ - ui_block_to_window_fl(butregion, but->block, &block->minx, &block->miny); - ui_block_to_window_fl(butregion, but->block, &block->maxx, &block->maxy); + /* aspect = (float)(BLI_RCT_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->minx -= 2.0; block->miny -= 2.0; - //block->maxx += 2.0; block->maxy += 2.0; + //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0; + //block->rect.xmax += 2.0; block->rect.ymax += 2.0; - xsize = block->maxx - block->minx + 4; // 4 for shadow - ysize = block->maxy - block->miny + 4; + xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */ + ysize = BLI_RCT_SIZE_Y(&block->rect) + 4; /* aspect /= (float)xsize;*/ /*UNUSED*/ { @@ -1428,20 +1418,20 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } if (dir1 == UI_LEFT) { - xof = butrct.xmin - block->maxx; - if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center; - else yof = butrct.ymax - block->maxy + center; + xof = butrct.xmin - block->rect.xmax; + if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center; + else yof = butrct.ymax - block->rect.ymax + center; } else if (dir1 == UI_RIGHT) { - xof = butrct.xmax - block->minx; - if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center; - else yof = butrct.ymax - block->maxy + center; + xof = butrct.xmax - block->rect.xmin; + if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center; + else yof = butrct.ymax - block->rect.ymax + center; } else if (dir1 == UI_TOP) { - yof = butrct.ymax - block->miny; - if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx; - else xof = butrct.xmin - block->minx; - // changed direction? + yof = butrct.ymax - block->rect.ymin; + if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; + else xof = butrct.xmin - block->rect.xmin; + /* changed direction? */ if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) xof += dir2 == UI_LEFT ? 25 : -25; @@ -1449,10 +1439,10 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, } } else if (dir1 == UI_DOWN) { - yof = butrct.ymin - block->maxy; - if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx; - else xof = butrct.xmin - block->minx; - // changed direction? + yof = butrct.ymin - block->rect.ymax; + if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax; + else xof = butrct.xmin - block->rect.xmin; + /* changed direction? */ if ((dir1 & block->direction) == 0) { if (block->direction & UI_SHIFT_FLIPPED) xof += dir2 == UI_LEFT ? 25 : -25; @@ -1463,7 +1453,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* and now we handle the exception; no space below or to top */ if (top == 0 && down == 0) { if (dir1 == UI_LEFT || dir1 == UI_RIGHT) { - // align with bottom of screen + /* align with bottom of screen */ // yof= ysize; (not with menu scrolls) } } @@ -1471,77 +1461,71 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* or no space left or right */ if (left == 0 && right == 0) { if (dir1 == UI_TOP || dir1 == UI_DOWN) { - // align with left size of screen - xof = -block->minx + 5; + /* align with left size of screen */ + xof = -block->rect.xmin + 5; } } - // apply requested offset in the block + /* apply requested offset in the block */ xof += block->xofs / block->aspect; yof += block->yofs / block->aspect; #if 0 /* clamp to window bounds, could be made into an option if its ever annoying */ - if ( (offscreen = (block->miny + yof)) < 0) yof -= offscreen; /* bottom */ - else if ((offscreen = (block->maxy + yof) - winy) > 0) yof -= offscreen; /* top */ - if ( (offscreen = (block->minx + xof)) < 0) xof -= offscreen; /* left */ - else if ((offscreen = (block->maxx + xof) - winx) > 0) xof -= offscreen; /* right */ + if ( (offscreen = (block->rect.ymin + yof)) < 0) yof -= offscreen; /* bottom */ + else if ((offscreen = (block->rect.ymax + yof) - winy) > 0) yof -= offscreen; /* top */ + if ( (offscreen = (block->rect.xmin + xof)) < 0) xof -= offscreen; /* left */ + else if ((offscreen = (block->rect.xmax + xof) - winx) > 0) xof -= offscreen; /* right */ #endif } /* apply offset, buttons in window coords */ for (bt = block->buttons.first; bt; bt = bt->next) { - ui_block_to_window_fl(butregion, but->block, &bt->x1, &bt->y1); - ui_block_to_window_fl(butregion, but->block, &bt->x2, &bt->y2); + ui_block_to_window_fl(butregion, but->block, &bt->rect.xmin, &bt->rect.ymin); + ui_block_to_window_fl(butregion, but->block, &bt->rect.xmax, &bt->rect.ymax); - bt->x1 += xof; - bt->x2 += xof; - bt->y1 += yof; - bt->y2 += yof; + BLI_rctf_translate(&bt->rect, xof, yof); - bt->aspect = 1.0; - // ui_check_but recalculates drawstring size in pixels + bt->aspect = 1.0f; + /* ui_check_but recalculates drawstring size in pixels */ ui_check_but(bt); } - block->minx += xof; - block->miny += yof; - block->maxx += xof; - block->maxy += yof; + BLI_rctf_translate(&block->rect, xof, yof); /* safety calculus */ if (but) { - float midx = (butrct.xmin + butrct.xmax) / 2.0f; - float midy = (butrct.ymin + butrct.ymax) / 2.0f; + const float midx = BLI_RCT_CENTER_X(&butrct); + const float midy = BLI_RCT_CENTER_Y(&butrct); /* when you are outside parent button, safety there should be smaller */ /* parent button to left */ - if (midx < block->minx) block->safety.xmin = block->minx - 3; - else block->safety.xmin = block->minx - 40; + if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3; + else block->safety.xmin = block->rect.xmin - 40; /* parent button to right */ - if (midx > block->maxx) block->safety.xmax = block->maxx + 3; - else block->safety.xmax = block->maxx + 40; + if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3; + else block->safety.xmax = block->rect.xmax + 40; /* parent button on bottom */ - if (midy < block->miny) block->safety.ymin = block->miny - 3; - else block->safety.ymin = block->miny - 40; + if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3; + else block->safety.ymin = block->rect.ymin - 40; /* parent button on top */ - if (midy > block->maxy) block->safety.ymax = block->maxy + 3; - else block->safety.ymax = block->maxy + 40; + if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3; + else block->safety.ymax = block->rect.ymax + 40; /* exception for switched pulldowns... */ if (dir1 && (dir1 & block->direction) == 0) { - if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3; - if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3; + if (dir2 == UI_RIGHT) block->safety.xmax = block->rect.xmax + 3; + if (dir2 == UI_LEFT) block->safety.xmin = block->rect.xmin - 3; } block->direction = dir1; } else { - block->safety.xmin = block->minx - 40; - block->safety.ymin = block->miny - 40; - block->safety.xmax = block->maxx + 40; - block->safety.ymax = block->maxy + 40; + 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 */ @@ -1568,15 +1552,15 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block) wm_window_get_size(window, &winx, &winy); - if (block->minx < MENU_SHADOW_SIDE) - block->minx = MENU_SHADOW_SIDE; - if (block->maxx > winx - MENU_SHADOW_SIDE) - block->maxx = winx - MENU_SHADOW_SIDE; + if (block->rect.xmin < MENU_SHADOW_SIDE) + block->rect.xmin = MENU_SHADOW_SIDE; + if (block->rect.xmax > winx - MENU_SHADOW_SIDE) + block->rect.xmax = winx - MENU_SHADOW_SIDE; - if (block->miny < MENU_SHADOW_BOTTOM) - block->miny = MENU_SHADOW_BOTTOM; - if (block->maxy > winy - MENU_TOP) - block->maxy = winy - MENU_TOP; + if (block->rect.ymin < MENU_SHADOW_BOTTOM) + block->rect.ymin = MENU_SHADOW_BOTTOM; + if (block->rect.ymax > winy - MENU_TOP) + block->rect.ymax = winy - MENU_TOP; } void ui_popup_block_scrolltest(uiBlock *block) @@ -1595,25 +1579,25 @@ void ui_popup_block_scrolltest(uiBlock *block) /* mark buttons that are outside boundary and the ones next to it for arrow(s) */ for (bt = block->buttons.first; bt; bt = bt->next) { - if (bt->y1 < block->miny) { + if (bt->rect.ymin < block->rect.ymin) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPBOTTOM; /* make space for arrow */ - if (bt->y2 < block->miny + 10) { - if (is_flip && bt->next && bt->next->y1 > bt->y1) + if (bt->rect.ymax < block->rect.ymin + 10) { + if (is_flip && bt->next && bt->next->rect.ymin > bt->rect.ymin) bt->next->flag |= UI_SCROLLED; - else if (!is_flip && bt->prev && bt->prev->y1 > bt->y1) + else if (!is_flip && bt->prev && bt->prev->rect.ymin > bt->rect.ymin) bt->prev->flag |= UI_SCROLLED; } } - if (bt->y2 > block->maxy) { + if (bt->rect.ymax > block->rect.ymax) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPTOP; /* make space for arrow */ - if (bt->y1 > block->maxy - 10) { - if (!is_flip && bt->next && bt->next->y2 < bt->y2) + if (bt->rect.ymin > block->rect.ymax - 10) { + if (!is_flip && bt->next && bt->next->rect.ymax < bt->rect.ymax) bt->next->flag |= UI_SCROLLED; - else if (is_flip && bt->prev && bt->prev->y2 < bt->y2) + else if (is_flip && bt->prev && bt->prev->rect.ymax < bt->rect.ymax) bt->prev->flag |= UI_SCROLLED; } } @@ -1628,7 +1612,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut static ARegionType type; ARegion *ar; uiBlock *block; - uiBut *bt; uiPopupBlockHandle *handle; uiSafetyRct *saferct; @@ -1691,22 +1674,12 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut /* the block and buttons were positioned in window space as in 2.4x, now * these menu blocks are regions so we bring it back to region space. * additionally we add some padding for the menu shadow or rounded menus */ - ar->winrct.xmin = block->minx - MENU_SHADOW_SIDE; - ar->winrct.xmax = block->maxx + MENU_SHADOW_SIDE; - ar->winrct.ymin = block->miny - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = block->maxy + MENU_TOP; + ar->winrct.xmin = block->rect.xmin - MENU_SHADOW_SIDE; + ar->winrct.xmax = block->rect.xmax + MENU_SHADOW_SIDE; + ar->winrct.ymin = block->rect.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.ymax = block->rect.ymax + MENU_TOP; - block->minx -= ar->winrct.xmin; - block->maxx -= ar->winrct.xmin; - block->miny -= ar->winrct.ymin; - block->maxy -= ar->winrct.ymin; - - for (bt = block->buttons.first; bt; bt = bt->next) { - bt->x1 -= ar->winrct.xmin; - bt->x2 -= ar->winrct.xmin; - bt->y1 -= ar->winrct.ymin; - bt->y2 -= ar->winrct.ymin; - } + ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); block->flag |= UI_BLOCK_LOOP; @@ -2368,7 +2341,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi if (pup->but) { /* minimum width to enforece */ - minwidth = pup->but->x2 - pup->but->x1; + minwidth = BLI_RCT_SIZE_X(&pup->but->rect); if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction = UI_DOWN; @@ -2410,15 +2383,15 @@ 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->x1 + 0.8f * (bt->x2 - bt->x1)); - offset[1] = -(bt->y1 + 0.5f * UI_UNIT_Y); + offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)); + offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); } else { /* position mouse at 0.8*width of the button and below the tile * on the first item */ offset[0] = 0; for (bt = block->buttons.first; bt; bt = bt->next) - offset[0] = mini(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1))); + offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect))); offset[1] = 1.5 * UI_UNIT_Y; } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 779341160c5..ee0613ea0d0 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 * (rect->ymax - rect->ymin - height)); + yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height)); if (fs->align == UI_STYLE_TEXT_CENTER) { - xofs = floor(0.5f * (rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str))); + xofs = floor(0.5f * (BLI_RCT_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 = rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1; + xofs = BLI_RCT_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 * (rect->ymax - rect->ymin - height)); + xofs = ceil(0.5f * (BLI_RCT_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 - (rect->ymax - rect->ymin); - txtrect.ymin = rect->ymin - (rect->xmax - rect->xmin); + txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect); + txtrect.ymin = rect->ymin - BLI_RCT_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 9207a6ff3b8..71c019ae29e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -40,6 +40,7 @@ #include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_ghash.h" +#include "BLI_rect.h" #include "BLF_translation.h" @@ -1378,7 +1379,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 = (butr->xmax - butr->xmin) / 14.0f; + float unit = BLI_RCT_SIZE_X(butr) / 14.0f; float xs = butr->xmin; uiBlockBeginAlign(block); @@ -1404,7 +1405,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, butr->xmax - butr->xmin, UI_UNIT_Y, coba, 0, 0, 0, 0, ""); + bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); uiBlockEndAlign(block); @@ -1479,7 +1480,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, rect.xmax - rect.xmin, hist->height, hist, 0, 0, 0, 0, ""); + bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1516,8 +1517,8 @@ 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, rect.xmax - rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); - (void)bt; // UNUSED + bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); + (void)bt; /* UNUSED */ MEM_freeN(cb); } @@ -1553,7 +1554,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, rect.xmax - rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); + bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); MEM_freeN(cb); @@ -1568,11 +1569,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar float d; /* we allow 20 times zoom */ - if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f * (cumap->clipr.xmax - cumap->clipr.xmin) ) { - d = 0.1154f * (cumap->curr.xmax - cumap->curr.xmin); + if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) { + d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr); cumap->curr.xmin += d; cumap->curr.xmax -= d; - d = 0.1154f * (cumap->curr.ymax - cumap->curr.ymin); + d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr); cumap->curr.ymin += d; cumap->curr.ymax -= d; } @@ -1586,8 +1587,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 ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f * (cumap->clipr.xmax - cumap->clipr.xmin) ) { - d = d1 = 0.15f * (cumap->curr.xmax - cumap->curr.xmin); + 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 (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.xmin - d < cumap->clipr.xmin) @@ -1600,7 +1601,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 * (cumap->curr.ymax - cumap->curr.ymin); + d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr); if (cumap->flag & CUMA_DO_CLIP) if (cumap->curr.ymin - d < cumap->clipr.ymin) @@ -1621,7 +1622,7 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); } static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) @@ -1629,7 +1630,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) CurveMapping *cumap = cumap_v; curvemap_remove(cumap->cm + cumap->cur, SELECT); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); rna_update_cb(C, cb_v, NULL); } @@ -1671,26 +1672,26 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) switch (event) { case 0: /* reset */ curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 1: cumap->curr = cumap->clipr; break; case 2: /* set vector */ curvemap_sethandle(cuma, 1); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 3: /* set auto */ curvemap_sethandle(cuma, 0); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 4: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; case 5: /* extend extrapolate */ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); break; } ED_region_tag_redraw(CTX_wm_region(C)); @@ -1756,7 +1757,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; curvemapping_set_black_white(cumap, NULL, NULL); - curvemapping_changed(cumap, 0); + curvemapping_changed(cumap, FALSE); rna_update_cb(C, cb_v, NULL); } @@ -2315,7 +2316,6 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype) { - //Scene *scene = CTX_data_scene(C); PropertyRNA *prop = NULL, *activeprop; PropertyType type, activetype; StructRNA *ptype; @@ -2571,7 +2571,7 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event) WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL); break; case B_STOPCOMPO: - WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL); + WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL); break; case B_STOPSEQ: WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL); @@ -2596,36 +2596,37 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiBlockSetHandleFunc(block, do_running_jobs, NULL); - if (sa->spacetype == SPACE_NODE) { - if (WM_jobs_test(wm, sa)) - owner = sa; - handle_event = B_STOPCOMPO; - } - else if (sa->spacetype == SPACE_SEQ) { - if (WM_jobs_test(wm, sa)) + if (sa->spacetype == SPACE_SEQ) { + if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) owner = sa; handle_event = B_STOPSEQ; } else if (sa->spacetype == SPACE_CLIP) { - if (WM_jobs_test(wm, sa)) + if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) owner = sa; handle_event = B_STOPCLIP; } else { Scene *scene; /* another scene can be rendering too, for example via compositor */ - for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) - if (WM_jobs_test(wm, scene)) + for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) { + if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) { + handle_event = B_STOPRENDER; break; + } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { + handle_event = B_STOPCOMPO; + break; + } + } owner = scene; - handle_event = B_STOPRENDER; } if (owner) { uiLayout *ui_abs; ui_abs = uiLayoutAbsolute(layout, FALSE); - (void)ui_abs; // UNUSED + (void)ui_abs; /* UNUSED */ uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); @@ -2634,7 +2635,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiLayoutRow(layout, FALSE); } - if (WM_jobs_test(wm, screen)) + if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); if (screen->animtimer) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b439271b23d..ef8d8302fa7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -260,8 +260,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r rad += step; - if (2.0f * rad > rect->ymax - rect->ymin) - rad = 0.5f * (rect->ymax - rect->ymin); + if (2.0f * rad > BLI_RCT_SIZE_Y(rect)) + rad = 0.5f * BLI_RCT_SIZE_Y(rect); minx = rect->xmin - step; miny = rect->ymin - step; @@ -346,8 +346,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((rect->xmax - rect->xmin) * hnum, - (rect->ymax - rect->ymin) * vnum); + minsize = mini(BLI_RCT_SIZE_X(rect) * hnum, + BLI_RCT_SIZE_Y(rect) * vnum); if (2.0f * rad > minsize) rad = 0.5f * minsize; @@ -492,7 +492,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 = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin); + minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -527,7 +527,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 = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin); + minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -571,14 +571,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmax - 0.5f * (rect->ymax - rect->ymin); - centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin); - size = 0.4f * (rect->ymax - rect->ymin); + 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); /* XXX exception */ - asp = ((float)rect->xmax - rect->xmin) / ((float)rect->ymax - rect->ymin); + asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect)); if (asp > 1.2f && asp < 2.6f) - centx = rect->xmax - 0.3f * (rect->ymax - rect->ymin); + centx = rect->xmax - 0.3f * BLI_RCT_SIZE_Y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * menu_tria_vert[a][0] + centx; @@ -595,9 +595,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmin + 0.5f * (rect->ymax - rect->ymin); - centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin); - size = 0.5f * (rect->ymax - rect->ymin); + 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); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * check_tria_vert[a][0] + centx; @@ -841,8 +841,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) if (icon == ICON_NONE) return; - w = rect->xmax - rect->xmin; - h = rect->ymax - rect->ymin; + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); size = MIN2(w, h); size -= PREVIEW_PAD * 2; /* padding */ @@ -970,7 +970,7 @@ static void ui_text_clip_give_next_off(uiBut *but) static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = rect->xmax - rect->xmin - border; + int okwidth = BLI_RCT_SIZE_X(rect) - border; if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; @@ -1033,7 +1033,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = rect->xmax - rect->xmin - border; + int okwidth = BLI_RCT_SIZE_X(rect) - border; char *cpoin = NULL; char *cpend = but->drawstr + strlen(but->drawstr); @@ -1095,7 +1095,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { -// int transopts; + //int transopts; // UNUSED char *cpoin = NULL; /* for underline drawing */ @@ -1170,7 +1170,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #if 0 ui_rasterpos_safe(x, y, but->aspect); - if (but->type == IDPOIN) transopts = 0; // no translation, of course! + if (but->type == IDPOIN) transopts = 0; /* no translation, of course! */ else transopts = ui_translate_buttons(); #endif @@ -1265,7 +1265,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; - rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1; + rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1; widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); rect->xmin = tmp; } @@ -1654,13 +1654,13 @@ static void widget_state(uiWidgetType *wt, int state) static void widget_state_numslider(uiWidgetType *wt, int state) { uiWidgetStateColors *wcol_state = wt->wcol_state; - float blend = wcol_state->blend - 0.2f; // XXX special tweak to make sure that bar will still be visible + float blend = wcol_state->blend - 0.2f; /* XXX special tweak to make sure that bar will still be visible */ /* call this for option button */ widget_state(wt, state); /* now, set the inner-part so that it reflects state settings too */ - // TODO: maybe we should have separate settings for the blending colors used for this case? + /* TODO: maybe we should have separate settings for the blending colors used for this case? */ if (state & UI_SELECT) { if (state & UI_BUT_ANIMATED_KEY) @@ -1760,8 +1760,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 * (rect1.ymax - rect1.ymin) ) - rect1.ymax -= 0.2f * (rect1.ymax - rect1.ymin); + if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1)) + rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1); else rect1.ymax -= 2.0f * radout; @@ -1843,14 +1843,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 = (float)(rect->xmin + rect->xmax) / 2; - float centy = (float)(rect->ymin + rect->ymax) / 2; + float centx = BLI_RCT_CENTER_X_FL(rect); + float centy = BLI_RCT_CENTER_Y_FL(rect); float radius, dist; - if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) - radius = (float)(rect->ymax - rect->ymin) / 2; + if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) + radius = (float)BLI_RCT_SIZE_Y(rect) / 2; else - radius = (float)(rect->xmax - rect->xmin) / 2; + radius = (float)BLI_RCT_SIZE_X(rect) / 2; mx -= centx; my -= centy; @@ -1876,13 +1876,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) color_profile = BLI_PR_NONE; radstep = 2.0f * (float)M_PI / (float)tot; - centx = (float)(rect->xmin + rect->xmax) / 2; - centy = (float)(rect->ymin + rect->ymax) / 2; + centx = BLI_RCT_CENTER_X_FL(rect); + centy = BLI_RCT_CENTER_Y_FL(rect); - if (rect->xmax - rect->xmin > rect->ymax - rect->ymin) - radius = (float)(rect->ymax - rect->ymin) / 2; + if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) + radius = (float)BLI_RCT_SIZE_Y(rect) / 2; else - radius = (float)(rect->xmax - rect->xmin) / 2; + radius = (float)BLI_RCT_SIZE_X(rect) / 2; /* color */ ui_get_but_vectorf(but, rgb); @@ -2007,13 +2007,13 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa /* old below */ for (dx = 0.0f; dx < 1.0f; dx += color_step) { - // previous color + /* previous color */ copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); copy_v3_v3(col0[2], col1[2]); copy_v3_v3(col0[3], col1[3]); - // new color + /* new color */ switch (type) { case UI_GRAD_SV: hsv_to_rgb(h, 0.0, dx, &col1[0][0], &col1[0][1], &col1[0][2]); @@ -2057,11 +2057,11 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa break; } - // rect - sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); - sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); + /* rect */ + sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect); + sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect); sy = rect->ymin; - dy = (rect->ymax - rect->ymin) / 3.0; + dy = BLI_RCT_SIZE_Y(rect) / 3.0; glBegin(GL_QUADS); for (a = 0; a < 3; a++, sy += dy) { @@ -2116,8 +2116,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) } /* cursor */ - x = rect->xmin + x * (rect->xmax - rect->xmin); - y = rect->ymin + y * (rect->ymax - rect->ymin); + x = rect->xmin + x * BLI_RCT_SIZE_X(rect); + y = rect->ymin + y * BLI_RCT_SIZE_Y(rect); CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); @@ -2132,7 +2132,7 @@ 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 * (rect->xmax - rect->xmin); + float rad = 0.5f * BLI_RCT_SIZE_X(rect); float x, y; float rgb[3], hsv[3], v, range; int color_profile = but->block->color_profile; @@ -2166,8 +2166,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) widgetbase_draw(&wtb, &wcol_tmp); /* cursor */ - x = rect->xmin + 0.5f * (rect->xmax - rect->xmin); - y = rect->ymin + v * (rect->ymax - rect->ymin); + x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect); + y = rect->ymin + v * BLI_RCT_SIZE_Y(rect); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); ui_hsv_cursor(x, y); @@ -2178,7 +2178,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 + (rect->ymax - rect->ymin) / 2 - 1; + int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1; unsigned char col[4]; col[0] = wcol->text[0]; @@ -2197,7 +2197,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 * (rect->ymax - rect->ymin); + float rad = 0.5f * BLI_RCT_SIZE_Y(rect); float textofs = rad * 0.75f; if (state & UI_SELECT) @@ -2221,7 +2221,6 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round rect->xmax -= textofs; } -//static int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol) int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol) { float dist, vec[4][2]; @@ -2252,7 +2251,7 @@ void ui_draw_link_bezier(rcti *rect) if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { /* we can reuse the dist variable here to increment the GL curve eval amount*/ - // const float dist = 1.0f/(float)LINK_RESOL; // UNUSED + // const float dist = 1.0f / (float)LINK_RESOL; // UNUSED glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -2279,12 +2278,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widget_init(&wtb); /* determine horizontal/vertical */ - horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin); + horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); if (horizontal) - rad = 0.5f * (rect->ymax - rect->ymin); + rad = 0.5f * BLI_RCT_SIZE_Y(rect); else - rad = 0.5f * (rect->xmax - rect->xmin); + rad = 0.5f * BLI_RCT_SIZE_X(rect); wtb.shadedir = (horizontal) ? 1 : 0; @@ -2296,9 +2295,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widgetbase_draw(&wtb, wcol); /* slider */ - if (slider->xmax - slider->xmin < 2 || slider->ymax - slider->ymin < 2) ; + if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) { + /* pass */ + } else { - SWAP(short, wcol->shadetop, wcol->shadedown); copy_v4_v4_char(wcol->inner, wcol->item); @@ -2361,34 +2361,34 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1 = *rect; /* determine horizontal/vertical */ - horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin); + horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); if (horizontal) { - fac = (rect->xmax - rect->xmin) / (size); + fac = BLI_RCT_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 = rect->ymax - rect->ymin; + min = BLI_RCT_SIZE_Y(rect); - if (rect1.xmax - rect1.xmin < min) { + if (BLI_RCT_SIZE_X(&rect1) < min) { rect1.xmax = rect1.xmin + min; if (rect1.xmax > rect->xmax) { rect1.xmax = rect->xmax; - rect1.xmin = MAX2(rect1.xmax - min, rect->xmin); + rect1.xmin = maxi(rect1.xmax - min, rect->xmin); } } } else { - fac = (rect->ymax - rect->ymin) / (size); + fac = BLI_RCT_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 = rect->xmax - rect->xmin; + min = BLI_RCT_SIZE_X(rect); - if (rect1.ymax - rect1.ymin < min) { + if (BLI_RCT_SIZE_Y(&rect1) < min) { rect1.ymax = rect1.ymin + min; if (rect1.ymax > rect->ymax) { @@ -2416,10 +2416,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 * (rect_prog.xmax - rect_prog.xmin); + w = value * BLI_RCT_SIZE_X(&rect_prog); /* ensure minimium size */ - min = rect_prog.ymax - rect_prog.ymin; + min = BLI_RCT_SIZE_Y(&rect_prog); w = MAX2(w, min); rect_bar.xmax = rect_bar.xmin + w; @@ -2439,8 +2439,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in UI_ThemeColor(TH_TEXT_HI); - rectlink.xmin = (rect->xmin + rect->xmax) / 2; - rectlink.ymin = (rect->ymin + rect->ymax) / 2; + rectlink.xmin = BLI_RCT_CENTER_X(rect); + rectlink.ymin = BLI_RCT_CENTER_Y(rect); rectlink.xmax = but->linkto[0]; rectlink.ymax = but->linkto[1]; @@ -2462,7 +2462,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* backdrop first */ /* fully rounded */ - offs = 0.5f * (rect->ymax - rect->ymin); + offs = 0.5f * BLI_RCT_SIZE_Y(rect); toffs = offs * 0.75f; round_box_edges(&wtb, roundboxalign, rect, offs); @@ -2483,7 +2483,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) * (rect1.xmax - rect1.xmin - offs) / (but->softmax - but->softmin); + fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax = rect1.xmin + ceil(offs + 1.0f); @@ -2616,7 +2616,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmax -= (rect->ymax - rect->ymin); + rect->xmax -= BLI_RCT_SIZE_Y(rect); } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -2659,7 +2659,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if (state & UI_ACTIVE) { uiWidgetBase wtb; - float rad = 0.5f * (rect->ymax - rect->ymin); // 4.0f + float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */ widget_init(&wtb); @@ -2705,10 +2705,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widget_init(&wtb); /* square */ - recttemp.xmax = recttemp.xmin + (recttemp.ymax - recttemp.ymin); + recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp); /* smaller */ - delta = 1 + (recttemp.ymax - recttemp.ymin) / 8; + delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8; recttemp.xmin += delta; recttemp.ymin += delta; recttemp.xmax -= delta; @@ -2725,7 +2725,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmin += (rect->ymax - rect->ymin) * 0.7 + delta; + rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta; } @@ -2787,7 +2787,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*(rect->ymax - rect->ymin); + float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */ widget_init(&wtb); @@ -3176,10 +3176,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; case HSVCUBE: - if (but->a1 == UI_GRAD_V_ALT) // vertical V slider, uses new widget draw now + if (but->a1 == UI_GRAD_V_ALT) { /* vertical V slider, uses new widget draw now */ ui_draw_but_HSV_v(but, rect); - else // other HSV pickers... + } + else { /* other HSV pickers... */ ui_draw_but_HSVCUBE(but, rect); + } break; case HSVCIRCLE: @@ -3268,12 +3270,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((rect->xmax + rect->xmin) / 2, rect->ymax - 8, 't'); + UI_DrawTriIcon(BLI_RCT_CENTER_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((rect->xmax + rect->xmin) / 2, rect->ymin + 10, 'v'); + UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v'); } } } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 0ff81f27f6b..ed6b2e00119 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -643,9 +643,7 @@ void ui_theme_init_default(void) bTheme *btheme; /* we search for the theme with name Default */ - for (btheme = U.themes.first; btheme; btheme = btheme->next) { - if (strcmp("Default", btheme->name) == 0) break; - } + btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); if (btheme == NULL) { btheme = MEM_callocN(sizeof(bTheme), "theme"); @@ -1969,6 +1967,10 @@ void init_userdef_do_versions(void) U.ndof_flag = NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; } + + if (U.ndof_orbit_sensitivity == 0.0f) { + U.ndof_orbit_sensitivity = 1.0f; + } if (U.tweak_threshold == 0) U.tweak_threshold = 10; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8ae08c08693..c3059b8d575 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 (v2d->tot.xmax - v2d->tot.xmin <= v2d->cur.xmax - v2d->cur.xmin) + if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur)) v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; if (v2d->scroll & V2D_SCROLL_VERTICAL) if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) - if (v2d->tot.ymax - v2d->tot.ymin <= v2d->cur.ymax - v2d->cur.ymin) + if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_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)(v2d->mask.xmax - v2d->mask.xmin + 1); - winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + winy = (float)(BLI_RCT_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 = tot->xmax - tot->xmin; - totheight = tot->ymax - tot->ymin; - curwidth = width = cur->xmax - cur->xmin; - curheight = height = cur->ymax - cur->ymin; + 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); /* 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 - (cur->xmax - cur->xmin); + cur->xmax += width - BLI_RCT_SIZE_X(cur); } else if (v2d->keepofs & V2D_KEEPOFS_X) { if (v2d->align & V2D_ALIGN_NO_POS_X) - cur->xmin -= width - (cur->xmax - cur->xmin); + cur->xmin -= width - BLI_RCT_SIZE_X(cur); else - cur->xmax += width - (cur->xmax - cur->xmin); + cur->xmax += width - BLI_RCT_SIZE_X(cur); } else { - temp = (cur->xmax + cur->xmin) * 0.5f; + temp = BLI_RCT_CENTER_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 - (cur->ymax - cur->ymin); + cur->ymax += height - BLI_RCT_SIZE_Y(cur); } else if (v2d->keepofs & V2D_KEEPOFS_Y) { if (v2d->align & V2D_ALIGN_NO_POS_Y) - cur->ymin -= height - (cur->ymax - cur->ymin); + cur->ymin -= height - BLI_RCT_SIZE_Y(cur); else - cur->ymax += height - (cur->ymax - cur->ymin); + cur->ymax += height - BLI_RCT_SIZE_Y(cur); } else { - temp = (cur->ymax + cur->ymin) * 0.5f; + temp = BLI_RCT_CENTER_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 = cur->xmax - cur->xmin; - curheight = cur->ymax - cur->ymin; + curwidth = BLI_RCT_SIZE_X(cur); + curheight = BLI_RCT_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 = (tot->xmax + tot->xmin) * 0.5f; + temp = BLI_RCT_CENTER_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 = (tot->ymax + tot->ymin) * 0.5f; + temp = BLI_RCT_CENTER_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)(v2d->mask.xmax - v2d->mask.xmin + 1); - height = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + width = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + height = (float)(BLI_RCT_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)) { @@ -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 = (v2d->cur.xmax - v2d->cur.xmin) / ((float)(v2d->mask.xmax - v2d->mask.xmin + 1)); - float dy = (v2d->cur.ymax - v2d->cur.ymin) / ((float)(v2d->mask.ymax - v2d->mask.ymin + 1)); + 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)); if (v2d->mask.xmin != 0) curmasked->xmin -= dx * (float)v2d->mask.xmin; @@ -985,8 +985,8 @@ 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 * (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); - yofs = 0.001f * (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin); + 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); /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); @@ -1044,8 +1044,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 = ar->winrct.xmax - ar->winrct.xmin + 1; - int height = ar->winrct.ymax - ar->winrct.ymin + 1; + int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); glLoadIdentity(); @@ -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 = v2d->cur.xmax - v2d->cur.xmin; - pixels = (float)(v2d->mask.xmax - v2d->mask.xmin); + space = BLI_RCT_SIZE_X(&v2d->cur); + pixels = (float)BLI_RCT_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 = v2d->cur.ymax - v2d->cur.ymin; + space = BLI_RCT_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 = (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize; + step = (BLI_RCT_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 = (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize; + step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a = 0; a <= step; a++) { @@ -1457,8 +1457,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* horizontal scrollers */ if (scroll & V2D_SCROLL_HORIZONTAL) { /* scroller 'button' extents */ - totsize = v2d->tot.xmax - v2d->tot.xmin; - scrollsize = (float)(hor.xmax - hor.xmin); + totsize = BLI_RCT_SIZE_X(&v2d->tot); + scrollsize = (float)BLI_RCT_SIZE_X(&hor); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize; @@ -1498,8 +1498,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* vertical scrollers */ if (scroll & V2D_SCROLL_VERTICAL) { /* scroller 'button' extents */ - totsize = v2d->tot.ymax - v2d->tot.ymin; - scrollsize = (float)(vert.ymax - vert.ymin); + totsize = BLI_RCT_SIZE_Y(&v2d->tot); + scrollsize = (float)BLI_RCT_SIZE_Y(&vert); if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize; @@ -1545,7 +1545,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short scrollers->yclamp = yclamp; scrollers->yunits = yunits; - scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin)); + 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)); } /* return scrollers */ @@ -1629,7 +1631,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) && - (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1649,11 +1651,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) / (v2d->cur.xmax - v2d->cur.xmin); - fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin); + fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor); - dfac = (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin); - dfac = dfac * (hor.xmax - hor.xmin); + dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur); + dfac = dfac * BLI_RCT_SIZE_X(&hor); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -1740,7 +1742,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) && - (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE)) + (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE)) { state |= UI_SCROLL_ARROWS; } @@ -1763,11 +1765,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) / (v2d->cur.ymax - v2d->cur.ymin); - fac = vert.ymin + fac * (vert.ymax - vert.ymin); + fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); + fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert); - dfac = (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin); - dfac = dfac * (vert.ymax - vert.ymin); + dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur); + dfac = dfac * BLI_RCT_SIZE_Y(&vert); /* set starting value, and text color */ UI_ThemeColor(TH_TEXT); @@ -1925,17 +1927,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)(v2d->mask.xmax - v2d->mask.xmin); + div = (float)BLI_RCT_SIZE_X(&v2d->mask); ofs = (float)v2d->mask.xmin; - *r_viewx = v2d->cur.xmin + (v2d->cur.xmax - v2d->cur.xmin) * ((float)x - ofs) / div; + *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div; } if (r_viewy) { - div = (float)(v2d->mask.ymax - v2d->mask.ymin); + div = (float)BLI_RCT_SIZE_Y(&v2d->mask); ofs = (float)v2d->mask.ymin; - *r_viewy = v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div; + *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div; } } @@ -1954,15 +1956,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) / (v2d->cur.xmax - v2d->cur.xmin); - y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_RCT_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 * (v2d->mask.xmax - v2d->mask.xmin)); + *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask)); if (regiony) - *regiony = (int)(v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin)); + *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask)); } } @@ -1975,12 +1977,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) / (v2d->cur.xmax - v2d->cur.xmin); - y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); + y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); /* step 2: convert proportional distances to screen coordinates */ - x = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin); - y = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin); + x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); + y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); /* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */ if (regionx) { @@ -2033,8 +2035,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C) */ void UI_view2d_getscale(View2D *v2d, float *x, float *y) { - if (x) *x = (v2d->mask.xmax - v2d->mask.xmin) / (v2d->cur.xmax - v2d->cur.xmin); - if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin); + 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); } /* Check if mouse is within scrollers @@ -2140,7 +2142,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height)); + yofs = ceil(0.5f * (BLI_RCT_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 33b72b34784..cc2ca5c5475 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)(ar->winrct.xmax - ar->winrct.xmin + 1); - winy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1); - vpd->facx = (v2d->cur.xmax - v2d->cur.xmin) / winx; - vpd->facy = (v2d->cur.ymax - v2d->cur.ymin) / winy; + 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; 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", ar->v2d.mask.ymax - ar->v2d.mask.ymin); + RNA_int_set(op->ptr, "deltay", BLI_RCT_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 = (v2d->cur.xmax - v2d->cur.xmin) * facx; - dy = (v2d->cur.ymax - v2d->cur.ymin) * facy; + dx = BLI_RCT_SIZE_X(&v2d->cur) * facx; + dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy; } else { - dx = ((v2d->cur.xmax - v2d->cur.xmin) / (1.0f + 2.0f * facx)) * facx; - dy = ((v2d->cur.ymax - v2d->cur.ymin) / (1.0f + 2.0f * facy)) * facy; + 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; } /* 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) / (v2d->cur.xmax - v2d->cur.xmin); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_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) / (v2d->cur.ymax - v2d->cur.ymin); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -672,13 +672,22 @@ static void view_zoomstep_exit(wmOperator *op) /* this operator only needs this single callback, where it calls the view_zoom_*() methods */ static int view_zoomin_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + short do_zoom_x = TRUE; + short do_zoom_y = TRUE; + /* check that there's an active region, as View2D data resides there */ if (!view_zoom_poll(C)) return OPERATOR_PASS_THROUGH; + /* default not to zoom the sequencer vertically */ + if (sa && sa->spacetype == SPACE_SEQ) { + do_zoom_y = FALSE; + } + /* set RNA-Props - zooming in by uniform factor */ - RNA_float_set(op->ptr, "zoomfacx", 0.0375f); - RNA_float_set(op->ptr, "zoomfacy", 0.0375f); + RNA_float_set(op->ptr, "zoomfacx", do_zoom_x ? 0.0375f : 0.0f); + RNA_float_set(op->ptr, "zoomfacy", do_zoom_y ? 0.0375f : 0.0f); /* apply movement, then we're done */ view_zoomstep_apply(C, op); @@ -729,13 +738,22 @@ static void VIEW2D_OT_zoom_in(wmOperatorType *ot) /* this operator only needs this single callback, where it callsthe view_zoom_*() methods */ static int view_zoomout_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + short do_zoom_x = TRUE; + short do_zoom_y = TRUE; + /* check that there's an active region, as View2D data resides there */ if (!view_zoom_poll(C)) return OPERATOR_PASS_THROUGH; + /* default not to zoom the sequencer vertically */ + if (sa && sa->spacetype == SPACE_SEQ) { + do_zoom_y = FALSE; + } + /* set RNA-Props - zooming in by uniform factor */ - RNA_float_set(op->ptr, "zoomfacx", -0.0375f); - RNA_float_set(op->ptr, "zoomfacy", -0.0375f); + RNA_float_set(op->ptr, "zoomfacx", do_zoom_x ? -0.0375f : 0.0f); + RNA_float_set(op->ptr, "zoomfacy", do_zoom_y ? -0.0375f : 0.0f); /* apply movement, then we're done */ view_zoomstep_apply(C, op); @@ -821,7 +839,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) / (v2d->cur.xmax - v2d->cur.xmin); + float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); @@ -840,7 +858,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) / (v2d->cur.ymax - v2d->cur.ymin); + float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur); float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); @@ -918,8 +936,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 * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f; - dy = fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f; + dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f; + dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f; RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); @@ -985,14 +1003,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; /* x-axis transform */ - dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f; + dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f; dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f); - dx *= 0.5f * (v2d->cur.xmax - v2d->cur.xmin); + dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur); /* y-axis transform */ - dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f; + dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f; dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f); - dy *= 0.5f * (v2d->cur.ymax - v2d->cur.ymin); + dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur); } else { /* 'continuous' or 'dolly' */ @@ -1000,11 +1018,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* x-axis transform */ fac = 0.01f * (event->x - vzd->lastx); - dx = fac * (v2d->cur.xmax - v2d->cur.xmin); + dx = fac * BLI_RCT_SIZE_X(&v2d->cur); /* y-axis transform */ fac = 0.01f * (event->y - vzd->lasty); - dy = fac * (v2d->cur.ymax - v2d->cur.ymin); + dy = fac * BLI_RCT_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? @@ -1137,17 +1155,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 = (cur_new.xmax - cur_new.xmin); - zoom = size / (rect.xmax - rect.xmin); - center = (cur_new.xmax + cur_new.xmin) * 0.5f; + size = BLI_RCT_SIZE_X(&cur_new); + zoom = size / BLI_RCT_SIZE_X(&rect); + center = BLI_RCT_CENTER_X(&cur_new); cur_new.xmin = center - (size * zoom); cur_new.xmax = center + (size * zoom); } if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { - size = (cur_new.ymax - cur_new.ymin); - zoom = size / (rect.ymax - rect.ymin); - center = (cur_new.ymax + cur_new.ymin) * 0.5f; + size = BLI_RCT_SIZE_Y(&cur_new); + zoom = size / BLI_RCT_SIZE_Y(&rect); + center = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = center - (size * zoom); cur_new.ymax = center + (size * zoom); @@ -1197,14 +1215,14 @@ struct SmoothView2DStore { */ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) { - float size_a[2] = {rect_a->xmax - rect_a->xmin, - rect_a->ymax - rect_a->ymin}; - float size_b[2] = {rect_b->xmax - rect_b->xmin, - rect_b->ymax - rect_b->ymin}; - float cent_a[2] = {(rect_a->xmax + rect_a->xmin) * 0.5f, - (rect_a->ymax + rect_a->ymin) * 0.5f}; - float cent_b[2] = {(rect_b->xmax + rect_b->xmin) * 0.5f, - (rect_b->ymax + rect_b->ymin) * 0.5f}; + 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 fac_max = 0.0f; float tfac; @@ -1477,8 +1495,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)(v2d->hor.xmax - v2d->hor.xmin); - vsm->fac = (v2d->tot.xmax - v2d->tot.xmin) / mask_size; + mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor); + vsm->fac = BLI_RCT_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); @@ -1493,8 +1511,8 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, } else { /* vertical scroller - calculate adjustment factor first */ - mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin); - vsm->fac = (v2d->tot.ymax - v2d->tot.ymin) / mask_size; + mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert); + vsm->fac = BLI_RCT_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); @@ -1774,8 +1792,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) int winx, winy; /* zoom 1.0 */ - winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1); - winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1); + winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1); + winy = (float)(BLI_RCT_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 ebfc0522f17..d0ce3f0cace 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -269,15 +269,15 @@ void WM_OT_collada_export(wmOperatorType *ot) RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer", - "Export textures assigned to the object UV maps"); + "Export textures assigned to the object UV maps"); RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures", - "Export textures assigned to the object UV maps"); + "Export textures assigned to the object UV maps"); RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", - "Export textures assigned to the object Materials"); + "Export textures assigned to the object Materials"); - RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", "Copy textures to same folder where the .dae file is exported"); diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index e9b31b8df1a..b37f758596b 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -180,24 +180,20 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no /******************** add vertex *********************/ -static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, +static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float tangent[2], const float u, - MaskSplinePoint *reference_point, const short reference_adjacent) + MaskSplinePoint *reference_point, const short reference_adjacent, + const float view_zoom) { - ScrArea *sa = CTX_wm_area(C); - MaskSplinePoint *prev_point = NULL; MaskSplinePoint *next_point = NULL; BezTriple *bezt; - int width, height; float co[3]; - const float len = 20.0; /* default length of handle in pixel space */ + const float len = 10.0; /* default length of handle in pixel space */ copy_v2_v2(co, point_co); co[2] = 0.0f; - ED_mask_get_size(sa, &width, &height); - /* point coordinate */ bezt = &new_point->bezt; @@ -225,21 +221,15 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline /* initial offset for handles */ if (spline->tot_point == 1) { /* first point of splien is aligned horizontally */ - bezt->vec[0][0] -= len / width; - bezt->vec[2][0] += len / width; + bezt->vec[0][0] -= len * view_zoom; + bezt->vec[2][0] += len * view_zoom; } else if (tangent) { float vec[2]; copy_v2_v2(vec, tangent); - vec[0] *= width; - vec[1] *= height; - - mul_v2_fl(vec, len / len_v2(vec)); - - vec[0] /= width; - vec[1] /= height; + mul_v2_fl(vec, len); sub_v2_v2(bezt->vec[0], vec); add_v2_v2(bezt->vec[2], vec); @@ -391,7 +381,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2] new_point = &spline->points[point_index + 1]; - setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE); + setup_vertex_point(mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f); /* TODO - we could pass the spline! */ BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE); @@ -490,7 +480,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, masklay->act_point = new_point; - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE); + setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f); if (masklay->splines_shapes.first) { point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); @@ -512,6 +502,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con MaskSpline *spline; MaskSplinePoint *point; MaskSplinePoint *new_point = NULL, *ref_point = NULL; + float view_zoom; if (!masklay) { /* if there's no masklay currently operationg on, create new one */ @@ -536,7 +527,22 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con masklay->act_point = new_point; - setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE); + { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + + float zoom_x, zoom_y; + /* calc view zoom in a simplistic way */ + ED_mask_zoom(sa, ar, &zoom_x, &zoom_y); + + view_zoom = zoom_x + zoom_y / 2.0f; + view_zoom = 1.0f / view_zoom; + + /* arbitrary but gives good results */ + view_zoom /= 500.0f; + } + + setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom); { int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 703ae70eb0f..c6b19e51de9 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_mask.h" @@ -387,7 +388,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point); + feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point, (is_fill != FALSE)); /* draw feather */ mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp); @@ -512,12 +513,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 = v2d->tot.xmax - v2d->tot.xmin; */ - /* h = v2d->tot.ymax - v2d->tot.ymin;/*/ + /* w = BLI_RCT_SIZE_X(&v2d->tot); */ + /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/ - zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)); - zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)); + 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)); if (do_scale_applied) { zoomx /= width; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 285306ce12f..ace427f65ab 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -440,7 +440,7 @@ static int border_select_exec(bContext *C, wmOperator *op) /* TODO: handles? */ /* TODO: uw? */ - if (BLI_in_rctf_v(&rectf, point_deform->bezt.vec[1])) { + if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) { BKE_mask_point_select_set(point, mode == GESTURE_MODAL_SELECT); BKE_mask_point_select_set_handle(point, mode == GESTURE_MODAL_SELECT); } @@ -525,7 +525,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1], &screen_co[0], &screen_co[1]); - if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) { BKE_mask_point_select_set(point, select); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 62600c7fe6b..3431bea18ea 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -570,8 +570,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; char *selar; int a, index; - int sx = rect->xmax - rect->xmin + 1; - int sy = rect->ymax - rect->ymin + 1; + int sx = BLI_RCT_SIZE_X(rect) + 1; + int sy = BLI_RCT_SIZE_Y(rect) + 1; me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 13c48c7f51d..92cc3366b3e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1056,6 +1056,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "edgeout", BM_EDGE, BM_ELEM_SELECT, TRUE); if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; @@ -2042,22 +2043,38 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; + const float mergedist = RNA_float_get(op->ptr, "mergedist"); + int use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); + int totvert_orig = em->bm->totvert; int count; - EDBM_op_init(em, &bmop, op, "find_doubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); - BMO_op_exec(em->bm, &bmop); - - count = BMO_slot_map_count(em->bm, &bmop, "targetmapout"); + if (use_unselected) { + EDBM_op_init(em, &bmop, op, + "automerge verts=%hv dist=%f", + BM_ELEM_SELECT, mergedist); + BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { - BMO_op_finish(em->bm, &bmop); - return OPERATOR_CANCELLED; + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + } } + else { + EDBM_op_init(em, &bmop, op, + "find_doubles verts=%hv dist=%f", + BM_ELEM_SELECT, mergedist); + BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { - return OPERATOR_CANCELLED; + if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { + BMO_op_finish(em->bm, &bmop); + return OPERATOR_CANCELLED; + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + } } + count = totvert_orig - em->bm->totvert; BKE_reportf(op->reports, RPT_INFO, "Removed %d vert%s", count, (count == 1) ? "ex" : "ices"); EDBM_update_generic(C, em, TRUE); @@ -2082,6 +2099,7 @@ void MESH_OT_remove_doubles(wmOperatorType *ot) RNA_def_float(ot->srna, "mergedist", 0.0001f, 0.000001f, 50.0f, "Merge Distance", "Minimum distance between elements to merge", 0.00001, 10.0); + RNA_def_boolean(ot->srna, "use_unselected", 0, "Unselected", "Merge selected to other unselected vertices"); } /************************ Vertex Path Operator *************************/ @@ -2105,23 +2123,49 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; + BMIter iter; + BMVert *eve = NULL, *svert = NULL, *evert = NULL; BMEditSelection *sv, *ev; /* get the type from RNA */ int type = RNA_enum_get(op->ptr, "type"); + /* first try to find vertices in edit selection */ sv = em->bm->selected.last; - if (sv != NULL) + if (sv != NULL) { ev = sv->prev; - else return OPERATOR_CANCELLED; - if (ev == NULL) - return OPERATOR_CANCELLED; - if ((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) + if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) { + svert = (BMVert *)sv->ele; + evert = (BMVert *)ev->ele; + } + } + + /* if those are not found, because vertices where selected by e.g. + border or circle select, find two selected vertices */ + if (svert == NULL) { + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) + continue; + + if (svert == NULL) svert = eve; + else if (evert == NULL) evert = eve; + else { + /* more than two vertices are selected, + show warning message and cancel operator */ + svert = evert = NULL; + break; + } + } + } + + if (svert == NULL || evert == NULL) { + BKE_report(op->reports, RPT_WARNING, "Path Selection requires that two vertices be selected"); return OPERATOR_CANCELLED; + } /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type); + EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", svert, evert, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -2915,12 +2959,12 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMe BMIter iter; int result = FALSE; - BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); - while ((f_cmp = BM_iter_at_index(bm_old, BM_FACES_OF_MESH, NULL, 0))) { const short mat_nr = f_cmp->mat_nr; int tot = 0; + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); + BM_ITER_MESH (f, &iter, bm_old, BM_FACES_OF_MESH) { if (f->mat_nr == mat_nr) { BMLoop *l_iter; @@ -4758,15 +4802,32 @@ void MESH_OT_bevel(wmOperatorType *ot) static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) { + BMOperator bmop; Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + const int use_merge = RNA_boolean_get(op->ptr, "use_merge"); + const float merge_factor = RNA_float_get(op->ptr, "merge_factor"); - if (!EDBM_op_callf(em, op, "bridge_loops edges=%he", BM_ELEM_SELECT)) + EDBM_op_init(em, &bmop, op, + "bridge_loops edges=%he use_merge=%b merge_factor=%f", + BM_ELEM_SELECT, use_merge, merge_factor); + + BMO_op_exec(em->bm, &bmop); + + /* when merge is used the edges are joined and remain selected */ + if (use_merge == FALSE) { + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; - - EDBM_update_generic(C, em, TRUE); - return OPERATOR_FINISHED; + } + else { + EDBM_update_generic(C, em, TRUE); + return OPERATOR_FINISHED; + } } void MESH_OT_bridge_edge_loops(wmOperatorType *ot) @@ -4784,6 +4845,9 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "inside", 0, "Inside", ""); + + RNA_def_boolean(ot->srna, "use_merge", FALSE, "Merge", "Merge rather than creating faces"); + RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f); } typedef struct { diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index c3093259fd8..59cc782f3eb 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1241,7 +1241,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); MultiresBakeJob *bkr; - wmJob *steve; + wmJob *wm_job; if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; @@ -1255,14 +1255,15 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) } /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS); - WM_jobs_customdata_set(steve, bkr, multiresbake_freejob); - WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(steve, multiresbake_startjob, NULL, NULL, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", + WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); + WM_jobs_customdata_set(wm_job, bkr, multiresbake_freejob); + WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_callbacks(wm_job, multiresbake_startjob, NULL, NULL, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ @@ -1438,7 +1439,7 @@ static void bake_freejob(void *bkv) static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running blender, remove handler and pass through */ - if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running render */ @@ -1468,7 +1469,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS } else { /* only one render job at a time */ - if (WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) return OPERATOR_CANCELLED; if (test_bake_internal(C, op->reports) == 0) { @@ -1476,21 +1477,22 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS } else { BakeRender *bkr = MEM_callocN(sizeof(BakeRender), "render bake"); - wmJob *steve; + wmJob *wm_job; init_bake_internal(bkr, C); bkr->reports = op->reports; /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS); - WM_jobs_customdata_set(steve, bkr, bake_freejob); - WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", + WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); + WM_jobs_customdata_set(wm_job, bkr, bake_freejob); + WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_callbacks(wm_job, bake_startjob, NULL, bake_update, NULL); G.is_break = FALSE; G.is_rendering = TRUE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index b5e85c3712b..aa885320b37 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1720,13 +1720,15 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { - if (type == COPY_PROPERTIES_REPLACE) + if (type == COPY_PROPERTIES_REPLACE) { copy_properties(&ob_iter->prop, &ob->prop); - - /* merge - the default when calling with no argument */ - else - for (prop = ob->prop.first; prop; prop = prop->next) + } + else { + /* merge - the default when calling with no argument */ + for (prop = ob->prop.first; prop; prop = prop->next) { set_ob_property(ob_iter, prop); + } + } } } CTX_DATA_END; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 53bfddee740..cca37cf3a44 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -370,6 +370,7 @@ void OBJECT_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = group_add_exec; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -403,6 +404,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot) /* api callbacks */ ot->exec = group_link_exec; ot->invoke = WM_enum_search_invoke; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -438,6 +440,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = group_remove_exec; + ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 2bace9c30d4..2b1492aa732 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -268,17 +268,12 @@ static int object_modifier_safe_to_delete(Main *bmain, Object *ob, static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, int *sort_depsgraph) { - ModifierData *obmd; - /* It seems on rapid delete it is possible to * get called twice on same modifier, so make * sure it is in list. */ - for (obmd = ob->modifiers.first; obmd; obmd = obmd->next) - if (obmd == md) - break; - - if (!obmd) + if (BLI_findindex(&ob->modifiers, md) == -1) { return 0; + } /* special cases */ if (md->type == eModifierType_ParticleSystem) { @@ -341,7 +336,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob ok = object_modifier_remove(bmain, ob, md, &sort_depsgraph); if (!ok) { - BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name); return 0; } @@ -1467,7 +1462,8 @@ static void modifier_skin_customdata_ensure(Object *ob) me->totvert); /* Mark an arbitrary vertex as root */ - vs->flag |= MVERT_SKIN_ROOT; + if (vs) + vs->flag |= MVERT_SKIN_ROOT; } } @@ -2114,7 +2110,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) int f, cfra, i = 0; int free = RNA_boolean_get(op->ptr, "free"); - wmJob *steve; + wmJob *wm_job; OceanBakeJob *oj; if (!omd) @@ -2181,17 +2177,18 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) scene->r.cfra = cfra; /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", + WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); oj->ocean = ocean; oj->och = och; oj->omd = omd; - WM_jobs_customdata_set(steve, oj, oceanbake_free); - WM_jobs_timer(steve, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); - WM_jobs_callbacks(steve, oceanbake_startjob, NULL, NULL, oceanbake_endjob); + WM_jobs_customdata_set(wm_job, oj, oceanbake_free); + WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); + WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ff7728d4f68..7eb8cc01db9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -988,13 +988,11 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "group", group_name); - for (group = CTX_data_main(C)->group.first; group; group = group->id.next) { - if (!strcmp(group->id.name, group_name)) - break; - } + group = (Group *)BKE_libblock_find_name(ID_GR, group_name); - if (!group) + if (!group) { return OPERATOR_PASS_THROUGH; + } CTX_DATA_BEGIN (C, Base *, base, visible_bases) { diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index f943c83f4ed..9129d651d4d 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -759,7 +759,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) float min[3], max[3]; /* only bounds support */ INIT_MINMAX(min, max); - BKE_object_minmax_dupli(scene, ob, min, max); + BKE_object_minmax_dupli(scene, ob, min, max, TRUE); mid_v3_v3v3(cent, min, max); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 11e98c970a0..c4616fc39c6 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -686,8 +686,9 @@ static void vgroup_duplicate(Object *ob) dw_org = defvert_find_index(dv, idg); if (dw_org) { /* defvert_verify_index re-allocs org so need to store the weight first */ + const float weight = dw_org->weight; dw_cpy = defvert_verify_index(dv, icdg); - dw_cpy->weight = dw_org->weight; + dw_cpy->weight = weight; } } @@ -2826,7 +2827,7 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot) } /* creates the name_array parameter for vgroup_do_remap, call this before fiddling - * with the order of vgroups then call vgroup_do_remap after*/ + * with the order of vgroups then call vgroup_do_remap after */ static char *vgroup_init_remap(Object *ob) { bDeformGroup *def; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index d6cf46363d3..72d2d67e081 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4111,7 +4111,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } if (!ok) { - BKE_object_minmax(ob, min, max); + BKE_object_minmax(ob, min, max, TRUE); ok= 1; } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 621d06a7bd8..f95b07bd71e 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1068,14 +1068,15 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fb->settings = fsset; if (do_job) { - wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS); + wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", + WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID); /* setup job */ - WM_jobs_customdata_set(steve, fb, fluidbake_free); - WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME); - WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob); + WM_jobs_customdata_set(wm_job, fb, fluidbake_free); + WM_jobs_timer(wm_job, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME); + WM_jobs_callbacks(wm_job, fluidbake_startjob, NULL, NULL, fluidbake_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } else { short dummy_stop, dummy_do_update; @@ -1112,7 +1113,7 @@ void fluidsimSettingsFree(FluidsimSettings *UNUSED(fss)) { } -FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss)) +FluidsimSettings *fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss)) { return NULL; } @@ -1130,7 +1131,7 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { /* only one bake job at a time */ - if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID)) return OPERATOR_CANCELLED; if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index ae1b82c6690..b236b555850 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -457,7 +457,7 @@ static int screen_render_modal(bContext *C, wmOperator *op, wmEvent *event) Scene *scene = (Scene *) op->customdata; /* no running blender, remove handler and pass through */ - if (0 == WM_jobs_test(CTX_wm_manager(C), scene)) { + if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) { return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } @@ -479,7 +479,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) SceneRenderLayer *srl = NULL; View3D *v3d = CTX_wm_view3d(C); Render *re; - wmJob *steve; + wmJob *wm_job; RenderJob *rj; Image *ima; int jobflag; @@ -489,7 +489,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) const char *name; /* only one render job at a time */ - if (WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) return OPERATOR_CANCELLED; if (!RE_is_rendering_allowed(scene, camera_override, op->reports)) { @@ -564,10 +564,10 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) if (RE_seq_render_active(scene, &scene->r)) name = "Sequence Render"; else name = "Render"; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag); - WM_jobs_customdata_set(steve, rj, render_freejob); - WM_jobs_timer(steve, 0.2, NC_SCENE | ND_RENDER_RESULT, 0); - WM_jobs_callbacks(steve, render_startjob, NULL, NULL, render_endjob); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag, WM_JOB_TYPE_RENDER); + WM_jobs_customdata_set(wm_job, rj, render_freejob); + WM_jobs_timer(wm_job, 0.2, NC_SCENE | ND_RENDER_RESULT, 0); + WM_jobs_callbacks(wm_job, render_startjob, NULL, NULL, render_endjob); /* get a render result image, and make sure it is empty */ ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); @@ -588,11 +588,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) /* store actual owner of job, so modal operator could check for it, * the reason of this is that active scene could change when rendering - * several layers from composistor [#31800] + * several layers from compositor [#31800] */ op->customdata = scene; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d705799b1d8..55df1caf3eb 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -309,7 +309,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) } /* only one render job at a time */ - if (WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) return 0; if (!is_view_context && scene->camera == NULL) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 03906c99c74..add2cbd566b 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -474,7 +474,9 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int RenderResult rres; char name[32]; int do_gamma_correct = FALSE, do_predivide = FALSE; - int offx = 0, newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin; + int offx = 0; + int newx = BLI_RCT_SIZE_X(rect); + int newy = BLI_RCT_SIZE_Y(rect); if (id && GS(id->name) != ID_TE) { /* exception: don't color manage texture previews - show the raw values */ @@ -547,7 +549,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 = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin; + int newx = BLI_RCT_SIZE_X(rect); + int newy = BLI_RCT_SIZE_Y(rect); newrect.xmin = rect->xmin; newrect.xmax = rect->xmin; @@ -746,7 +749,6 @@ static void shader_preview_free(void *customdata) if (sp->matcopy) { struct IDProperty *properties; - int a; /* node previews */ shader_preview_updatejob(sp); @@ -754,13 +756,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - /* BKE_material_free decrements texture, prevent this. hack alert! */ - for (a = 0; a < MAX_MTEX; a++) { - MTex *mtex = sp->matcopy->mtex[a]; - if (mtex && mtex->tex) mtex->tex = NULL; - } - - BKE_material_free(sp->matcopy); + BKE_material_free_ex(sp->matcopy, FALSE); properties = IDP_GetProperties((ID *)sp->matcopy, FALSE); if (properties) { @@ -1022,16 +1018,17 @@ static void icon_preview_free(void *customdata) void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) { - wmJob *steve; + wmJob *wm_job; IconPreview *ip, *old_ip; /* suspended start means it starts after 1 timer step, see WM_jobs_timer below */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", + WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND, WM_JOB_TYPE_RENDER_PREVIEW); ip = MEM_callocN(sizeof(IconPreview), "icon preview"); /* render all resolutions from suspended job too */ - old_ip = WM_jobs_customdata_get(steve); + old_ip = WM_jobs_customdata_get(wm_job); if (old_ip) BLI_movelisttolist(&ip->sizes, &old_ip->sizes); @@ -1043,20 +1040,21 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r icon_preview_add_size(ip, rect, sizex, sizey); /* setup job */ - WM_jobs_customdata_set(steve, ip, icon_preview_free); - WM_jobs_timer(steve, 0.25, NC_MATERIAL, NC_MATERIAL); - WM_jobs_callbacks(steve, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); + WM_jobs_customdata_set(wm_job, ip, icon_preview_free); + WM_jobs_timer(wm_job, 0.25, NC_MATERIAL, NC_MATERIAL); + WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method) { Object *ob = CTX_data_active_object(C); - wmJob *steve; + wmJob *wm_job; ShaderPreview *sp; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", WM_JOB_EXCL_RENDER); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", + WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); sp = MEM_callocN(sizeof(ShaderPreview), "shader preview"); /* customdata for preview thread */ @@ -1072,11 +1070,11 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f; /* setup job */ - WM_jobs_customdata_set(steve, sp, shader_preview_free); - WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL); - WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob, NULL); + WM_jobs_customdata_set(wm_job, sp, shader_preview_free); + WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL); + WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void ED_preview_kill_jobs(const struct bContext *C) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 293af4357d4..0bfe5d04e5e 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 = ar->winrct.xmax - ar->winrct.xmin + 1; - int height = ar->winrct.ymax - ar->winrct.ymin + 1; + int width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); glLoadIdentity(); @@ -161,7 +161,7 @@ void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) ys = (az->y1 + az->y2) / 2; /* test if inside */ - if (BLI_in_rcti(&ar->winrct, xs, ys)) { + if (BLI_rcti_isect_pt(&ar->winrct, xs, ys)) { az->do_draw = TRUE; } } @@ -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 rect->xmax - rect->xmin - size; + return BLI_RCT_SIZE_X(rect) - size; } - else { // 'v' - return rect->ymax - rect->ymin - size; + else { /* 'v' */ + return BLI_RCT_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 = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_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 = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.ymax = BLI_RCT_CENTER_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 = (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); + ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); } else if (quad == 2) { /* left top */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmax = BLI_RCT_CENTER_X(remainder); + ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1; } else if (quad == 3) { /* right bottom */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; + ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder); } else { /* right top */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; + ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1; + ar->winrct.ymin = BLI_RCT_CENTER_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 = ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + ar->winy = BLI_RCT_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 = ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; - ar->prev->winy = ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; + ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1; + ar->prev->winy = BLI_RCT_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 = sa->totrct.xmax - sa->totrct.xmin + 1; - sa->winy = sa->totrct.ymax - sa->totrct.ymin + 1; + sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1; + sa->winy = BLI_RCT_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 = ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; /* UI convention */ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); @@ -1425,7 +1425,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(C); - /*send space change notifier*/ + /* send space change notifier */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); ED_area_tag_refresh(sa); @@ -1452,7 +1452,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) } ED_area_tag_redraw(sa); - /*send space change notifier*/ + /* send space change notifier */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); } @@ -1503,7 +1503,7 @@ static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2) ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype); ED_area_tag_redraw(CTX_wm_area(C)); - /*send space change notifier*/ + /* send space change notifier */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, CTX_wm_area(C)); } @@ -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 = v2d->cur.xmax - v2d->cur.xmin; + w = BLI_RCT_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, ar->v2d.tot.ymax - ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_RCT_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 = ar->winrct.ymax - ar->winrct.ymin - header_height; + rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height; if (block) { - rect.xmax = ar->winrct.xmax - ar->winrct.xmin; + rect.xmax = BLI_RCT_SIZE_X(&ar->winrct); } else { rect.xmax = rect.xmin + BLF_width(fontid, text) + 24; } - rect.ymax = ar->winrct.ymax - ar->winrct.ymin; + rect.ymax = BLI_RCT_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 a534124d2c0..967c6e85590 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -35,6 +35,7 @@ #include "DNA_vec_types.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "BKE_colortools.h" @@ -668,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) { - int sc_w = screen_rect->xmax - screen_rect->xmin + 1; - int sc_h = screen_rect->ymax - screen_rect->ymin + 1; + const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1; + const int sc_h = BLI_RCT_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); @@ -713,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) di->world_rect = *rect; - sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); - sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); - wo_w = (di->world_rect.xmax - di->world_rect.xmin); - wo_h = (di->world_rect.ymax - di->world_rect.ymin); + 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); di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; @@ -744,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->world_rect.ymax = di->screen_rect.ymax; } - sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); - sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); - wo_w = (di->world_rect.xmax - di->world_rect.xmin); - wo_h = (di->world_rect.ymax - di->world_rect.ymin); + 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); 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 d1458fec94b..adffb97c16f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1267,7 +1267,7 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) } if (sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (BLI_in_rcti_v(&ar->winrct, &event->x)) + if (BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) scr->subwinactive = ar->swinid; } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e92f7b7a3c2..823037a7903 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -521,7 +521,7 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) ScrArea *sa = NULL; sa = scr->areabase.first; while (sa) { - if (BLI_in_rcti(&sa->totrct, x, y)) break; + if (BLI_rcti_isect_pt(&sa->totrct, x, y)) break; sa = sa->next; } @@ -540,7 +540,7 @@ static int actionzone_area_poll(bContext *C) int y = win->eventstate->y; for (az = sa->actionzones.first; az; az = az->next) - if (BLI_in_rcti(&az->rect, x, y)) + if (BLI_rcti_isect_pt(&az->rect, x, y)) return 1; } return 0; @@ -551,7 +551,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) AZone *az = NULL; for (az = sa->actionzones.first; az; az = az->next) { - if (BLI_in_rcti_v(&az->rect, xy)) { + if (BLI_rcti_isect_pt_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); @@ -1612,10 +1612,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 = sa->totrct.xmax - sa->totrct.xmin; + dist = BLI_RCT_SIZE_X(&sa->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ - dist = sa->totrct.ymax - sa->totrct.ymin; + dist = BLI_RCT_SIZE_Y(&sa->totrct); } /* subtractwidth of regions on opposite side @@ -2030,8 +2030,8 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) ot->poll = ED_operator_screenactive_norender; ot->flag = OPTYPE_UNDO; - /* rna */ - RNA_def_boolean(ot->srna, "next", 1, "Next Keyframe", ""); + /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Keyframe", ""); } /* ************** switch screen operator ***************************** */ diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 166a4943db0..4e71c49465f 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -149,14 +149,16 @@ 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 y, cropw = crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; + int crop_x = BLI_RCT_SIZE_X(&crop); + int crop_y = BLI_RCT_SIZE_Y(&crop); + int y; - if (cropw > 0 && croph > 0) { - for (y = 0; y < croph; y++, to += cropw, from += ibuf->x) - memmove(to, from, sizeof(unsigned int) * cropw); + if (crop_x > 0 && crop_y > 0) { + for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x) + memmove(to, from, sizeof(unsigned int) * crop_x); - ibuf->x = cropw; - ibuf->y = croph; + ibuf->x = crop_x; + ibuf->y = crop_y; } } @@ -396,7 +398,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float static int screencast_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - wmJob *steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0); + wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST); ScreenshotJob *sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); /* setup sj */ @@ -420,11 +422,11 @@ static int screencast_exec(bContext *C, wmOperator *op) BKE_reports_init(&sj->reports, RPT_PRINT); /* setup job */ - WM_jobs_customdata_set(steve, sj, screenshot_freejob); - WM_jobs_timer(steve, 0.1, 0, NC_SCREEN | ND_SCREENCAST); - WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL); + WM_jobs_customdata_set(wm_job, sj, screenshot_freejob); + WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST); + WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 7f51f54ee4b..8616d4e66eb 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "DNA_brush_types.h" @@ -440,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, else { quad.xmin = 0; quad.ymin = 0; - quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin; - quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin; + quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct); + quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct); } /* set quad color */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 76e4a75ea8b..953215b83aa 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -388,7 +388,11 @@ typedef struct UndoImageTile { char idname[MAX_ID_NAME]; /* name instead of pointer*/ char ibufname[IB_FILENAME_SIZE]; - void *rect; + union { + float *fp; + unsigned int *uint; + void *pt; + } rect; int x, y; short source, use_float; @@ -406,10 +410,10 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); if (ibuf->rect_float) { - SWAP(void *, tmpibuf->rect_float, tile->rect); + SWAP(float *, tmpibuf->rect_float, tile->rect.fp); } else { - SWAP(void *, tmpibuf->rect, tile->rect); + SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint); } if (restore) @@ -428,7 +432,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) if (tile->use_float == use_float) if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0) - return tile->rect; + return tile->rect.pt; if (*tmpibuf == NULL) *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect); @@ -440,7 +444,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4; allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char); - tile->rect = MEM_mapallocN(allocsize, "UndeImageTile.rect"); + tile->rect.pt = MEM_mapallocN(allocsize, "UndeImageTile.rect"); BLI_strncpy(tile->ibufname, ibuf->name, sizeof(tile->ibufname)); @@ -453,7 +457,7 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int BLI_addtail(lb, tile); - return tile->rect; + return tile->rect.pt; } static void image_undo_restore(bContext *C, ListBase *lb) @@ -517,7 +521,7 @@ static void image_undo_free(ListBase *lb) UndoImageTile *tile; for (tile = lb->first; tile; tile = tile->next) - MEM_freeN(tile->rect); + MEM_freeN(tile->rect.pt); } /* get active image for face depending on old/new shading system */ @@ -1615,7 +1619,7 @@ static int line_clip_rect2f( if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1643,7 +1647,7 @@ static int line_clip_rect2f( } if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); copy_v2_v2(l2_clip, l2); return 1; @@ -1667,12 +1671,12 @@ static int line_clip_rect2f( /* Done with vertical lines */ /* are either of the points inside the rectangle ? */ - if (BLI_in_rctf_v(rect, l1)) { + if (BLI_rctf_isect_pt_v(rect, l1)) { copy_v2_v2(l1_clip, l1); ok1 = 1; } - if (BLI_in_rctf_v(rect, l2)) { + if (BLI_rctf_isect_pt_v(rect, l2)) { copy_v2_v2(l2_clip, l2); ok2 = 1; } @@ -1820,7 +1824,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s * this is even less work then an intersection test */ #if 0 - if (BLI_in_rctf_v(bucket_bounds, cent)) + if (BLI_rctf_isect_pt_v(bucket_bounds, cent)) return 1; #endif @@ -1987,9 +1991,9 @@ static void project_bucket_clip_face( float bucket_bounds_ss[4][2]; /* get the UV space bounding box */ - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v1coSS); - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v2coSS) << 1; - inside_bucket_flag |= BLI_in_rctf_v(bucket_bounds, v3coSS) << 2; + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v1coSS); + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v2coSS) << 1; + inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v3coSS) << 2; if (inside_bucket_flag == ISECT_ALL3) { /* all screenspace points are inside the bucket bounding box, this means we don't need to clip and can simply return the UVs */ @@ -2057,7 +2061,7 @@ static void project_bucket_clip_face( float v1_clipSS[2], v2_clipSS[2]; float w[3]; - /* calc center*/ + /* calc center */ float cent[2] = {0.0f, 0.0f}; /*float up[2] = {0.0f, 1.0f};*/ int i; @@ -2816,7 +2820,7 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke fidx = mf->v4 ? 3 : 2; do { v = ps->screenCoords[(*(&mf->v1 + fidx))]; - if (BLI_in_rctf_v(&bucket_bounds, v)) { + if (BLI_rctf_isect_pt_v(&bucket_bounds, v)) { return 1; } } while (fidx--); @@ -4545,15 +4549,15 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) /* temporarily add float rect for cloning */ if (s->canvas->rect_float && !s->clonecanvas->rect_float) { - int profile = IB_PROFILE_NONE; + short profile = IB_PROFILE_NONE; /* Don't want to color manage, but don't disturb existing profiles */ - SWAP(int, s->clonecanvas->profile, profile); + SWAP(short, s->clonecanvas->profile, profile); IMB_float_from_rect(s->clonecanvas); s->clonefreefloat = 1; - SWAP(int, s->clonecanvas->profile, profile); + SWAP(short, s->clonecanvas->profile, profile); } else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 560174e73ae..104f727c603 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -624,7 +624,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Sculpt mode */ keymap = WM_keymap_find(keyconf, "Sculpt", 0, 0); - keymap->poll = sculpt_poll; + keymap->poll = sculpt_mode_poll; RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index f327f67be33..c62dc687c73 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -32,6 +32,7 @@ * \ingroup edsculpt */ +#include <stddef.h> #include "MEM_guardedalloc.h" @@ -379,16 +380,12 @@ static void sculpt_undo_free(ListBase *lb) SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) { ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH); - SculptUndoNode *unode; - if (!lb) + if (!lb) { return NULL; + } - for (unode = lb->first; unode; unode = unode->next) - if (unode->node == node) - return unode; - - return NULL; + return BLI_findptr(lb, node, offsetof(SculptUndoNode, node)); } static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index edec57d9e93..878fd20b27e 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 > (v2d->mask.ymax - v2d->mask.ymin)) { + if (height > BLI_RCT_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 dbde950188d..c95f1dba31d 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 * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin); + v2d->cur.ymin = (float)-BLI_RCT_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 6b61990d485..c9f765ac3db 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 ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect)) mode = ACTKEYS_BORDERSEL_FRAMERANGE; else mode = ACTKEYS_BORDERSEL_CHANNELS; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 199875fdc7b..4bcd4a933ed 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), ar->v2d.tot.ymax - ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_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 e561b2a9e79..e66faa88b93 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -168,7 +169,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, rect.xmax - rect.xmin, + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_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 83d895067cc..5d890155e25 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -44,6 +44,7 @@ #include "BLI_string.h" #include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "ED_screen.h" #include "ED_clip.h" @@ -273,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 > (v2d->mask.ymax - v2d->mask.ymin)) { + if (height > BLI_RCT_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_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 6d1610f3f91..09f6271b6ef 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -157,7 +157,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, - "Location", "Mouse location to select channel", -100.0f, 100.0f); + "Location", "Mouse location to select channel", -100.0f, 100.0f); RNA_def_boolean(ot->srna, "extend", 0, - "Extend", "Extend selection rather than clearing the existing selection"); + "Extend", "Extend selection rather than clearing the existing selection"); } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index c24cdab29e5..2353f8f8c12 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -958,12 +958,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 / (v2d->cur.xmax - v2d->cur.xmin); - y = -v2d->cur.ymin / (v2d->cur.ymax - v2d->cur.ymin); + x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur); + y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur); /* convert proportional distances to screen coordinates */ - *regionx = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin); - *regiony = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin); + *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask); + *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask); } static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 5e4ef1aa24a..7a54a39ee48 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -44,6 +44,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "GPU_extensions.h" @@ -148,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)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * 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); } void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -247,6 +248,54 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale return NULL; } +/* returns color in SRGB */ +/* matching ED_space_image_color_sample() */ +int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3]) +{ + ImBuf *ibuf; + float fx, fy, co[2]; + int ret = FALSE; + + ibuf = ED_space_clip_get_buffer(sc); + if (!ibuf) { + return FALSE; + } + + /* map the mouse coords to the backdrop image space */ + ED_clip_mouse_pos(sc, ar, mval, co); + + fx = co[0]; + fy = co[1]; + + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { + float *fp; + unsigned char *cp; + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); + + 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); + } + ret = TRUE; + } + else if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + rgb_uchar_to_float(r_col, cp); + ret = TRUE; + } + } + + return ret; +} + void ED_clip_update_frame(const Main *mainp, int cfra) { wmWindowManager *wm; @@ -345,8 +394,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) ED_space_clip_get_aspect(sc, &aspx, &aspy); - width = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; zoomx = (float)width / w / aspx; zoomy = (float)height / h / aspy; diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index a2cb812d51c..71dcd326887 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -321,7 +321,7 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), { BorderSelectuserData *data = (BorderSelectuserData *) userdata; - if (BLI_in_rctf(&data->rect, scene_framenr, val)) { + if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) { int flag = 0; if (coord == 0) @@ -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 * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra = 0.01f * (v2d->cur.ymax - v2d->cur.ymin); + extra = 0.01f * BLI_RCT_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 = (v2d->cur.xmax - v2d->cur.xmin) / 2.0f; + float extra = BLI_RCT_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 9b4f3fcdd68..aa2cadbd2d3 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -39,6 +39,7 @@ #include "BLI_path_util.h" #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_global.h" @@ -89,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 ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) + else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; - else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) + else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; } @@ -455,7 +456,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, - "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX); + "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX); } /********************** view zoom operator *********************/ @@ -579,7 +580,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) /* properties */ RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX, - "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX); + "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX); } /********************** view zoom in/out operator *********************/ @@ -700,7 +701,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot) /* properties */ RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX, - "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX); + "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX); } /********************** view all operator *********************/ @@ -725,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 = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_SIZE_Y(&ar->winrct) + 1; if (fit_view) { const int margin = 5; /* margin from border */ @@ -1031,7 +1032,7 @@ static void proxy_endjob(void *pjv) static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { - wmJob * steve; + wmJob *wm_job; ProxyJob *pj; Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); @@ -1041,7 +1042,8 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) if ((clip->flag & MCLIP_USE_PROXY) == 0) return OPERATOR_CANCELLED; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_BUILD_PROXY); pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); pj->scene = scene; @@ -1054,12 +1056,12 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) clip->proxy.build_size_flag, clip->proxy.quality); } - WM_jobs_customdata_set(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); + WM_jobs_customdata_set(wm_job, pj, proxy_freejob); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); + WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index bf65429b9f4..bb06104d442 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 = ar->winrct.xmax - ar->winrct.xmin + 1; - winy = ar->winrct.ymax - ar->winrct.ymin + 1; + winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index bf0a6617e2b..97f7d7bf132 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -42,7 +42,6 @@ #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rect.h" -#include "BLI_lasso.h" #include "BLI_blenlib.h" #include "BKE_main.h" @@ -1235,11 +1234,11 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); - wmJob *steve; + wmJob *wm_job; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); - if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) { /* only one tracking is allowed at a time */ return OPERATOR_CANCELLED; } @@ -1261,23 +1260,24 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve } /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", WM_JOB_PROGRESS); - WM_jobs_customdata_set(steve, tmj, track_markers_freejob); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_TRACK_MARKERS); + WM_jobs_customdata_set(wm_job, tmj, track_markers_freejob); /* if there's delay set in tracking job, tracking should happen * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ if (tmj->delay > 0) - WM_jobs_timer(steve, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_timer(wm_job, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); else - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); - WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); + WM_jobs_callbacks(wm_job, track_markers_startjob, NULL, track_markers_updatejob, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ @@ -1289,7 +1289,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running tracking, remove handler and pass through */ - if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ @@ -1467,10 +1467,10 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); - wmJob *steve; + wmJob *wm_job; char error_msg[256] = "\0"; - if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) { /* only one solve is allowed at a time */ return OPERATOR_CANCELLED; } @@ -1492,14 +1492,15 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); - WM_jobs_customdata_set(steve, scj, solve_camera_freejob); - WM_jobs_timer(steve, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); - WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_SOLVE_CAMERA); + WM_jobs_customdata_set(wm_job, scj, solve_camera_freejob); + WM_jobs_timer(wm_job, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_callbacks(wm_job, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ @@ -1511,7 +1512,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running solver, remove handler and pass through */ - if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 5a79e832ebe..507e492497d 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -363,7 +363,7 @@ static int border_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { - if (BLI_in_rctf_v(&rectf, marker->pos)) { + if (BLI_rctf_isect_pt_v(&rectf, marker->pos)) { if (mode == GESTURE_MODAL_SELECT) BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); else @@ -441,7 +441,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho /* marker in screen coords */ ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); - if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) { if (select) diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 460b31d69bd..a4f7e30ed7b 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 = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur); ar->v2d.cur.ymin = prev_y_min; ar->v2d.cur.ymax = prev_y_min + cur_y_range; } @@ -326,6 +326,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ #endif + WM_keymap_add_item(keymap, "CONSOLE_OT_copy_as_script", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 01962853556..ff7a71af8c2 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -327,7 +327,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) rect.xmin = rect.xmax = event->mval[0]; rect.ymin = rect.ymax = event->mval[1]; - if (!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) + if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) return OPERATOR_CANCELLED; /* single select, deselect all selected first */ @@ -525,7 +525,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) mx -= ar->winrct.xmin; my -= ar->winrct.ymin; - if (BLI_in_rcti(&ar->v2d.mask, mx, my)) { + if (BLI_rcti_isect_pt(&ar->v2d.mask, mx, my)) { float fx, fy; int active_file; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 27db7907e30..337e13f7785 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1346,7 +1346,7 @@ static void thumbnails_free(void *tjv) void thumbnails_start(struct FileList *filelist, const struct bContext *C) { - wmJob *steve; + wmJob *wm_job; ThumbnailJob *tj; int idx; @@ -1368,13 +1368,14 @@ void thumbnails_start(struct FileList *filelist, const struct bContext *C) BKE_reports_init(&tj->reports, RPT_PRINT); /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); - WM_jobs_customdata_set(steve, tj, thumbnails_free); - WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW); - WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", + 0, WM_JOB_TYPE_FILESEL_THUMBNAIL); + WM_jobs_customdata_set(wm_job, tj, thumbnails_free); + WM_jobs_timer(wm_job, 0.5, NC_WINDOW, NC_WINDOW); + WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, NULL); /* start the job */ - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void thumbnails_stop(struct FileList *filelist, const struct bContext *C) @@ -1384,5 +1385,5 @@ void thumbnails_stop(struct FileList *filelist, const struct bContext *C) int thumbnails_running(struct FileList *filelist, const struct bContext *C) { - return WM_jobs_test(CTX_wm_manager(C), filelist); + return WM_jobs_test(CTX_wm_manager(C), filelist, WM_JOB_TYPE_FILESEL_THUMBNAIL); } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 34f16c11537..09231efd367 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)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2 * layout->tile_border_x); + int width = (int)(BLI_RCT_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)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2 * layout->tile_border_y); + int height = (int)(BLI_RCT_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)(v2d->cur.xmax - v2d->cur.xmin - 2 * layout->tile_border_x); + layout->width = (int)(BLI_RCT_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)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y); + layout->height = (int)(BLI_RCT_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/space_file.c b/source/blender/editors/space_file/space_file.c index 17669dfa8f9..fcf6f28b406 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -252,7 +252,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) static void file_listener(ScrArea *sa, wmNotifier *wmn) { - /* SpaceFile* sfile = (SpaceFile*)sa->spacedata.first; */ + /* SpaceFile *sfile = (SpaceFile*)sa->spacedata.first; */ /* context changes */ switch (wmn->category) { @@ -525,7 +525,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 = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + ar->v2d.cur.ymax = BLI_RCT_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_draw.c b/source/blender/editors/space_graph/graph_draw.c index 870e9bb8168..ad97b7853c4 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 * (v2d->cur.xmax - v2d->cur.xmin); + const float fac = 0.05f * BLI_RCT_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 * (v2d->cur.xmax - v2d->cur.xmin); + const float fac = 0.05f * BLI_RCT_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 8a0538eddb0..f01d64b46b8 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -86,6 +86,8 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_sel_only, const short include_handles) { + Scene *scene = ac->scene; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -94,7 +96,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* set large values to try to override */ + /* set large values initial values that will be easy to override */ if (xmin) *xmin = 999999999.0f; if (xmax) *xmax = -999999999.0f; if (ymin) *ymin = 999999999.0f; @@ -102,6 +104,8 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa /* check if any channels to set range with */ if (anim_data.first) { + short foundBounds = FALSE; + /* go through channels, finding max extents */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); @@ -110,29 +114,39 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa float unitFac; /* get range */ - calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles); - - /* apply NLA scaling */ - if (adt) { - txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); - txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); + if (calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles)) { + /* apply NLA scaling */ + if (adt) { + txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); + txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); + } + + /* apply unit corrections */ + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + tymin *= unitFac; + tymax *= unitFac; + + /* try to set cur using these values, if they're more extreme than previously set values */ + if ((xmin) && (txmin < *xmin)) *xmin = txmin; + if ((xmax) && (txmax > *xmax)) *xmax = txmax; + if ((ymin) && (tymin < *ymin)) *ymin = tymin; + if ((ymax) && (tymax > *ymax)) *ymax = tymax; + + foundBounds = TRUE; } - - /* apply unit corrections */ - unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); - tymin *= unitFac; - tymax *= unitFac; - - /* try to set cur using these values, if they're more extreme than previously set values */ - if ((xmin) && (txmin < *xmin)) *xmin = txmin; - if ((xmax) && (txmax > *xmax)) *xmax = txmax; - if ((ymin) && (tymin < *ymin)) *ymin = tymin; - if ((ymax) && (tymax > *ymax)) *ymax = tymax; } /* ensure that the extents are not too extreme that view implodes...*/ - if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.1f)) *xmax += 0.1f; - if ((ymin && ymax) && (fabsf(*ymax - *ymin) < 0.1f)) *ymax += 0.1f; + if (foundBounds) { + if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.1f)) *xmax += 0.1f; + if ((ymin && ymax) && (fabsf(*ymax - *ymin) < 0.1f)) *ymax += 0.1f; + } + else { + if (xmin) *xmin = (float)PSFRA; + if (xmax) *xmax = (float)PEFRA; + if (ymin) *ymin = -5; + if (ymax) *ymax = 5; + } /* free memory */ BLI_freelistN(&anim_data); @@ -140,8 +154,8 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa else { /* set default range */ if (ac->scene) { - if (xmin) *xmin = (float)ac->scene->r.sfra; - if (xmax) *xmax = (float)ac->scene->r.efra; + if (xmin) *xmin = (float)PSFRA; + if (xmax) *xmax = (float)PEFRA; } else { if (xmin) *xmin = -5; @@ -210,16 +224,16 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i return OPERATOR_CANCELLED; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ - get_graph_keyframe_extents(&ac, - &cur_new.xmin, &cur_new.xmax, - &cur_new.ymin, &cur_new.ymax, - do_sel_only, include_handles); + get_graph_keyframe_extents(&ac, + &cur_new.xmin, &cur_new.xmax, + &cur_new.ymin, &cur_new.ymax, + do_sel_only, include_handles); - extra = 0.1f * (cur_new.xmax - cur_new.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&cur_new); cur_new.xmin -= extra; cur_new.xmax += extra; - extra = 0.1f * (cur_new.ymax - cur_new.ymin); + extra = 0.1f * BLI_RCT_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 781099f6a68..32abad86828 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 ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_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 51bd4e16d06..40f0683a852 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -268,13 +268,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) int mval[2]; if (G.scene->r.mode & R_BORDER) { - winx *= (G.scene->r.border.xmax - G.scene->r.border.xmin); - winy *= (G.scene->r.border.ymax - G.scene->r.border.ymin); + winx *= BLI_RCT_SIZE_X(&G.scene->r.border); + winy *= BLI_RCT_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, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ @@ -681,10 +681,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ - Render *re = RE_GetRender(scene->id.name); - RenderResult *rr = RE_AcquireResultRead(re); + RenderResult *rr; + + /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ + rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); - RE_ReleaseResult(re); + BKE_image_release_renderresult(scene, ima); } } else { @@ -867,16 +869,16 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) { Scene *scene = CTX_data_scene(C); - Render *re; - RenderResult *rr; /* render layers and passes */ if (ima && iuser) { const float dpi_fac = UI_DPI_FAC; - re = RE_GetRender(scene->id.name); - rr = RE_AcquireResultRead(re); + RenderResult *rr; + + /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ + rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); - RE_ReleaseResult(re); + BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 52ed7fd1d0b..e293264c021 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -44,6 +44,7 @@ #include "PIL_time.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BLI_threads.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -135,7 +136,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, ar->winrct.xmax - ar->winrct.xmin + 1, 20); + glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20); glDisable(GL_BLEND); BLF_size(blf_mono_font, 11, 72); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 58e6a1aa94a..ac9883b411d 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/space_image/image_editor.c +/** \file blender/editors/space_image/image_edit.c * \ingroup spimage */ @@ -33,6 +33,7 @@ #include "DNA_scene_types.h" #include "BLI_math.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "BKE_global.h" @@ -181,8 +182,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 *= (scene->r.border.xmax - scene->r.border.xmin); - *height *= (scene->r.border.ymax - scene->r.border.ymin); + *width *= BLI_RCT_SIZE_X(&scene->r.border); + *height *= BLI_RCT_SIZE_Y(&scene->r.border); } } @@ -229,8 +230,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float ED_space_image_get_size(sima, &width, &height); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * 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); } void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b2a9584b243..3d6b316b743 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -98,9 +98,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat if ((width < 4) && (height < 4)) sima->zoom = oldzoom; - else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) + else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; - else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) + else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom) sima->zoom = oldzoom; } @@ -581,8 +581,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 = ar->winrct.xmax - ar->winrct.xmin + 1; - height = ar->winrct.ymax - ar->winrct.ymin + 1; + width = BLI_RCT_SIZE_X(&ar->winrct) + 1; + height = BLI_RCT_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 */ @@ -1948,6 +1948,52 @@ static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_ } } +/* returns color in SRGB */ +/* matching ED_space_node_color_sample() */ +int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3]) +{ + void *lock; + ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); + float fx, fy; + int ret = FALSE; + + if (ibuf == NULL) { + ED_space_image_release_buffer(sima, lock); + return FALSE; + } + + UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &fx, &fy); + + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { + float *fp; + unsigned char *cp; + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); + + 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); + } + ret = TRUE; + } + else if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + rgb_uchar_to_float(r_col, cp); + ret = TRUE; + } + } + + ED_space_image_release_buffer(sima, lock); + return ret; +} + static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) { SpaceImage *sima = CTX_wm_space_image(C); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index cc8940201e2..d2639edb276 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -42,6 +42,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_image.h" +#include "BKE_global.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_tessmesh.h" @@ -373,7 +374,10 @@ static void image_refresh(const bContext *C, ScrArea *sa) /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) { - if (sima->lock) { + if (sima->lock == FALSE && G.moving) { + /* pass */ + } + else { if (scene->nodetree) { Mask *mask = ED_space_image_get_mask(sima); if (mask) { @@ -556,8 +560,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) if (ima) h *= ima->aspy / ima->aspx; - winx = ar->winrct.xmax - ar->winrct.xmin + 1; - winy = ar->winrct.ymax - ar->winrct.ymin + 1; + winx = BLI_RCT_SIZE_X(&ar->winrct) + 1; + winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1; ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 1595889f596..abffb955405 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) (line->from->x1 + line->from->x2) / 2; - rectlink.ymin = (int) (line->from->y1 + line->from->y2) / 2; - rectlink.xmax = (int) (line->to->x1 + line->to->x2) / 2; - rectlink.ymax = (int) (line->to->y1 + line->to->y2) / 2; + 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); 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 915e5c20e99..08e0934e8ae 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -109,7 +109,7 @@ static int vergname(const void *v1, const void *v2) x1= (char **)v1; x2= (char **)v2; - return strcmp(*x1, *x2); + return BLI_natstrcmp(*x1, *x2); } void make_unique_prop_names(bContext *C, char *str) @@ -724,25 +724,25 @@ static const char *actuator_name(int type) 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_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; + 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"; + 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"); } } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 1caf1075ae6..1a50f72153a 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -302,48 +302,48 @@ static void logic_header_area_draw(const bContext *C, ARegion *ar) /* only called once, from space/spacetypes.c */ void ED_spacetype_logic(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype logic"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic"); ARegionType *art; - st->spaceid= SPACE_LOGIC; + st->spaceid = SPACE_LOGIC; strncpy(st->name, "Logic", BKE_ST_MAXNAME); - st->new= logic_new; - st->free= logic_free; - st->init= logic_init; - st->duplicate= logic_duplicate; - st->operatortypes= logic_operatortypes; - st->keymap= logic_keymap; - st->refresh= logic_refresh; - st->context= logic_context; + st->new = logic_new; + st->free = logic_free; + st->init = logic_init; + st->duplicate = logic_duplicate; + st->operatortypes = logic_operatortypes; + st->keymap = logic_keymap; + st->refresh = logic_refresh; + st->context = logic_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES|ED_KEYMAP_VIEW2D; - art->init= logic_main_area_init; - art->draw= logic_main_area_draw; - art->listener= logic_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_VIEW2D; + art->init = logic_main_area_init; + art->draw = logic_main_area_draw; + art->listener = logic_listener; BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_UI; art->prefsizex= 220; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= logic_listener; - art->init= logic_buttons_area_init; - art->draw= logic_buttons_area_draw; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = logic_listener; + art->init = logic_buttons_area_init; + art->draw = logic_buttons_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->init= logic_header_area_init; - art->draw= logic_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->init = logic_header_area_init; + art->draw = logic_header_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index a3e9ca1c4a2..775dd5445c3 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 * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; /* set vertical range */ v2d->cur.ymax = 0.0f; - v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin); + v2d->cur.ymin = (float)-BLI_RCT_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_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index b6bef651af3..e7610210881 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 ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) + if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_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 615c4fb4b46..8a1f0e5b611 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -386,7 +386,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)(butr->xmax - butr->xmin), (short)(butr->xmax - butr->xmin), + (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr), nor, 0.0f, 1.0f, 0, 0, ""); uiButSetFunc(bt, node_normal_cb, ntree, node); } @@ -454,7 +454,7 @@ static int node_resize_area_default(bNode *node, int x, int y) rctf totr = node->totr; /* right part of node */ totr.xmin = node->totr.xmax - 20.0f; - if (BLI_in_rctf(&totr, x, y)) + if (BLI_rctf_isect_pt(&totr, x, y)) return NODE_RESIZE_RIGHT; else return 0; @@ -522,7 +522,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) rect->ymax += NODE_DY; /* input sockets */ - dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->inputs) - 1); + dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1)); gsock = ngroup->inputs.first; sock = gnode->inputs.first; while (gsock || sock) { @@ -570,7 +570,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) } /* output sockets */ - dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->outputs) - 1); + dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1)); gsock = ngroup->outputs.first; sock = gnode->outputs.first; while (gsock || sock) { @@ -837,7 +837,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)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); + mini((int)(BLI_RCT_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); @@ -857,13 +857,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN while (gsock && (!sock || sock->groupsock != gsock)) { draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN); gsock = gsock->next; - ++index; + index++; } while (sock && gsock && sock->groupsock == gsock) { draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN); sock = sock->next; gsock = gsock->next; - ++index; + index++; } } gsock = ngroup->outputs.first; @@ -877,13 +877,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN while (gsock && (!sock || sock->groupsock != gsock)) { draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT); gsock = gsock->next; - ++index; + index++; } while (sock && gsock && sock->groupsock == gsock) { draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT); sock = sock->next; gsock = gsock->next; - ++index; + index++; } } @@ -979,7 +979,7 @@ static void node_draw_frame_label(bNode *node, const float aspect) ascender = BLF_ascender(fontid); /* 'x' doesn't need aspect correction */ - x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width; + x = BLI_RCT_CENTER_X(rct) - (0.5f * width); y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect)); BLF_position(fontid, x, y, 0); @@ -1812,6 +1812,15 @@ static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), Po uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE); } +static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *col; + + col = uiLayoutColumn(layout, FALSE); + uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE); +} + static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; @@ -2674,6 +2683,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_INPAINT: ntype->uifunc = node_composit_buts_inpaint; break; + case CMP_NODE_DESPECKLE: + ntype->uifunc = node_composit_buts_despeckle; + break; case CMP_NODE_OUTPUT_FILE: ntype->uifunc = node_composit_buts_file_output; ntype->uifuncbut = node_composit_buts_file_output_details; diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 7d007d024ab..99d49fa1e8f 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/space_node/node_relationships.c +/** \file blender/editors/space_node/node_add.c * \ingroup spnode */ @@ -360,7 +360,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) /* RNA_property_pointer_set increases the user count, * fixed here as the editor is the initial user. */ - --ntree->id.us; + ntree->id.us++; RNA_property_update(C, &ptr, prop); } else if (snode) { diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 1a4c302124f..f1a91df6f53 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -226,12 +226,12 @@ void ED_node_sort(bNodeTree *ntree) while (a < k && b < k && node_b) { if (compare_nodes(node_a, node_b) == 0) { node_a = node_a->next; - ++a; + a++; } else { tmp = node_b; node_b = node_b->next; - ++b; + b++; BLI_remlink(&ntree->nodes, tmp); BLI_insertlinkbefore(&ntree->nodes, node_a, tmp); } @@ -343,7 +343,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 = node->prvr.ymax - node->prvr.ymin; + float oldh = BLI_RCT_SIZE_Y(&node->prvr); if (oldh == 0.0f) oldh = 0.6f * node->width - NODE_DY; dy -= NODE_DYS / 2; @@ -476,12 +476,12 @@ void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) int node_select_area_default(bNode *node, int x, int y) { - return BLI_in_rctf(&node->totr, x, y); + return BLI_rctf_isect_pt(&node->totr, x, y); } int node_tweak_area_default(bNode *node, int x, int y) { - return BLI_in_rctf(&node->totr, x, y); + return BLI_rctf_isect_pt(&node->totr, x, y); } int node_get_colorid(bNode *node) @@ -584,9 +584,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 = (prv->xmax - prv->xmin) / ((float)preview->xsize); - float yscale = (prv->ymax - prv->ymin) / ((float)preview->ysize); - float tile = (prv->xmax - prv->xmin) / 10.0f; + 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 x, y; /* draw checkerboard backdrop to show alpha */ @@ -852,8 +852,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b { bNodeSocket *sock; rctf *rct = &node->totr; - float dx, centy = 0.5f * (rct->ymax + rct->ymin); - float hiddenrad = 0.5f * (rct->ymax - rct->ymin); + float dx, centy = BLI_RCT_CENTER_Y(rct); + float hiddenrad = BLI_RCT_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 +932,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)(rct->xmax - rct->xmin - 18.0f - 12.0f), (short)NODE_DY, + (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY, NULL, 0, 0, 0, 0, ""); } @@ -989,7 +989,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) else { /* check nodes front to back */ for (node = ntree->nodes.last; node; node = node->prev) { - if (BLI_in_rctf(&node->totr, snode->cursor[0], snode->cursor[1])) + if (BLI_rctf_isect_pt(&node->totr, snode->cursor[0], snode->cursor[1])) break; /* first hit on node stops */ } if (node) { @@ -1110,7 +1110,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glEnable(GL_MAP1_VERTEX_3); /* aspect+font, set each time */ - snode->aspect = (v2d->cur.xmax - v2d->cur.xmin) / ((float)ar->winx); + snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx; snode->aspect_sqrt = sqrtf(snode->aspect); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 60375e9ab02..fbae8b17ebf 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -40,6 +40,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BKE_blender.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -72,6 +73,8 @@ #include "node_intern.h" /* own include */ +#define USE_ESC_COMPO + /* ***************** composite job manager ********************** */ typedef struct CompoJob { @@ -88,7 +91,13 @@ static int compo_breakjob(void *cjv) { CompoJob *cj = cjv; - return *(cj->stop); + /* without G.is_break 'ESC' wont quit - which annoys users */ + return (*(cj->stop) +#ifdef USE_ESC_COMPO + || + G.is_break +#endif + ); } /* called by compo, wmJob sends notifier */ @@ -173,7 +182,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog */ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner) { - wmJob *steve; + wmJob *wm_job; CompoJob *cj; /* to fix bug: [#32272] */ @@ -181,7 +190,12 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene return; } - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS); +#ifdef USE_ESC_COMPO + G.is_break = FALSE; +#endif + + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", + WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ @@ -189,11 +203,11 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene cj->ntree = nodetree; /* setup job */ - WM_jobs_customdata_set(steve, cj, compo_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); - WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL); + WM_jobs_customdata_set(wm_job, cj, compo_freejob); + WM_jobs_timer(wm_job, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); + WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } /* ***************************************** */ @@ -1023,11 +1037,11 @@ static int UNUSED_FUNCTION(node_mouse_groupheader) (SpaceNode * snode) // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if (BLI_in_rctf(&gnode->totr, mx, my) == 0) { + if (BLI_rctf_isect_pt(&gnode->totr, mx, my) == 0) { rctf rect = gnode->totr; rect.ymax += NODE_DY; - if (BLI_in_rctf(&rect, mx, my) == 0) + if (BLI_rctf_isect_pt(&rect, mx, my) == 0) snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -1071,7 +1085,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_IN) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { *nodep = node; *sockp = sock; @@ -1084,7 +1098,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_OUT) { for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { *nodep = node; *sockp = sock; @@ -1102,7 +1116,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_IN) { for (sock = snode->edittree->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { *nodep = NULL; /* NULL node pointer indicates group socket */ *sockp = sock; return 1; @@ -1113,7 +1127,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out & SOCK_OUT) { for (sock = snode->edittree->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { - if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) { *nodep = NULL; /* NULL node pointer indicates group socket */ *sockp = sock; return 1; @@ -1824,7 +1838,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; BLI_remlink(&node->inputs, sock); BLI_insertlinkbefore(&node->inputs, before, sock); - --nimf->active_input; + nimf->active_input--; } else { bNodeSocket *after = sock->next; @@ -1832,7 +1846,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; BLI_remlink(&node->inputs, sock); BLI_insertlinkafter(&node->inputs, after, sock); - ++nimf->active_input; + nimf->active_input++; } snode_notify(C, snode); @@ -2004,47 +2018,69 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *gnode = node_tree_get_editgroup(snode->nodetree); - float gnode_x = 0.0f, gnode_y = 0.0f; + float gnode_center[2]; + const ListBase *clipboard_nodes_lb; + const ListBase *clipboard_links_lb; bNode *node; bNodeLink *link; int num_nodes; - float centerx, centery; + float center[2]; + int is_clipboard_valid; + + /* validate pointers in the clipboard */ + is_clipboard_valid = BKE_node_clipboard_validate(); + clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); + clipboard_links_lb = BKE_node_clipboard_get_links(); + + if (clipboard_nodes_lb->first == NULL) { + BKE_report(op->reports, RPT_ERROR, "Clipboard is empty"); + return OPERATOR_CANCELLED; + } if (BKE_node_clipboard_get_type() != ntree->type) { BKE_report(op->reports, RPT_ERROR, "Clipboard nodes are an incompatible type"); return OPERATOR_CANCELLED; } + /* only warn */ + if (is_clipboard_valid == FALSE) { + BKE_report(op->reports, RPT_WARNING, "Some nodes references could not be restored, will be left empty"); + } + ED_preview_kill_jobs(C); /* deselect old nodes */ node_deselect_all(snode); /* get group node offset */ - if (gnode) - nodeToView(gnode, 0.0f, 0.0f, &gnode_x, &gnode_y); + if (gnode) { + nodeToView(gnode, 0.0f, 0.0f, &gnode_center[0], &gnode_center[1]); + } + else { + zero_v2(gnode_center); + } /* calculate "barycenter" for placing on mouse cursor */ - num_nodes = 0; - centerx = centery = 0.0f; - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { - ++num_nodes; - centerx += 0.5f * (node->totr.xmin + node->totr.xmax); - centery += 0.5f * (node->totr.ymin + node->totr.ymax); + 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); } - centerx /= num_nodes; - centery /= num_nodes; + mul_v2_fl(center, 1.0 / num_nodes); /* copy nodes from clipboard */ - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { + for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = nodeCopyNode(ntree, node); + /* needed since nodeCopyNode() doesn't increase ID's */ + id_us_plus(node->id); + /* pasted nodes are selected */ node_select(new_node); } /* reparent copied nodes */ - for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) { + for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; if (new_node->parent) new_node->parent = new_node->parent->new_node; @@ -2052,12 +2088,12 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* place nodes around the mouse cursor. child nodes locations are relative to parent */ if (!new_node->parent) { - new_node->locx += snode->cursor[0] - centerx - gnode_x; - new_node->locy += snode->cursor[1] - centery - gnode_y; + new_node->locx += snode->cursor[0] - center[0] - gnode_center[0]; + new_node->locy += snode->cursor[1] - center[1] - gnode_center[1]; } } - for (link = BKE_node_clipboard_get_links()->first; link; link = link->next) { + for (link = clipboard_links_lb->first; link; link = link->next) { nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock); } diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index efd2378bf31..77583ae1325 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -421,10 +421,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) node->new_node = NULL; /* wgroup is a temporary copy of the NodeTree we're merging in - * - all of wgroup's nodes are transferred across to their new home - * - ngroup (i.e. the source NodeTree) is left unscathed + * - all of wgroup's nodes are transferred across to their new home + * - ngroup (i.e. the source NodeTree) is left unscathed + * - temp copy. don't change ID usercount */ - wgroup = ntreeCopyTree(ngroup); + wgroup = ntreeCopyTree_ex(ngroup, FALSE); /* add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextn) { diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 048e09efab5..2bb550d1a63 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -107,6 +107,7 @@ void NODE_OT_select_all(wmOperatorType *ot); void NODE_OT_select_linked_to(wmOperatorType *ot); void NODE_OT_select_linked_from(wmOperatorType *ot); void NODE_OT_select_border(struct wmOperatorType *ot); +void NODE_OT_select_lasso(struct wmOperatorType *ot); void NODE_OT_select_same_type(struct wmOperatorType *ot); void NODE_OT_select_same_type_next(wmOperatorType *ot); void NODE_OT_select_same_type_prev(wmOperatorType *ot); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 195dd60b72a..a5032fb6465 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -55,6 +55,7 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_linked_to); WM_operatortype_append(NODE_OT_select_linked_from); WM_operatortype_append(NODE_OT_select_border); + WM_operatortype_append(NODE_OT_select_lasso); WM_operatortype_append(NODE_OT_select_same_type); WM_operatortype_append(NODE_OT_select_same_type_next); WM_operatortype_append(NODE_OT_select_same_type_prev); @@ -217,6 +218,11 @@ void node_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_boolean_set(kmi->ptr, "tweak", TRUE); + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "deselect", FALSE); + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "deselect", TRUE); + /* each of these falls through if not handled... */ WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 6295a568113..12c221b9273 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -224,8 +224,9 @@ static void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) if (!sock_fr) continue; - if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) - ++numlinks; + if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { + numlinks++; + } } } @@ -246,7 +247,7 @@ static void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) continue; if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { - ++numlinks; + numlinks++; break; } } @@ -1139,7 +1140,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) /* skip selected, those are the nodes we want to attach */ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) continue; - if (BLI_in_rctf(&frame->totr, snode->cursor[0], snode->cursor[1])) + if (BLI_rctf_isect_pt(&frame->totr, snode->cursor[0], snode->cursor[1])) break; } if (frame) { diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 2f4e7648a5f..a56d76a3ef7 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -35,6 +35,7 @@ #include "BKE_node.h" #include "BLI_rect.h" +#include "BLI_lasso.h" #include "BLI_utildefines.h" #include "ED_node.h" /* own include */ @@ -48,7 +49,9 @@ #include "WM_types.h" #include "UI_view2d.h" - + +#include "MEM_guardedalloc.h" + #include "node_intern.h" /* own include */ /* ****** helpers ****** */ @@ -534,6 +537,92 @@ void NODE_OT_select_border(wmOperatorType *ot) RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); } +/* ****** Lasso Select ****** */ + +static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short select) +{ + SpaceNode *snode = CTX_wm_space_node(C); + bNode *node; + + ARegion *ar = CTX_wm_region(C); + + rcti rect; + int change = FALSE; + + /* get rectangle from operator */ + BLI_lasso_boundbox(&rect, mcords, moves); + + /* 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)}; + + /* marker in screen coords */ + UI_view2d_view_to_region(&ar->v2d, + cent[0], cent[1], + &screen_co[0], &screen_co[1]); + + if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && + BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) + { + if (select) + node_select(node); + else + node_deselect(node); + + change = TRUE; + } + } + + if (change) { + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); + } + + return change; +} + +static int node_lasso_select_exec(bContext *C, wmOperator *op) +{ + int mcords_tot; + int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + + if (mcords) { + short select; + + select = !RNA_boolean_get(op->ptr, "deselect"); + do_lasso_select_node(C, mcords, mcords_tot, select); + + MEM_freeN(mcords); + + return OPERATOR_FINISHED; + } + return OPERATOR_PASS_THROUGH; +} + +void NODE_OT_select_lasso(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Lasso Select"; + ot->description = "Select nodes using lasso selection"; + ot->idname = "NODE_OT_select_lasso"; + + /* api callbacks */ + ot->invoke = WM_gesture_lasso_invoke; + ot->modal = WM_gesture_lasso_modal; + ot->exec = node_lasso_select_exec; + ot->poll = ED_operator_node_active; + ot->cancel = WM_gesture_lasso_cancel; + + /* flags */ + ot->flag = OPTYPE_UNDO; + + /* properties */ + RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); + RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items"); + RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); +} + /* ****** Select/Deselect All ****** */ static int node_select_all_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index a8fe8318f22..989b3999018 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -596,7 +596,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; - bt->x2 = UI_UNIT_X / 2; + bt->rect.xmax = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 4be51a02137..e89e798a6fa 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -32,6 +32,7 @@ #include "BLI_rect.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_image.h" @@ -71,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons int tot = 0; int has_frame = FALSE; - oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin; - oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin; + oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur); + oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur); BLI_rctf_init_minmax(&cur_new); @@ -90,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons } if (tot) { - width = cur_new.xmax - cur_new.xmin; - height = cur_new.ymax - cur_new.ymin; + width = BLI_RCT_SIZE_X(&cur_new); + height = BLI_RCT_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 */ @@ -103,9 +104,6 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons BLI_rctf_resize(&cur_new, oldwidth, oldheight); } else { - width = cur_new.xmax - cur_new.xmin; - height = cur_new.ymax - cur_new.ymin; - if (width > height) { float newheight; newheight = oldheight * width / oldwidth; @@ -350,6 +348,59 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) } } +/* returns color in SRGB */ +/* matching ED_space_image_color_sample() */ +int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3]) +{ + void *lock; + Image *ima; + ImBuf *ibuf; + float fx, fy, bufx, bufy; + int ret = FALSE; + + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + if (!ibuf) { + return FALSE; + } + + /* map the mouse coords to the backdrop image space */ + bufx = ibuf->x * snode->zoom; + bufy = ibuf->y * snode->zoom; + fx = (bufx > 0.0f ? ((float)mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? ((float)mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f); + + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { + float *fp; + unsigned char *cp; + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); + + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); + + 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); + } + ret = TRUE; + } + else if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + rgb_uchar_to_float(r_col, cp); + ret = TRUE; + } + } + + BKE_image_release_ibuf(ima, lock); + + return ret; +} + static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) { SpaceNode *snode = CTX_wm_space_node(C); @@ -383,7 +434,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { float *fp; - char *cp; + unsigned char *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -395,7 +446,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->channels = ibuf->channels; if (ibuf->rect) { - cp = (char *)(ibuf->rect + y * ibuf->x + x); + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); info->col[0] = cp[0]; info->col[1] = cp[1]; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 4fa8686bce3..0874ddcb279 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 + (v2d->mask.ymax - v2d->mask.ymin) / 2); + ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2); if (ytop > 0) ytop = 0; v2d->cur.ymax = (float)ytop; - v2d->cur.ymin = (float)(ytop - (v2d->mask.ymax - v2d->mask.ymin)); + v2d->cur.ymin = (float)(ytop - BLI_RCT_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 = ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int dy = BLI_RCT_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 + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2); + ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2); if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; - ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin)); + ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_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/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 489a4efe891..6cfc3f97b31 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -483,7 +483,7 @@ void ED_spacetype_outliner(void) BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 7bee8c2bebf..c1f7fc942e4 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -40,9 +40,11 @@ set(SRC sequencer_buttons.c sequencer_draw.c sequencer_edit.c + sequencer_modifier.c sequencer_ops.c sequencer_scopes.c sequencer_select.c + sequencer_view.c space_sequencer.c sequencer_intern.h diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7dd98c39e4c..d6a2b0a001e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -428,7 +428,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 = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin); + pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); if (pixely <= 0) return; /* can happen when the view is split/resized */ @@ -721,7 +721,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, (ar->v2d.cur.xmax - ar->v2d.cur.xmin) / ar->winx); + drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx); } /* draw lock */ @@ -811,6 +811,41 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } +ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs) +{ + SeqRenderData context; + ImBuf *ibuf; + int rectx, recty; + float render_size = 0.0; + float proxy_size = 100.0; + + render_size = sseq->render_size; + if (render_size == 0) { + render_size = scene->r.size; + } + else { + proxy_size = render_size; + } + + if (render_size < 0) { + return NULL; + } + + rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f; + recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f; + + context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); + + if (special_seq_update) + ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); + else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { + ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); + else + ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + + return ibuf; +} + 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); @@ -824,7 +859,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq float col[3]; GLuint texid; GLuint last_texid; - SeqRenderData context; render_size = sseq->render_size; if (render_size == 0) { @@ -865,14 +899,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (G.is_rendering) return; - context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); - - if (special_seq_update) - ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); - else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); - else - ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs); if (ibuf == NULL) return; @@ -929,10 +956,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { rctf tot_clip; - tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); - tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); - tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax); - tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax); + 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); 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); @@ -1114,7 +1141,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 = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); + float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_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 9e730fff940..81699d36f5f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -177,7 +177,7 @@ static void proxy_endjob(void *pjv) static void seq_proxy_build_job(const bContext *C) { - wmJob *steve; + wmJob *wm_job; ProxyJob *pj; Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, FALSE); @@ -186,9 +186,10 @@ static void seq_proxy_build_job(const bContext *C) LinkData *link; Sequence *seq; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", + WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PROXY); - pj = WM_jobs_customdata_get(steve); + pj = WM_jobs_customdata_get(wm_job); if (!pj) { pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); @@ -196,9 +197,9 @@ static void seq_proxy_build_job(const bContext *C) pj->scene = scene; pj->main = CTX_data_main(C); - WM_jobs_customdata_set(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); + WM_jobs_customdata_set(wm_job, pj, proxy_freejob); + WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER); + WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob); } SEQP_BEGIN (ed, seq) @@ -211,9 +212,9 @@ static void seq_proxy_build_job(const bContext *C) } SEQ_END - if (!WM_jobs_is_running(steve)) { + if (!WM_jobs_is_running(wm_job)) { G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } ED_area_tag_redraw(CTX_wm_area(C)); @@ -371,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ if (ed == NULL) return NULL; - pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); + pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -2141,8 +2142,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 = (v2d->mask.xmax - v2d->mask.xmin) / winx; - float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy; + float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx; + float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy; BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1); @@ -2245,7 +2246,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) ymax += ymargin; ymin -= ymargin; - orig_height = cur_new.ymax - cur_new.ymin; + orig_height = BLI_RCT_SIZE_Y(&cur_new); cur_new.xmin = xmin; cur_new.xmax = xmax; @@ -2254,8 +2255,8 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) cur_new.ymax = ymax; /* only zoom out vertically */ - if (orig_height > cur_new.ymax - cur_new.ymin) { - ymid = (cur_new.ymax + cur_new.ymin) / 2; + if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) { + ymid = BLI_RCT_CENTER_Y(&cur_new); cur_new.ymin = ymid - (orig_height / 2); cur_new.ymax = ymid + (orig_height / 2); @@ -2287,7 +2288,9 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) } -static int find_next_prev_edit(Scene *scene, int cfra, int side) +static int find_next_prev_edit(Scene *scene, int cfra, + const short side, + const short do_skip_mute, const short do_center) { Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL, *frame_seq = NULL; @@ -2298,19 +2301,32 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) if (ed == NULL) return cfra; for (seq = ed->seqbasep->first; seq; seq = seq->next) { + int seq_frame; + + if (do_skip_mute && (seq->flag & SEQ_MUTE)) { + continue; + } + + if (do_center) { + seq_frame = (seq->startdisp + seq->enddisp) / 2; + } + else { + seq_frame = seq->startdisp; + } + dist = MAXFRAME * 2; switch (side) { case SEQ_SIDE_LEFT: - if (seq->startdisp < cfra) { - dist = cfra - seq->startdisp; + if (seq_frame < cfra) { + dist = cfra - seq_frame; } break; case SEQ_SIDE_RIGHT: - if (seq->startdisp > cfra) { - dist = seq->startdisp - cfra; + if (seq_frame > cfra) { + dist = seq_frame - cfra; } - else if (seq->startdisp == cfra) { + else if (seq_frame == cfra) { frame_seq = seq; } break; @@ -2325,83 +2341,77 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) /* if no sequence to the right is found and the * frame is on the start of the last sequence, * move to the end of the last sequence */ - if (frame_seq) cfra = frame_seq->enddisp; + if (frame_seq) { + if (do_center) { + cfra = (frame_seq->startdisp + frame_seq->enddisp) / 2; + } + else { + cfra = frame_seq->enddisp; + } + } - return best_seq ? best_seq->startdisp : cfra; + if (best_seq) { + if (do_center) { + cfra = (best_seq->startdisp + best_seq->enddisp) / 2; + } + else { + cfra = best_seq->startdisp; + } + } + + return cfra; } -static int next_prev_edit_internal(Scene *scene, int side) +static int strip_jump_internal(Scene *scene, + const short side, + const short do_skip_mute, const short do_center) { - int change = 0; + int change = FALSE; int cfra = CFRA; - int nfra = find_next_prev_edit(scene, cfra, side); + int nfra = find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center); if (nfra != cfra) { CFRA = nfra; - change = 1; + change = TRUE; } return change; } -/* move frame to next edit point operator */ -static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op)) +/* jump frame to edit point operator */ +static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - - if (!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) - return OPERATOR_CANCELLED; - - WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + short next = RNA_boolean_get(op->ptr, "next"); + short center = RNA_boolean_get(op->ptr, "center"); - return OPERATOR_FINISHED; -} - -void SEQUENCER_OT_next_edit(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Next Edit"; - ot->idname = "SEQUENCER_OT_next_edit"; - ot->description = "Move frame to next edit point"; - - /* api callbacks */ - ot->exec = sequencer_next_edit_exec; - ot->poll = sequencer_edit_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ -} - -/* move frame to previous edit point operator */ -static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Scene *scene = CTX_data_scene(C); - - if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) + /* currently do_skip_mute is always TRUE */ + if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, TRUE, center)) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -void SEQUENCER_OT_previous_edit(wmOperatorType *ot) +void SEQUENCER_OT_strip_jump(wmOperatorType *ot) { /* identifiers */ - ot->name = "Previous Edit"; - ot->idname = "SEQUENCER_OT_previous_edit"; + ot->name = "Jump to Strip"; + ot->idname = "SEQUENCER_OT_strip_jump"; ot->description = "Move frame to previous edit point"; - + /* api callbacks */ - ot->exec = sequencer_previous_edit_exec; + ot->exec = sequencer_strip_jump_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", ""); + RNA_def_boolean(ot->srna, "center", TRUE, "Use strip center", ""); } static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) @@ -2768,11 +2778,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) if (ed == NULL) return OPERATOR_CANCELLED; - rect.xmin /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); - rect.ymin /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin)); + rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); + rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); - rect.xmax /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); - rect.ymax /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin)); + rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); + rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); rect.xmin += 0.5f; rect.xmax += 0.5f; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 16cf929a832..f5c3a4c4d89 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -44,6 +44,7 @@ struct ScrArea; struct ARegion; struct ARegionType; struct Scene; +struct Main; /* space_sequencer.c */ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); @@ -51,10 +52,12 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); /* sequencer_draw.c */ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar); -void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); +void draw_image_seq(const struct bContext *C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); void seq_reset_imageofs(struct SpaceSeq *sseq); +struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs); + /* sequencer_edit.c */ struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); @@ -95,8 +98,7 @@ void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot); void SEQUENCER_OT_snap(struct wmOperatorType *ot); -void SEQUENCER_OT_previous_edit(struct wmOperatorType *ot); -void SEQUENCER_OT_next_edit(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_jump(struct wmOperatorType *ot); void SEQUENCER_OT_swap(struct wmOperatorType *ot); void SEQUENCER_OT_swap_data(struct wmOperatorType *ot); void SEQUENCER_OT_rendersize(struct wmOperatorType *ot); @@ -177,5 +179,13 @@ struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf); void sequencer_buttons_register(struct ARegionType *art); void SEQUENCER_OT_properties(struct wmOperatorType *ot); +/* sequencer_modifiers.c */ +void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_modifier_move(struct wmOperatorType *ot); + +/* sequencer_view.c */ +void SEQUENCER_OT_sample(struct wmOperatorType *ot); + #endif /* __SEQUENCER_INTERN_H__ */ diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c new file mode 100644 index 00000000000..a4a485b34c6 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -0,0 +1,222 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +/** \file blender/editors/space_sequencer/sequencer_modifier.c + * \ingroup spseq + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" +#include "DNA_mask_types.h" +#include "DNA_userdef_types.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_sequencer.h" +#include "BKE_movieclip.h" +#include "BKE_sequencer.h" +#include "BKE_mask.h" +#include "BKE_report.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +/* own include */ +#include "sequencer_intern.h" + +/*********************** Add modifier operator *************************/ + +static int strip_modifier_active_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + + if (ed) { + Sequence *seq = BKE_sequencer_active_get(scene); + + if (seq) + return BKE_sequence_supports_modifiers(seq); + } + + return FALSE; +} + +static int strip_modifier_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + int type = RNA_enum_get(op->ptr, "type"); + + BKE_sequence_modifier_new(seq, NULL, type); + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Add Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_add"; + ot->description = "Add a modifier to strip"; + + /* api callbacks */ + ot->exec = strip_modifier_add_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_enum(ot->srna, "type", sequence_modifier_type_items, seqModifierType_ColorBalance, "Type", ""); + ot->prop = prop; +} + +/*********************** Remove modifier operator *************************/ + +static int strip_modifier_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + char name[MAX_NAME]; + SequenceModifierData *smd; + + RNA_string_get(op->ptr, "name", name); + + smd = BKE_sequence_modifier_find_by_name(seq, name); + if (!smd) + return OPERATOR_CANCELLED; + + BLI_remlink(&seq->modifiers, smd); + BKE_sequence_modifier_free(smd); + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_remove"; + ot->description = "Add a modifier to strip"; + + /* api callbacks */ + ot->exec = strip_modifier_remove_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); +} + +/*********************** Move operator *************************/ + +enum { + SEQ_MODIFIER_MOVE_UP = 0, + SEQ_MODIFIER_MOVE_DOWN +}; + +static int strip_modifier_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + char name[MAX_NAME]; + int direction; + SequenceModifierData *smd; + + RNA_string_get(op->ptr, "name", name); + direction = RNA_enum_get(op->ptr, "direction"); + + smd = BKE_sequence_modifier_find_by_name(seq, name); + if (!smd) + return OPERATOR_CANCELLED; + + if (direction == SEQ_MODIFIER_MOVE_UP) { + if (smd->prev) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->prev->prev, smd); + } + } + else if (direction == SEQ_MODIFIER_MOVE_DOWN) { + if (smd->next) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->next, smd); + } + } + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"}, + {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Move Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_move"; + ot->description = "Move modifier up and down in the stack"; + + /* api callbacks */ + ot->exec = strip_modifier_move_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); + RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", ""); +} diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 4a1c8f0c006..aa6bacf8836 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -72,8 +72,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); WM_operatortype_append(SEQUENCER_OT_snap); - WM_operatortype_append(SEQUENCER_OT_next_edit); - WM_operatortype_append(SEQUENCER_OT_previous_edit); + WM_operatortype_append(SEQUENCER_OT_strip_jump); WM_operatortype_append(SEQUENCER_OT_swap); WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); @@ -114,6 +113,14 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_copy); WM_operatortype_append(SEQUENCER_OT_paste); + + /* sequencer_modifiers.c */ + WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); + WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove); + WM_operatortype_append(SEQUENCER_OT_strip_modifier_move); + + /* sequencer_view.h */ + WM_operatortype_append(SEQUENCER_OT_sample); } @@ -185,8 +192,20 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", FALSE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", FALSE); + + /* alt for center */ + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", TRUE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", TRUE); 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); @@ -319,6 +338,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) 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); #endif + + /* sample */ + WM_keymap_add_item(keymap, "SEQUENCER_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0); } void ED_operatormacros_sequencer(void) diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c new file mode 100644 index 00000000000..fa39003bd55 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -0,0 +1,221 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +/** \file blender/editors/space_sequencer/sequencer_modifier.c + * \ingroup spseq + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" + +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_sequencer.h" +#include "BKE_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_image.h" +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "UI_view2d.h" + +/* own include */ +#include "sequencer_intern.h" + +/******************** sample backdrop operator ********************/ + +typedef struct ImageSampleInfo { + ARegionType *art; + void *draw_handle; + int x, y; + int channels; + + unsigned char col[4]; + float colf[4]; + + unsigned char *colp; + float *colfp; + + int draw; +} ImageSampleInfo; + +static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) +{ + Scene *scene = CTX_data_scene(C); + 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); + } +} + +static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); + ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0); + ImageSampleInfo *info = op->customdata; + float fx, fy; + + if (ibuf == NULL) { + IMB_freeImBuf(ibuf); + info->draw = 0; + return; + } + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); + + fx += (float) ibuf->x / 2.0f; + fy += (float) ibuf->y / 2.0f; + + if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { + float *fp; + unsigned char *cp; + int x = (int) fx, y = (int) fy; + + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; + + info->colp = NULL; + info->colfp = NULL; + + if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; + info->colp = info->col; + + info->colf[0] = (float)cp[0] / 255.0f; + 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->colfp = info->colf; + } + if (ibuf->rect_float) { + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); + + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; + info->colfp = info->colf; + } + } + else { + info->draw = 0; + } + + IMB_freeImBuf(ibuf); + ED_area_tag_redraw(CTX_wm_area(C)); +} + +static void sample_exit(bContext *C, wmOperator *op) +{ + ImageSampleInfo *info = op->customdata; + + ED_region_draw_cb_exit(info->art, info->draw_handle); + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(info); +} + +static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + ImageSampleInfo *info; + + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; + info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); + op->customdata = info; + + sample_apply(C, op, event); + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + switch (event->type) { + case LEFTMOUSE: + case RIGHTMOUSE: /* XXX hardcoded */ + sample_exit(C, op); + return OPERATOR_CANCELLED; + case MOUSEMOVE: + sample_apply(C, op, event); + break; + } + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_cancel(bContext *C, wmOperator *op) +{ + sample_exit(C, op); + + return OPERATOR_CANCELLED; +} + +int sample_poll(bContext *C) +{ + return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; +} + +void SEQUENCER_OT_sample(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Sample Color"; + ot->idname = "SEQUENCER_OT_sample"; + ot->description = "Use mouse to sample color in current frame"; + + /* api callbacks */ + ot->invoke = sample_invoke; + ot->modal = sample_modal; + ot->cancel = sample_cancel; + ot->poll = sample_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING; +} diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 6240d174575..97eb5b41db7 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -39,6 +39,7 @@ #include "BLF_api.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "DNA_text_types.h" @@ -1231,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 * MIN2(st->txtscroll.xmax - st->txtscroll.xmin, st->txtscroll.ymax - st->txtscroll.ymin); + rad = 0.4f * mini(BLI_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll)); UI_GetThemeColor3ubv(TH_HILITE, col); col[3] = 48; glColor4ubv(col); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index df90ce24dda..5af44f93d06 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2409,8 +2409,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 + (st->txtbar.xmax + st->txtbar.xmin) / 2; - tsc->old[1] = ar->winrct.ymin + (st->txtbar.ymax + st->txtbar.ymin) / 2; + 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->delta[0] = 0; tsc->delta[1] = 0; diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 189c8bfc7d0..733fd27135b 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 * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b31550af289..6a9be8d979c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -193,6 +193,17 @@ static void drawcircle_size(float size); static void draw_empty_sphere(float size); static void draw_empty_cone(float size); +static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], const int theme_id, float fac) +{ + float col_wire[3], col_bg[3], col[3]; + + rgb_uchar_to_float(col_wire, ob_wire_col); + + UI_GetThemeColor3fv(theme_id, col_bg); + interp_v3_v3v3(col, col_bg, col_wire, fac); + glColor3fv(col); +} + /* this condition has been made more complex since editmode can draw textures */ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) { @@ -653,7 +664,7 @@ void drawaxes(float size, char drawtype) /* Function to draw an Image on a empty Object */ -static void draw_empty_image(Object *ob) +static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4]) { Image *ima = (Image *)ob->data; ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; @@ -726,15 +737,17 @@ static void draw_empty_image(Object *ob) glDisable(GL_BLEND); } - UI_ThemeColor((ob->flag & SELECT) ? TH_SELECT : TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); - /* Calculate the outline vertex positions */ - glBegin(GL_LINE_LOOP); - glVertex2f(ofs_x, ofs_y); - glVertex2f(ofs_x + ima_x, ofs_y); - glVertex2f(ofs_x + ima_x, ofs_y + ima_y); - glVertex2f(ofs_x, ofs_y + ima_y); - glEnd(); + /* Calculate the outline vertex positions */ + glBegin(GL_LINE_LOOP); + glVertex2f(ofs_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y + ima_y); + glVertex2f(ofs_x, ofs_y + ima_y); + glEnd(); + } /* Reset GL settings */ glMatrixMode(GL_MODELVIEW); @@ -1559,17 +1572,18 @@ static void draw_bundle_sphere(void) static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, MovieTrackingObject *tracking_object, - const short dflag, int *global_track_index, int draw_selected) + const short dflag, const unsigned char ob_wire_col[4], + int *global_track_index, int draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; float mat[4][4], imat[4][4]; - unsigned char col[4], scol[4]; + unsigned char col_unsel[4], col_sel[4]; int tracknr = *global_track_index; ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); - UI_GetThemeColor4ubv(TH_TEXT, col); - UI_GetThemeColor4ubv(TH_SELECT, scol); + UI_GetThemeColor4ubv(TH_TEXT, col_unsel); + UI_GetThemeColor4ubv(TH_SELECT, col_sel); BKE_tracking_get_camera_object_matrix(scene, base->object, mat); @@ -1612,13 +1626,13 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->drawtype == OB_WIRE) { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } + else { + glColor3fv(track->color); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1629,8 +1643,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) { /* selection outline */ if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } glLineWidth(2.f); glDisable(GL_LIGHTING); @@ -1643,21 +1658,24 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glLineWidth(1.f); } - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_BUNDLE_SOLID); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_BUNDLE_SOLID); + } draw_bundle_sphere(); } else { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected) { + glColor3ubv(ob_wire_col); + } + else { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_WIRE); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1670,13 +1688,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) { float pos[3]; - unsigned char tcol[4]; - - if (selected) memcpy(tcol, scol, sizeof(tcol)); - else memcpy(tcol, col, sizeof(tcol)); mul_v3_m4v3(pos, mat, track->bundle_pos); - view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, tcol); + view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, selected ? col_sel : col_unsel); } tracknr++; @@ -1734,7 +1748,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, tracking_object = tracking->objects.first; while (tracking_object) { draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object, - dflag, &global_track_index, draw_selected); + dflag, ob_wire_col, &global_track_index, draw_selected); tracking_object = tracking_object->next; } @@ -2242,9 +2256,9 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; @@ -3354,7 +3368,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) } static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const short dflag) + const short dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; Mesh *me = ob->data; @@ -3428,13 +3442,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } if (!(draw_flags & DRAW_FACE_SELECT)) { - if (base->flag & SELECT) - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - else - UI_ThemeColor(TH_WIRE); - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } dm->drawLooseEdges(dm); + } } } else if (dt == OB_SOLID) { @@ -3518,14 +3531,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); - if (base->flag & SELECT) { - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - } - else { - UI_ThemeColor(TH_WIRE); - } - if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) + if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } dm->drawLooseEdges(dm); + } } } else if (dt == OB_PAINT) { @@ -3534,42 +3545,22 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* since we already draw wire as wp guide, don't draw over the top */ draw_wire = OBDRAW_WIRE_OFF; } - - /* set default draw color back for wire or for draw-extra later on */ - if (dt != OB_WIRE) { - if (base->flag & SELECT) { - if (is_obact && ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP_ACTIVE); - else if (ob->flag & OB_FROMGROUP) - UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); - else if (dflag != DRAW_CONSTCOLOR) - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - else - glColor3ub(80, 80, 80); - } - else { - if (ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP); - else { - if (ob->dtx & OB_DRAWWIRE && dflag == DRAW_CONSTCOLOR) - glColor3ub(80, 80, 80); - else - UI_ThemeColor(TH_WIRE); - } - } - } - if (draw_wire != OBDRAW_WIRE_OFF) { + if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */ + /* when overriding with render only, don't bother */ + (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0)) + { /* When using wireframe object draw in particle edit mode * the mesh gets in the way of seeing the particles, fade the wire color * with the background. */ - if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { - float col_wire[4], col_bg[4], col[3]; - UI_GetThemeColor3fv(TH_BACK, col_bg); - glGetFloatv(GL_CURRENT_COLOR, col_wire); - interp_v3_v3v3(col, col_bg, col_wire, 0.15); - glColor3fv(col); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f); + } + else { + glColor3ubv(ob_wire_col); + } } /* If drawing wire and drawtype is not OB_WIRE then we are @@ -3586,8 +3577,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ } - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) - dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), me->drawflag & ME_ALLEDGES); + dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), me->drawflag & ME_ALLEDGES); if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { glDepthMask(1); @@ -3609,7 +3599,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* returns 1 if nothing was drawn, for detecting to draw an object center */ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const short dflag) + const short dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; Object *obedit = scene->obedit; @@ -3673,7 +3663,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D (check_alpha) ? &do_alpha_after : NULL); } - draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, dflag); + draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); GPU_end_object_materials(); @@ -5913,9 +5903,9 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[ glVertex3f(cur[0], cur[1] - radius, cur[2]); glEnd(); } -/* return 1 if nothing was drawn */ +/* return TRUE if nothing was drawn */ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const unsigned char ob_wire_col[4]) + const short dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; MetaBall *mb; @@ -5942,27 +5932,32 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml = mb->elems.first; } - if (ml == NULL) return 1; + if (ml == NULL) { + return TRUE; + } - if (v3d->flag2 & V3D_RENDER_OVERRIDE) return 0; - - /* in case solid draw, reset wire colors */ - if (ob->flag & SELECT) { - if (ob == OBACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); + if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + return FALSE; } - else UI_ThemeColor(TH_WIRE); invert_m4_m4(imat, rv3d->viewmatob); normalize_v3(imat[0]); normalize_v3(imat[1]); + + if (mb->editelems == NULL) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } + } while (ml) { /* draw radius */ if (mb->editelems) { - if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); - else cpack(0x3030A0); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); + else cpack(0x3030A0); + } if (G.f & G_PICKSEL) { ml->selcol1 = code; @@ -5973,8 +5968,10 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* draw stiffness */ if (mb->editelems) { - if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); - else cpack(0x30A030); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); + else cpack(0x30A030); + } if (G.f & G_PICKSEL) { ml->selcol2 = code; @@ -5985,23 +5982,16 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml = ml->next; } - return 0; + return FALSE; } -static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) +static void draw_forcefield(Object *ob, RegionView3D *rv3d, + const short dflag, const unsigned char ob_wire_col[4]) { PartDeflect *pd = ob->pd; float imat[4][4], tmat[4][4]; float vec[3] = {0.0, 0.0, 0.0}; - int curcol; float size; - - /* XXX why? */ - if (ob != scene->obedit && (ob->flag & SELECT)) { - if (ob == OBACT) curcol = TH_ACTIVE; - else curcol = TH_SELECT; - } - else curcol = TH_EMPTY; /* scale size of circle etc with the empty drawsize */ if (ob->type == OB_EMPTY) size = ob->empty_drawsize; @@ -6014,16 +6004,19 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) if (pd->forcefield == PFIELD_WIND) { float force_val; - - unit_m4(tmat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); - + + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } + //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); //else { force_val = pd->f_strength; } + + unit_m4(tmat); force_val *= 0.1f; drawcircball(GL_LINE_LOOP, vec, size, tmat); vec[2] = 0.5f * force_val; @@ -6045,11 +6038,11 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) ffall_val = pd->f_power; } - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); drawcircball(GL_LINE_LOOP, vec, size, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); drawcircball(GL_LINE_LOOP, vec, size * 2.0f, imat); } else if (pd->forcefield == PFIELD_VORTEX) { @@ -6068,7 +6061,10 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) force_val = pd->f_strength; } - UI_ThemeColorBlend(curcol, TH_BACK, 0.7f); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.7f); + } + if (force_val < 0) { drawspiral(vec, size, tmat, 1); drawspiral(vec, size, tmat, 16); @@ -6090,16 +6086,18 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) mindist = pd->f_strength; } + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } + /*path end*/ setlinestyle(3); where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); /*path beginning*/ setlinestyle(0); where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); copy_v3_v3(vec, guidevec1); /* max center */ @@ -6107,7 +6105,10 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) } setlinestyle(3); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); + + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } if (pd->falloff == PFIELD_FALL_SPHERE) { /* as last, guide curve alters it */ @@ -6357,59 +6358,46 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glDepthMask(1); } -static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) +static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsigned char ob_wire_col[4]) { - if (ob != scene->obedit && (ob->flag & SELECT)) { - if (ob == OBACT) { - if (ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP_ACTIVE); - else UI_ThemeColor(TH_ACTIVE); + if (ELEM4(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) { + + if (scene->obedit == ob) { + UI_ThemeColor(TH_WIRE); } - else if (ob->flag & OB_FROMGROUP) - UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); - else - UI_ThemeColor(TH_SELECT); - } - else { - if (ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP); else { - if (ob->dtx & OB_DRAWWIRE) { - glColor3ub(80, 80, 80); - } - else { - UI_ThemeColor(TH_WIRE); - } + glColor3ubv(ob_wire_col); } - } - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ - if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - Curve *cu = ob->data; - if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - if (ob->type == OB_CURVE) - draw_index_wire = 0; + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ + + if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { + Curve *cu = ob->data; + if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { + if (ob->type == OB_CURVE) + draw_index_wire = 0; + + if (ob->derivedFinal) { + drawCurveDMWired(ob); + } + else { + drawDispListwire(&ob->disp); + } - if (ob->derivedFinal) { - drawCurveDMWired(ob); + if (ob->type == OB_CURVE) + draw_index_wire = 1; } - else { + } + else if (ob->type == OB_MBALL) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } - - if (ob->type == OB_CURVE) - draw_index_wire = 1; - } - } - else if (ob->type == OB_MBALL) { - if (BKE_mball_is_basis(ob)) { - drawDispListwire(&ob->disp); } - } - glDepthMask(1); - bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + bglPolygonOffset(rv3d->dist, 0.0); + } } /* should be called in view space */ @@ -6550,7 +6538,10 @@ static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_ r_ob_wire_col[3] = 255; } -/* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET */ +/** + * main object drawing function, draws in selection + * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET + */ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag) { static int warning_recursive = 0; @@ -6692,7 +6683,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short switch (ob->type) { case OB_MESH: - empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, dflag); + empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself break; @@ -6812,20 +6803,20 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short MetaBall *mb = ob->data; if (mb->editelems) - drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); + drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else - empty_object = drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); + empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); break; } case OB_EMPTY: if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob); + draw_empty_image(ob, dflag, ob_wire_col); } else { drawaxes(ob->empty_drawsize, ob->empty_drawtype); @@ -6897,7 +6888,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } if (ob->pd && ob->pd->forcefield) { - draw_forcefield(scene, ob, rv3d); + draw_forcefield(ob, rv3d, dflag, ob_wire_col); } } @@ -7106,7 +7097,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } /*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/ if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) { - drawWireExtra(scene, rv3d, ob); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + draw_wire_extra(scene, rv3d, ob, ob_wire_col); + } } } } @@ -7578,7 +7571,8 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object break; case OB_EMPTY: if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob); + /* CONSTCOLOR == no wire outline */ + draw_empty_image(ob, DRAW_CONSTCOLOR, NULL); } else { drawaxes(ob->empty_drawsize, ob->empty_drawtype); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 199a1751f9d..24395865a5e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -971,10 +971,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) / (rect_view.xmax - rect_view.xmin)) * ar->winx; - viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx; - viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; - viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy; + 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; } void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) @@ -982,8 +982,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] = viewborder.xmax - viewborder.xmin; - size_r[1] = viewborder.ymax - viewborder.ymin; + size_r[0] = BLI_RCT_SIZE_X(&viewborder); + size_r[1] = BLI_RCT_SIZE_Y(&viewborder); } void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, @@ -1339,7 +1339,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_MULTISAMPLE_ARB); region_scissor_winrct(ar, &winrct); - glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin); + glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct)); glClearColor(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { @@ -2038,8 +2038,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) x = rect->xmin; y = rect->ymin; - w = rect->xmax - rect->xmin; - h = rect->ymax - rect->ymin; + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); if (w <= 0 || h <= 0) { if (d->depths) @@ -2846,10 +2846,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 * (viewborder.xmax - viewborder.xmin); - cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin); - cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin); - cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin); + 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 += ar->winrct.xmin; cliprct.xmax += ar->winrct.xmin; @@ -2863,7 +2863,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, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); + glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct)); } else return 0; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8b8adb193bf..e74bda87a43 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -382,10 +382,10 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) radius = TRACKBALLSIZE; /* normalize x and y */ - x = (rect->xmax + rect->xmin) / 2 - mx; - x /= (float)((rect->xmax - rect->xmin) / 4); - y = (rect->ymax + rect->ymin) / 2 - my; - y /= (float)((rect->ymax - rect->ymin) / 2); + 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); d = sqrt(x * x + y * y); if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ @@ -662,8 +662,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (vod->use_dyn_ofs) { /* compute the post multiplication quat, to rotate the offset correctly */ - copy_qt_qt(q1, vod->oldquat); - conjugate_qt(q1); + conjugate_qt_qt(q1, vod->oldquat); mul_qt_qtqt(q1, q1, vod->viewquat); conjugate_qt(q1); /* conj == inv for unit quat */ @@ -1022,9 +1021,10 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* tune these until everything feels right */ const float rot_sensitivity = 1.f; +#if 0 const float zoom_sensitivity = 1.f; +#endif const float pan_sensitivity = 1.f; - const int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec); float view_inv[4]; @@ -1036,20 +1036,6 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); #endif - if (ndof->tz) { - /* Zoom! - * velocity should be proportional to the linear velocity attained by rotational motion of same strength - * [got that?] - * proportional to arclength = radius * angle - */ - float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz; - - if (U.ndof_flag & NDOF_ZOOM_INVERT) - zoom_distance = -zoom_distance; - - rv3d->dist += zoom_distance; - } - if (rv3d->viewlock == RV3D_LOCKED) { /* rotation not allowed -- explore panning options instead */ float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f}; @@ -1067,34 +1053,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rv3d->view = RV3D_VIEW_USER; - if (U.flag & USER_TRACKBALL) { - float rot[4]; - float axis[3]; - float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); - - if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) - axis[2] = -axis[2]; - - if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) - axis[0] = -axis[0]; - - if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) - axis[1] = -axis[1]; - - /* transform rotation axis from view to world coordinates */ - mul_qt_v3(view_inv, axis); - - /* update the onscreen doo-dad */ - rv3d->rot_angle = angle; - copy_v3_v3(rv3d->rot_axis, axis); - - axis_angle_to_quat(rot, axis, angle); - - /* apply rotation */ - mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); - - } - else { + if (U.ndof_flag & NDOF_TURNTABLE) { /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ float angle, rot[4]; @@ -1127,6 +1086,33 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rot[3] = sin(angle); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); } + else { + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } } } @@ -1247,6 +1233,160 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) ot->flag = 0; } + +/* +* this is basically just the pan only code + the rotate only code crammed into one function that does both +*/ +static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if (event->type != NDOF_MOTION) + return OPERATOR_CANCELLED; + else { + + ViewOpsData *vod; + RegionView3D *rv3d; + + View3D *v3d = CTX_wm_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + + viewops_data_create(C, op, event); + vod = op->customdata; + rv3d = vod->rv3d; + + ED_view3d_camera_lock_init(v3d, rv3d); + + if (ndof->progress != P_FINISHING) { + + const float dt = ndof->dt; + float view_inv[4]; + + float speed = 10.f; /* blender units per second */ + /* ^^ this is ok for default cube scene, but should scale with.. something */ + + /* tune these until everything feels right */ + const float forward_sensitivity = 1.f; + const float vertical_sensitivity = 0.4f; + const float lateral_sensitivity = 0.6f; + + float pan_vec[3]; + const float rot_sensitivity = 1.f; +#if 0 + const float zoom_sensitivity = 1.f; + const float pan_sensitivity = 1.f; + float rot[4]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + float axis[3]; +#endif + + if (U.ndof_flag & NDOF_PANX_INVERT_AXIS) + pan_vec[0] = -lateral_sensitivity * ndof->tvec[0]; + else + pan_vec[0] = lateral_sensitivity * ndof->tvec[0]; + + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) + pan_vec[1] = -vertical_sensitivity * ndof->tvec[1]; + else + pan_vec[1] = vertical_sensitivity * ndof->tvec[1]; + + if (U.ndof_flag & NDOF_PANY_INVERT_AXIS) + pan_vec[2] = -forward_sensitivity * ndof->tvec[2]; + else + pan_vec[2] = forward_sensitivity * ndof->tvec[2]; + + mul_v3_fl(pan_vec, speed * dt); + + /* transform motion from view to world coordinates */ + invert_qt_qt(view_inv, rv3d->viewquat); + mul_qt_v3(view_inv, pan_vec); + + /* move center of view opposite of hand motion (this is camera mode, not object mode) */ + sub_v3_v3(rv3d->ofs, pan_vec); + + if (U.ndof_flag & NDOF_TURNTABLE) { + /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ + float angle, rot[4]; + float xvec[3] = {1, 0, 0}; + + /* Determine the direction of the x vector (for rotating up and down) */ + mul_qt_v3(view_inv, xvec); + + /* Perform the up/down rotation */ + angle = rot_sensitivity * dt * ndof->rx; + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + angle = -angle; + rot[0] = cos(angle); + mul_v3_v3fl(rot + 1, xvec, sin(angle)); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + /* Perform the orbital rotation */ + angle = rot_sensitivity * dt * ndof->ry; + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + angle = -angle; + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + rv3d->rot_axis[0] = 0; + rv3d->rot_axis[1] = 0; + rv3d->rot_axis[2] = 1; + + rot[0] = cos(angle); + rot[1] = rot[2] = 0.0; + rot[3] = sin(angle); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + else { + + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + } + ED_view3d_camera_lock_sync(v3d, rv3d); + + ED_region_tag_redraw(CTX_wm_region(C)); + viewops_data_free(C, op); + return OPERATOR_FINISHED; + } +} + +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "NDOF move View"; + ot->description = "Position your viewpoint with the 3D mouse"; + ot->idname = "VIEW3D_OT_ndof_all"; + + /* api callbacks */ + ot->invoke = ndof_all_invoke; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; +} + /* ************************ viewmove ******************************** */ @@ -1525,8 +1665,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] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; - ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; + ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct); + ctr[1] = BLI_RCT_CENTER_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; @@ -2072,7 +2212,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - BKE_object_minmax(base->object, min, max); + BKE_object_minmax(base->object, min, max, FALSE); } } if (!onedone) { @@ -2218,8 +2358,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) - BKE_object_minmax(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max, FALSE) == 0) + BKE_object_minmax(base->object, min, max, FALSE); /* use if duplis not found */ ok = 1; } @@ -2476,10 +2616,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) / (vb.xmax - vb.xmin); - scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin); - scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin); - scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin); + 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); /* actually set border */ CLAMP(scene->r.border.xmin, 0.0f, 1.0f); @@ -2643,8 +2783,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } /* work out the ratios, so that everything selected fits when we zoom */ - xscale = ((rect.xmax - rect.xmin) / vb[0]); - yscale = ((rect.ymax - rect.ymin) / vb[1]); + xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]); + yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]); new_dist *= maxf(xscale, yscale); /* zoom in as required, or as far as we can go */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 561e97a8393..855771b17a2 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -489,7 +489,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) else if (event->type == NDOF_MOTION) { /* do these automagically get delivered? yes. */ // puts("ndof motion detected in fly mode!"); - // static const char* tag_name = "3D mouse position"; + // static const char *tag_name = "3D mouse position"; wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata; switch (incoming_ndof->progress) { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a6a22d85cd9..996525d2be4 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -79,6 +79,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot); void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7b3e7358978..14c02c2357e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -64,6 +64,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_dolly); WM_operatortype_append(VIEW3D_OT_ndof_orbit); WM_operatortype_append(VIEW3D_OT_ndof_pan); + WM_operatortype_append(VIEW3D_OT_ndof_all); WM_operatortype_append(VIEW3D_OT_view_all); WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_view_orbit); @@ -221,8 +222,9 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "align_active", TRUE); /* 3D mouse */ - WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_pan", NDOF_MOTION, 0, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_all", NDOF_MOTION, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 69fa42b0abb..6f3cc744537 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -291,7 +291,7 @@ static int view3d_selectable_data(bContext *C) /* helper also for borderselect */ static int edge_fully_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) { - return BLI_in_rcti(rect, x1, y1) && BLI_in_rcti(rect, x2, y2); + return BLI_rcti_isect_pt(rect, x1, y1) && BLI_rcti_isect_pt(rect, x2, y2); } static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) @@ -394,7 +394,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); @@ -425,7 +425,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_face_select_set(data->vc->em->bm, efa, data->select); @@ -654,8 +654,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; int a, index; char *selar; - int sx = rect->xmax - rect->xmin + 1; - int sy = rect->ymax - rect->ymin + 1; + int sx = BLI_RCT_SIZE_X(rect) + 1; + int sy = BLI_RCT_SIZE_Y(rect) + 1; me = vc->obact->data; @@ -765,12 +765,11 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { - - node_centf[0] = (node->totr.xmin + node->totr.xmax) / 2; - node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; + node_centf[0] = BLI_RCT_CENTER_X(&node->totr); + node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } @@ -1553,7 +1552,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi Object *obedit = data->vc->obedit; Curve *cu = (Curve *)obedit->data; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; @@ -1600,7 +1599,7 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } @@ -1625,7 +1624,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); } } @@ -1651,7 +1650,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_face_select_set(data->vc->em->bm, efa, data->select); } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 604d101abd5..fbbf23beca4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -308,11 +308,11 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent step_inv = 1.0f - step; - interp_v3_v3v3(rv3d->ofs, sms->new_ofs, sms->orig_ofs, step); + interp_v3_v3v3(rv3d->ofs, sms->orig_ofs, sms->new_ofs, step); interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); rv3d->dist = sms->new_dist * step + sms->orig_dist * step_inv; - v3d->lens = sms->new_lens * step + sms->orig_lens * step_inv; + v3d->lens = sms->new_lens * step + sms->orig_lens * step_inv; ED_view3d_camera_lock_sync(v3d, rv3d); } @@ -1212,10 +1212,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b rect.ymax = input->ymin + 12; } else { - rect.xmin = input->xmin; - rect.xmax = input->xmax; - rect.ymin = input->ymin; - rect.ymax = input->ymax; + BLI_rctf_rcti_copy(&rect, input); } setwinmatrixview3d(ar, v3d, &rect); @@ -1409,7 +1406,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL } else { if (scene->obedit) { - BKE_object_minmax(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max, FALSE); ok = TRUE; @@ -1419,7 +1416,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - BKE_object_minmax(base->object, min, max); + BKE_object_minmax(base->object, min, max, FALSE); base->lay |= locallay; base->object->lay = base->lay; ok = TRUE; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f88d4becc74..8259ca64bad 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -125,11 +125,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy) { float divx, divy; - divx = v2d->mask.xmax - v2d->mask.xmin; - divy = v2d->mask.ymax - v2d->mask.ymin; + divx = BLI_RCT_SIZE_X(&v2d->mask); + divy = BLI_RCT_SIZE_Y(&v2d->mask); - r_vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx; - r_vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy; + r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx; + r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy; r_vec[2] = 0.0f; } @@ -138,11 +138,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy) float divx, divy; float mulx, muly; - divx = v2d->mask.xmax - v2d->mask.xmin; - divy = v2d->mask.ymax - v2d->mask.ymin; + divx = BLI_RCT_SIZE_X(&v2d->mask); + divy = BLI_RCT_SIZE_Y(&v2d->mask); - mulx = (v2d->cur.xmax - v2d->cur.xmin); - muly = (v2d->cur.ymax - v2d->cur.ymin); + mulx = BLI_RCT_SIZE_X(&v2d->cur); + muly = BLI_RCT_SIZE_Y(&v2d->cur); /* difference with convertViewVec2D */ /* clamp w/h, mask only */ @@ -208,6 +208,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) /* TODO - NOT WORKING, this isnt so bad since its only display aspect */ ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); } + else { + /* should never happen, quiet warnings */ + BLI_assert(0); + aspx = aspy = 1.0f; + } r_vec[0] *= aspx; r_vec[1] *= aspy; @@ -4978,7 +4983,9 @@ static int createSlideVerts(TransInfo *t) /* This test is only relevant if object is not wire-drawn! See [#32068]. */ if (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE && !BMBVH_EdgeVisible(btree, e2, ar, v3d, t->obedit)) + { continue; + } j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index c22a645eb53..8eba8ebea41 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4209,7 +4209,7 @@ static void freeSeqData(TransInfo *t) for (a = 0; a < t->total; a++, td++) { if ((seq != seq_prev) && (seq->depth == 0) && (seq->flag & SEQ_OVERLAP)) { seq = ((TransDataSeq *)td->extra)->seq; - shuffle_seq(seqbasep, seq); + BKE_sequence_base_shuffle(seqbasep, seq, t->scene); } seq_prev = seq; @@ -4244,7 +4244,7 @@ static void freeSeqData(TransInfo *t) has_effect = TRUE; } else { - /* Tag seq with a non zero value, used by shuffle_seq_time to identify the ones to shuffle */ + /* Tag seq with a non zero value, used by BKE_sequence_base_shuffle_time to identify the ones to shuffle */ seq->tmp = (void *)1; } } @@ -4289,7 +4289,7 @@ static void freeSeqData(TransInfo *t) BKE_sequence_base_shuffle_time(seqbasep, t->scene); } #else - shuffle_seq_time(seqbasep, t->scene); + BKE_sequence_base_shuffle_time(seqbasep, t->scene); #endif if (has_effect) { @@ -4340,6 +4340,9 @@ static void freeSeqData(TransInfo *t) for (a = 0; a < t->total; a++, td++) { seq = ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth == 0)) { + if (seq->flag & SEQ_OVERLAP) + BKE_sequence_base_shuffle(seqbasep, seq, t->scene); + BKE_sequence_calc_disp(t->scene, seq); } seq_prev = seq; @@ -5548,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] = {(node->totr.xmax + node->totr.xmin) / 2.0f, - (node->totr.ymax + node->totr.ymin) / 2.0f}; + float locxy[2] = {BLI_RCT_CENTER_X(&node->totr), + BLI_RCT_CENTER_Y(&node->totr)}; copy_v2_v2(td2d->loc, locxy); td2d->loc[2] = 0.0f; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8e73fb8b8cb..bcebca52ce8 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -71,6 +71,7 @@ #include "BKE_mesh.h" #include "BKE_nla.h" #include "BKE_context.h" +#include "BKE_sequencer.h" #include "BKE_tessmesh.h" #include "BKE_tracking.h" #include "BKE_mask.h" @@ -890,6 +891,14 @@ static void recalcData_view3d(TransInfo *t) } } +/* helper for recalcData() - for sequencer transforms */ +static void recalcData_sequencer(TransInfo *t) +{ + BKE_sequencer_preprocessed_cache_cleanup(); + + flushTransSeq(t); +} + /* called for updating while transform acts, once per redraw */ void recalcData(TransInfo *t) { @@ -897,7 +906,7 @@ void recalcData(TransInfo *t) flushTransNodes(t); } else if (t->spacetype == SPACE_SEQ) { - flushTransSeq(t); + recalcData_sequencer(t); } else if (t->spacetype == SPACE_ACTION) { recalcData_actedit(t); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a89ba06c1af..74a2292d74c 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -84,22 +84,22 @@ /* return codes for select, and drawing flags */ -#define MAN_TRANS_X 1 -#define MAN_TRANS_Y 2 -#define MAN_TRANS_Z 4 -#define MAN_TRANS_C 7 - -#define MAN_ROT_X 8 -#define MAN_ROT_Y 16 -#define MAN_ROT_Z 32 -#define MAN_ROT_V 64 -#define MAN_ROT_T 128 -#define MAN_ROT_C 248 - -#define MAN_SCALE_X 256 -#define MAN_SCALE_Y 512 -#define MAN_SCALE_Z 1024 -#define MAN_SCALE_C 1792 +#define MAN_TRANS_X (1 << 0) +#define MAN_TRANS_Y (1 << 1) +#define MAN_TRANS_Z (1 << 2) +#define MAN_TRANS_C (MAN_TRANS_X | MAN_TRANS_Y | MAN_TRANS_Z) + +#define MAN_ROT_X (1 << 3) +#define MAN_ROT_Y (1 << 4) +#define MAN_ROT_Z (1 << 5) +#define MAN_ROT_V (1 << 6) +#define MAN_ROT_T (1 << 7) +#define MAN_ROT_C (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z | MAN_ROT_V | MAN_ROT_T) + +#define MAN_SCALE_X (1 << 8) +#define MAN_SCALE_Y (1 << 9) +#define MAN_SCALE_Z (1 << 10) +#define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) /* color codes */ diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index b9583fc21e1..237f6b35eb0 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -33,6 +33,7 @@ #include "DNA_armature_types.h" #include "DNA_curve_types.h" #include "DNA_mesh_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -549,8 +550,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Object *ob = OBACT; int result = ORIENTATION_NONE; - normal[0] = normal[1] = normal[2] = 0; - plane[0] = plane[1] = plane[2] = 0; + zero_v3(normal); + zero_v3(plane); if (obedit) { float imat[3][3], mat[3][3]; @@ -743,37 +744,20 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } } else if (obedit->type == OB_MBALL) { -#if 0 // XXX - /* editmball.c */ - MetaElem *ml, *ml_sel = NULL; - - /* loop and check that only one element is selected */ - for (ml = editelems.first; ml; ml = ml->next) { - if (ml->flag & SELECT) { - if (ml_sel == NULL) { - ml_sel = ml; - } - else { - ml_sel = NULL; - break; - } - } - } + MetaBall *mb = obedit->data; - if (ml_sel) { + if (mb->lastelem) { float mat[4][4]; /* Rotation of MetaElem is stored in quat */ - quat_to_mat4(mat, ml_sel->quat); + quat_to_mat4(mat, mb->lastelem->quat); copy_v3_v3(normal, mat[2]); negate_v3_v3(plane, mat[1]); - result = ORIENTATION_NORMAL; + result = ORIENTATION_FACE; } -#endif - } else if (obedit->type == OB_ARMATURE) { bArmature *arm = obedit->data; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fcb857be4e0..89cb83e3661 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -961,8 +961,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 = node->totr.xmax - node->totr.xmin; - float height = node->totr.ymax - node->totr.ymin; + float width = BLI_RCT_SIZE_X(&node->totr); + float height = BLI_RCT_SIZE_Y(&node->totr); if (border & NODE_LEFT) t->tsnap.snapTarget[0] -= 0.5f * width; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 65b92168842..4213ff68cf2 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -129,7 +129,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) /* undo during jobs are running can easily lead to freeing data using by jobs, * or they can just lead to freezing job in some other cases */ - if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_ANY)) { return OPERATOR_CANCELLED; } @@ -359,7 +359,7 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) * (which copy their data), wont stop redo, see [#29579]], * * note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */ - (WM_jobs_test(wm, scene) == 0)) + (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0)) { int retval; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 54c5cbfce93..6f3e6bee850 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -205,8 +205,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im ED_image_get_uv_aspect(previma, prev_aspect, prev_aspect + 1); ED_image_get_uv_aspect(ima, aspect, aspect + 1); - fprev_aspect = prev_aspect[0]/prev_aspect[1]; - faspect = aspect[0]/aspect[1]; + fprev_aspect = prev_aspect[0] / prev_aspect[1]; + faspect = aspect[0] / aspect[1]; #endif /* ensure we have a uv map */ @@ -2567,7 +2567,7 @@ static int border_select_exec(bContext *C, wmOperator *op) tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (uvedit_face_visible_test(scene, ima, efa, tf)) { uv_poly_center(em, efa, cent); - if (BLI_in_rctf_v(&rectf, cent)) { + if (BLI_rctf_isect_pt_v(&rectf, cent)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2592,13 +2592,13 @@ static int border_select_exec(bContext *C, wmOperator *op) if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if (BLI_in_rctf_v(&rectf, luv->uv)) { + if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } } else if (pinned) { - if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf_v(&rectf, luv->uv)) { + if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) { if (select) uvedit_uv_select_enable(em, scene, l, FALSE); else uvedit_uv_select_disable(em, scene, l); } @@ -2771,7 +2771,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh float cent[2]; uv_poly_center(em, efa, cent); UI_view2d_view_to_region(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti_v(&rect, screen_uv) && + if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { uvedit_face_select_enable(scene, em, efa, FALSE); @@ -2788,7 +2788,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh if ((select) != (uvedit_uv_select_test(em, scene, l))) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UI_view2d_view_to_region(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]); - if (BLI_in_rcti_v(&rect, screen_uv) && + if (BLI_rcti_isect_pt_v(&rect, screen_uv) && BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED)) { if (select) { diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 2161d4989db..f017394356e 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -45,7 +45,7 @@ #include <stdio.h> #include <string.h> -#include "BLO_sys_types.h" // for intptr_t support +#include "BLO_sys_types.h" /* for intptr_t support */ /* Utils */ @@ -1040,7 +1040,7 @@ static PFace *p_face_add(PHandle *handle) /* allocate */ f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f); - f->flag = 0; // init ! + f->flag = 0; /* init ! */ e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1); e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2); @@ -1135,7 +1135,11 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3) static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys) { - float fac = len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]); + /* slight bias to prefer one edge over the other in case they are equal, so + * that in symmetric models we choose the same split direction instead of + * depending on floating point errors to decide */ + float bias = 1.0f + 1e-6f; + float fac = len_v3v3(co[0], co[2]) * bias - len_v3v3(co[1], co[3]); PBool dir = (fac <= 0.0f); /* the face exists check is there because of a special case: when diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 682b35072f6..b4903390408 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -882,14 +882,14 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result, mid_v3_v3v3(result, min, max); break; - case V3D_CURSOR: /*cursor center*/ + case V3D_CURSOR: /* cursor center */ cursx = give_cursor(scene, v3d); /* shift to objects world */ sub_v3_v3v3(result, cursx, ob->obmat[3]); break; - case V3D_LOCAL: /*object center*/ - case V3D_CENTROID: /* multiple objects centers, only one object here*/ + case V3D_LOCAL: /* object center */ + case V3D_CENTROID: /* multiple objects centers, only one object here*/ default: result[0] = result[1] = result[2] = 0.0; break; |