Beispiel #1
0
        public void Move()
        {

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format(@"Moving: {0}
", DescribeMoves()));
            }
#endif

            // TODO: CreatingContentPane pane has already been set from the outside (the caller of this method)
            // that is because this flag has to be set not only for mover operations, but also for "manual" aditions
            // so we must rethink if this is to be used also here (it's redundant)

            List<DisplayListMember> childrenToTransfer = new List<DisplayListMember>();

            for (int i = 0; i < _numberOfChildrenToMove; i++)
            {
                childrenToTransfer.Add(_docFrom.QChildren[i]);
            }

            foreach (DisplayListMember child in childrenToTransfer)
            {
                /**
                 * Note: we have to use container's AddChild/RemoveChild stuff, because else the control won't initialize properly and its Visible will be false! // 20130507
                 * */
                if (null != _docFrom)
                    _docFrom.RemoveChild(child);

                if (null != _docTo)
                    _docTo.AddChild(child);
            }

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format(@"Moved: {0}
", DescribeMoves()));
            }
#endif

            if (null != _docFrom)
                _docFrom.InvalidateDrawingList();
            if (null != _docTo)
                _docTo.InvalidateDrawingList();
        }
Beispiel #2
0
        /// <summary>
        /// Gets all skin classes
        /// </summary>
        public static List<Type> GetAllStyleableClasses()
        {
            List<Type> allTypes = TypeReflector.GetAllLoadedTypes();
            List<Type> output = new List<Type>();

            foreach (Type type in allTypes)
            {
                if (type.IsClass)
                {
                    if (/*!GuiComponentsOnly || */StyleClientType.IsAssignableFrom(type))
                    {
                        if (CoreReflector.HasClassAttributes<StyleAttribute>(type))
                            output.Add(type);
                    }
                }
            }

            return output;
        }
Beispiel #3
0
        /// <summary>
        /// Gets a parent chain
        /// Example: If out component is in a chain Stage-A-B-C-Component, this method returns the list of: Stage, A, B, C.
        /// </summary>
        /// <param name="component">Compo</param>
        /// <param name="reverse">Reverse the chain</param>
        /// <returns></returns>
        public static List<DisplayListMember> GetParentChain(DisplayListMember component, bool reverse)
        {
            if (null == component)
                throw new Exception("Component not defined");

            List<DisplayListMember> list = new List<DisplayListMember>();
            DisplayListMember current = component;

            //list.Add(current); // removed on 2011-09-18

            while (!(current is Stage) && null != current.Parent)
            {
                current = current.Parent;
                list.Add(current);
            }

            if (reverse)
                list.Reverse();

            return list;
        }
Beispiel #4
0
        /// <summary>
        /// Updates the supplied depth list using the order list<br/>
        /// Generally, it removes all the depth values, refills the list, and then sorts by the child Depth value
        /// </summary>
        /// <param name="orderList"></param>
        /// <param name="depthList"></param>
        // ReSharper disable SuggestBaseTypeForParameter
        private static void UpdateDrawingList(List<DisplayListMember> orderList, List<DisplayListMember> depthList)
        // ReSharper restore SuggestBaseTypeForParameter
        {
            //Debug.Log(string.Format("                  ! -> [orderList: {0}, depthList: {1}]", orderList.Count, depthList.Count));

            /**
             * 1. Empty the list
             * */
            depthList.Clear();

            int len = orderList.Count;

            /**
             * 2. Fill the list with values from the order list
             * */
            foreach (DisplayListMember displayListMember in orderList)
            {
                depthList.Add(displayListMember);
            }

            //Debug.Log("     depthList.Count: " + depthList.Count);

            if (len <= 1)
            {
#if DEBUG
                if (DebugMode)
                {
                    Debug.Log(string.Format("                       -> [orderList: {0}, depthList: {1}] *", orderList.Count, depthList.Count));
                }
#endif
                return; // don't bother
            }

            /**
             * 3. Sort by Depth
             * */
            for (int i = 1; i < len; i++)
            {
                for (int j = i; j > 0; j--)
                {
                    if (depthList[j].Depth < depthList[j - 1].Depth)
                    {
                        _tmp = depthList[j];
                        depthList[j] = depthList[j - 1];
                        depthList[j - 1] = _tmp;
                    }
                    //else
                    //    break;
                }
            }

            //Debug.Log(ListUtil<DisplayListMember>.Format(depthList));

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format("                       -> [orderList: {0}, depthList: {1}]", orderList.Count, depthList.Count));
            }
#endif
        }
