Skip to content

Commit

Permalink
Fixes #132 - Cosmetic changes from ViewGroup -> ViewParent
Browse files Browse the repository at this point in the history
  • Loading branch information
rozele committed Feb 14, 2016
1 parent a14413f commit 86ef666
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 63 deletions.
4 changes: 2 additions & 2 deletions ReactWindows/ReactNative/ReactNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@
<Compile Include="UIManager\UIManagerModule.Constants.cs" />
<Compile Include="UIManager\UIViewOperationQueue.cs" />
<Compile Include="UIManager\ViewAtIndex.cs" />
<Compile Include="UIManager\ViewGroupManager.cs" />
<Compile Include="UIManager\PanelViewGroupManager.cs" />
<Compile Include="UIManager\ViewParentManager.cs" />
<Compile Include="UIManager\PanelViewParentManager.cs" />
<Compile Include="UIManager\ViewManager.cs" />
<Compile Include="UIManager\ViewManager.Generic.cs" />
<Compile Include="UIManager\ViewManagerRegistry.cs" />
Expand Down
18 changes: 0 additions & 18 deletions ReactWindows/ReactNative/Touch/IOnInterceptTouchEventListener.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ReactNative.Touch
/// This class coordinates JSResponder commands for <see cref="ReactNative.UIManager.UIManagerModule"/>.
/// It should be set as the <see cref="IOnInterceptTouchEventListener"/>
/// for all newly created native views that implement
/// <see cref="IReactInterceptingViewGroup"/> and will dispatch touch
/// <see cref="IReactInterceptingViewParent"/> and will dispatch touch
/// events to the JavaScript gesture recognizer when the JavaScript
/// responder is set to be enabled.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace ReactNative.UIManager.Events
public interface IOnInterceptTextInputEventListener
{
/// <summary>
/// Called when a onInterceptTouch is invoked on a view group
/// Called when a onInterceptTouch is invoked on a view parent
/// </summary>
/// <param name="event"> The motion event being dispatched down the hierarchy.</param>
/// <returns>Return true to steal motion event from the children and have the dispatched to this view, or return false to allow motion event to be delivered to children view</returns>
Expand Down
32 changes: 16 additions & 16 deletions ReactWindows/ReactNative/UIManager/NativeViewHierarchyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ public void UpdateLayout(int parentTag, int tag, int x, int y, int width, int he
var viewToUpdate = ResolveView(tag);

var parentViewManager = default(ViewManager);
var parentViewGroupManager = default(ViewGroupManager);
var parentViewParentManager = default(ViewParentManager);
if (!_tagsToViewManagers.TryGetValue(parentTag, out parentViewManager) ||
(parentViewGroupManager = parentViewManager as ViewGroupManager) == null)
(parentViewParentManager = parentViewManager as ViewParentManager) == null)
{
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
"Trying to use view with tag '{0}' as a parent, but its manager doesn't extend ViewGroupManager.",
"Trying to use view with tag '{0}' as a parent, but its manager doesn't extend ViewParentManager.",
tag));
}

if (!parentViewGroupManager.NeedsCustomLayoutForChildren)
if (!parentViewParentManager.NeedsCustomLayoutForChildren)
{
UpdateLayout(viewToUpdate, x, y, width, height);
}
Expand Down Expand Up @@ -212,10 +212,10 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo
tag));
}

var viewGroupManager = (ViewGroupManager)viewManager;
var viewParentManager = (ViewParentManager)viewManager;
var viewToManage = _tagsToViews[tag];

var lastIndexToRemove = viewGroupManager.GetChildCount(viewToManage);
var lastIndexToRemove = viewParentManager.GetChildCount(viewToManage);
if (indicesToRemove != null)
{
for (var i = indicesToRemove.Length - 1; i >= 0; --i)
Expand All @@ -231,7 +231,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo
tag));
}

if (indexToRemove >= viewGroupManager.GetChildCount(viewToManage))
if (indexToRemove >= viewParentManager.GetChildCount(viewToManage))
{
throw new InvalidOperationException(
string.Format(
Expand All @@ -252,7 +252,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo
tag));
}

