aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-05-12 19:19:29 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-05-12 19:21:48 +0900
commit3a602462971861d9b7a65aa4aa795f3ee182ab44 (patch)
tree9f09db9405f035c4bf75d32a928160ee42fcf7a6 /src
parentefreet: Fix failure to save list data to output (diff)
downloadefl-3a602462971861d9b7a65aa4aa795f3ee182ab44.tar.gz
efl ui win -> add test for centering + fix center of window before show
we haven't gotten replies yet on what our position or size should be, so we should store them so centering works before show but after resizing is evaluated (that also fixed by forcing an eval). @fix
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_win_dialog.c36
-rw-r--r--src/lib/elementary/efl_ui_win.c51
2 files changed, 83 insertions, 4 deletions
diff --git a/src/bin/elementary/test_win_dialog.c b/src/bin/elementary/test_win_dialog.c
index a7c3bf31eb..b90dfc61da 100644
--- a/src/bin/elementary/test_win_dialog.c
+++ b/src/bin/elementary/test_win_dialog.c
@@ -99,6 +99,36 @@ _bt3_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
efl_gfx_visible_set(dia, EINA_TRUE);
}
+static void
+_bt4_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Efl_Canvas_Object *dia, *lb, *parent = data;
+
+ dia = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL,
+ efl_ui_win_type_set(efl_added, EFL_UI_WIN_DIALOG_BASIC),
+ efl_ui_win_name_set(efl_added, "window-dia-4"),
+ efl_ui_win_autodel_set(efl_added, EINA_TRUE),
+ efl_text_set(efl_added, "Min/Max Size Dialog")
+ );
+
+ //lb = efl_add(EFL_UI_TEXT_CLASS, dia);,
+ lb = elm_label_add(dia);
+ efl_event_callback_add(dia, EFL_GFX_EVENT_CHANGE_SIZE_HINTS, _size_update, lb);
+ efl_event_callback_add(dia, EFL_GFX_EVENT_RESIZE, _size_update, lb);
+ elm_object_text_set(lb, "This is a Centered Dialog Window");
+ efl_gfx_size_hint_weight_set(lb, 1.0, 1.0);
+
+ // Swallow in the label as the default content, this will make it visible.
+ efl_content_set(dia, lb);
+
+ // Set min & max size (app-side)
+ efl_gfx_size_hint_min_set(dia, ELM_SCALE_SIZE(0), ELM_SCALE_SIZE(100));
+ efl_gfx_size_hint_max_set(dia, ELM_SCALE_SIZE(800), ELM_SCALE_SIZE(600));
+
+ efl_ui_win_center(dia, EINA_TRUE, EINA_TRUE);
+ efl_gfx_visible_set(dia, EINA_TRUE);
+}
+
void
test_win_dialog(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -130,6 +160,12 @@ test_win_dialog(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *even
elm_box_pack_end(box, bt);
evas_object_show(bt);
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Create a new centered dialog");
+ evas_object_smart_callback_add(bt, "clicked", _bt4_clicked_cb, win);
+ elm_box_pack_end(box, bt);
+ evas_object_show(bt);
+
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 0d9907e7bf..0feb119eb6 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -187,10 +187,13 @@ struct _Efl_Ui_Win_Data
int aspect_w, aspect_h; /* used for the get API */
int size_base_w, size_base_h;
int size_step_w, size_step_h;
+ int req_x, req_y, req_w, req_h;
int max_w, max_h;
int norender;
int modal_count;
int response;
+ Eina_Bool req_wh : 1;
+ Eina_Bool req_xy : 1;
struct {
short pointer_move;
@@ -874,6 +877,7 @@ _elm_win_move(Ecore_Evas *ee)
efl_event_callback_legacy_call(sd->obj, EFL_GFX_EVENT_MOVE, NULL);
evas_nochange_push(evas_object_evas_get(sd->obj));
sd->response++;
+ sd->req_xy = EINA_FALSE;
evas_object_move(sd->obj, x, y);
sd->response--;
evas_nochange_pop(evas_object_evas_get(sd->obj));
@@ -915,6 +919,7 @@ _elm_win_resize_job(void *data)
}
sd->response++;
+ sd->req_wh = EINA_FALSE;
evas_object_resize(sd->obj, w, h);
evas_object_resize(sd->legacy.edje, w, h);
sd->response--;
@@ -2899,7 +2904,13 @@ _efl_ui_win_efl_gfx_position_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Coord x, Eva
}
else
{
- if (!sd->response) TRAP(sd, move, x, y);
+ if (!sd->response)
+ {
+ sd->req_xy = EINA_TRUE;
+ sd->req_x = x;
+ sd->req_y = y;
+ TRAP(sd, move, x, y);
+ }
if (!ecore_evas_override_get(sd->ee)) goto super_skip;
}
@@ -2959,7 +2970,13 @@ _efl_ui_win_efl_gfx_size_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Coord w, Evas_Co
}
_elm_win_frame_geometry_adjust(sd);
- if (!sd->response) TRAP(sd, resize, w, h);
+ if (!sd->response)
+ {
+ sd->req_wh = EINA_TRUE;
+ sd->req_w = w;
+ sd->req_h = h;
+ TRAP(sd, resize, w, h);
+ }
efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);
}
@@ -3444,11 +3461,18 @@ _elm_win_resize_objects_eval(Evas_Object *obj)
if (w > maxw) w = maxw;
if (h > maxh) h = maxh;
//if ((w == ow) && (h == oh)) return;
+ sd->req_wh = EINA_FALSE;
if (sd->img_obj) evas_object_resize(obj, w, h);
else
{
_elm_win_frame_geometry_adjust(sd);
- if (!sd->response) TRAP(sd, resize, w, h);
+ if (!sd->response)
+ {
+ sd->req_wh = EINA_TRUE;
+ sd->req_w = w;
+ sd->req_h = h;
+ TRAP(sd, resize, w, h);
+ }
}
}
@@ -5416,6 +5440,10 @@ _efl_ui_win_center(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool h, Eina_Bool v)
{
int win_w, win_h, screen_x, screen_y, screen_w, screen_h, nx, ny;
+ if (sd->deferred_resize_job) _elm_win_resize_job(sd->obj);
+ if (sd->frame_obj) edje_object_message_signal_process(sd->frame_obj);
+ evas_smart_objects_calculate(evas_object_evas_get(obj));
+ _elm_win_resize_objects_eval(obj);
if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj, h, v)))
return;
@@ -5424,12 +5452,27 @@ _efl_ui_win_center(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool h, Eina_Bool v)
&screen_w, &screen_h);
if ((!screen_w) || (!screen_h)) return;
- evas_object_geometry_get(obj, &nx, &ny, &win_w, &win_h);
+ if (sd->req_wh)
+ {
+ win_w = sd->req_w;
+ win_h = sd->req_h;
+ }
+ else evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
+ if (sd->req_xy)
+ {
+ nx = sd->req_x;
+ ny = sd->req_y;
+ }
+ else evas_object_geometry_get(obj, &nx, &ny, NULL, NULL);
+
if ((!win_w) || (!win_h)) return;
if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
+ sd->req_xy = EINA_TRUE;
+ sd->req_x = screen_x + nx;
+ sd->req_y = screen_y + ny;
evas_object_move(obj, screen_x + nx, screen_y + ny);
}