[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59339] trunk/blender/source/blender/ editors/space_image: Image Editor: implement FKey to call 'View All' with ' fit_view'
Dalai Felinto
dfelinto at gmail.com
Wed Aug 21 01:40:46 CEST 2013
Revision: 59339
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59339
Author: dfelinto
Date: 2013-08-20 23:40:46 +0000 (Tue, 20 Aug 2013)
Log Message:
-----------
Image Editor: implement FKey to call 'View All' with 'fit_view'
This mimics the behaviour we have in the Clip Editor.
I personally would prefer if we had no border once in fullscreen
(current border is 5 pixels).
I will consult Sergey Sharybin first to see if we can change that in the clip editor as well (though there I
believe the border is useful - the bottom of the editor is used to indicate 'tracked' frames.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_image/image_ops.c
trunk/blender/source/blender/editors/space_image/space_image.c
Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c 2013-08-20 23:23:17 UTC (rev 59338)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c 2013-08-20 23:40:46 UTC (rev 59339)
@@ -646,12 +646,13 @@
* Default behavior is to reset the position of the image and set the zoom to 1
* If the image will not fit within the window rectangle, the zoom is adjusted */
-static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int image_view_all_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima;
ARegion *ar;
float aspx, aspy, zoomx, zoomy, w, h;
int width, height;
+ int fit_view = RNA_boolean_get(op->ptr, "fit_view");
/* retrieve state */
sima = CTX_wm_space_image(C);
@@ -667,15 +668,26 @@
width = BLI_rcti_size_x(&ar->winrct) + 1;
height = BLI_rcti_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 */
- zoomx = width / w;
- zoomy = height / h;
- sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
+ if (fit_view) {
+ const int margin = 5; /* margin from border */
+
+ zoomx = (float) width / (w + 2 * margin);
+ zoomy = (float) height / (h + 2 * margin);
+
+ sima_zoom_set(sima, ar, min_ff(zoomx, zoomy), NULL);
}
- else
- sima_zoom_set(sima, ar, 1.0f, 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 */
+ sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
+ }
+ else
+ sima_zoom_set(sima, ar, 1.0f, NULL);
+ }
+
sima->xof = sima->yof = 0.0f;
ED_region_tag_redraw(CTX_wm_region(C));
@@ -685,6 +697,8 @@
void IMAGE_OT_view_all(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "View All";
ot->idname = "IMAGE_OT_view_all";
@@ -693,6 +707,10 @@
/* api callbacks */
ot->exec = image_view_all_exec;
ot->poll = space_image_main_area_poll;
+
+ /* properties */
+ prop = RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/********************** view selected operator *********************/
Modified: trunk/blender/source/blender/editors/space_image/space_image.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/space_image.c 2013-08-20 23:23:17 UTC (rev 59338)
+++ trunk/blender/source/blender/editors/space_image/space_image.c 2013-08-20 23:40:46 UTC (rev 59339)
@@ -277,6 +277,10 @@
keymap = WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+
+ kmi = WM_keymap_add_item(keymap, "IMAGE_OT_view_all", FKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "fit_view", TRUE);
+
WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
More information about the Bf-blender-cvs
mailing list