viewGroupManager.RemoveChildAt(viewToManage, indexToRemove);
viewParentManager.RemoveChildAt(viewToManage, indexToRemove);
lastIndexToRemove = indexToRemove;
}
}
Expand All @@ -272,7 +272,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo
viewAtIndex.Tag));
}

viewGroupManager.AddView(viewToManage, viewToAdd, viewAtIndex.Index);
viewParentManager.AddView(viewToManage, viewToAdd, viewAtIndex.Index);
}
}

Expand Down Expand Up @@ -365,7 +365,7 @@ public void Measure(int tag, int[] outputBuffer)
/// <param name="themedContext">The themed context.</param>
public void AddRootView(int tag, SizeMonitoringCanvas view, ThemedReactContext themedContext)
{
AddRootViewGroup(tag, view, themedContext);
AddRootViewParent(tag, view, themedContext);
}

/// <summary>
Expand Down Expand Up @@ -515,7 +515,7 @@ private ViewManager ResolveViewManager(int tag)
return viewManager;
}

private void AddRootViewGroup(int tag, FrameworkElement view, ThemedReactContext themedContext)
private void AddRootViewParent(int tag, FrameworkElement view, ThemedReactContext themedContext)
{
DispatcherHelpers.AssertOnDispatcher();
_tagsToViews.Add(tag, view);
Expand All @@ -539,20 +539,20 @@ private void DropView(FrameworkElement view)
var viewManager = default(ViewManager);
if (_tagsToViewManagers.TryGetValue(tag, out viewManager))
{
var viewGroupManager = viewManager as ViewGroupManager;
if (viewGroupManager != null)
var viewParentManager = viewManager as ViewParentManager;
if (viewParentManager != null)
{
for (var i = viewGroupManager.GetChildCount(view) - 1; i >= 0; --i)
for (var i = viewParentManager.GetChildCount(view) - 1; i >= 0; --i)
{
var child = viewGroupManager.GetChildAt(view, i);
var child = viewParentManager.GetChildAt(view, i);
var managedChild = default(FrameworkElement);
if (_tagsToViews.TryGetValue(child.GetTag(), out managedChild))
{
DropView(managedChild);
}
}

viewGroupManager.RemoveAllChildren(view);
viewParentManager.RemoveAllChildren(view);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ReactNative.UIManager
/// extending <see cref="Panel"/>.
/// </summary>
/// <typeparam name="TPanel">Type of panel.</typeparam>
public abstract class PanelViewGroupManager<TPanel> : ViewGroupManager
public abstract class PanelViewParentManager<TPanel> : ViewParentManager
where TPanel : Panel
{
/// <summary>
Expand Down Expand Up @@ -54,9 +54,9 @@ public sealed override void UpdateExtraData(FrameworkElement root, object extraD
}

/// <summary>
/// Gets the number of children in the view group.
/// Gets the number of children for the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <returns>The number of children.</returns>
public sealed override int GetChildCount(FrameworkElement parent)
{
Expand Down Expand Up @@ -88,17 +88,17 @@ public sealed override void AddView(FrameworkElement parent, FrameworkElement ch
/// <summary>
/// Removes the child at the given index.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <param name="index">The index.</param>
public override void RemoveChildAt(FrameworkElement parent, int index)
{
RemoveChildAt((TPanel)parent, index);
}

/// <summary>
/// Removes all children from the view group.
/// Removes all children from the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
public override void RemoveAllChildren(FrameworkElement parent)
{
RemoveAllChildren((TPanel)parent);
Expand Down Expand Up @@ -225,9 +225,9 @@ protected virtual void UpdateExtraData(TPanel root, object extraData)
}

/// <summary>
/// Gets the number of children in the view group.
/// Gets the number of children in the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <returns>The number of children.</returns>
protected virtual int GetChildCount(TPanel parent)
{
Expand Down Expand Up @@ -259,17 +259,17 @@ protected virtual void AddView(TPanel parent, FrameworkElement child, int index)
/// <summary>
/// Removes the child at the given index.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <param name="index">The index.</param>
protected virtual void RemoveChildAt(TPanel parent, int index)
{
parent.Children.RemoveAt(index);
}

/// <summary>
/// Removes all children from the view group.
/// Removes all children from the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
protected virtual void RemoveAllChildren(TPanel parent)
{
parent.Children.Clear();
Expand Down
2 changes: 1 addition & 1 deletion ReactWindows/ReactNative/UIManager/RootViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// View manager for react root view components.
/// </summary>
public class RootViewManager : PanelViewGroupManager<SizeMonitoringCanvas>
public class RootViewManager : PanelViewParentManager<SizeMonitoringCanvas>
{
/// <summary>
/// The name of the react root view.
Expand Down
8 changes: 4 additions & 4 deletions ReactWindows/ReactNative/UIManager/UIImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,17 +735,17 @@ private void AssertNodeDoesNotNeedCustomLayoutForChildren(ReactShadowNode node)
node.ViewClass));
}

var viewGroupManager = viewManager as ViewGroupManager;
if (viewGroupManager == null)
var viewParentManager = viewManager as ViewParentManager;
if (viewParentManager == null)
{
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
"Trying to use view '{0}' as a parent but its manager is not a ViewGroupManager.",
"Trying to use view '{0}' as a parent but its manager is not a ViewParentManager.",
node.ViewClass));
}

if (viewGroupManager.NeedsCustomLayoutForChildren)
if (viewParentManager.NeedsCustomLayoutForChildren)
{
throw new InvalidOperationException(
string.Format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ReactNative.UIManager
/// <summary>
/// Class providing child management API for view managers.
/// </summary>
public abstract class ViewGroupManager : ViewManager
public abstract class ViewParentManager : ViewManager
{
/// <summary>
/// The <see cref="Type"/> instance that represents the type of shadow
Expand Down Expand Up @@ -67,9 +67,9 @@ public override void UpdateExtraData(FrameworkElement root, object extraData)
public abstract void AddView(FrameworkElement parent, FrameworkElement child, int index);

/// <summary>
/// Gets the number of children in the view group.
/// Gets the number of children in the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <returns>The number of children.</returns>
public abstract int GetChildCount(FrameworkElement parent);

Expand All @@ -84,14 +84,14 @@ public override void UpdateExtraData(FrameworkElement root, object extraData)
/// <summary>
/// Removes the child at the given index.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
/// <param name="index">The index.</param>
public abstract void RemoveChildAt(FrameworkElement parent, int index);

/// <summary>
/// Removes all children from the view group.
/// Removes all children from the view parent.
/// </summary>
/// <param name="parent">The view group.</param>
/// <param name="parent">The view parent.</param>
public abstract void RemoveAllChildren(FrameworkElement parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ReactNative.Views.Scroll
/// <remarks>
/// TODO: implement this as a proper ScrollViewer instead of a ListView.
/// </remarks>
public class ReactScrollViewManager : ViewGroupManager
public class ReactScrollViewManager : ViewParentManager
{
private const string ReactClass = "RCTScrollView";

Expand Down
2 changes: 1 addition & 1 deletion ReactWindows/ReactNative/Views/View/ReactCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ReactNative.Views.View
/// aren't common, lazy initializes most of the storage needed for them. Also supports
/// 3D transformations such as elevation depth.
/// </summary>
public class ReactCanvas : Canvas, IReactInterceptingViewGroup, IReactPointerEventsView
public class ReactCanvas : Canvas, IReactInterceptingViewParent, IReactPointerEventsView
{
/// <summary>
/// Sets an elevation 3D transformation effect on the <see cref="ReactCanvas"/>.
Expand Down
2 changes: 1 addition & 1 deletion ReactWindows/ReactNative/Views/View/ReactViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ReactNative.Views.View
{
public class ReactViewManager : ViewGroupManager
public class ReactViewManager : ViewParentManager
{
private const string ReactClass = ViewProperties.ViewClassName;
private const int CommandSetPressed = 1;
Expand Down

0 comments on commit 86ef666

Please sign in to comment.