summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-27 18:30:00 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-12-02 18:30:20 +0100
commitacfd031e47735576a4757818d486158d68f4e9a9 (patch)
treec2318cc2ef5e6657061256d79be281c099b3fb5c
parentd51bdf3c77adf81495c9a777e591079d42735b47 (diff)
downloadefl-acfd031e47735576a4757818d486158d68f4e9a9.tar.gz
efl_ui_spotlight_indicator: make this undependend from the main widget
the main widget before presented a layout to hold the indicator, however, for the causual case, this is not really needed. The indicator itself is anyways going to be a more general prupose widget soon, where the layout here can be taken as an starting point. Additionally, this fixes general displaying of the indicator, before the box padding refactor, a padding would have changed the minsize of the mix, this is not the case anymore, which forces us to calculate the minsize of the indicator theme. Differential Revision: https://phab.enlightenment.org/D10764
-rw-r--r--data/elementary/themes/edc/efl/spotlight.edc12
-rw-r--r--src/lib/elementary/efl_ui_spotlight_container.c1
-rw-r--r--src/lib/elementary/efl_ui_spotlight_indicator_icon.c51
-rw-r--r--src/lib/elementary/efl_ui_spotlight_indicator_icon.eo1
4 files changed, 60 insertions, 5 deletions
diff --git a/data/elementary/themes/edc/efl/spotlight.edc b/data/elementary/themes/edc/efl/spotlight.edc
index 725cdce611..27a1bfca32 100644
--- a/data/elementary/themes/edc/efl/spotlight.edc
+++ b/data/elementary/themes/edc/efl/spotlight.edc
@@ -10,6 +10,18 @@ group { "efl/spotlight"; data.item: "version" "123";
}
}
}
+group { "efl/spotlight/indicator_holder"; data.item: "version" "123";
+ parts {
+ swallow { "efl.indicator";
+ scale;
+ desc { "default";
+ rel2.relative: 1.0 0.0;
+ align: 0.5 0.0;
+ min: 0 50;
+ }
+ }
+ }
+}
group { "efl/spotlight/indicator"; data.item: "version" "123";
images {
diff --git a/src/lib/elementary/efl_ui_spotlight_container.c b/src/lib/elementary/efl_ui_spotlight_container.c
index 2d964e57e3..44d099a7af 100644
--- a/src/lib/elementary/efl_ui_spotlight_container.c
+++ b/src/lib/elementary/efl_ui_spotlight_container.c
@@ -656,7 +656,6 @@ _efl_ui_spotlight_container_indicator_set(Eo *obj, Efl_Ui_Spotlight_Container_Da
{
if (pd->indicator)
{
- efl_ui_spotlight_indicator_bind(pd->indicator, obj);
efl_del(pd->indicator);
}
pd->indicator = indicator;
diff --git a/src/lib/elementary/efl_ui_spotlight_indicator_icon.c b/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
index 6437710494..5f59b513cd 100644
--- a/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
+++ b/src/lib/elementary/efl_ui_spotlight_indicator_icon.c
@@ -10,6 +10,7 @@
typedef struct {
Efl_Ui_Box *indicator;
Efl_Ui_Spotlight_Container *container;
+ Efl_Canvas_Layout *layout;
double last_position;
} Efl_Ui_Spotlight_Indicator_Icon_Data;
@@ -32,6 +33,7 @@ _add_item(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Indicator_Icon_Data *pd)
efl_gfx_hint_align_set(item, 0.5, 0.5);
efl_gfx_hint_weight_set(item, 0, 0);
efl_gfx_hint_fill_set(item, 0, 0);
+ efl_gfx_hint_size_min_set(item, efl_layout_calc_size_min(item, EINA_SIZE2D(0, 0)));
efl_pack_end(pd->indicator, item);
_flush_state(item, 0.0);
}
@@ -70,22 +72,50 @@ _flush_position(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Indicator_Icon_Data *pd)
_flush_state(efl_pack_content_get(pd->indicator, next), fabs(1.0f - fabs((next - pd->last_position))));
}
+static void
+_resize_cb(void *data, const Efl_Event *ev)
+{
+ efl_gfx_entity_size_set(data, efl_gfx_entity_size_get(ev->object));
+}
+
+static void
+_position_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+ efl_gfx_entity_position_set(data, efl_gfx_entity_position_get(ev->object));
+}
+
+EFL_CALLBACKS_ARRAY_DEFINE(spotlight_resized,
+ {EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _resize_cb},
+ {EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, _position_cb},
+)
+
EOLIAN static void
_efl_ui_spotlight_indicator_icon_efl_ui_spotlight_indicator_bind(Eo *obj, Efl_Ui_Spotlight_Indicator_Icon_Data *pd, Efl_Ui_Spotlight_Container *spotlight)
{
if (spotlight)
{
pd->container = spotlight;
- pd->indicator = efl_add(EFL_UI_BOX_CLASS, spotlight);
+ efl_event_callback_array_add(pd->container, spotlight_resized(), pd->layout);
+ pd->layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, pd->container);
+
+ if (elm_widget_theme_object_set(pd->container, pd->layout,
+ "spotlight",
+ "indicator_holder",
+ elm_widget_theme_style_get(pd->container)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
+ CRI("Failed to set layout!");
+ efl_canvas_group_member_add(pd->container, pd->layout);
+ efl_gfx_entity_geometry_set(pd->layout, efl_gfx_entity_geometry_get(pd->container));
+
+ pd->indicator = efl_add(EFL_UI_BOX_CLASS, pd->container);
efl_ui_widget_internal_set(pd->indicator, EINA_TRUE);
- efl_content_set(efl_part(pd->container, "efl.indicator"), pd->indicator);
- efl_gfx_entity_visible_set(pd->indicator, EINA_TRUE);
efl_ui_layout_orientation_set(pd->indicator, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
- efl_gfx_arrangement_content_padding_set(pd->indicator, 15, 15);
+ efl_content_set(efl_part(pd->layout, "efl.indicator"), pd->indicator);
for (int i = 0; i < efl_content_count(pd->container); ++i)
{
+ Eo *subobj = efl_pack_content_get(pd->container, i);
_add_item(obj, pd);
+ efl_gfx_stack_above(pd->layout, subobj);
}
}
}
@@ -95,6 +125,7 @@ _efl_ui_spotlight_indicator_icon_efl_ui_spotlight_indicator_content_add(Eo *obj,
{
_add_item(obj, pd);
_flush_position(obj, pd);
+ efl_gfx_stack_above(pd->layout, subobj);
}
EOLIAN static void
@@ -111,4 +142,16 @@ _efl_ui_spotlight_indicator_icon_efl_ui_spotlight_indicator_position_update(Eo *
_flush_position(obj, pd);
}
+EOLIAN static void
+_efl_ui_spotlight_indicator_icon_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Indicator_Icon_Data *pd)
+{
+ if (pd->layout)
+ efl_del(pd->layout);
+ if (pd->indicator)
+ efl_del(pd->indicator);
+
+ efl_destructor(efl_super(obj, EFL_UI_SPOTLIGHT_INDICATOR_ICON_CLASS));
+}
+
+
#include "efl_ui_spotlight_indicator_icon.eo.c"
diff --git a/src/lib/elementary/efl_ui_spotlight_indicator_icon.eo b/src/lib/elementary/efl_ui_spotlight_indicator_icon.eo
index fbd08a6b9d..de1d689d74 100644
--- a/src/lib/elementary/efl_ui_spotlight_indicator_icon.eo
+++ b/src/lib/elementary/efl_ui_spotlight_indicator_icon.eo
@@ -4,5 +4,6 @@ class @beta Efl.Ui.Spotlight.Indicator_Icon extends Efl.Ui.Spotlight.Indicator {
Efl.Ui.Spotlight.Indicator.content_del;
Efl.Ui.Spotlight.Indicator.content_add;
Efl.Ui.Spotlight.Indicator.position_update;
+ Efl.Object.destructor;
}
}