Fix Box.MinimumHeight issue
authorSeungkeun Lee <sngn.lee@samsung.com>
Mon, 12 Dec 2016 06:34:10 +0000 (15:34 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Mon, 12 Dec 2016 06:34:10 +0000 (15:34 +0900)
 - Box has fake handle, and it is a layout
 - When setting a MinimunHeight of Box, it does not apply to box, is set in the layout
 - Introduce new internal property "RealHandle"
   - It is normally same with Handle
   - It used for some internal APIs, to get inner handle (RealHandle)

Change-Id: I0608b14e700f2adb21566b05a06982c43bbfb067

src/ElmSharp/ElmSharp/Box.cs
src/ElmSharp/ElmSharp/Container.cs
src/ElmSharp/ElmSharp/EvasObject.cs
src/ElmSharp/ElmSharp/Table.cs

index f67d30dedac60a3ddc5ab9cc223b73666ba9e72d..8bec6c3e2785efc5c2804b717d8d04a1d16047d2 100644 (file)
@@ -30,41 +30,41 @@ namespace ElmSharp
         {
             get
             {
-                return Interop.Elementary.elm_box_horizontal_get(GetRealHandle(Handle));
+                return Interop.Elementary.elm_box_horizontal_get(RealHandle);
             }
             set
             {
-                Interop.Elementary.elm_box_horizontal_set(GetRealHandle(Handle), value);
+                Interop.Elementary.elm_box_horizontal_set(RealHandle, value);
             }
         }
 
         public void PackEnd(EvasObject content)
         {
-            Interop.Elementary.elm_box_pack_end(GetRealHandle(Handle), content);
+            Interop.Elementary.elm_box_pack_end(RealHandle, content);
             AddChild(content);
         }
 
         public void PackStart(EvasObject content)
         {
-            Interop.Elementary.elm_box_pack_start(GetRealHandle(Handle), content);
+            Interop.Elementary.elm_box_pack_start(RealHandle, content);
             AddChild(content);
         }
 
         public void PackAfter(EvasObject content, EvasObject after)
         {
-            Interop.Elementary.elm_box_pack_after(GetRealHandle(Handle), content, after);
+            Interop.Elementary.elm_box_pack_after(RealHandle, content, after);
             AddChild(content);
         }
 
         public void UnPack(EvasObject content)
         {
-            Interop.Elementary.elm_box_unpack(GetRealHandle(Handle), content);
+            Interop.Elementary.elm_box_unpack(RealHandle, content);
             RemoveChild(content);
         }
 
         public void UnPackAll()
         {
-            Interop.Elementary.elm_box_unpack_all(GetRealHandle(Handle));
+            Interop.Elementary.elm_box_unpack_all(RealHandle);
             ClearChildren();
         }
 
@@ -74,7 +74,7 @@ namespace ElmSharp
             {
                 action();
             };
-            Interop.Elementary.elm_box_layout_set(GetRealHandle(Handle), _layoutCallback, IntPtr.Zero, null);
+            Interop.Elementary.elm_box_layout_set(RealHandle, _layoutCallback, IntPtr.Zero, null);
         }
 
         protected override IntPtr CreateHandle(EvasObject parent)
@@ -82,8 +82,8 @@ namespace ElmSharp
             IntPtr handle = Interop.Elementary.elm_layout_add(parent);
             Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
 
-            IntPtr realHandle = Interop.Elementary.elm_box_add(handle);
-            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle);
+            RealHandle = Interop.Elementary.elm_box_add(handle);
+            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
 
             return handle;
         }
index 75a1f5c76f8c4136c575db75e9418a48af326db4..284262990026dbb8930ae4dcd0f3afd889e15f08 100644 (file)
@@ -43,11 +43,6 @@ namespace ElmSharp
             }
         }
 
-        protected virtual IntPtr GetRealHandle(IntPtr handle)
-        {
-            return Interop.Elementary.elm_object_part_content_get(handle, "elm.swallow.content");
-        }
-
         internal void AddChild(EvasObject obj)
         {
             _children.Add(obj);
index 87ac0ebad9f4397902238f763149d36e94ea0296..6b732c22a186014f1ea197f5f1014ab9ab8284a6 100644 (file)
@@ -22,8 +22,20 @@ namespace ElmSharp
 {
     public abstract class EvasObject
     {
+        private IntPtr _realHandle = IntPtr.Zero;
         internal IntPtr Handle { get; set; }
         internal EvasObject Parent { get; set; }
+        internal IntPtr RealHandle
+        {
+            get
+            {
+                return _realHandle == IntPtr.Zero ? Handle : _realHandle;
+            }
+            set
+            {
+                _realHandle = value;
+            }
+        }
 
         EvasObjectEvent _deleted;
         EvasObjectEvent<EvasKeyEventArgs> _keyup;
@@ -136,13 +148,13 @@ namespace ElmSharp
             get
             {
                 int w, h;
-                Interop.Evas.evas_object_size_hint_min_get(Handle, out w, out h);
+                Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h);
                 return w;
             }
             set
             {
                 int h = MinimumHeight;
-                Interop.Evas.evas_object_size_hint_min_set(Handle, value, h);
+                Interop.Evas.evas_object_size_hint_min_set(RealHandle, value, h);
             }
         }
 
@@ -151,13 +163,13 @@ namespace ElmSharp
             get
             {
                 int w, h;
-                Interop.Evas.evas_object_size_hint_min_get(Handle, out w, out h);
+                Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h);
                 return h;
             }
             set
             {
                 int w = MinimumWidth;
-                Interop.Evas.evas_object_size_hint_min_set(Handle, w, value);
+                Interop.Evas.evas_object_size_hint_min_set(RealHandle, w, value);
             }
         }
 
