diff --git a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncHorizontalLayout.cs b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncHorizontalLayout.cs index e6fa3c483..824f58327 100644 --- a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncHorizontalLayout.cs +++ b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncHorizontalLayout.cs @@ -101,15 +101,15 @@ public HorizontalLayout() View = mGrid; - mGrid.Margin = new Thickness(0); + mGrid.Margin = new Thickness(0.0); mStackPanels = new System.Collections.Generic.List(); setHorizontalSizePolicyFlags(true, false); setVerticalSizePolicyFlags(true, false); -//#if DEBUG + //#if DEBUG //mGrid.ShowGridLines = true; -//#endif + //#endif } /** @@ -183,7 +183,10 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // Adding a new container mStackPanels.Insert(sIndex, new StackPanel()); - int stackPanelIndex = sIndex; + // by default, the stack panel orientation is Vertical (inside a horizontal layout it should + // be Horizontal + mStackPanels[sIndex].Orientation = Orientation.Horizontal; + bool stackPanelRequired = true; // The column for the widget has the default GridUnitType set on 1 x Auto @@ -208,17 +211,17 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // FILL_SPACE_H && WRAP_CONT_V else if (widget.WRAP_CONT_V) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Vertical; + mStackPanels[sIndex].Orientation = Orientation.Vertical; } } // WRAP_CONT_H else if (widget.WRAP_CONT_H) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Vertical; + mStackPanels[sIndex].Orientation = Orientation.Vertical; // WRAP_CONT_V && WRAP_CONT_H if (widget.FILL_SPACE_V) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Horizontal; + mStackPanels[sIndex].Orientation = Orientation.Horizontal; } } @@ -231,11 +234,11 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) { // If the stack panel container is required the widget gets added to that container // and then this goes to the grid. Read above for the logical explanation. - mStackPanels[stackPanelIndex].Children.Add((widget.View as System.Windows.FrameworkElement)); - Grid.SetRow(mStackPanels[stackPanelIndex], 1); - Grid.SetColumn(mStackPanels[stackPanelIndex], gIndex); + mStackPanels[sIndex].Children.Add((widget.View as System.Windows.FrameworkElement)); + Grid.SetRow(mStackPanels[sIndex], 1); + Grid.SetColumn(mStackPanels[sIndex], gIndex); - mGrid.Children.Add(mStackPanels[stackPanelIndex]); + mGrid.Children.Add(mStackPanels[sIndex]); } else { @@ -244,10 +247,10 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // posible use. (in case the size policy changes after the child widget // was added to the parent. Grid.SetRow((widget.View as FrameworkElement), 1); - Grid.SetColumn(mStackPanels[stackPanelIndex], gIndex); + Grid.SetColumn(mStackPanels[sIndex], gIndex); Grid.SetColumn((widget.View as FrameworkElement), gIndex); - mGrid.Children.Add(mStackPanels[stackPanelIndex]); + mGrid.Children.Add(mStackPanels[sIndex]); mGrid.Children.Add(widget.View); } diff --git a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncVerticalLayout.cs b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncVerticalLayout.cs index 3dbe9b67e..3bf959ae5 100644 --- a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncVerticalLayout.cs +++ b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncVerticalLayout.cs @@ -182,8 +182,6 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // Adding a new container mStackPanels.Insert(sIndex, new StackPanel()); - - int stackPanelIndex = sIndex; bool stackPanelRequired = true; // The row for the widget has the default GridUnitType set on 1 x Auto @@ -208,18 +206,18 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // FILL_SPACE_V && WRAP_CONT_H else if (widget.WRAP_CONT_H) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Horizontal; + mStackPanels[sIndex].Orientation = Orientation.Horizontal; } } // WRAP_CONT_V else if (widget.WRAP_CONT_V) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Vertical; + mStackPanels[sIndex].Orientation = Orientation.Vertical; // WRAP_CONT_V && WRAP_CONT_H if (widget.WRAP_CONT_H) { - mStackPanels[stackPanelIndex].Orientation = Orientation.Horizontal; + mStackPanels[sIndex].Orientation = Orientation.Horizontal; } } @@ -232,11 +230,11 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) { // If the stack panel container is required the widget gets added to that container // and then this goes to the grid. Read above for the logical explanation. - mStackPanels[stackPanelIndex].Children.Add((widget.View as System.Windows.FrameworkElement)); - Grid.SetColumn(mStackPanels[stackPanelIndex], 1); - Grid.SetRow(mStackPanels[stackPanelIndex], gIndex); + mStackPanels[sIndex].Children.Add((widget.View as System.Windows.FrameworkElement)); + Grid.SetColumn(mStackPanels[sIndex], 1); + Grid.SetRow(mStackPanels[sIndex], gIndex); - mGrid.Children.Add(mStackPanels[stackPanelIndex]); + mGrid.Children.Add(mStackPanels[sIndex]); } else { @@ -245,10 +243,10 @@ private void InsertWidget(IWidget child, int sIndex, int gIndex) // posible use. (in case the size policy changes after the child widget // was added to the parent. Grid.SetColumn((widget.View as FrameworkElement), 1); - Grid.SetRow(mStackPanels[stackPanelIndex], gIndex); + Grid.SetRow(mStackPanels[sIndex], gIndex); Grid.SetRow((widget.View as FrameworkElement), gIndex); - mGrid.Children.Add(mStackPanels[stackPanelIndex]); + mGrid.Children.Add(mStackPanels[sIndex]); mGrid.Children.Add(widget.View); } @@ -287,6 +285,7 @@ where Grid.GetColumn(d as FrameworkElement) == columnIndex } // go through all the widget and modify their row numbers + // TODO SA: should this loop start from gridIndex? for (int j = 0; j < mChildren.Count; j++) { WidgetBaseWindowsPhone widget = mChildren[j] as WidgetBaseWindowsPhone; @@ -361,11 +360,12 @@ where Grid.GetColumn(d as FrameworkElement) == columnIndexToRemove { FrameworkElement control = currentControls.First() as FrameworkElement; int controlRow = Grid.GetRow(control); - Grid.SetRow(control, controlRow - 1 > 0 ? controlRow - 1 : 0); + Grid.SetRow(control, controlRow - 1 > 0 ? controlRow - 1 : 1); } } // update all the widgets row numbers + // TODO SA: should this start from widget.RowNumber? for (int i = 0; i < mChildren.Count; i++) { WidgetBaseWindowsPhone currentWidget = mChildren[i] as WidgetBaseWindowsPhone;