diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:47:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:59:40 +0400 |
commit | 9ae0e585b0aab466c978ec1a55c824d902faa3b4 (patch) | |
tree | 6a99d63651f1b66ffacac2582b5f03d58898ad99 /source/blender/editors/space_sequencer | |
parent | 6ee8670fca946d146332e80ceff29e459cd91ed5 (diff) |
View2d: API Cleanup for view<->region conversion
View2D had some inconsistencies making it error prone in some cases.
- Inconstant checking for NULL x/y args.
Disallow NULL args for x/y destination pointers, instead add:
- UI_view2d_region_to_view_x/y
- UI_view2d_view_to_region_x/y
- '_no_clip' suffix wasn't always used for non-clipping conversion,
switch it around and use a '_clip' suffix for all funcs that clip.
- UI_view2d_text_cache_add now clips before adding cache.
- '_clip' funcs return a bool to quickly check if its in the view.
- add conversion for rectangles, since this is a common task:
- UI_view2d_view_to_region_rcti
- UI_view2d_region_to_view_rctf
Diffstat (limited to 'source/blender/editors/space_sequencer')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_select.c | 14 |
2 files changed, 5 insertions, 17 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 8c664a1f423..f14eb2f1b18 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2955,17 +2955,13 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot) static int view_ghost_border_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = BKE_sequencer_editing_get(scene, false); View2D *v2d = UI_view2d_fromcontext(C); rctf rect; /* convert coordinates of rect to 'tot' rect coordinates */ - UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin); - UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax); - - if (ed == NULL) - return OPERATOR_CANCELLED; + WM_operator_properties_border_to_rctf(op, &rect); + UI_view2d_region_to_view_rctf(v2d, &rect, &rect); rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot)); rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot)); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 496be65cf0e..cfae0056a35 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -361,7 +361,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e /* use different logic for this */ float x; ED_sequencer_deselect_all(scene); - UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); + x = UI_view2d_region_to_view_x(v2d, event->mval[0]); SEQP_BEGIN (ed, seq) { @@ -849,23 +849,15 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) View2D *v2d = UI_view2d_fromcontext(C); Sequence *seq; - rcti rect; rctf rectf, rq; const bool select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); const bool extend = RNA_boolean_get(op->ptr, "extend"); - int mval[2]; if (ed == NULL) return OPERATOR_CANCELLED; - WM_operator_properties_border_to_rcti(op, &rect); - - mval[0] = rect.xmin; - mval[1] = rect.ymin; - UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin); - mval[0] = rect.xmax; - mval[1] = rect.ymax; - UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax); + WM_operator_properties_border_to_rctf(op, &rectf); + UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf); for (seq = ed->seqbasep->first; seq; seq = seq->next) { seq_rectf(seq, &rq); |