aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2018-01-19 15:55:19 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2018-01-19 16:19:36 +0900
commita465f4d878e3cc3b1c1b5a3a7aa79f5cb97b047f (patch)
tree6bea78e67cfba7021bb6439f59258335d5fbf200
parentcxx: Fix a trivial warning (diff)
downloadefl-a465f4d878e3cc3b1c1b5a3a7aa79f5cb97b047f.tar.gz
widget: Use enum for orientation_mode
This was proposed by Dave on the ML, I think it makes sense. Right now the enum is just like the boolean, feature-wise, but it makes more sense semantically (mode is not a bool) and allows for future extension (eg. only apply orientation update for landscape vs. portrait modes). There is absolutely zero testing for this in our existing codebase. Yay.
-rw-r--r--src/lib/elementary/efl_ui.eot14
-rw-r--r--src/lib/elementary/efl_ui_widget.c18
-rw-r--r--src/lib/elementary/efl_ui_widget.eo49
-rw-r--r--src/lib/elementary/elm_main.c7
4 files changed, 55 insertions, 33 deletions
diff --git a/src/lib/elementary/efl_ui.eot b/src/lib/elementary/efl_ui.eot
index 2f30386de9..bdf0b74a61 100644
--- a/src/lib/elementary/efl_ui.eot
+++ b/src/lib/elementary/efl_ui.eot
@@ -88,5 +88,19 @@ enum Efl.Ui.Activate
back, [[Activate back]]
}
+enum Efl.Ui.Widget.Orientation_Mode
+{
+ [[Widget orientation mode, or how the theme handles screen orientation.
+
+ Note: Support for this feature is highly dependent on the theme in use.
+ At the time of writing, the default theme for EFL does not implement
+ support for orientation modes.
+ ]]
+ default, [[Default or automatic mode: if the widget's theme supports
+ orientation, it will be handled automatically.]]
+ disabled, [[No signal is sent to the widget's theme. Widget's theme will
+ not change according to the window or screen orientation.]]
+}
+
/* Types for A11Y (internal/beta API) */
type @extern Efl.Access.Action_Data: __undefined_type; [[Internal struct for accesssibility.]]
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index e8ee8ca9be..b028177df6 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -3456,26 +3456,26 @@ elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
}
EOLIAN static void
-_efl_ui_widget_orientation_mode_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool enabled)
+_efl_ui_widget_orientation_mode_set(Eo *obj, Elm_Widget_Smart_Data *sd, Efl_Ui_Widget_Orientation_Mode mode)
{
- int orient_mode = -1;
+ int rotation = -1;
- if (enabled)
+ if (mode != EFL_UI_WIDGET_ORIENTATION_MODE_DISABLED)
{
//Get current orient mode from it's parent otherwise, 0.
sd->orient_mode = 0;
ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
- if (!sd_parent) orient_mode = 0;
- else orient_mode = sd_parent->orient_mode;
+ if (!sd_parent) rotation = 0;
+ else rotation = sd_parent->orient_mode;
}
- efl_ui_widget_on_orientation_update(obj, orient_mode);
+ efl_ui_widget_on_orientation_update(obj, rotation);
}
-EOLIAN static Eina_Bool
+EOLIAN static Efl_Ui_Widget_Orientation_Mode
_efl_ui_widget_orientation_mode_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
{
- if (sd->orient_mode == -1) return EINA_FALSE;
- else return EINA_TRUE;
+ if (sd->orient_mode == -1) return EFL_UI_WIDGET_ORIENTATION_MODE_DISABLED;
+ else return EFL_UI_WIDGET_ORIENTATION_MODE_DEFAULT;
}
EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo
index 85de10bcf8..e681450216 100644
--- a/src/lib/elementary/efl_ui_widget.eo
+++ b/src/lib/elementary/efl_ui_widget.eo
@@ -111,23 +111,6 @@ abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access,
return: bool; [[$true on success, $false otherwise]]
legacy: null;
}
- @property orientation_mode {
- [[Whether the widget's automatic orientation is enabled or not.
-
- Orientation mode is used for widgets to change their style or send
- signals based on the canvas rotation (i.e. the window orientation).
- If the orientation mode is enabled, the widget will emit signals
- such as "elm,state,orient,N" where $N is one of 0, 90, 180, 270,
- depending on the window orientation. Such signals may be handled by
- the theme in order to provide a different look for the widget based
- on the canvas orientation.
-
- By default orientation mode is enabled, i.e. this is $true.
- ]]
- values {
- disabled: bool(true); [[$false if orientation mode is disabled.]]
- }
- }
// FIXME: focus_allow? can_focus? focusable?
@property focus_allow {
[[The ability for a widget to be focused.
@@ -263,24 +246,46 @@ abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access,
return: bool; [[Indicates if the operation succeeded.]]
legacy: elm_widget_sub_object_del;
}
+ @property orientation_mode {
+ [[Whether the widget's automatic orientation is enabled or not.
+
+ Orientation mode is used for widgets to change their style or send
+ signals based on the canvas rotation (i.e. the window orientation).
+ If the orientation mode is enabled, the widget will emit signals
+ such as "elm,state,orient,N" where $N is one of 0, 90, 180, 270,
+ depending on the window orientation. Such signals may be handled by
+ the theme in order to provide a different look for the widget based
+ on the canvas orientation.
+
+ By default orientation mode is enabled.
+
+ See also @.on_orientation_update.
+ ]]
+ values {
+ mode: Efl.Ui.Widget.Orientation_Mode(Efl.Ui.Widget.Orientation_Mode.default);
+ [[How window orientation should affect this widget.]]
+ }
+ }
on_orientation_update @protected {
[[Virtual function handling canvas orientation changes.
This method will be called recursively from the top widget (the
window) to all the children objects whenever the window rotation
is changed. The given $rotation will be one of 0, 90, 180, 270 or
- the special value -1 if @.orientation_mode is $false.
+ the special value -1 if @.orientation_mode is $disabled.
- If @.orientation_mode is $true, the default implementation
- will emit the signal "elm,state,orient,$R" will be emitted (where $R
- is the rotation angle in degrees).
+ If @.orientation_mode is $default, the widget implementation will
+ emit the signal "elm,state,orient,$R" will be emitted (where $R is
+ the rotation angle in degrees).
Note: This function may be called even if the orientation has not
actually changed, like when a widget needs to be reconfigured.
+
+ See also @.orientation_mode.
]]
params {
rotation: int; [[Orientation in degrees: 0, 90, 180, 270 or -1 if
- @.orientation_mode is $false.]]
+ @.orientation_mode is $disabled.]]
}
}
on_disabled_update @protected {
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index c48f3adee8..7819b11b0d 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -2051,13 +2051,16 @@ elm_object_name_find(const Evas_Object *obj, const char *name, int recurse)
EAPI void
elm_object_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled)
{
- efl_ui_widget_orientation_mode_set(obj, !disabled);
+ Efl_Ui_Widget_Orientation_Mode mode =
+ disabled ? EFL_UI_WIDGET_ORIENTATION_MODE_DISABLED
+ : EFL_UI_WIDGET_ORIENTATION_MODE_DEFAULT;
+ efl_ui_widget_orientation_mode_set(obj, mode);
}
EAPI Eina_Bool
elm_object_orientation_mode_disabled_get(const Evas_Object *obj)
{
- return !efl_ui_widget_orientation_mode_get(obj);
+ return efl_ui_widget_orientation_mode_get(obj) == EFL_UI_WIDGET_ORIENTATION_MODE_DISABLED;
}
EAPI Elm_Object_Item *