@@ -227,11 +239,11 @@ namespace ElmSharp
         {
             get
             {
-                return Interop.Evas.evas_object_repeat_events_get(Handle);
+                return Interop.Evas.evas_object_repeat_events_get(RealHandle);
             }
             set
             {
-                Interop.Evas.evas_object_repeat_events_set(Handle, value);
+                Interop.Evas.evas_object_repeat_events_set(RealHandle, value);
             }
         }
 
@@ -239,11 +251,11 @@ namespace ElmSharp
         {
             get
             {
-                return Interop.Evas.evas_object_propagate_events_get(Handle);
+                return Interop.Evas.evas_object_propagate_events_get(RealHandle);
             }
             set
             {
-                Interop.Evas.evas_object_propagate_events_set(Handle, value);
+                Interop.Evas.evas_object_propagate_events_set(RealHandle, value);
             }
         }
 
@@ -251,11 +263,11 @@ namespace ElmSharp
         {
             get
             {
-                return Interop.Evas.evas_object_pass_events_get(Handle);
+                return Interop.Evas.evas_object_pass_events_get(RealHandle);
             }
             set
             {
-                Interop.Evas.evas_object_pass_events_set(Handle, value);
+                Interop.Evas.evas_object_pass_events_set(RealHandle, value);
             }
         }
 
@@ -318,7 +330,7 @@ namespace ElmSharp
 
         public void MarkChanged()
         {
-            Interop.Evas.evas_object_smart_changed(Handle);
+            Interop.Evas.evas_object_smart_changed(RealHandle);
         }
 
         protected virtual void OnInvalidate()
index 252e6d0ade387deb5f3cfa4a03050a089e78a7ec..7b1792c4b576f7894ef7bf571aeee3f2d00e7fb8 100644 (file)
@@ -31,11 +31,11 @@ namespace ElmSharp
         {
             get
             {
-                return Interop.Elementary.elm_table_homogeneous_get(GetRealHandle(Handle));
+                return Interop.Elementary.elm_table_homogeneous_get(RealHandle);
             }
             set
             {
-                Interop.Elementary.elm_table_homogeneous_set(GetRealHandle(Handle), value);
+                Interop.Elementary.elm_table_homogeneous_set(RealHandle, value);
             }
         }
 
@@ -48,7 +48,7 @@ namespace ElmSharp
             set
             {
                 _paddingX = value;
-                Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY);
+                Interop.Elementary.elm_table_padding_set(RealHandle, _paddingX, _paddingY);
             }
         }
 
@@ -61,7 +61,7 @@ namespace ElmSharp
             set
             {
                 _paddingY = value;
-                Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY);
+                Interop.Elementary.elm_table_padding_set(RealHandle, _paddingX, _paddingY);
             }
         }
 
@@ -69,7 +69,7 @@ namespace ElmSharp
         {
             if (obj == null)
                 throw new ArgumentNullException("obj");
-            Interop.Elementary.elm_table_pack(GetRealHandle(Handle), obj, col, row, colspan, rowspan);
+            Interop.Elementary.elm_table_pack(RealHandle, obj, col, row, colspan, rowspan);
             AddChild(obj);
         }
 
@@ -77,13 +77,13 @@ namespace ElmSharp
         {
             if (obj == null)
                 throw new ArgumentNullException("obj");
-            Interop.Elementary.elm_table_unpack(GetRealHandle(Handle), obj);
+            Interop.Elementary.elm_table_unpack(RealHandle, obj);
             RemoveChild(obj);
         }
 
         public void Clear()
         {
-            Interop.Elementary.elm_table_clear(GetRealHandle(Handle), false);
+            Interop.Elementary.elm_table_clear(RealHandle, false);
             ClearChildren();
         }
 
@@ -92,8 +92,8 @@ namespace ElmSharp
             IntPtr handle = Interop.Elementary.elm_layout_add(parent);
             Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
 
-            IntPtr realHandle = Interop.Elementary.elm_table_add(handle);
-            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle);
+            RealHandle = Interop.Elementary.elm_table_add(handle);
+            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
 
             return handle;
         }