[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29525] trunk/blender/source/blender: sequencer numpad keys for zoom levels
Campbell Barton
ideasman42 at gmail.com
Thu Jun 17 16:22:54 CEST 2010
Revision: 29525
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29525
Author: campbellbarton
Date: 2010-06-17 16:22:54 +0200 (Thu, 17 Jun 2010)
Log Message:
-----------
sequencer numpad keys for zoom levels
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_rect.h
trunk/blender/source/blender/blenlib/intern/path_util.c
trunk/blender/source/blender/blenlib/intern/rct.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c
trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h
trunk/blender/source/blender/editors/space_sequencer/sequencer_ops.c
Modified: trunk/blender/source/blender/blenlib/BLI_rect.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_rect.h 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/blenlib/BLI_rect.h 2010-06-17 14:22:54 UTC (rev 29525)
@@ -52,6 +52,8 @@
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);
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2010-06-17 14:22:54 UTC (rev 29525)
@@ -703,7 +703,7 @@
}
-/* 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);
Modified: trunk/blender/source/blender/blenlib/intern/rct.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/rct.c 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/blenlib/intern/rct.c 2010-06-17 14:22:54 UTC (rev 29525)
@@ -142,6 +142,27 @@
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;
Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c 2010-06-17 14:22:54 UTC (rev 29525)
@@ -2218,6 +2218,43 @@
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", ""},
Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_intern.h 2010-06-17 14:22:54 UTC (rev 29525)
@@ -100,6 +100,7 @@
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);
Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_ops.c 2010-06-17 14:22:13 UTC (rev 29524)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_ops.c 2010-06-17 14:22:54 UTC (rev 29525)
@@ -79,6 +79,7 @@
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 @@
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);
}
More information about the Bf-blender-cvs
mailing list