sequencer numpad keys for zoom levels
This commit is contained in:
@@ -52,6 +52,8 @@ void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float
|
||||
void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
|
||||
void BLI_translate_rctf(struct rctf *rect, float x, float y);
|
||||
void BLI_translate_rcti(struct rcti *rect, int x, int y);
|
||||
void BLI_resize_rcti(struct rcti *rect, int x, int y);
|
||||
void BLI_resize_rctf(struct rctf *rect, float x, float y);
|
||||
int BLI_in_rcti(struct rcti *rect, int x, int y);
|
||||
int BLI_in_rctf(struct rctf *rect, float x, float y);
|
||||
int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
|
||||
|
||||
@@ -703,7 +703,7 @@ int BLI_path_cwd(char *path)
|
||||
}
|
||||
|
||||
|
||||
/* copy di to fi, filename only */
|
||||
/* 'di's filename component is moved into 'fi', di is made a dir path */
|
||||
void BLI_splitdirstring(char *di, char *fi)
|
||||
{
|
||||
char *lslash= BLI_last_slash(di);
|
||||
|
||||
@@ -142,6 +142,27 @@ void BLI_translate_rctf(rctf *rect, float x, float y)
|
||||
rect->ymax += y;
|
||||
}
|
||||
|
||||
/* change width & height around the central location */
|
||||
void BLI_resize_rcti(rcti *rect, int x, int y)
|
||||
{
|
||||
rect->xmin= rect->xmax= (rect->xmax + rect->xmin) / 2;
|
||||
rect->ymin= rect->ymax= (rect->ymax + rect->ymin) / 2;
|
||||
rect->xmin -= x / 2;
|
||||
rect->ymin -= y / 2;
|
||||
rect->xmax= rect->xmin + x;
|
||||
rect->ymax= rect->ymin + y;
|
||||
}
|
||||
|
||||
void BLI_resize_rctf(rctf *rect, float x, float y)
|
||||
{
|
||||
rect->xmin= rect->xmax= (rect->xmax + rect->xmin) * 0.5f;
|
||||
rect->ymin= rect->ymax= (rect->ymax + rect->ymin) * 0.5f;
|
||||
rect->xmin -= x * 0.5f;
|
||||
rect->ymin -= y * 0.5f;
|
||||
rect->xmax= rect->xmin + x;
|
||||
rect->ymax= rect->ymin + y;
|
||||
}
|
||||
|
||||
int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest)
|
||||
{
|
||||
float xmin, xmax;
|
||||
|
||||
@@ -2218,6 +2218,43 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER;
|
||||
}
|
||||
|
||||
|
||||
static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
RenderData *r= &CTX_data_scene(C)->r;
|
||||
View2D *v2d= UI_view2d_fromcontext(C);
|
||||
|
||||
float ratio= RNA_float_get(op->ptr, "ratio");
|
||||
|
||||
float winx= (int)(r->size * r->xsch)/100;
|
||||
float winy= (int)(r->size * r->ysch)/100;
|
||||
|
||||
float facx= (v2d->mask.xmax - v2d->mask.xmin) / winx;
|
||||
float facy= (v2d->mask.ymax - v2d->mask.ymin) / winy;
|
||||
|
||||
BLI_resize_rctf(&v2d->cur, winx*facx*ratio, winy*facy*ratio);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Sequencer View Zoom Ratio";
|
||||
ot->idname= "SEQUENCER_OT_view_zoom_ratio";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= sequencer_view_zoom_ratio_exec;
|
||||
ot->poll= ED_operator_sequencer_active;
|
||||
|
||||
/* properties */
|
||||
RNA_def_float(ot->srna, "ratio", 1.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);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static EnumPropertyItem view_type_items[] = {
|
||||
{SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
|
||||
|
||||
@@ -100,6 +100,7 @@ void SEQUENCER_OT_rendersize(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_view_zoom_ratio(struct wmOperatorType *ot);
|
||||
|
||||
void SEQUENCER_OT_copy(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_paste(struct wmOperatorType *ot);
|
||||
|
||||
@@ -79,6 +79,7 @@ void sequencer_operatortypes(void)
|
||||
WM_operatortype_append(SEQUENCER_OT_view_selected);
|
||||
WM_operatortype_append(SEQUENCER_OT_view_all_preview);
|
||||
WM_operatortype_append(SEQUENCER_OT_view_toggle);
|
||||
WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
|
||||
|
||||
/* sequencer_select.c */
|
||||
WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
|
||||
@@ -224,5 +225,17 @@ void sequencer_keymap(wmKeyConfig *keyconf)
|
||||
keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
|
||||
|
||||
|
||||
keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
|
||||
|
||||
/* would prefer to use numpad keys for job */
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user