summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-09-22 21:44:40 +0100
committerTom Hacohen <tom@stosb.com>2014-09-22 21:44:40 +0100
commit1c7f31bc0f9f3bc639b18ba4790ba469f9b87792 (patch)
tree4e8be24e20c20e473bc6d624d3fe8decafbad676
parent432ca9ea0e61a9492173402307128d1cfc0d1a6a (diff)
Create windows according to the pdf's ratios.
-rw-r--r--src/bin/main.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 0fa06d1..6ace3bf 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -144,6 +144,9 @@ main(int argc, char *argv[])
144 144
145 DBG("Opening filename: '%s'", ctx.filename); 145 DBG("Opening filename: '%s'", ctx.filename);
146 146
147 w *= elm_config_scale_get();
148 h *= elm_config_scale_get();
149
147 /* Main win */ 150 /* Main win */
148 ctx.main.win = elm_win_add(NULL, "gifter", ELM_WIN_BASIC); 151 ctx.main.win = elm_win_add(NULL, "gifter", ELM_WIN_BASIC);
149 eo_do(ctx.main.win, elm_obj_win_autodel_set(EINA_FALSE), 152 eo_do(ctx.main.win, elm_obj_win_autodel_set(EINA_FALSE),
@@ -154,7 +157,7 @@ main(int argc, char *argv[])
154 evas_obj_visibility_set(EINA_TRUE), 157 evas_obj_visibility_set(EINA_TRUE),
155 elm_obj_bg_color_set(0, 0, 0, 255)); 158 elm_obj_bg_color_set(0, 0, 0, 255));
156 159
157 evas_object_resize(ctx.main.win, w * elm_config_scale_get(), h * elm_config_scale_get()); 160 evas_object_resize(ctx.main.win, w, h);
158 elm_win_resize_object_add(ctx.main.win, bg); 161 elm_win_resize_object_add(ctx.main.win, bg);
159 eo_unref(bg); 162 eo_unref(bg);
160 163
@@ -166,6 +169,20 @@ main(int argc, char *argv[])
166 elm_win_resize_object_add(ctx.main.win, ctx.main.pdf); 169 elm_win_resize_object_add(ctx.main.win, ctx.main.pdf);
167 eo_unref(ctx.main.pdf); 170 eo_unref(ctx.main.pdf);
168 171
172 {
173 /* Update w/h according to aspect ratio. */
174 int tw = 0, th = 0;
175 eo_do(ctx.main.pdf, elm_obj_image_object_size_get(&tw, &th));
176
177 if (tw && th)
178 {
179 double ratio = ((double) th) / tw;
180 h = w * ratio;
181 }
182
183 evas_object_resize(ctx.main.win, w, h);
184 }
185
169 evas_object_smart_callback_add(ctx.main.win, "delete,request", my_win_del, NULL); 186 evas_object_smart_callback_add(ctx.main.win, "delete,request", my_win_del, NULL);
170 evas_object_show(ctx.main.win); 187 evas_object_show(ctx.main.win);
171 188
@@ -178,7 +195,7 @@ main(int argc, char *argv[])
178 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 195 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
179 evas_obj_visibility_set(EINA_TRUE)); 196 evas_obj_visibility_set(EINA_TRUE));
180 197
181 evas_object_resize(ctx.preview.win, w * elm_config_scale_get(), h * elm_config_scale_get()); 198 evas_object_resize(ctx.preview.win, w, h);
182 elm_win_resize_object_add(ctx.preview.win, bg); 199 elm_win_resize_object_add(ctx.preview.win, bg);
183 eo_unref(bg); 200 eo_unref(bg);
184 201