From 48991a1f35c8b47af91c834e39e58271176cdbb9 Mon Sep 17 00:00:00 2001 From: "sung-su.kim" Date: Mon, 5 Jun 2017 18:54:59 +0900 Subject: [PATCH] Enhance Layout Change-Id: Ice8b30935992e1f79a6a11aaf58950115e81d534 --- src/ElmSharp/ElmSharp/Container.cs | 6 +- src/ElmSharp/ElmSharp/Layout.cs | 202 ++++++++++++++++++++++++++++- src/ElmSharp/ElmSharp/Widget.cs | 29 +++-- src/ElmSharp/Interop/Interop.Elementary.cs | 111 ++++++++-------- 4 files changed, 274 insertions(+), 74 deletions(-) mode change 100644 => 100755 src/ElmSharp/ElmSharp/Container.cs mode change 100755 => 100644 src/ElmSharp/ElmSharp/Layout.cs diff --git a/src/ElmSharp/ElmSharp/Container.cs b/src/ElmSharp/ElmSharp/Container.cs old mode 100644 new mode 100755 index f9e87c1..5701fe6 --- a/src/ElmSharp/ElmSharp/Container.cs +++ b/src/ElmSharp/ElmSharp/Container.cs @@ -57,18 +57,18 @@ namespace ElmSharp } } - internal void AddChild(EvasObject obj) + protected void AddChild(EvasObject obj) { _children.Add(obj); obj.Deleted += OnChildDeleted; } - internal void RemoveChild(EvasObject obj) + protected void RemoveChild(EvasObject obj) { _children.Remove(obj); } - internal void ClearChildren() + protected void ClearChildren() { _children.Clear(); } diff --git a/src/ElmSharp/ElmSharp/Layout.cs b/src/ElmSharp/ElmSharp/Layout.cs old mode 100755 new mode 100644 index 4c92402..217a0a3 --- a/src/ElmSharp/ElmSharp/Layout.cs +++ b/src/ElmSharp/ElmSharp/Layout.cs @@ -22,7 +22,7 @@ namespace ElmSharp /// This is a container widget that takes a standard Edje design file and wraps it very thinly in a widget. /// Inherits Widget /// - public class Layout : Widget + public class Layout : Container { SmartEvent _languageChanged; SmartEvent _themeChanged; @@ -72,6 +72,204 @@ namespace ElmSharp } /// + /// Gets or sets accessibility state of texblock(text) parts in the layout object. + /// + public bool TextBlockAccessibility + { + get + { + return Interop.Elementary.elm_layout_edje_object_can_access_get(RealHandle); + } + set + { + Interop.Elementary.elm_layout_edje_object_can_access_set(RealHandle, value); + } + } + + /// + /// Freezes the Elementary layout object. + /// This function puts all changes on hold. + /// Successive freezes will nest, requiring an equal number of thaws. + /// + /// The frozen state or 0 if the object is not frozen or on error. + public int Freeze() + { + return Interop.Elementary.elm_layout_freeze(RealHandle); + } + + /// + /// Thaws the Elementary object. + /// If sucessives freezes were done, an equal number of thaws will be required. + /// + /// The frozen state or 0 if the object is not frozen or on error. + public int Thaw() + { + return Interop.Elementary.elm_layout_thaw(RealHandle); + } + + /// + /// Eval sizing. + /// Manually forces a sizing re-evaluation. + /// This is useful when the minimum size required by the edje theme of this layout has changed. + /// The change on the minimum size required by the edje theme is not immediately reported to the elementary layout, so one needs to call this function in order to tell the widget (layout) that it needs to reevaluate its own size. + /// The minimum size of the theme is calculated based on minimum size of parts, the size of elements inside containers like box and table, etc. + /// All of this can change due to state changes, and that's when this function should be called. + /// + public void Resizing() + { + Interop.Elementary.elm_layout_sizing_eval(RealHandle); + } + + /// + /// Request sizing reevaluation, restricted to current width and/or height. + /// Useful mostly when there are TEXTBLOCK parts defining the height of the object and nothing else restricting it to a minimum width.Calling this function will restrict the minimum size in the Edje calculation to whatever size it the layout has at the moment. + /// + /// Restrict minimum size ot the current width. + /// Restrict minimum size ot the current height. + public void Resizing(bool width, bool height) + { + Interop.Elementary.elm_layout_sizing_restricted_eval(RealHandle, width, height); + } + + /// + /// Get the edje data from the given layout. + /// This function fetches data specified inside the edje theme of this layout. + /// This function return NULL if data is not found. + /// + /// The data key + /// The data + public string GetData(string key) + { + return Interop.Elementary.elm_layout_data_get(RealHandle, key); + } + + /// + /// Gets the text set in the given part. + /// + /// The TEXT part to retrieve the text off. + /// + public override string GetPartText(string part) + { + return Interop.Elementary.elm_layout_text_get(RealHandle, part); + } + + /// + /// Sets the text set in the given part. + /// + /// The TEXT part to retrieve the text off. + /// The text to set. + /// + public override bool SetPartText(string part, string text) + { + return Interop.Elementary.elm_layout_text_set(RealHandle, part, text); + } + + /// + /// Append child to layout box part. + /// Once the object is appended, it will become child of the layout. + /// Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. + /// + /// The part + /// The Object to append + /// Sucess is true + public bool BoxAppend(string part, EvasObject child) + { + AddChild(child); + return Interop.Elementary.elm_layout_box_append(RealHandle, part, child.Handle); + } + + /// + /// Prepend child to layout box part. + /// Once the object is prepended, it will become child of the layout. + /// Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. + /// + /// The part + /// The Object to prepend + /// Sucess is true + public bool BoxPrepend(string part, EvasObject child) + { + AddChild(child); + return Interop.Elementary.elm_layout_box_prepend(RealHandle, part, child.Handle); + } + + /// + /// Remove a child of the given part box. + /// The object will be removed from the box part and its lifetime will not be handled by the layout anymore. + /// + /// The part + /// The Object to remove + /// Sucess is true + public bool BoxRemove(string part, EvasObject child) + { + RemoveChild(child); + return Interop.Elementary.elm_layout_box_remove(RealHandle, part, child.Handle) != null; + } + + /// + /// Remove all children of the given part box. + /// The objects will be removed from the box part and their lifetime will not be handled by the layout anymore. + /// + /// The part + /// If true, then all objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas. + /// Sucess is true + public bool BoxRemoveAll(string part, bool clear) + { + ClearChildren(); + return Interop.Elementary.elm_layout_box_remove_all(RealHandle, part, clear); + } + + /// + /// Insert child to layout box part at a given position. + /// Once the object is inserted, it will become child of the layout. + /// Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. + /// + /// The part + /// The child object to insert into box. + /// The numeric position >=0 to insert the child. + /// Sucess is true + public bool BoxInsertAt(string part, EvasObject child, uint position) + { + AddChild(child); + return Interop.Elementary.elm_layout_box_insert_at(RealHandle, part, child.Handle, position); + } + + /// + /// Insert child to layout box part before a reference object. + /// Once the object is inserted, it will become child of the layout. + /// Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. + /// + /// + /// The child object to insert into box. + /// Another reference object to insert before in box. + /// Sucess is true + public bool BoxInsertBefore(string part, EvasObject child, EvasObject reference) + { + AddChild(child); + return Interop.Elementary.elm_layout_box_insert_before(RealHandle, part, child.Handle, reference.Handle); + } + + /// + /// Sets the layout content. + /// + /// The swallow part name in the edje file + /// The child that will be added in this layout object. + /// TRUE on success, FALSE otherwise + public override bool SetPartContent(string part, EvasObject content) + { + return SetPartContent(part, content, false); + } + + public override bool SetPartContent(string part, EvasObject content, bool preserveOldContent) + { + if (preserveOldContent) + { + Interop.Elementary.elm_layout_content_unset(RealHandle, part); + } + UpdatePartContents(content, part); + return Interop.Elementary.elm_layout_content_set(RealHandle, part, content); + } + + /// /// Sets the edje group from the elementary theme that is used as a layout. /// /// The class of the group @@ -144,4 +342,4 @@ namespace ElmSharp return Interop.Elementary.elm_layout_add(parent.Handle); } } -} +} \ No newline at end of file diff --git a/src/ElmSharp/ElmSharp/Widget.cs b/src/ElmSharp/ElmSharp/Widget.cs index ccd9ef4..daa5731 100755 --- a/src/ElmSharp/ElmSharp/Widget.cs +++ b/src/ElmSharp/ElmSharp/Widget.cs @@ -29,22 +29,27 @@ namespace ElmSharp /// Previous direction /// Previous, + /// /// Next direction /// Next, + /// /// Up direction /// Up, + /// /// Down direction /// Down, + /// /// Right direction /// Right, + /// /// Left direction /// @@ -82,6 +87,11 @@ namespace ElmSharp _unfocused.On += (s, e) => Unfocused?.Invoke(this, EventArgs.Empty); } + protected void UpdatePartContents(EvasObject content, string part = "__default__") + { + _partContents[part] = content; + } + /// /// Focused will be triggered when the widget is focused. /// @@ -253,9 +263,9 @@ namespace ElmSharp /// The name of particular part /// The content /// - public void SetPartContent(string part, EvasObject content) + public virtual bool SetPartContent(string part, EvasObject content) { - SetPartContent(part, content, false); + return SetPartContent(part, content, false); } /// @@ -265,15 +275,15 @@ namespace ElmSharp /// The content /// true, preserve old content will be unset. false, preserve old content will not be unset. /// - public void SetPartContent(string part, EvasObject content, bool preserveOldContent) + public virtual bool SetPartContent(string part, EvasObject content, bool preserveOldContent) { if (preserveOldContent) { Interop.Elementary.elm_object_part_content_unset(RealHandle, part); } Interop.Elementary.elm_object_part_content_set(RealHandle, part, content); - - _partContents[part ?? "__default__"] = content; + UpdatePartContents(content, part); + return true; } /// @@ -300,7 +310,7 @@ namespace ElmSharp } Interop.Elementary.elm_object_content_set(RealHandle, content); - _partContents["__default__"] = content; + UpdatePartContents(content); } /// @@ -308,9 +318,10 @@ namespace ElmSharp /// /// The name of particular part /// The text - public void SetPartText(string part, string text) + public virtual bool SetPartText(string part, string text) { Interop.Elementary.elm_object_part_text_set(RealHandle, part, text); + return true; } /// @@ -318,7 +329,7 @@ namespace ElmSharp /// /// The name of particular part /// Text of the particular part of the widget - public string GetPartText(string part) + public virtual string GetPartText(string part) { return Interop.Elementary.elm_object_part_text_get(RealHandle, part); } @@ -377,4 +388,4 @@ namespace ElmSharp return Interop.Elementary.elm_object_part_content_get(RealHandle, part); } } -} +} \ No newline at end of file diff --git a/src/ElmSharp/Interop/Interop.Elementary.cs b/src/ElmSharp/Interop/Interop.Elementary.cs index 30e7bbb..c865f12 100755 --- a/src/ElmSharp/Interop/Interop.Elementary.cs +++ b/src/ElmSharp/Interop/Interop.Elementary.cs @@ -180,7 +180,7 @@ internal static partial class Interop internal static extern void elm_object_tooltip_hide(IntPtr obj); [DllImport(Libraries.Elementary)] - internal static extern void elm_object_tooltip_orient_set(IntPtr obj, Elm_Tooltip_Orient orient); + internal static extern void elm_object_tooltip_orient_set(IntPtr obj, int orient); internal static string elm_object_part_text_get(IntPtr obj, string part) { @@ -209,7 +209,7 @@ internal static partial class Interop } [DllImport(Libraries.Elementary)] - internal static extern void elm_object_part_content_unset(IntPtr obj, string part); + internal static extern IntPtr elm_object_part_content_unset(IntPtr obj, string part); internal static void elm_object_content_unset(IntPtr obj) { @@ -244,6 +244,9 @@ internal static partial class Interop internal static extern bool elm_layout_theme_set(IntPtr obj, string klass, string group, string style); [DllImport(Libraries.Elementary)] + internal static extern void elm_layout_file_get(IntPtr obj, IntPtr file, IntPtr group); + + [DllImport(Libraries.Elementary)] internal static extern bool elm_layout_file_set(IntPtr obj, string file, string group); [DllImport(Libraries.Elementary)] @@ -346,7 +349,7 @@ internal static partial class Interop internal static extern bool elm_object_tree_focus_allow_get(IntPtr obj); [DllImport(Libraries.Elementary)] - internal static extern IntPtr elm_object_focus_next_object_get(IntPtr obj, Elm_Focus_Direction dir); + internal static extern IntPtr elm_object_focus_next_object_get(IntPtr obj, int dir); [DllImport(Libraries.Elementary)] internal static extern IntPtr elm_object_focused_object_get(IntPtr obj); @@ -554,7 +557,7 @@ internal static partial class Interop internal static extern void elm_transit_objects_final_state_keep_set(IntPtr transit, bool stateKeep); [DllImport(Libraries.Elementary)] - internal static extern void elm_transit_tween_mode_set(IntPtr transit, Elm_Transit_Tween_Mode tweenMode); + internal static extern void elm_transit_tween_mode_set(IntPtr transit, int tweenMode); [DllImport(Libraries.Elementary)] internal static extern void elm_transit_repeat_times_set(IntPtr transit, int repeat); @@ -611,7 +614,7 @@ internal static partial class Interop internal static extern int elm_transit_repeat_times_get(IntPtr transit); [DllImport(Libraries.Elementary)] - internal static extern Elm_Transit_Tween_Mode elm_transit_tween_mode_get(IntPtr transit); + internal static extern int elm_transit_tween_mode_get(IntPtr transit); [DllImport(Libraries.Elementary)] internal static extern void elm_transit_tween_mode_factor_set(IntPtr transit, double v1, double v2); @@ -650,13 +653,13 @@ internal static partial class Interop internal static extern bool elm_transit_smooth_get(IntPtr transit); [DllImport(Libraries.Elementary)] - internal static extern IntPtr elm_transit_effect_flip_add(IntPtr transit, Elm_Transit_Effect_Flip_Axis axis, bool cw); + internal static extern IntPtr elm_transit_effect_flip_add(IntPtr transit, int axis, bool cw); [DllImport(Libraries.Elementary)] - internal static extern IntPtr elm_transit_effect_resizable_flip_add(IntPtr transit, Elm_Transit_Effect_Flip_Axis axis, bool cw); + internal static extern IntPtr elm_transit_effect_resizable_flip_add(IntPtr transit, int axis, bool cw); [DllImport(Libraries.Elementary)] - internal static extern IntPtr elm_transit_effect_wipe_add(IntPtr transit, Elm_Transit_Effect_Wipe_Type type, Elm_Transit_Effect_Wipe_Dir dir); + internal static extern IntPtr elm_transit_effect_wipe_add(IntPtr transit, int type, int dir); [DllImport(Libraries.Elementary)] internal static extern IntPtr elm_transit_effect_blend_add(IntPtr transit); @@ -679,61 +682,49 @@ internal static partial class Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void Elm_Transit_Del_Cb(IntPtr data, IntPtr transit); - internal enum Elm_Transit_Tween_Mode - { - ELM_TRANSIT_TWEEN_MODE_LINEAR, - ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL, - ELM_TRANSIT_TWEEN_MODE_DECELERATE, - ELM_TRANSIT_TWEEN_MODE_ACCELERATE, - ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP, - ELM_TRANSIT_TWEEN_MODE_BOUNCE, - ELM_TRANSIT_TWEEN_MODE_SPRING, - ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE, - } + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_box_insert_at(IntPtr obj, string part, IntPtr child, uint pos); - internal enum Elm_Transit_Effect_Flip_Axis - { - ELM_TRANSIT_EFFECT_FLIP_AXIS_X, - ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, - } + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_box_insert_before(IntPtr obj, string part, IntPtr child, IntPtr reference); - internal enum Elm_Transit_Effect_Wipe_Type - { - ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE, - ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW, - } + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_edje_object_can_access_get(IntPtr obj); - internal enum Elm_Transit_Effect_Wipe_Dir - { - ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT, - ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT, - ELM_TRANSIT_EFFECT_WIPE_DIR_UP, - ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN, - } + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_edje_object_can_access_set(IntPtr obj, bool canAccess); - internal enum Elm_Focus_Direction - { - ELM_FOCUS_PREVIOUS, - ELM_FOCUS_NEXT, - ELM_FOCUS_UP, - ELM_FOCUS_DOWN, - ELM_FOCUS_RIGHT, - ELM_FOCUS_LEFT, - } + [DllImport(Libraries.Elementary)] + internal static extern int elm_layout_freeze(IntPtr obj); - internal enum Elm_Tooltip_Orient - { - ELM_TOOLTIP_ORIENT_NONE, - ELM_TOOLTIP_ORIENT_TOP_LEFT, - ELM_TOOLTIP_ORIENT_TOP, - ELM_TOOLTIP_ORIENT_TOP_RIGHT, - ELM_TOOLTIP_ORIENT_LEFT, - ELM_TOOLTIP_ORIENT_CENTER, - ELM_TOOLTIP_ORIENT_RIGHT, - ELM_TOOLTIP_ORIENT_BOTTOM_LEFT, - ELM_TOOLTIP_ORIENT_BOTTOM, - ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT, - ELM_TOOLTIP_ORIENT_LAST, - } + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_part_cursor_engine_only_get(IntPtr obj, string part); + + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_part_cursor_engine_only_set(IntPtr obj, string part, bool engineOnly); + + [DllImport(Libraries.Elementary)] + internal static extern string elm_layout_part_cursor_get(IntPtr obj, string part); + + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_part_cursor_set(IntPtr obj, string part, string cursor); + + [DllImport(Libraries.Elementary)] + internal static extern string elm_layout_part_cursor_style_get(IntPtr obj, string part); + + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_part_cursor_style_set(IntPtr obj, string part, string style); + + [DllImport(Libraries.Elementary)] + internal static extern bool elm_layout_part_cursor_unset(IntPtr obj, string part); + + [DllImport(Libraries.Elementary)] + internal static extern void elm_layout_sizing_eval(IntPtr obj); + + [DllImport(Libraries.Elementary)] + internal static extern void elm_layout_sizing_restricted_eval(IntPtr obj, bool width, bool height); + + [DllImport(Libraries.Elementary)] + internal static extern int elm_layout_thaw(IntPtr obj); } -} \ No newline at end of file +} -- 2.7.4