Compare commits
4 Commits
master
...
devs/thiep
Author | SHA1 | Date |
---|---|---|
Thiep Ha | 9c96a1f05e | |
Thiep Ha | 87de2deb55 | |
Thiep Ha | 635af90cb6 | |
Thiep Ha | 746e0f62c4 |
|
@ -18,6 +18,7 @@ typedef enum {
|
|||
TWO
|
||||
} Weight_Mode;
|
||||
|
||||
/*
|
||||
static void
|
||||
weights_cb(void *data, const Efl_Event *event)
|
||||
{
|
||||
|
@ -210,6 +211,7 @@ custom_check_cb(void *data, const Efl_Event *event)
|
|||
// function was just overridden.
|
||||
efl_pack_layout_request(box);
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
|
@ -231,7 +233,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
|
||||
|
||||
/* controls */
|
||||
f = elm_frame_add(win);
|
||||
/*f = elm_frame_add(win);
|
||||
elm_object_text_set(f, "Controls");
|
||||
efl_gfx_size_hint_align_set(f, -1, -1);
|
||||
efl_gfx_size_hint_weight_set(f, 1, 0);
|
||||
|
@ -244,7 +246,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_gfx_visible_set(hbox, 1);
|
||||
|
||||
|
||||
/* weights radio group */
|
||||
/* weights radio group *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -298,7 +300,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
elm_radio_value_set(chk, NONE);
|
||||
|
||||
|
||||
/* misc */
|
||||
/* misc *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -353,7 +355,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
|
||||
/* user min size setter */
|
||||
/* user min size setter *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -380,7 +382,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
|
||||
/* inner box padding */
|
||||
/* inner box padding *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -407,7 +409,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
|
||||
/* outer margin */
|
||||
/* outer margin *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -434,7 +436,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
|
||||
/* Box align */
|
||||
/* Box align *
|
||||
bx = efl_add(EFL_UI_BOX_CLASS, win,
|
||||
efl_orientation_set(efl_added, EFL_ORIENT_DOWN));
|
||||
efl_gfx_size_hint_align_set(bx, 0, -1);
|
||||
|
@ -472,7 +474,7 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
elm_slider_step_set(o, 0.1);
|
||||
elm_slider_value_set(o, 0.5);
|
||||
efl_pack(bx, o);
|
||||
efl_gfx_visible_set(o, 1);
|
||||
efl_gfx_visible_set(o, 1);*/
|
||||
|
||||
|
||||
/* contents */
|
||||
|
@ -488,17 +490,24 @@ test_ui_box(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
efl_pack_padding_set(bx, 10, 10, EINA_TRUE);
|
||||
efl_gfx_size_hint_align_set(bx, 0.5, 0.5);
|
||||
efl_gfx_size_hint_weight_set(bx, 1, 1);
|
||||
//efl_orientation_set(bx, EFL_ORIENT_HORIZONTAL);
|
||||
efl_orientation_set(bx, EFL_ORIENT_VERTICAL);
|
||||
elm_object_content_set(f, bx);
|
||||
efl_gfx_visible_set(bx, 1);
|
||||
|
||||
objects[i++] = o = elm_button_add(win);
|
||||
elm_object_text_set(o, "Btn1");
|
||||
efl_gfx_size_hint_weight_set(o, 1, 1);
|
||||
efl_pack(bx, o);
|
||||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
objects[i++] = o = elm_button_add(win);
|
||||
elm_object_text_set(o, "Button 2");
|
||||
efl_gfx_size_hint_weight_set(o, 1, 1);
|
||||
efl_gfx_size_hint_align_set(o, -1, -1);
|
||||
//efl_gfx_size_hint_min_set(o, 200, 200);
|
||||
efl_gfx_size_hint_max_set(o, -1, 0);
|
||||
efl_gfx_size_hint_aspect_set(o, EFL_GFX_SIZE_HINT_ASPECT_BOTH, 3, 1);
|
||||
efl_pack(bx, o);
|
||||
efl_gfx_visible_set(o, 1);
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
evas_object_box_layout_stack);
|
||||
|
||||
elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
|
||||
_test_box_transition_change(&tdata);
|
||||
//_test_box_transition_change(&tdata);
|
||||
|
||||
evas_object_resize(win, 300, 320);
|
||||
evas_object_show(win);
|
||||
|
|
|
@ -7,7 +7,13 @@ static void
|
|||
on_click(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_exit();
|
||||
//elm_exit();
|
||||
}
|
||||
|
||||
static void
|
||||
_button_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
printf("%s %d: clicked by edje\n\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
EAPI_MAIN int
|
||||
|
@ -32,6 +38,10 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
evas_object_move(btn, 60, 15);
|
||||
evas_object_show(btn);
|
||||
|
||||
//elm_object_signal_callback_add(btn, "elm,action,click", "*",
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(btn), "elm,action,click", "*",
|
||||
_button_clicked_cb, btn);
|
||||
|
||||
evas_object_resize(win, 240, 60);
|
||||
evas_object_show(win);
|
||||
|
||||
|
|
|
@ -66,8 +66,12 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
// Adding layout and filling it with widgets
|
||||
layout = elm_layout_add(win);
|
||||
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, layout);
|
||||
snprintf(buf, sizeof(buf), "%s/examples/layout_example.edj", elm_app_data_dir_get());
|
||||
//elm_win_resize_object_add(win, layout);
|
||||
//evas_object_resize(layout, 100, 100);
|
||||
evas_object_size_hint_min_set(layout, 100, 100);
|
||||
evas_object_move(layout, 0, 0);
|
||||
//snprintf(buf, sizeof(buf), "%s/examples/layout_example.edj", elm_app_data_dir_get());
|
||||
snprintf(buf, sizeof(buf), "%s/layout_example.edj", ".");
|
||||
elm_layout_file_set(layout, buf, "example/mylayout");
|
||||
evas_object_show(layout);
|
||||
|
||||
|
@ -129,6 +133,32 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
elm_object_part_content_set(layout, SWALLOW, bt2);
|
||||
evas_object_smart_callback_add(bt2, "clicked", _swallow_btn_cb, layout);
|
||||
|
||||
|
||||
//proxy of layout: OK
|
||||
//proxy of mapped object: No
|
||||
Evas_Object *proxy = evas_object_image_filled_add(evas_object_evas_get(layout));
|
||||
//Evas_Object *proxy = evas_object_image_add(evas_object_evas_get(layout)); //must be filled image
|
||||
evas_object_image_source_set(proxy, layout);
|
||||
evas_object_resize(proxy, 100, 100);
|
||||
evas_object_move(proxy, 200, 200);
|
||||
evas_object_show(proxy);
|
||||
|
||||
//map of layout: OK
|
||||
Evas_Coord x, y, w, h;
|
||||
evas_object_geometry_get(layout, &x, &y, &w, &h);
|
||||
printf("layout geo: %d %d %d %d\n", x, y, w, h);
|
||||
Evas_Map *m = evas_map_new(4);
|
||||
evas_map_point_coord_set(m, 0, 100, 100, 0);
|
||||
evas_map_point_coord_set(m, 1, 200, 100, 0);
|
||||
evas_map_point_coord_set(m, 2, 100, 200, 0);
|
||||
evas_map_point_coord_set(m, 3, 0, 200, 0);
|
||||
evas_map_point_image_uv_set(m, 0, 0, 0);
|
||||
evas_map_point_image_uv_set(m, 1, 100, 0);
|
||||
evas_map_point_image_uv_set(m, 2, 100, 100);
|
||||
evas_map_point_image_uv_set(m, 3, 0, 100);
|
||||
evas_object_map_enable_set(layout, EINA_TRUE);
|
||||
evas_object_map_set(layout, m);
|
||||
|
||||
evas_object_resize(win, 320, 320);
|
||||
evas_object_show(win);
|
||||
|
||||
|
|
|
@ -15,9 +15,13 @@ struct _Item_Calc
|
|||
int max[2];
|
||||
int pad[4];
|
||||
int want[2];
|
||||
Efl_Gfx_Size_Hint_Aspect aspect;
|
||||
int aw, ah;
|
||||
int min[2];
|
||||
int id;
|
||||
};
|
||||
|
||||
#define D(format, args...) WRN("item: %d (%s): " format, id, elm_object_text_get((items[id]).obj), ##args)
|
||||
void
|
||||
_efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
||||
{
|
||||
|
@ -38,6 +42,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
evas_object_geometry_get(ui_box, &boxx, &boxy, &boxw, &boxh);
|
||||
efl_gfx_size_hint_margin_get(ui_box, &boxl, &boxr, &boxt, &boxb);
|
||||
scale = evas_object_scale_get(ui_box);
|
||||
WRN("box geo: %d %d %d %d ------------------------------", boxx, boxy, boxw, boxh);
|
||||
|
||||
// Box align: used if "item has max size and fill" or "no item has a weight"
|
||||
// Note: cells always expand on the orthogonal direction
|
||||
|
@ -77,6 +82,86 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
efl_gfx_size_hint_margin_get(o, &item->pad[0], &item->pad[1], &item->pad[2], &item->pad[3]);
|
||||
efl_gfx_size_hint_max_get(o, &item->max[0], &item->max[1]);
|
||||
efl_gfx_size_hint_combined_min_get(o, &item->want[0], &item->want[1]);
|
||||
efl_gfx_size_hint_aspect_get(o, &item->aspect, &item->aw, &item->ah);
|
||||
efl_gfx_size_hint_min_get(o, &item->min[0], &item->min[1]);
|
||||
D("weight: %1.f %.1f, align: %.1f %.1f, min: %d %d, max: %d %d, aspect: (%d) %d %d", item->weight[0], item->weight[1], item->align[0], item->align[1], item->min[0], item->min[1], item->max[0], item->max[1], item->aspect, item->aw, item->ah);
|
||||
if (item->aw == 0 || item->ah == 0)
|
||||
{
|
||||
item->aw = item->ah = 0;
|
||||
item->aspect = EFL_GFX_SIZE_HINT_ASPECT_NONE;
|
||||
}
|
||||
|
||||
//aspect ratio support
|
||||
//lam sao de tinh chi tinh min + van support aspect ratio???
|
||||
if (item->aspect >= EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
int w1, h1;
|
||||
if (horiz)
|
||||
{
|
||||
if (item->min[0] > 0)
|
||||
{
|
||||
w1 = item->min[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
if (h1 < item->min[1])
|
||||
{
|
||||
h1 = item->min[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
D("min: %d %d, w h: %d %d", item->min[0], item->min[1], w1, h1);
|
||||
}
|
||||
else if (item->min[1] > 0)
|
||||
{
|
||||
h1 = item->min[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
if (w1 < item->min[0])
|
||||
{
|
||||
w1 = item->min[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
D("min: %d %d, w h: %d %d", item->min[0], item->min[1], w1, h1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//no min: keep combined min + aspect
|
||||
if (item->aw < item->ah)
|
||||
{
|
||||
w1 = item->want[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
D("want: %d %d, w h: %d %d", item->want[0], item->want[1], w1, h1);
|
||||
}
|
||||
else
|
||||
{
|
||||
h1 = item->want[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
D("want: %d %d, w h: %d %d", item->want[0], item->want[1], w1, h1);
|
||||
}
|
||||
}
|
||||
if (w1 > 0 || h1 > 0)
|
||||
{
|
||||
item->want[0] = w1;
|
||||
item->want[1] = h1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//FIXME: add more handling as horiz case
|
||||
w1 = item->min[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
if (h1 < item->min[1])
|
||||
{
|
||||
h1 = item->min[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
if (w1 > 0 || h1 > 0)
|
||||
{
|
||||
item->want[0] = w1;
|
||||
item->want[1] = h1;
|
||||
}
|
||||
}
|
||||
//int minh = item->want[0] * item->ah / item->aw;
|
||||
//if (item->want[1] < minh)
|
||||
// item->want[1] = minh;
|
||||
}
|
||||
|
||||
if (item->weight[0] < 0) item->weight[0] = 0;
|
||||
if (item->weight[1] < 0) item->weight[1] = 0;
|
||||
|
@ -112,6 +197,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
wantw = item->want[0];
|
||||
}
|
||||
|
||||
D("want: %d %d :: %d %d", item->want[0], item->want[1], wantw, wanth);
|
||||
item->id = id++;
|
||||
}
|
||||
|
||||
|
@ -121,6 +207,60 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
boxx += boxl;
|
||||
boxy += boxt;
|
||||
|
||||
|
||||
//support aspect ratio
|
||||
/*id = 0;
|
||||
WRN("before: wantw: %d, wanth: %d", wantw, wanth);
|
||||
EINA_LIST_FOREACH(bd->children, li, opt)
|
||||
{
|
||||
item = &items[id];
|
||||
if (horiz)
|
||||
{
|
||||
wantw -= item->want[0];
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
//item->want[0] = item->min[0];
|
||||
item->want[1] = item->want[0] * item->aw / item->ah;
|
||||
}
|
||||
else if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL)
|
||||
{
|
||||
item->want[1] = wanth;
|
||||
item->want[0] = wanth * item->aw / item->ah;
|
||||
}
|
||||
else if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH)
|
||||
{
|
||||
item->want[1] = wanth;
|
||||
item->want[0] = wanth * item->aw / item->ah;
|
||||
}
|
||||
wantw += item->want[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
wanth -= item->want[1];
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
item->want[0] = wantw;
|
||||
item->want[1] = wantw * item->ah / item->aw;
|
||||
}
|
||||
else if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL)
|
||||
{
|
||||
//item->want[1] = item->min[1];
|
||||
item->want[0] = item->want[1] * item->aw / item->ah;
|
||||
}
|
||||
else if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH)
|
||||
{
|
||||
item->want[0] = wantw;
|
||||
item->want[1] = wantw * item->ah / item->ah;
|
||||
}
|
||||
wanth += item->want[1];
|
||||
}
|
||||
|
||||
id++;
|
||||
}
|
||||
WRN("after: wantw: %d, wanth: %d", wantw, wanth);
|
||||
*/
|
||||
//////
|
||||
|
||||
// total space & available space
|
||||
if (horiz)
|
||||
{
|
||||
|
@ -141,6 +281,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
// available space. if <0 we overflow
|
||||
extra = length - want;
|
||||
|
||||
/*
|
||||
if (horiz)
|
||||
{
|
||||
evas_object_size_hint_min_set(ui_box,
|
||||
|
@ -152,10 +293,132 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
evas_object_size_hint_min_set(ui_box,
|
||||
wantw + boxl + boxr,
|
||||
wanth + pad * (count - 1) + boxt + boxb);
|
||||
}
|
||||
}*/
|
||||
|
||||
WRN("total weight: %.1f %.1f, extra: %.1f", weight[0], weight[1], extra);
|
||||
if (extra < 0) extra = 0;
|
||||
|
||||
//double cx, cy, cw, ch, x, y, w, h;
|
||||
//work on items having aspect ratio first
|
||||
/*for (id = 0; id < count; id++)
|
||||
{
|
||||
item = &items[id];
|
||||
if (item->aspect >= EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
if (horiz)
|
||||
{
|
||||
//consider aspect, min, max, fill
|
||||
int old_w = item->want[0];
|
||||
int w1 = item->want[0];
|
||||
int h1 = item->want[1];
|
||||
if (weight[0] > 0)
|
||||
w1 = item->want[0] + extra * item->weight[0] / weight[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
D("w h: %d %d, want: %d %d, extra: %d, weight: %.1f / %.1f", w1, h1, item->want[0], item->want[1], extra, item->weight[0], weight[0]);
|
||||
if (h1 < item->want[1])
|
||||
{
|
||||
h1 = item->want[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
D("w h: %d %d", w1, h1);
|
||||
}
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
|
||||
item->aspect == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL)
|
||||
{
|
||||
if (h1 > boxh)
|
||||
{
|
||||
h1 = boxh;
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
}
|
||||
|
||||
//aspect and fill: aspect does not respect fill
|
||||
//if (item->align[1] < 0) //should check in first place
|
||||
// {
|
||||
// h1 = boxh;
|
||||
// w1 = h1 * item->aw / item->ah;
|
||||
// D("w, h: %d %d", w1, h1);
|
||||
// }
|
||||
|
||||
//aspect and max
|
||||
double mar = 0.0;
|
||||
if ((item->max[0] != INT_MAX) && (item->max[1] != INT_MAX))
|
||||
{
|
||||
mar = item->max[0] / (double)item->max[1];
|
||||
D("mar: %.2f, max: %d %d", mar, item->max[0], item->max[1]);
|
||||
if (item->ah > 0)
|
||||
{
|
||||
double ar = item->aw / (double)item->ah;
|
||||
D("ar: %.2f, mar: %.2f", ar, mar);
|
||||
if (ar < mar)
|
||||
{
|
||||
if (h1 > item->max[1])
|
||||
{
|
||||
h1 = item->max[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w1 > item->max[0])
|
||||
{
|
||||
w1 = item->max[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
}
|
||||
}
|
||||
item->want[0] = w1;
|
||||
item->want[1] = h1;
|
||||
extra -= item->want[0] - old_w;
|
||||
weight[0] -= item->weight[0];
|
||||
D("horiz: w, h: %d %d, extra: %d", w1, h1, extra);
|
||||
//ch = boxh;
|
||||
//if (ch > item->max[1])
|
||||
// ch = item->max[1];
|
||||
//cw = ch * item->aw / item->ah;
|
||||
//if (cw > item->max[0])
|
||||
// {
|
||||
// cw = item->max[0];
|
||||
// ch = cw * item->ah / item->aw;
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
int w1, h1;
|
||||
int old_h = item->want[1];
|
||||
|
||||
h1 = item->want[1] + extra * item->weight[1] / weight[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
|
||||
item->aspect == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
if (w1 > boxw)
|
||||
{
|
||||
w1 = boxw;
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
}
|
||||
D("vertical: w,h: %d %d", w1, h1);
|
||||
item->want[0] = w1;
|
||||
item->want[1] = h1;
|
||||
extra -= item->want[1] - old_h;
|
||||
weight[1] -= item->weight[1];
|
||||
//cw = boxw;
|
||||
//if (cw > item->max[0])
|
||||
// cw = item->max[0];
|
||||
//ch = cw * item->ah / item->aw;
|
||||
//if (ch > item->max[1])
|
||||
// {
|
||||
// ch = item->max[1];
|
||||
// cw = ch * item->aw / item->ah;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (EINA_DBL_EQ(weight[!horiz], 0))
|
||||
{
|
||||
if (box_fill[!horiz])
|
||||
|
@ -197,56 +460,261 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
|
|||
cur_pos += ch + pad;
|
||||
}
|
||||
|
||||
// horizontally
|
||||
if (item->max[0] < INT_MAX)
|
||||
if (item->aspect >= EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
w = MIN(MAX(item->want[0] - item->pad[0] - item->pad[1], item->max[0]), cw);
|
||||
if (item->align[0] < 0)
|
||||
if (horiz)
|
||||
{
|
||||
// bad case: fill+max are not good together
|
||||
x = cx + ((cw - w) * box_align[0]) + item->pad[0];
|
||||
}
|
||||
else
|
||||
x = cx + ((cw - w) * item->align[0]) + item->pad[0];
|
||||
}
|
||||
else if (item->align[0] < 0)
|
||||
{
|
||||
// fill x
|
||||
w = cw - item->pad[0] - item->pad[1];
|
||||
x = cx + item->pad[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
w = item->want[0] - item->pad[0] - item->pad[1];
|
||||
x = cx + ((cw - w) * item->align[0]) + item->pad[0];
|
||||
}
|
||||
//consider aspect, min, max, fill
|
||||
//int old_w = item->want[0];
|
||||
int w1 = item->want[0];
|
||||
int h1 = item->want[1];
|
||||
if (weight[0] > 0)
|
||||
w1 = item->want[0] + extra * item->weight[0] / weight[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
D("w h: %d %d, want: %d %d, extra: %d, weight: %.1f / %.1f", w1, h1, item->want[0], item->want[1], extra, item->weight[0], weight[0]);
|
||||
if (h1 < item->want[1]) //how?
|
||||
{
|
||||
h1 = item->want[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
D("w h: %d %d", w1, h1);
|
||||
}
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
|
||||
item->aspect == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL)
|
||||
{
|
||||
if (h1 > boxh)
|
||||
{
|
||||
h1 = boxh;
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
}
|
||||
|
||||
// vertically
|
||||
if (item->max[1] < INT_MAX)
|
||||
{
|
||||
h = MIN(MAX(item->want[1] - item->pad[2] - item->pad[3], item->max[1]), ch);
|
||||
if (item->align[1] < 0)
|
||||
{
|
||||
// bad case: fill+max are not good together
|
||||
y = cy + ((ch - h) * box_align[1]) + item->pad[2];
|
||||
//aspect and fill: aspect does not respect fill
|
||||
/*if (item->align[1] < 0) //should check in first place
|
||||
{
|
||||
h1 = boxh;
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}*/
|
||||
|
||||
//aspect and max
|
||||
double mar = 0.0;
|
||||
if ((item->max[0] != INT_MAX) && (item->max[1] != INT_MAX))
|
||||
{
|
||||
mar = item->max[0] / (double)item->max[1];
|
||||
D("mar: %.2f, max: %d %d", mar, item->max[0], item->max[1]);
|
||||
if (item->ah > 0)
|
||||
{
|
||||
double ar = item->aw / (double)item->ah;
|
||||
D("ar: %.2f, mar: %.2f", ar, mar);
|
||||
if (ar < mar)
|
||||
{
|
||||
if (h1 > item->max[1])
|
||||
{
|
||||
h1 = item->max[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w1 > item->max[0])
|
||||
{
|
||||
w1 = item->max[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
}
|
||||
}
|
||||
w = w1 - item->pad[0] - item->pad[1];
|
||||
h = h1 - item->pad[2] - item->pad[3];
|
||||
if (item->align[0] < 0)
|
||||
{
|
||||
x = cx + (cw - w) * 0.5 + item->pad[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
x = cx + (cw - w) * item->align[0] + item->pad[0];
|
||||
}
|
||||
if (item->align[1] < 0)
|
||||
{
|
||||
y = cy + (ch - h) * 0.5 + item->pad[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
y = cy + (ch - h) * item->align[1] + item->pad[2];
|
||||
}
|
||||
//item->want[0] = w1;
|
||||
//item->want[1] = h1;
|
||||
//extra -= item->want[0] - old_w;
|
||||
//weight[0] -= item->weight[0];
|
||||
D("horiz: w, h: %d %d, extra: %d", w1, h1, extra);
|
||||
}
|
||||
else
|
||||
y = cy + ((ch - h) * item->align[1]) + item->pad[2];
|
||||
}
|
||||
else if (item->align[1] < 0)
|
||||
{
|
||||
// fill y
|
||||
h = ch - item->pad[2] - item->pad[3];
|
||||
y = cy + item->pad[2];
|
||||
{
|
||||
//consider aspect, min, max, fill
|
||||
int w1 = item->want[0];
|
||||
int h1 = item->want[1];
|
||||
if (weight[1] > 0)
|
||||
h1 = item->want[1] + extra * item->weight[1] / weight[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
D("w h: %d %d, want: %d %d, extra: %d, weight: %.1f / %.1f", w1, h1, item->want[0], item->want[1], extra, item->weight[1], weight[1]);
|
||||
if (w1 < item->want[0]) //how?
|
||||
{
|
||||
w1 = item->want[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
D("w h: %d %d", w1, h1);
|
||||
}
|
||||
if (item->aspect == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
|
||||
item->aspect == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
|
||||
{
|
||||
if (w1 > boxw)
|
||||
{
|
||||
w1 = boxw;
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
}
|
||||
|
||||
//aspect and max
|
||||
double mar = 0.0;
|
||||
//if ((item->max[0] != INT_MAX) && (item->max[1] != INT_MAX))
|
||||
//if max = 0, max is set to INT_MAX, what is correct behaviour for max = 0?
|
||||
if (item->max[1] != 0)
|
||||
{
|
||||
mar = item->max[0] / (double)item->max[1];
|
||||
D("mar: %.2f, max: %d %d", mar, item->max[0], item->max[1]);
|
||||
if (item->ah > 0)
|
||||
{
|
||||
double ar = item->aw / (double)item->ah;
|
||||
D("ar: %.2f, mar: %.2f", ar, mar);
|
||||
if (ar < mar)
|
||||
{
|
||||
if (h1 > item->max[1])
|
||||
{
|
||||
h1 = item->max[1];
|
||||
w1 = h1 * item->aw / item->ah;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w1 > item->max[0])
|
||||
{
|
||||
w1 = item->max[0];
|
||||
h1 = w1 * item->ah / item->aw;
|
||||
}
|
||||
D("w, h: %d %d", w1, h1);
|
||||
}
|
||||
}
|
||||
}
|
||||
w = w1 - item->pad[0] - item->pad[1];
|
||||
h = h1 - item->pad[2] - item->pad[3];
|
||||
if (item->align[0] < 0)
|
||||
{
|
||||
x = cx + (cw - w) * 0.5 + item->pad[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
x = cx + (cw - w) * item->align[0] + item->pad[0];
|
||||
}
|
||||
if (item->align[1] < 0)
|
||||
{
|
||||
y = cy + (ch - h) * 0.5 + item->pad[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
y = cy + (ch - h) * item->align[1] + item->pad[2];
|
||||
}
|
||||
D("verical: w, h: %d %d, extra: %d", w1, h1, extra);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
h = item->want[1] - item->pad[2] - item->pad[3];
|
||||
y = cy + ((ch - h) * item->align[1]) + item->pad[2];
|
||||
// horizontally
|
||||
if (item->max[0] < INT_MAX)
|
||||
{
|
||||
w = MIN(MAX(item->want[0] - item->pad[0] - item->pad[1], item->max[0]), cw);
|
||||
if (item->align[0] < 0)
|
||||
{
|
||||
// bad case: fill+max are not good together
|
||||
x = cx + ((cw - w) * box_align[0]) + item->pad[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
x = cx + ((cw - w) * item->align[0]) + item->pad[0];
|
||||
D("x: %.1f, cx: %.1f", x, cx);
|
||||
}
|
||||
}
|
||||
else if (item->align[0] < 0)
|
||||
{
|
||||
// fill x
|
||||
w = cw - item->pad[0] - item->pad[1];
|
||||
x = cx + item->pad[0];
|
||||
D("x: %.1f, cx: %.1f", x, cx);
|
||||
}
|
||||
else
|
||||
{
|
||||
//lam sao support align + weight???
|
||||
//w = item->want[0] - item->pad[0] - item->pad[1];
|
||||
if (item->weight[0] > 0)
|
||||
w = cw - item->pad[0] - item->pad[1];
|
||||
else
|
||||
w = item->want[0] - item->pad[0] - item->pad[1];
|
||||
x = cx + ((cw - w) * item->align[0]) + item->pad[0];
|
||||
D("x: %.1f, cx: %.1f", x, cx);
|
||||
}
|
||||
|
||||
// vertically
|
||||
if (item->max[1] < INT_MAX)
|
||||
{
|
||||
h = MIN(MAX(item->want[1] - item->pad[2] - item->pad[3], item->max[1]), ch);
|
||||
if (horiz && item->align[1] < 0)
|
||||
{
|
||||
// bad case: fill+max are not good together
|
||||
y = cy + ((ch - h) * box_align[1]) + item->pad[2];
|
||||
}
|
||||
else
|
||||
y = cy + ((ch - h) * item->align[1]) + item->pad[2];
|
||||
}
|
||||
else if (item->align[1] < 0)
|
||||
{
|
||||
// fill y
|
||||
h = ch - item->pad[2] - item->pad[3];
|
||||
y = cy + item->pad[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
//h = item->want[1] - item->pad[2] - item->pad[3];
|
||||
if (!horiz && item->weight[1] > 0)
|
||||
h = ch - item->pad[2] - item->pad[3];
|
||||
else
|
||||
h = item->want[1] - item->pad[2] - item->pad[3];
|
||||
y = cy + ((ch - h) * item->align[1]) + item->pad[2];
|
||||
}
|
||||
}
|
||||
|
||||
//DBG("[%2d/%2d] cell: %.0f,%.0f %.0fx%.0f item: %.0f,%.0f %.0fx%.0f",
|
||||
// id, count, cx, cy, cw, ch, x, y, w, h);
|
||||
D("geo: %.0f %.0f %.0f %.0f", x, y, w, h);
|
||||
evas_object_geometry_set(item->obj, x, y, w, h);
|
||||
}
|
||||
|
||||
int hh, hw;
|
||||
if (horiz)
|
||||
{
|
||||
evas_object_size_hint_min_set(ui_box,
|
||||
wantw + boxl + boxr + pad * (count - 1),
|
||||
wanth + boxt + boxb);
|
||||
hw = wantw + boxl + boxr + pad * (count - 1);
|
||||
hh = wanth + boxt + boxb;
|
||||
}
|
||||
else
|
||||
{
|
||||
evas_object_size_hint_min_set(ui_box,
|
||||
wantw + boxl + boxr,
|
||||
wanth + pad * (count - 1) + boxt + boxb);
|
||||
hw = wantw + boxl + boxr;
|
||||
hh = wanth + pad * (count - 1) + boxt + boxb;
|
||||
}
|
||||
WRN("box min: %d %d", hw, hh);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue