Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-03-05 01:02:58 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-03-05 01:02:58 +0400
commit5f509134ec22102cb00fdc9a623798c149fa43a9 (patch)
tree637b8066b22cd5413147c8318778fd85a8b72cd3 /source/blender/editors/space_clip
parentc395c862e96bcf2f63d4f60b2863933b52b277cc (diff)
Added option to fit frame to the whole clip editor viewport instead of zooming
to a power-of-two factor. Shortcut is F.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_ops.c32
-rw-r--r--source/blender/editors/space_clip/space_clip.c4
2 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 99ee4974659..d627d0cbfd7 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -649,12 +649,14 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot)
/********************** view all operator *********************/
-static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int view_all_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc;
ARegion *ar;
int w, h, width, height;
float aspx, aspy;
+ int fit_view= RNA_boolean_get(op->ptr, "fit_view");
+ float zoomx, zoomy;
/* retrieve state */
sc= CTX_wm_space_clip(C);
@@ -670,16 +672,25 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
width= ar->winrct.xmax - ar->winrct.xmin + 1;
height= ar->winrct.ymax - ar->winrct.ymin + 1;
- if((w >= width || h >= height) && (width > 0 && height > 0)) {
- float zoomx, zoomy;
+ if(fit_view) {
+ const int margin = 5; /* margin from border */
- /* find the zoom value that will fit the image in the image space */
- zoomx= (float)width/w;
- zoomy= (float)height/h;
- sclip_zoom_set(sc, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL);
+ zoomx= (float)width / (w + 2*margin);
+ zoomy= (float)height / (h + 2*margin);
+
+ sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL);
+ }
+ else {
+ if((w >= width || h >= height) && (width > 0 && height > 0)) {
+ zoomx= (float)width/w;
+ zoomy= (float)height/h;
+
+ /* find the zoom value that will fit the image in the image space */
+ sclip_zoom_set(sc, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL);
+ }
+ else
+ sclip_zoom_set(sc, ar, 1.0f, NULL);
}
- else
- sclip_zoom_set(sc, ar, 1.0f, NULL);
sc->xof= sc->yof= 0.0f;
@@ -697,6 +708,9 @@ void CLIP_OT_view_all(wmOperatorType *ot)
/* api callbacks */
ot->exec= view_all_exec;
ot->poll= ED_space_clip_poll;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
}
/********************** view selected operator *********************/
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 2c98f460749..fe0bb425de6 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -461,6 +461,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
RNA_float_set(WM_keymap_add_item(keymap, "CLIP_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
WM_keymap_add_item(keymap, "CLIP_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+
+ kmi = WM_keymap_add_item(keymap, "CLIP_OT_view_all", FKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "fit_view", TRUE);
+
WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
/* jump to special frame */