summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-13 15:00:56 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-16 09:18:11 +0100
commit3af2b57fd24babd770514662ed2599df3354e307 (patch)
treeb319425f3e5a97dabb3c50355c97b76a76b51c32
parentb57d0aa571fb9a2353d2fba9107c13717cd3c4b4 (diff)
efl_ui_progressbar: fix theming of progressbar
There was code in progressbar that parsed its own theme name, applied a change, reassembed it, and set it again. However, when we simply stick to the theme apply code path that we have in efl.ui.layout_base, we can simply set the horizontal / vertical part to be the element, the rest is the class. This safes a lot of code, additionally, the setting of the spacer had to be moved to the theme_apply method, as this would not work otherwise. ref T8501 Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11076
-rw-r--r--src/lib/elementary/efl_ui_progressbar.c93
1 files changed, 15 insertions, 78 deletions
diff --git a/src/lib/elementary/efl_ui_progressbar.c b/src/lib/elementary/efl_ui_progressbar.c
index 8c206e9099..0bc3f9ca86 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -134,62 +134,13 @@ _val_set(Evas_Object *obj)
134 } 134 }
135} 135}
136 136
137//TODO: efl_ui_slider also use this. 137static void
138static const char * 138_sync_widget_theme_klass(Eo *obj, Efl_Ui_Progressbar_Data *pd)
139_theme_group_modify_pos_get(const char *cur_group, const char *search, size_t len, Eina_Bool is_legacy)
140{
141 const char *pos = NULL;
142 const char *temp_str = NULL;
143
144 if (is_legacy)
145 return cur_group;
146
147 temp_str = cur_group + len - strlen(search);
148 if (temp_str >= cur_group)
149 {
150 if (!strcmp(temp_str, search))
151 pos = temp_str;
152 }
153
154 return pos;
155}
156
157static char *
158_efl_ui_progressbar_theme_group_get(Evas_Object *obj, Efl_Ui_Progressbar_Data *sd)
159{ 139{
160 const char *pos = NULL; 140 if (efl_ui_layout_orientation_is_horizontal(pd->dir, EINA_TRUE))
161 const char *cur_group = elm_widget_theme_element_get(obj); 141 elm_widget_theme_element_set(obj, "horizontal");
162 Eina_Strbuf *new_group = eina_strbuf_new();
163 Eina_Bool is_legacy = elm_widget_is_legacy(obj);
164 size_t len = 0;
165
166 if (cur_group)
167 {
168 len = strlen(cur_group);
169 pos = _theme_group_modify_pos_get(cur_group, "horizontal", len, is_legacy);
170 if (!pos)
171 pos = _theme_group_modify_pos_get(cur_group, "vertical", len, is_legacy);
172
173
174 // TODO: change separator when it is decided.
175 // can skip when prev_group == cur_group
176 if (!pos)
177 {
178 eina_strbuf_append(new_group, cur_group);
179 eina_strbuf_append(new_group, "/");
180 }
181 else
182 {
183 eina_strbuf_append_length(new_group, cur_group, pos - cur_group);
184 }
185 }
186
187 if (_is_horizontal(sd->dir))
188 eina_strbuf_append(new_group, "horizontal");
189 else 142 else
190 eina_strbuf_append(new_group, "vertical"); 143 elm_widget_theme_element_set(obj, "vertical");
191
192 return eina_strbuf_release(new_group);
193} 144}
194 145
195EOLIAN static Eina_Error 146EOLIAN static Eina_Error
@@ -197,7 +148,7 @@ _efl_ui_progressbar_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Progressbar_Data *
197{ 148{
198 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; 149 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
199 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC); 150 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
200 char *group; 151
201 const char *statuspart[] = 152 const char *statuspart[] =
202 { 153 {
203 "efl.text.status", 154 "efl.text.status",
@@ -208,13 +159,7 @@ _efl_ui_progressbar_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Progressbar_Data *
208 "efl.cur.progressbar", 159 "efl.cur.progressbar",
209 "elm.cur.progressbar", 160 "elm.cur.progressbar",
210 }; 161 };
211 162 _sync_widget_theme_klass(obj, sd);
212 group = _efl_ui_progressbar_theme_group_get(obj, sd);
213 if (group)
214 {
215 elm_widget_theme_element_set(obj, group);
216 free(group);
217 }
218 163
219 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 164 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
220 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; 165 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
@@ -284,6 +229,11 @@ _efl_ui_progressbar_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Progressbar_Data *
284 229
285 edje_object_message_signal_process(wd->resize_obj); 230 edje_object_message_signal_process(wd->resize_obj);
286 231
232 if (elm_widget_is_legacy(obj))
233 elm_layout_content_set(obj, "elm.swallow.bar", sd->spacer);
234 else
235 elm_layout_content_set(obj, "efl.bar", sd->spacer);
236
287 return int_ret; 237 return int_ret;
288} 238}
289 239
@@ -330,10 +280,7 @@ EOLIAN static void
330_efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data *priv) 280_efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data *priv)
331{ 281{
332 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 282 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
333 char *group;
334 283
335 if (!elm_widget_theme_klass_get(obj))
336 elm_widget_theme_klass_set(obj, "progressbar");
337 efl_canvas_group_add(efl_super(obj, MY_CLASS)); 284 efl_canvas_group_add(efl_super(obj, MY_CLASS));
338 285
339 efl_ui_layout_finger_size_multiplier_set(obj, 0, 0); 286 efl_ui_layout_finger_size_multiplier_set(obj, 0, 0);
@@ -341,14 +288,6 @@ _efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data
341 priv->dir = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL; 288 priv->dir = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
342 priv->val = MIN_RATIO_LVL; 289 priv->val = MIN_RATIO_LVL;
343 priv->val_max = 1.0; 290 priv->val_max = 1.0;
344 group = _efl_ui_progressbar_theme_group_get(obj, priv);
345
346 if (elm_widget_theme_object_set(obj, wd->resize_obj,
347 elm_widget_theme_klass_get(obj),
348 group,
349 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
350
351 free(group);
352 291
353 efl_ui_format_string_set(obj, "%.0f%%", EFL_UI_FORMAT_STRING_TYPE_SIMPLE); 292 efl_ui_format_string_set(obj, "%.0f%%", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
354 293
@@ -356,11 +295,6 @@ _efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data
356 evas_object_color_set(priv->spacer, 0, 0, 0, 0); 295 evas_object_color_set(priv->spacer, 0, 0, 0, 0);
357 evas_object_pass_events_set(priv->spacer, EINA_TRUE); 296 evas_object_pass_events_set(priv->spacer, EINA_TRUE);
358 297
359 if (elm_widget_is_legacy(obj))
360 elm_layout_content_set(obj, "elm.swallow.bar", priv->spacer);
361 else
362 elm_layout_content_set(obj, "efl.bar", priv->spacer);
363
364 _units_set(obj); 298 _units_set(obj);
365 _val_set(obj); 299 _val_set(obj);
366 300
@@ -398,6 +332,9 @@ _efl_ui_progressbar_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Progressbar_Data
398EOLIAN static Eo * 332EOLIAN static Eo *
399_efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd EINA_UNUSED) 333_efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd EINA_UNUSED)
400{ 334{
335 if (!elm_widget_theme_klass_get(obj))
336 elm_widget_theme_klass_set(obj, "progressbar");
337
401 obj = efl_constructor(efl_super(obj, MY_CLASS)); 338 obj = efl_constructor(efl_super(obj, MY_CLASS));
402 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 339 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
403 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PROGRESS_BAR); 340 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PROGRESS_BAR);