widget: Forward focus_highlight_style to win
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 31 Aug 2017 07:10:43 +0000 (16:10 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Fri, 1 Sep 2017 01:09:37 +0000 (10:09 +0900)
See the previous commits. All focus_highlight APIs are defined in the
Widget class but only implemented at the Window level. For consistency I
believe this call should also be forwarded to the window. The previous
logic had absolutely no effect at all, except storing a stringshare.

The day focus_highlight becomes widget-specific (i.e. each widget has
its own highlight style) then this can be changed.

Note: This will apply to legacy API as well.

Ref T5363

src/lib/elementary/elm_widget.c
src/lib/elementary/elm_widget.eo
src/lib/elementary/elm_widget.h

index 8d5fe3a..aae92a4 100644 (file)
@@ -234,6 +234,30 @@ _elm_widget_focus_highlight_animate_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_
      elm_win_focus_highlight_animate_set(win, enable);
 }
 
+EOLIAN static Eina_Bool
+_elm_widget_focus_highlight_style_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *style)
+{
+   // Forward to closest parent Window
+   Evas_Object *win = elm_widget_top_get(obj);
+
+   if (win && efl_isa(win, EFL_UI_WIN_CLASS))
+     return elm_obj_widget_focus_highlight_style_set(win, style);
+
+   return EINA_FALSE;
+}
+
+EOLIAN static const char *
+_elm_widget_focus_highlight_style_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
+{
+   // Forward to closest parent Window
+   Evas_Object *win = elm_widget_top_get(obj);
+
+   if (win && efl_isa(win, EFL_UI_WIN_CLASS))
+     return elm_win_focus_highlight_style_get(win);
+
+   return NULL;
+}
+
 static Eina_Bool
 _tree_unfocusable(Eo *obj)
 {
@@ -1117,22 +1141,6 @@ _elm_widget_focus_region_show(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
      }
 }
 
-EOLIAN static Eina_Bool
-_elm_widget_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *style)
-{
-   // FIXME: This does not return the proper error code! Who cares if the
-   // string was changed?? This should return false if the desired style does
-   // not exist...
-   if (eina_stringshare_replace(&sd->focus_highlight_style, style)) return EINA_TRUE;
-   return EINA_FALSE;
-}
-
-EOLIAN static const char*
-_elm_widget_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
-{
-   return sd->focus_highlight_style;
-}
-
 static void
 _parent_focus(Evas_Object *obj, Elm_Object_Item *item)
 {
index 08cbd8f..ebeea3d 100644 (file)
@@ -516,45 +516,73 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
             region: Eina.Rectangle; [[The rectangle area.]]
          }
       }
-      @property focus_highlight_style {
-         [[Control the widget focus highlight style.
+      @property focus_highlight_enabled {
+         [[Whether focus highlight is enabled or not.
 
-           If $style is $null, the default will be used.
+           As of EFL 1.21 focus highlight properties apply to a single window,
+           not a single widget. As a consequence, calls to this function may
+           be forwarded to the parent window. Future versions of EFL may
+           implement widget-specific focus highlight properties.
+
+           See also @.widget_top.
+           See also @.focus_highlight_style.
+           See also @.focus_highlight_animate.
          ]]
          set {
-            return: bool; [[$true on success, $false otherwise.]]
+            [[Set the enabled status for the focus highlight in a window.
+
+              This function will enable or disable the focus highlight,
+              regardless of the global setting for it.
+            ]]
          }
          get {
+            [[Get the enabled value of the focus highlight for this window.]]
          }
          values {
-            style: string @nullable; [[The name of the focus highlight style.]]
+            enabled: bool; [[The enabled value for the highlight.]]
          }
       }
-      @property focus_highlight_enabled {
-         [[Whether focus highlight is enabled or not.]]
-         set {
-            [[Set the enabled status for the focus highlight in a window.
+      @property focus_highlight_style {
+         [[Control the widget focus highlight style.
 
-              This function will enable or disable the focus highlight only
-              for the given window, regardless of the global setting for it.
-            ]]
+           If $style is $null, the default will be used.
+
+           As of EFL 1.21 focus highlight properties apply to a single window,
+           not a single widget. As a consequence, calls to this function may
+           be forwarded to the parent window. Future versions of EFL may
+           implement widget-specific focus highlight properties.
+
+           See also @.widget_top.
+           See also @.focus_highlight_enabled.
+           See also @.focus_highlight_animate.
+         ]]
+         set {
+            /* FIXME: This is async... success here means nothing. */
+            return: bool; [[$true on success, $false otherwise.]]
          }
          get {
-            [[Get the enabled value of the focus highlight for this window.]]
          }
          values {
-            enabled: bool; [[The enabled value for the highlight.]]
+            style: string @nullable; [[The name of the focus highlight style.]]
          }
       }
       @property focus_highlight_animate {
-         [[Whether focus highlight should animate or not.]]
+         [[Whether focus highlight should animate or not.
+
+           As of EFL 1.21 focus highlight properties apply to a single window,
+           not a single widget. As a consequence, calls to this function may
+           be forwarded to the parent window. Future versions of EFL may
+           implement widget-specific focus highlight properties.
+
+           See also @.widget_top.
+           See also @.focus_highlight_style.
+           See also @.focus_highlight_enabled.
+         ]]
          set {
             [[Set the animate status for the focus highlight for this window.
 
               This function will enable or disable the animation of focus
-              highlight only for the given window. If the widget is not a
-              window, then this call is forwarded to the window (using
-              @.widget_top).
+              highlight.
             ]]
          }
          get {
index fe8f6c3..3bd9b02 100644 (file)
@@ -407,7 +407,6 @@ typedef struct _Elm_Widget_Smart_Data
    double                        scale;
    Elm_Theme                    *theme;
    const char                   *style;
-   const char                   *focus_highlight_style;  /**< custom focus style for a widget */
    const char                   *access_info;
    const char                   *accessible_name;
    unsigned int                  focus_order;