Beispiel #5
0
        ///<summary>
        ///</summary>
        ///<param name="component"></param>
        ///<param name="delimiter"></param>
        ///<returns></returns>
        public static string PathToString(Component component, string delimiter)
        {
            if (string.IsNullOrEmpty(delimiter))
                delimiter = ".";

            /**
             * 1. Build path
             * */
            List<Component> list = new List<Component>();

            while (null != component)
            {
                list.Add(component);
                component = component.Parent as Component;
            }

            list.Reverse();

            string name = "";
            int count = list.Count;
            for (int i = 0; i < count; i++)
            {
                name += list[i].Name;
                if (i < count - 1)
                    name += delimiter;
            }

            return name;
        }
        /// <summary>
        /// Describes mulricast delegates
        /// </summary>
        /// <param name="componentType"></param>
        /// <returns></returns>
        public static string GetMulticastDelegates(Type componentType)
        {
            var memberNames = CoreReflector.GetFieldAndPropertyNames(componentType);
            //memberNames.Sort(MemberInfoSort);
            List<string> data = new List<string>();
            foreach (var name in memberNames)
            {
                MemberWrapper mw = new MemberWrapper(componentType, name);
                if (mw.MemberType == typeof (Core.Events.MulticastDelegate))
                {
                    var output = mw.MemberInfo.Name;

                    /*var clazz = mw.MemberInfo.DeclaringType;
                    if (null != clazz)
                    {
                        var types = 


                        var instance = Activator.CreateInstance(clazz);
                        var value = mw.GetValue(instance);
                        if (null != value)
                            output = string.Format(@"{0} [{1}]", output, value.GetType().FullName);
                    }*/
                    
                    var attributes = CoreReflector.GetMemberAttributes<EventAttribute>(mw.MemberInfo);
                    if (attributes.Count > 0)
                    {
                        var eventAttribute = attributes[0];
                        output = string.Format(@"{0} → {1}", output, eventAttribute);
                    }

                    data.Add(output);
                }
            }

            data.Sort();

            StringBuilder sb = new StringBuilder();
            foreach (var item in data)
            {
                sb.AppendLine(item);
            }

            return string.Format(@"Multicast delegates ({0}):
{1}
{2}", data.Count, Line, sb) + NewLine/* + NewLine*/;
        }
        /*private static string GetInterfaces(Type componentType)
        {
            var interfaces = componentType.GetInterfaces();

            var list = new List<string>();
            foreach (Type type in interfaces)
            {
                list.Add(type.Name);
            }

            return string.Join(", ", list.ToArray());
        }*/

        private static string GetSubclasses(Type componentType)
        {
            var list = new List<string>();
            foreach (Type type in GlobalTypeDictionary.Instance.Values)
            {
                if (type.BaseType == componentType)
                    list.Add(type.Name);
            }
            return list.Count == 0 ? "-" : string.Join(", ", list.ToArray());
        }
        public override void Apply(Component component)
        {
            DataGroup dataProviderClient = component as DataGroup;
            SkinnableDataContainer skinnableDataContainer = component as SkinnableDataContainer;
            if (null == dataProviderClient && null == skinnableDataContainer)
            {
                Debug.LogWarning("GUI component is not a DataGroup nor SkinnableDataContainer");
                return;
            }

            List<object> list = new List<object>();
            foreach (string s in Data)
            {
                list.Add(new ListItem(s, s));
            }

            if (null != dataProviderClient)
                dataProviderClient.DataProvider = new ArrayList(list);
            else
                skinnableDataContainer.DataProvider = new ArrayList(list);
        }
Beispiel #9
0
        private void LoadAvailableSkins(ComponentAdapter adapter)
        {
            var skins = EditorReflector.GetSkins(adapter.ComponentType).ToList();

#if DEBUG
            if (true)
            {
                StringBuilder sb = new StringBuilder();
                if (skins.Count == 0)
                {
                    sb.AppendLine("No available skins.");
                }
                else
                {
                    /*foreach (KeyValuePair<string, Type> pair in skins)
                    {
                        sb.AppendLine(string.Format("    {0} -> {1}", pair.Key, pair.Value));
                    }*/
                    foreach (var skin in skins)
                    {
                        sb.AppendLine(string.Format("    -> {0}", skin));
                    }
                }

                /*Debug.Log(string.Format(@"====== Skins ======
{0}", sb));*/
            }
#endif
            _availableSkinClasses = new List<string>();
            //if (_couldNotLocateMapper)
            //    list.Add("=== Not found ===");
            //list.Add("= Default =");
            foreach (Type skinClass in skins)
            {
                _availableSkinClasses.Add(skinClass.FullName);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Used by designer
        /// </summary>
        /// <param name="componentType"></param>
        public static List<Type> GetSkinClasses(Type componentType)
        {
            List<Type> list = new List<Type>();

            //Debug.Log("componentType: " + componentType);
            if (!componentType.IsSubclassOf(typeof(SkinnableComponent)))
            {
                //Debug.LogError("Component is not a subclass of SkinnableComponent: " + componentType);
                return list;
            }

            List<Type> types = GuiReflector.GetAllLoadedTypes();

            foreach (Type type in types)
            {
                if (!type.IsClass)
                    continue;

                if (!type.IsSubclassOf(typeof (Skin)))
                    continue;
                
                var componentTypeSpecifiedInAttribute = SkinUtil.GetHostComponent(type);
                if (componentTypeSpecifiedInAttribute == componentType)
                {
                    list.Add(type);
                }
            }

            return list;
        }
Beispiel #11
0
        /// <summary>
        /// Gets style properties (attributes converted to style properties)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="restrictToSerializableTypes"></param>
        /// <returns></returns>
        public static List<StyleProperty> GetStyleProperties(Type type, bool restrictToSerializableTypes = false)
        {
            var attributes = GetStyleAttributes(type);

            List<StyleProperty> list = new List<StyleProperty>();
            foreach (var attribute in attributes)
            {
                /* with "skinClass" style, the Type isn't required. Set it here */
                if (attribute.Name == "skinClass"/* && null == attribute.Type*/) { 
                    attribute.Type = typeof(string);
                    attribute.Default = null;
                }
                
                if (restrictToSerializableTypes && StyleProperty.NonSerializableStyleTypes.Contains(attribute.Type))
                    continue;

                //if (!restrictToSerializableTypes || StyleProperty.AlowedTypes.ContainsKey(attribute.GetType()))
                try
                {
                    list.Add(StyleProperty.FromAttribute(attribute));
                }
                catch (StylePropertyCreationException ex)
                {
                    // cannot be created
                }
            }

            return list;
        }
Beispiel #12
0
        public static List<ScriptWithEventHandlers> GetEventHandlerScriptsPacked(GameObject go)
        {
            List<ScriptWithEventHandlers> list = new List<ScriptWithEventHandlers>();
            
            MonoBehaviour[] components = go.GetComponents<MonoBehaviour>();
            foreach (MonoBehaviour component in components)
            {
                if (component is ComponentAdapter)
                    continue; // ignore component descriptors

                ScriptWithEventHandlers mapping = new ScriptWithEventHandlers();
                mapping.AddRange(GetMethodsBySignature(component.GetType(), typeof(void), typeof(Event)));

                list.Add(mapping);
            }

            return list;
        }
        /// <summary>
        /// Looks for a stack of components under the specified coordinates inside of the parent component
        /// Does the top-down processing: from parent to children
        /// Returns the top-most rendered component on given coordinates (on a single stage)
        /// Notes:
        /// 1. The returned list must be refersed in order to get the top component at the beginning of the list!
        /// 2. This is a recursive operation
        /// </summary>
        /// <param name="dlm">Parent component</param>
        /// <param name="coords">Coordinates</param>
        /// <param name="filter">Filter</param>
        /// <param name="stopOnDisabled">Should the process stop if component disabled</param>
        /// <param name="stopOnInvisible">Should the process stop if component not visible></param>
        /// <param name="list">The list passed by reference</param>
        /// <returns></returns>
        private static void GetComponentStackUnderCoordinates(DisplayListMember dlm, Point coords, Filter filter, bool stopOnDisabled, bool stopOnInvisible, ref List<DisplayListMember> list)
        {
            var component = dlm as InteractiveComponent;

            //Debug.Log("GetComponentStackUnderCoordinates: " + dlm);

            if (null != component)
            {
                if (stopOnInvisible && !dlm.Visible) // invisible
                    return;

                if (stopOnDisabled && !component.Enabled) // disabled
                    return;
            }

            _containsPoint = dlm.ContainsPoint(coords, false);

            //Debug.Log("    _containsPoint: " + dlm);

            if (_containsPoint && PassesFilter(dlm, filter))
            {
                //Debug.Log("    PassesFilter: " + dlm);
                list.Add(dlm);
            }

            Group @group = dlm as Group;

            // in the case of container check the children 
            if (null != @group)
            {
                if (!_containsPoint /*&& container.QClipContent*/)
                    return;

                // the click was inside the container bounds, or container isn't clipping
                // check the children for clicks
                if (@group.MouseChildren)
                {
                    foreach(DisplayListMember d in @group.QDrawingList)
                    {
                        //Component child = d as Component;
                        //if (null != child)
                        //{
                            /* Recursive call! */
                            //DisplayListMember c = GetComponentUnderCoordinates(d, coords, filter, stopOnDisabled);
                            GetComponentStackUnderCoordinates(d, coords, filter, stopOnDisabled, stopOnInvisible, ref list);
                            //Debug.Log("   -> " + c);
                            //if (null != c)
                            //    list.Add(c);
                        //}
                    }
                }
            }
            else // simple component
            {
                DisplayObjectContainer doc = dlm as DisplayObjectContainer;
                // the click was inside the container bounds, or container isn't clipping
                // check the children for clicks

                if (null != doc && doc.QNumberOfChildren > 0 && doc.MouseChildren)
                {
                    foreach (DisplayListMember d in doc.QDrawingList)
                    {
                        GetComponentStackUnderCoordinates(d, coords, filter, stopOnDisabled, stopOnInvisible, ref list);
                        //DisplayListMember c = GetComponentUnderCoordinates(d, coords, filter, stopOnDisabled);
                        //if (null != c)
                        //    list.Add(c);
                    }
                }
            }
        }
        /// <summary>
        /// Finds the Component stack under the mouse poiner
        /// </summary>
// ReSharper disable MemberCanBePrivate.Global
        public void RecalculateMouseWheelTargets()
// ReSharper restore MemberCanBePrivate.Global
        {
            //Debug.Log("RecalculateMouseWheelTargets: " + deltaY);
            if (_isMouseLeave)
            {
                _mouseWheelTargets.Clear();
                return;
            }

            var members = CoordinateProcessor.GetComponentStackUnderCoordinatesOnAllStages(
                _mouseEvent.GlobalPosition,
                MouseWheelFilter, 
                true, true // stopOnDisabled, stopOnInvisible
            );

            _mouseWheelTargets = new List<Component>();

            foreach (DisplayListMember member in members)
            {
                _mouseWheelTargets.Add((Component)member);
            }

            // Important: reverse targets
            //_mouseWheelTargets.Reverse();

//            Debug.Log(string.Format(@"Mouse wheel targets ({0}): 
//{1}", _mouseWheelTargets.Count, ComponentUtil.DescribeComponentList(_mouseWheelTargets)));

#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format(@"Mouse wheel targets ({0}): 
{1}", _mouseWheelTargets.Count, ComponentUtil.DescribeComponentList(_mouseWheelTargets)));
            }
#endif
        }
Beispiel #15
0
        /**
         *  
         *  Returns the base states for a given state.
         *  This Array is in high-to-low order - the first entry
         *  is the immediate basedOn state, the last entry is the topmost
         *  basedOn state.
         */
        private List<string> GetBaseStates(State state)
        {
            var baseStates = new List<string>();

            // Push each basedOn name
            while (null != state && null != state.BasedOn)
            {
                baseStates.Add(state.BasedOn);
                state = GetState(state.BasedOn, true);
            }

            return baseStates;
        }
        internal void RefreshComponentList()
        {
            _showComponents = EditorSettings.ReferenceShowComponents;
            _showSkinnableComponents = EditorSettings.ReferenceShowSkinnableComponents;
            _showSkins = EditorSettings.ReferenceShowSkins;

            _selectedIndex = -1;
            _selectionChanged = false;

            _classes.Clear();

            var allClasses = GuiReflector.GetAllLoadedTypes();

            foreach (var type in allClasses)
            {
                if (typeof(Component).IsAssignableFrom(type))
                {
                    if (!string.IsNullOrEmpty(_searchText) && !PassesSearchFilter(type.FullName, _searchText))
                        /*!type.FullName.ToUpper().Contains(_searchText.ToUpper())*/
                        continue;
                    _classes.Add(type);
                }
            }

            _classes.Sort(TypeSort);
            //Debug.Log("_classes: " + _classes.Count);

            List<GUIContent> contentList = new List<GUIContent>();

            foreach (var @class in _classes)
            {
                var isSkinnableComponent = typeof(SkinnableComponent).IsAssignableFrom(@class);
                var isSkin = typeof(Skin).IsAssignableFrom(@class);
                var isSimpleComponent = !isSkinnableComponent && !isSkin;
                var texture = GuiComponentEvaluator.EvaluateComponentRowIcon(@class);

                if (_showComponents && isSimpleComponent ||
                    _showSkinnableComponents && isSkinnableComponent ||
                    _showSkins && isSkin)
                {
                    contentList.Add(new GUIContent(" " + @class.FullName, texture));    
                }
            }

            _contents = contentList.ToArray();
            //Debug.Log("_contents: " + _contents.Length);
        }
Beispiel #17
0
        override protected void AdjustSelection(int index, bool add/*=false*/)
        {
            int i; 
            int curr; 
            var newInterval = new List<int>(); 
            IndexChangeEvent e; 
            
            if (SelectedIndex == NO_SELECTION || DoingWholesaleChanges)
            {
                // The case where one item has been newly added and it needs to be 
                // selected and careted because requireSelection is true. 
                if (null != DataProvider && DataProvider.Length == 1 && RequireSelection)
                {
                    newInterval.Add(0);
                    _selectedIndices = newInterval;   
                    SelectedIndex = 0; 
                    ItemShowingCaret(0, true); 
                    // If the selection properties have been adjusted to account for items that
                    // have been added or removed, send out a "valueCommit" event and 
                    // "caretChange" event so any bindings to them are updated correctly.
                     
                    DispatchEvent(new FrameworkEvent(FrameworkEvent.VALUE_COMMIT));
                    
                    e = new IndexChangeEvent(IndexChangeEvent.CARET_CHANGE) {OldIndex = -1, NewIndex = CaretIndex};
                    DispatchEvent(e); 
                }
                return; 
            }
            
            // Ensure multiple and single selection are in-sync before adjusting  
            // selection. Sometimes if selection has been changed before adding/removing
            // an item, we may not have handled selection via invalidation, so in those 
            // cases, force a call to commitSelection() to validate and commit the selection. 
            if ((null == SelectedIndices && SelectedIndex > NO_SELECTION) ||
                (SelectedIndex > NO_SELECTION && null != SelectedIndices && SelectedIndices.IndexOf(SelectedIndex) == -1))
            {
                CommitSelection(true); 
            }
            
            // Handle the add or remove and adjust selection accordingly. 
            if (add)
            {
                if (null != SelectedIndices)
                {
                    for (i = 0; i < SelectedIndices.Count; i++)
                    {
                        curr = SelectedIndices[i];

                        // Adding an item above one of the selected items,
                        // bump the selected item up. 
                        if (curr >= index)
                            newInterval.Add(curr + 1);
                        else
                            newInterval.Add(curr);
                    }
                }
            }
            else
            {
                // Quick check to see if we're removing the only selected item
                // in which case we need to honor requireSelection. 
                if (null != SelectedIndices && !IsEmpty(SelectedIndices) && SelectedIndices.Count == 1 
                    && index == SelectedIndex && RequireSelection)
                {
                    //Removing the last item 
                    if (DataProvider.Length == 0)
                    {
                        newInterval = new List<int>(); 
                    }
                    else if (index == 0)
                    {
                        // We can't just set selectedIndex to 0 directly
                        // since the previous value was 0 and the new value is
                        // 0, so the setter will return early.
                        ProposedSelectedIndex = 0; 
                        InvalidateProperties();
                        return;
                    }    
                    else
                    {
                        newInterval.Add(0);  
                    }
                }
                else if (null != SelectedIndices)
                {    
                    for (i = 0; i < SelectedIndices.Count; i++)
                    {
                        curr = SelectedIndices[i]; 
                        // Removing an item above one of the selected items,
                        // bump the selected item down. 
                        if (curr > index)
                            newInterval.Add(curr - 1); 
                        else if (curr < index) 
                            newInterval.Add(curr);
                    }
                }
            }
            
            if (CaretIndex == SelectedIndex)
            {
                var oldIndex = CaretIndex; 
                CaretIndex = GetFirstItemValue(newInterval);
                e = new IndexChangeEvent(IndexChangeEvent.CARET_CHANGE) {OldIndex = oldIndex, NewIndex = CaretIndex};
                DispatchEvent(e); 
            }
            else 
            {
                 ItemShowingCaret(CaretIndex, false); 
                CaretIndexAdjusted = true; 
                InvalidateProperties(); 
            }
            
            var oldIndices = SelectedIndices;  
            _selectedIndices = newInterval;
            SelectedIndex = GetFirstItemValue(newInterval);
            if (_selectedIndices != oldIndices)
            {
                SelectedIndexAdjusted = true; 
                InvalidateProperties(); 
            }
        }
Beispiel #18
0
        public override List<DisplayListMember> GetTabChildren()
        {
            List<DisplayListMember> list = new List<DisplayListMember>();
            list.AddRange(new DisplayListMember[]{ _btnCc, _btnBcc, _txtTo });

            if (_btnCc.Selected)
                list.Add(_txtCc);
            if (_btnBcc.Selected)
                list.Add(_txtBcc);

            list.AddRange(new DisplayListMember[]{ _txtMessage, _btnSend });

            return list;
        }
Beispiel #19
0
        /**
         *  
         *  Given a new selection interval, figure out which
         *  items are newly added/removed from the selection interval and update
         *  selection properties and view accordingly. 
         */
// ReSharper disable MemberCanBePrivate.Global
        protected void CommitMultipleSelection()
// ReSharper restore MemberCanBePrivate.Global
        {
            var removedItems = new List<int>();
            var addedItems = new List<int>();
            int i;
            int count;
            
            if (!IsEmpty(_selectedIndices) && !IsEmpty(_proposedSelectedIndices))
            {
                // Changing selection, determine which items were added to the 
                // selection interval 
                count = _proposedSelectedIndices.Count;
                for (i = 0; i < count; i++)
                {
                    if (_selectedIndices.IndexOf(_proposedSelectedIndices[i]) < 0)
                        addedItems.Add(_proposedSelectedIndices[i]);
                }
                // Then determine which items were removed from the selection 
                // interval 
                count = _selectedIndices.Count; 
                for (i = 0; i < count; i++)
                {
                    if (_proposedSelectedIndices.IndexOf(_selectedIndices[i]) < 0)
                        removedItems.Add(_selectedIndices[i]);
                }
            }
            else if (!IsEmpty(_selectedIndices))
            {
                // Going to a null selection, remove all
                removedItems = _selectedIndices;
            }
            else if (!IsEmpty(_proposedSelectedIndices))
            {
                // Going from a null selection, add all
                addedItems = _proposedSelectedIndices;
            }
             
            // De-select the old items that were selected 
            if (removedItems.Count > 0)
            {
                count = removedItems.Count;
                for (i = 0; i < count; i++)
                {
                    ItemSelected(removedItems[i], false);
                }
            }
            
            // Select the new items in the new selection interval 
            if (!IsEmpty(_proposedSelectedIndices))
            {
                count = _proposedSelectedIndices.Count;
                for (i = 0; i < count; i++)
                {
                    ItemSelected(_proposedSelectedIndices[i], true);
                }
            }
            
            // Commit the selected indices and put _proposedSelectedIndices
            // back to its default value.  
            _selectedIndices = _proposedSelectedIndices;
            _proposedSelectedIndices = new List<int>();
        }
        private static string GetInheritance(Type componentType)
        {
            List<string> list = new List<string>();
            while (null != componentType && (componentType != typeof(Component).BaseType)) // all up to Component
            {
                list.Add(componentType.Name);
                componentType = componentType.BaseType;
            }

            return string.Join(" → ", list.ToArray());
        }
Beispiel #21
0
		internal static void InitProtoChain(IStyleClient client)
		{
			/*if (client.GetType().FullName == "Assets.eDriven.Skins.ImageButtonSkin")
				Debug.Log("Assets.eDriven.Skins.ImageButtonSkin: " + client);*/

			//Debug.Log("InitProtoChain: " + client);
			StyleManager styleManager = StyleManager.Instance;
			//StyleDeclaration classSelector = null;

			Component uicObject = client as Component;
			StyleDeclaration styleDeclaration;

			List<StyleDeclaration> universalSelectors = new List<StyleDeclaration>();
			bool hasStyleName = false;
			object styleName = client.StyleName;

			//Debug.LogWarning("styleName: " + styleName);

			/**
			 * prvo gledamo classname setiran na ovoj komponenti
			 * ako je setiran, uzimamo style declaration za taj classname iz poola
			 * */

			if (null != styleName)
			{
				/*if (client.StyleName is string && (string)client.StyleName == "test")
					Debug.Log("client.StyleName");*/

				// Get the style sheet referenced by the styleName property
				//classSelector = StyleManager.Instance.GetStyleDeclaration("." + StyleName);
				if (styleName is StyleDeclaration)
				{
					//Debug.LogWarning("Style name is StyleDeclaration: " + styleName);
					// Get the styles referenced by the styleName property.
					universalSelectors.Add((StyleDeclaration)styleName);
				}

				#region Still not used. This is normally used for parent-child style propagation (skins)
				//else if (/*styleName is IFlexDisplayObject || */styleName is IStyleClient) // TODO
				//{
				//    // If the styleName property is a Component, then there's a
				//    // special search path for that case.
				//    StyleProtoChain.InitProtoChainForUIComponentStyleName(client);
				//    return;
				//}
				#endregion

				else if (styleName is string)
				{
					//Debug.LogWarning("Style name is istring: " + styleName);
					hasStyleName = true;
				}
				else
				{
					Debug.LogWarning("Error");
				}
			}

			/**
			 * ovdje sada imamo style declaration za classname
			
			 * nakon toga moramo uzeti non-inherit chain (global root) i 
			 * inherit chain (inheriting styles od parenta)
			 * oni su nam potrebni kako bi prenijeli stilove iz parenta ukoliko nisu deklarirani na ovoj komponenti		
			 * */

			// To build the proto chain, we start at the end and work forward.
			// Referring to the list at the top of this function, we'll start by
			// getting the tail of the proto chain, which is:
			//  - for non-inheriting styles, the global style sheet
			//  - for inheriting styles, my parent's style object
			StyleTable nonInheritChain = styleManager.StylesRoot;
			StyleTable inheritChain;

			//IStyleClient p = Parent as IStyleClient;
			IStyleClient p = null;
			var visual = client as IVisualElement;
			if (null != visual)
				p = visual.Parent as IStyleClient;

			if (null != p)
			{
				inheritChain = p.InheritingStyles;

				#region Monitor

//#if DEBUG
//                if (null != TYPE_TO_MONITOR)
//                {
//                    if (uicObject.GetType() == TYPE_TO_MONITOR)
//                    {
//                        StringBuilder sb = new StringBuilder();
//                        sb.AppendLine(client + " -> parent chains:");
//                        sb.AppendLine("p.InheritingStyles: " + p.InheritingStyles);
//                        sb.AppendLine("p.NonInheritingStyles: " + p.NonInheritingStyles);
//                        Debug.Log(sb);
//                    }
//                }
//#endif

				#endregion

				if (inheritChain == STYLE_UNINITIALIZED)
				{
					// ako parent nema inicijaliziran inherit chain, znači da ništa ne nasljeđuje od svojih parenta
					// te također ni on sam ne definira niti jedan inheriting style.
					// u tom slučaju se možemo referencirati na non-inherit chain
					inheritChain = nonInheritChain;
				}
			}
			else
			{
				inheritChain = styleManager.StylesRoot;
			}

			#region Monitor

//#if DEBUG
//            if (null != TYPE_TO_MONITOR)
//            {
//                if (uicObject.GetType() == TYPE_TO_MONITOR)
//                {
//                    StringBuilder sb = new StringBuilder();
//                    sb.AppendLine(client + " -> chains:");
//                    sb.AppendLine("inheritChain: " + inheritChain);
//                    sb.AppendLine("nonInheritChain: " + nonInheritChain);
//                    Debug.Log(sb);
//                }
//            }
//#endif

			#endregion

			/**
			 * Sada moramo obraditi type deklaracije
			 * Radi se o tome da stil Buttona nasljeđuje i stilove definirane na superklasama
			 * Znači prvo potrebno je izbildati niz deklaracija (gleda se da li postoje definirane u stylesheetu)
			 * i to redoslijedom od superklasa do ove klase
			 * To odrađuje metoda "getClassStyleDeclarations()" koja vraća taj mini-niz
			 * Redoslijed u nizu je bitan jer propertyji definirani na subklasi overrajdaju one na superklasi
			 * */

			// Working backwards up the list, the next element in the
			// search path is the type selector

			List<StyleDeclaration> styleDeclarations = GetMatchingStyleDeclarations(client, universalSelectors);

			if (null != styleDeclarations)
			{
				#region Monitor

				if (StyleDebugging.DebugComponents.Contains(client.GetType()))
				{
					StyleDebugging.DebugDeclarationApplication(client, styleDeclarations);
				}

				#endregion

				int n = styleDeclarations.Count; //typeSelectors.Count;
				for (int i = 0; i < n; i++)
				{
					styleDeclaration = styleDeclarations[i];
					inheritChain = styleDeclaration.AddStyleToProtoChain(inheritChain, uicObject);
					nonInheritChain = styleDeclaration.AddStyleToProtoChain(nonInheritChain, uicObject);
				}
			}

			#region For simple (string) styles (like ".stile") - not used here

			//int n;

			//if (hasStyleName)
			//{
			//    var styleNames = Regex.Split((string) styleName, @"/\s+/");
			//    n = styleNames.Count();
			//    for (var i = 0; i < n; i++)
			//    {
			//        if (styleNames[i].Length > 0)
			//        {
			//            styleDeclaration = styleManager.GetMergedStyleDeclaration("." + styleNames[i]);
			//            if (null != styleDeclaration)
			//                universalSelectors.Add(styleDeclaration);
			//        }
			//    }
			//}

			//// Working backwards up the list, the next element in the
			//// search path is the type selector
			//var styleDeclarations = client.GetClassStyleDeclarations();
			////Debug.Log("##### styleDeclarations: " + styleDeclarations.Count);

			////if (client is Skin && ((Skin)client).Parent is Button)
			///*if (client.GetType().FullName == "Assets.eDriven.Skins.ImageButtonSkin")
			//    Debug.Log("Skin: " + client);*/

			//if (null != styleDeclarations)
			//{
			//    n = styleDeclarations.Count; //typeSelectors.Count;
			//    for (int i = 0; i < n; i++)
			//    {
			//        styleDeclaration = styleDeclarations[i];
			//        inheritChain = styleDeclaration.AddStyleToProtoChain(inheritChain, uicObject);
			//        nonInheritChain = styleDeclaration.AddStyleToProtoChain(nonInheritChain, uicObject);
			//        /*if (styleDeclaration.effects)
			//            object.registerEffects(styleDeclaration.effects);*/
			//    }
			//}

			//// Next are the class selectors
			//n = universalSelectors.Count;
			//for (var i = 0; i < n; i++)
			//{
			//    styleDeclaration = universalSelectors[i];
			//    if (null != styleDeclaration)
			//    {
			//        inheritChain = styleDeclaration.AddStyleToProtoChain(inheritChain, uicObject);
			//        nonInheritChain = styleDeclaration.AddStyleToProtoChain(nonInheritChain, uicObject);
			//        /*if (styleDeclaration.effects)
			//            object.registerEffects(styleDeclaration.effects);*/
			//    }
			//}

			#endregion
			
			// Finally, we'll add the in-line styles
			// to the head of the proto chain.

			styleDeclaration = client.StyleDeclaration;

			client.InheritingStyles =
				null != styleDeclaration ?
				styleDeclaration.AddStyleToProtoChain(inheritChain, uicObject) :
				inheritChain;

			client.NonInheritingStyles =
				null != styleDeclaration ?
				styleDeclaration.AddStyleToProtoChain(nonInheritChain, uicObject) :
				nonInheritChain;

			#region Monitor

//#if DEBUG
//            if (null != TYPE_TO_MONITOR)
//            {
//                if (uicObject.GetType() == TYPE_TO_MONITOR || uicObject.GetType() == typeof(HGroup))
//                {
//                    StringBuilder sb = new StringBuilder();
//                    sb.AppendLine(@"### proto chain initialized ###
//" + ComponentUtil.PathToString(uicObject, "->"));
//                    sb.AppendLine();

//                    if (null != client.StyleDeclaration && null != client.StyleDeclaration.Overrides)
//                    {
//                        sb.AppendLine("Overrides: " + client.StyleDeclaration.Overrides);
//                    }
//                    sb.AppendLine();

//                    sb.AppendLine("InheritingStyles: " + client.InheritingStyles);
//                    sb.AppendLine();

//                    sb.AppendLine("NonInheritingStyles: " + client.NonInheritingStyles);

//                    Debug.Log(sb);
//                }
//            }
//#endif

			#endregion

		}
        /*private static int ClassNameSort(Type x, Type y)
        {
            return String.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);
        }*/

        #endregion

        #region Skin parts
        
        /// <summary>
        /// Describes skin parts
        /// </summary>
        /// <param name="componentType"></param>
        /// <returns></returns>
        public static string GetSkinParts(Type componentType)
        {
            if (!typeof(SkinnableComponent).IsAssignableFrom(componentType))
            {
                return string.Format(@"Skin parts: Not a skinnable component." + NewLine + NewLine);
            }

            var dict = GuiReflector.GetSkinParts(componentType); // string->bool

            var list = new List<string>();
            foreach (string key in dict.Keys)
            {
                list.Add(key);
            }
            list.Sort();

            StringBuilder sb = new StringBuilder();
            foreach (var name in list)
            {
                MemberWrapper mw = new MemberWrapper(componentType, name);
                sb.AppendLine(string.Format("{0} [Type: {1}, Required: {2}]", name, mw.MemberType, dict[name]));
            }

            return string.Format(@"Skin parts ({0}):
{1}
{2}", list.Count, Line, sb) + NewLine/* + NewLine*/;
        }
Beispiel #23
0
		private static List<StyleDeclaration> MatchStyleDeclarations(List<StyleDeclaration> declarations, IStyleClient client)
		{
			//Debug.Log("declarations: " + declarations);
			//if (null == declarations)
			//    return null;

			var matchingDecls = new List<StyleDeclaration>();
			if (null == declarations)
				return matchingDecls;

			// Find the subset of declarations that match this component
			foreach (StyleDeclaration decl in declarations)
			{
				if (decl.MatchesStyleClient(client))
					matchingDecls.Add(decl);
			}

			return matchingDecls;
		}
        private static string GetSignals(Type componentType)
        {
            var memberNames = CoreReflector.GetFieldAndPropertyNames(componentType);
            //memberNames.Sort(MemberInfoSort);
            List<MemberInfo> infos = new List<MemberInfo>();
            foreach (var name in memberNames)
            {
                MemberWrapper mw = new MemberWrapper(componentType, name);
                if (mw.MemberType == typeof(Signal))
                    infos.Add(mw.MemberInfo);
            }

            infos.Sort(MemberInfoSort);

            StringBuilder sb = new StringBuilder();
            foreach (var memberInfo in infos)
            {
                sb.AppendLine(memberInfo.Name);
            }

            return string.Format(@"Signals ({0}):
{1}
{2}", infos.Count, Line, sb) + NewLine/* + NewLine*/;
        }
Beispiel #25
0
        // TODO: handle skipping non-focused components and circular changes
        private List<FocusableComponentDescriptor> GetFocusableComponents()
        {
            List<FocusableComponentDescriptor> list = new List<FocusableComponentDescriptor>();

            ITabManagerClient fmc = _component as ITabManagerClient;
            if (null == fmc)
                return list;

            _components = TabChildren ?? fmc.GetTabChildren();

            int index = 0;
            _components.ForEach(delegate(DisplayListMember child)
            {
                InteractiveComponent comp = child as InteractiveComponent; // form item
                if (FocusManager.IsFocusCandidate(comp)) // visible & enabled & focus enabled?
                    list.Add(new FocusableComponentDescriptor(index, comp));
                index++;
            });

            return list;
        }
Beispiel #26
0
        /// <summary>
        /// Gets all style properties
        /// </summary>
        /// <param name="type"></param>
        /// <param name="restrictToInspectableTypes"></param>
        public static List<StyleAttribute> GetStyleAttributes(Type type)
        {
            if (StyleAttributeCache.ContainsKey(type))
                return StyleAttributeCache[type];

            var styleAttributes = CoreReflector.GetClassAttributes<StyleAttribute>(type);

            List<StyleAttribute> attributes = new List<StyleAttribute>();

            foreach (StyleAttribute attribute in styleAttributes)
            {
                /* with "skinClass" style, the Type isn't required. Set it here */
                /*if (attribute.Name == "skinClass" && null == attribute.Type)
                    attribute.Type = typeof(object);*/

                if (/*!restrictToInspectableTypes || */(attribute.Name == "skinClass" || null != attribute.Type/* && StyleProperty.AlowedTypes.ContainsKey(attribute.Type)*/))
                {
                    /**
                     * Important: Avoid duplication
                     * Subclass attributes are being added before the superclass attributes, so we're fine
                     * */
                    var name = attribute.Name;

                    if (!attributes.Exists(delegate(StyleAttribute a)
                    {
                        return a.Name == name;
                    }))
                    {
                        attributes.Add(attribute);
                    }
                    else
                    {
                        //Debug.Log(type + " has duplicated attribute: " + name + ": " + attribute.GetDefault());
                    }
                }
            }

            StyleAttributeCache[type] = attributes;

            return attributes;
        }
Beispiel #27
0
        ///<summary>
        ///</summary>
        ///<param name="type"></param>
        ///<param name="class"></param>
        ///<param name="id"></param>
        ///<param name="pseudo"></param>
        ///<returns></returns>
        internal static Selector BuildSelector(string type, string @class, string id, string pseudo)
        {
            Selector selector = new Selector(null);
            if (!string.IsNullOrEmpty(type))
            {
                selector.Subject = type;
            }
            //Debug.Log(2);

            List<CSSCondition> conditions = new List<CSSCondition>();

            if (!string.IsNullOrEmpty(@class))
            {
                conditions.Add(new CSSCondition(CSSConditionKind.Class, @class));
            }
            //Debug.Log(3);
            if (!string.IsNullOrEmpty(id))
            {
                conditions.Add(new CSSCondition(CSSConditionKind.Id, id));
            }

            /*if (!string.IsNullOrEmpty(pseudo))
            {
                conditions.Add(new CSSCondition(CSSConditionKind.Pseudo, pseudo));
            }*/

            selector.Conditions = conditions;

            return selector;
        }
Beispiel #28
0
        /**
         *   
         */ 
        // Returns an array of possible values
        private List<int> FindMatchingItems(string input)
        {
            // For now, just select the first match
            int startIndex;
            int stopIndex;
            int retVal;  
            var retVector = new List<int>();

            retVal = FindStringLoop(input, 0, DataProvider.Length); 
        
            if (retVal != -1)
                retVector.Add(retVal);
            return retVector;
        }
Beispiel #29
0
		/**
		 *  Return the indices of the item renderers visible within this DataGroup.
		 * 
		 *  <p>If clipAndEnableScrolling=true, return the indices of the visible=true 
		 *  ItemRenderers that overlap this DataGroup's scrollRect, i.e. the ItemRenders 
		 *  that are at least partially visible relative to this DataGroup.  If 
		 *  clipAndEnableScrolling=false, return a list of integers from 
		 *  0 to dataProvider.length - 1.  Note that if this DataGroup's owner is a 
		 *  Scroller, then clipAndEnableScrolling has been set to true.</p>
		 * 
		 *  <p>The corresponding item renderer for each returned index can be 
		 *  retrieved with getElementAt(), even if the layout is virtual</p>
		 * 
		 *  <p>The order of the items in the returned Vector is not guaranteed.</p>
		 * 
		 *  <p>Note that the VerticalLayout and HorizontalLayout classes provide bindable
		 *  firstIndexInView and lastIndexInView properties which convey the same information
		 *  as this method.</p>
		 * 
		 *  Returns: The indices of the visible item renderers.
		 */
		///<summary>
		///</summary>
		///<returns></returns>
// ReSharper disable UnusedMember.Global
		public List<int> GetItemIndicesInView()
// ReSharper restore UnusedMember.Global
		{
			if (null != Layout/* && Layout.UseVirtualLayout*/)
				return (null != _virtualRendererIndices) ? new List<int>(_virtualRendererIndices) : new List<int>(0);
			
			if (null == DataProvider)
				return new List<int>();
			
			Rectangle scrollR = ScrollRect;
			int dataProviderLength = DataProvider.Length;
			
			if (null != scrollR)
			{
				List<int> visibleIndices = new List<int>();
				Rectangle eltR = new Rectangle();
				//const perspectiveProjection:PerspectiveProjection = transform.perspectiveProjection;            
				
				for (int index = 0; index < dataProviderLength; index++)
				{
					//IVisualElement elt = GetContentChildAt(index); // element!
					InvalidationManagerClient elt = (InvalidationManagerClient) GetContentChildAt(index); // element!
					if (null == elt || !elt.Visible)
						continue;
					
					eltR.X = LayoutUtil.GetLayoutBoundsX(elt); //elt.getLayoutBoundsX();
					eltR.Y = LayoutUtil.GetLayoutBoundsX(elt); //elt.getLayoutBoundsY();
					eltR.Width = LayoutUtil.GetLayoutBoundsWidth(elt); //elt.getLayoutBoundsWidth();
					eltR.Height = LayoutUtil.GetLayoutBoundsHeight(elt); //elt.getLayoutBoundsHeight();
					
					if (scrollR.Intersects(eltR))
						visibleIndices.Add(index);
				}

				return visibleIndices;
			}
			
			List<int> allIndices = new List<int>(dataProviderLength);
			for (var index = 0; index < dataProviderLength; index++)
				allIndices[index] = index;
			return allIndices;
		}