Skip to content

Commit

Permalink
MOSYNC-3355: inside a horizontal layout the default stack panel orien…
Browse files Browse the repository at this point in the history
…tation should be Horizontal (without being set, the default was Vertical)
  • Loading branch information
spiridon-alexandru committed Jun 27, 2013
1 parent 6214451 commit 48e7393
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<StackPanel>();

setHorizontalSizePolicyFlags(true, false);
setVerticalSizePolicyFlags(true, false);
//#if DEBUG
//#if DEBUG
//mGrid.ShowGridLines = true;
//#endif
//#endif
}

/**
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}

Expand All @@ -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
{
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

Expand All @@ -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
{
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 48e7393

Please sign in to comment.