/// <summary>
        /// Applies changes
        /// </summary>
        /// <param name="component"></param>
        public override void Apply(Component component)
        {
            base.Apply(component);

            #region Skin

            if (component is SkinnableComponent && !string.IsNullOrEmpty(SkinClass) &&
                (null == component.SkinClass || SkinClass != component.SkinClass.FullName))
            {
                //Debug.Log("SkinClass: " + SkinClass);

                if (!GlobalTypeDictionary.Instance.ContainsKey(SkinClass)) {
                    Debug.LogError(string.Format(@"Couldn't find reflected class [{0}] on adapter [{1}]. Maybe you have changed a class name or namespace? 
Click this message to select the problematic component.", SkinClass, this), this);
                    throw new Exception(string.Format(@"Couldn't find reflected class"));
                }

                var type = GlobalTypeDictionary.Instance[SkinClass];
                if (component.SkinClass != type)
                {
                    component.SkinClass = type;
                    SkinChanged(GetType(), SkinClass);
                }
            }

            #endregion
        }
Esempio n. 2
0
        public static string HierarchyToString(Component displayListMember)
        {
            //Debug.Log("HierarchyAsString");

            string result = null;

            // Play at the specified object and walk up the parent chain
            // to build up the string to return.
            try
            {
                for (Component control = displayListMember; control != null; control = (Component)control.Parent)
                {
                    result = (null == result) ? control.Uid : control.Uid + "." + result;

                    // If this object is in the display tree,
                    // stop after we've prepended the topmost Stage instance.
                    //if (null != control.Owner && null != control.Stage && control.Owner == control.Stage)
                    //{
                    //    //result = control.Uid;
                    //    break;
                    //}
                }
            }
            catch (Exception ex)
            {
                Debug.Log("Error: " + ex);
            }

            return(result ?? displayListMember.Uid ?? "?");
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a component from the adapter specified by ID
        /// </summary>
        /// <returns></returns>
        public static Component GetComponent(GameObject parentGameObject, string id)
        {
            ComponentAdapter adapter = GetAdapter(parentGameObject);

            if (null == adapter)
            {
                Debug.LogWarning("Cannot find component adapter on game object: " + parentGameObject);
                return(null);
            }

            if (null == adapter.Component)
            {
                Debug.LogWarning("Component not instantiated. Adapter: " + adapter);
                return(null);
            }

            Component parentComponent = adapter.Component;

            // TODO: create method ComponentManager.Instance.GetMultiple(id); and use it here!
            InteractiveComponent component = ComponentManager.Instance.Get(id);

            if (parentComponent.HasChild(component))
            {
                return((Component)component);
            }

            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Finds a gui element in children. If such an element exists, returns it; if not, returns null
        /// </summary>
        /// <typeparam name="T">Type of the adapter to find</typeparam>
        /// <param name="go">Game object on which to do the search</param>
        /// <param name="id">Adapter ID</param>
        /// <returns></returns>
        public static T FindComponent <T>(GameObject go, string id) where T : Component
        {
            ComponentAdapter adapter   = go.GetComponent <ComponentAdapter>();
            Component        component = adapter.Component;

            if (adapter.Id == id && adapter.ComponentType == typeof(T))
            {
                return(component as T);
            }

            GroupAdapter groupAdapter = adapter as GroupAdapter;

            if (null != groupAdapter)
            {
                int count = groupAdapter.transform.childCount;
                for (int i = 0; i < count; i++)
                {
                    Transform childTransform = groupAdapter.transform.GetChild(i);
                    adapter = childTransform.GetComponent <ComponentAdapter>();
                    if (adapter.ComponentType == typeof(T) && null != adapter.Component && adapter.Component.Id == id)
                    {
                        break;
                    }
                }
            }

            return(adapter.Component as T);
        }
Esempio n. 5
0
        /// <summary>
        /// Finds a gui element in children. If such an element exists, returns it; if not, returns null
        /// </summary>
        /// <param name="go">Game object on which to do the search</param>
        /// <param name="id">Adapter ID</param>
        /// <returns></returns>
        public static Component FindComponent(GameObject go, string id)
        {
            ComponentAdapter adapter   = go.GetComponent <ComponentAdapter>();
            Component        component = adapter.Component;

            if (adapter.Id == id)
            {
                return(component);
            }

            GroupAdapter groupAdapter = adapter as GroupAdapter;

            if (null != groupAdapter)
            {
                int count = groupAdapter.transform.childCount;
                for (int i = 0; i < count; i++)
                {
                    Transform childTransform = groupAdapter.transform.GetChild(i);
                    adapter = childTransform.GetComponent <ComponentAdapter>();
                    if (null != adapter.Component && adapter.Component.Id == id)
                    {
                        break;
                    }
                }
            }

            return(adapter.Component);
        }
Esempio n. 6
0
        private void StopSlot(object[] parameters)
        {
            Component component = parameters[0] as Component;

            if (null == component)
            {
                return;
            }

            Group container = component.Parent as Group;

            if (null == container)
            {
                return;
            }

            if (_dict.ContainsKey(container))
            {
                _dict[container]--;
            }

            if (_dict[container] <= 0)
            {
                _dict.Remove(container);
#if DEBUG
                if (DebugMode)
                {
                    Debug.Log(string.Format(@"Setting AutoLayout to true on " + container));
                }
#endif
                container.AutoLayout = true; // turn AutoLayout ON
                //container.ForceLayout = true;
                //container.AutoLayout = false; // turn AutoLayout ON
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the parent game object to which a component adapter is attached to<br/>
        /// If this component is not being attached directly, but as a part of the container,<br/>
        /// the container registered in component adapter collection is returned
        /// </summary>
        /// <param name="component">Component to get the game object for</param>
        /// <returns></returns>
        public static GameObject GetGameObject(Component component)
        {
            if (null == component)
            {
                return(null);
            }

            GameObject gameObject = null;

            if (ComponentAdapter.Registry.ContainsKey(component))
            {
                gameObject = ComponentAdapter.Registry[component];
            }
            else
            {
                if (null != component.Parent)
                {
                    return(GetGameObject(component.Parent as Component));
                }
            }

            if (null != gameObject)
            {
                return(gameObject);
            }

            return(null);
        }
        /// <summary>
        /// Recalculates the inspector target
        /// </summary>
        private void RecalculateInspectorTarget()
        {
            //Debug.Log("RecalculateInspectorTarget");
            _oldInspectorTarget = InspectorTarget;

            if (_isMouseLeave)
            {
                //Debug.Log("   -> InspectorTarget: mouse leave");
                InspectorMouseOutSignal.Emit(InspectorTarget);
                InspectorMouseLeaveSignal.Emit();
                InspectorTarget = null;
                return;
            }

            InspectorTarget = CoordinateProcessor.GetComponentUnderCoordinatesOnAllStages(
                _mouseEvent.GlobalPosition,
                InspectorTargetFilter,
                !SystemManager.Instance.ShiftKeyPressed, // don't stopOnDisabled
                !SystemManager.Instance.AltKeyPressed    // don't stopOnInvisible
                ) as Component;

            // emit signals
            if (_oldInspectorTarget != InspectorTarget)
            {
                //Debug.Log("   -> InspectorTarget: " + InspectorTarget);
                //Debug.Log(3);
                InspectorMouseOutSignal.Emit(_oldInspectorTarget);
                InspectorMouseOverSignal.Emit(InspectorTarget);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Creates the popup via factory/reflection
        /// </summary>
        /// <param name="parent">Parent component (for position calculations)</param>
        /// <param name="popupType">The popup class for instantiation</param>
        /// <param name="modal">Is this a modal popup</param>
        /// <param name="centered">Should popup be centered</param>
        /// <param name="keepCenter">Should popup stay centered after the screen resize</param>
        /// <returns></returns>
        public DisplayObject CreatePopup(Type popupType, DisplayObjectContainer parent, bool modal, bool centered, bool keepCenter)
        {
            Component popup = (Component)Activator.CreateInstance(popupType);

            AddPopup(popup, parent, modal, centered, keepCenter);
            return(popup);
        }
Esempio n. 10
0
        /// <summary>
        /// Adds a popup to popup stage
        /// </summary>
        /// <param name="popupType">The popup class for instantiation</param>
        /// <param name="options">Popup options</param>
        public DisplayObject CreatePopup(Type popupType, params PopupOption[] options)
        {
            Component popup = (Component)Activator.CreateInstance(popupType);

            AddPopup(popup, options);
            return(popup);
        }
Esempio n. 11
0
        private void OnMiddleMouseDown(Event e)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("MouseEventDispatcher.OnMiddleMouseDown");
            }
#endif


            _mouseEvent = (MouseEvent)e;

            RecalculateMouseTarget();

            if (MouseTarget == null)
            {
                return;
            }

            _middleMouseDownComponent = MouseTarget;

#if DEBUG
            if (DebugMode)
            {
                Debug.Log("OnMiddleMouseDown component: " + MouseTarget);
            }
#endif
            MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MIDDLE_MOUSE_DOWN,
                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
        }
Esempio n. 12
0
 /// <summary>
 /// Registers rollover component
 /// </summary>
 /// <param name="component"></param>
 /// <param name="isOver"></param>
 public void RegisterRollOverComponent(Component component, bool isOver)
 {
     if (!_rollOveredComponents.ContainsKey(component))
     {
         _rollOveredComponents[component] = isOver;
     }
 }
Esempio n. 13
0
        public void Initialize(InvalidationManagerClient component)
        {
            Debug.Log("Draggable Initialize: _dragHandle: " + _dragHandle);

            if (_initialized)
                return;

            _initialized = true;

            _component = (Component) component;
            
            // subscribe to CAPTURE PHASE component events

            _constraintMode = null == _dragHandle;
            //Debug.Log("Constrain mode: " + _constraintMode);

            //if (null != _dragHandle && _dragHandle is InvalidationManagerClient)
            //    ((InvalidationManagerClient)_dragHandle).SetStyle("cursor", "move");

            DisplayObject target = _dragHandle ?? _component;

            target.AddEventListener(MouseEvent.MOUSE_MOVE, ComponentMouseMoveHandler, /*EventPhase.Capture | */EventPhase.Target); // NOTE: Target phase must be present because of the simple components
            target.AddEventListener(MouseEvent.MOUSE_OUT, ComponentMouseOutHandler, /*EventPhase.Capture | */EventPhase.Target);
            target.AddEventListener(MouseEvent.MOUSE_DOWN, ComponentMouseDownHandler, /*EventPhase.Capture | */EventPhase.Target);
            target.AddEventListener(FrameworkEvent.REMOVE, ComponentRemovedHandler);
        }
Esempio n. 14
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            DropDownList dropDownList = (DropDownList)component;
            dropDownList.Prompt = Prompt;
        }
Esempio n. 15
0
        /// <summary>
        /// Applies changes
        /// </summary>
        /// <param name="component"></param>
        public override void Apply(Component component)
        {
            base.Apply(component);

            #region Skin

            if (component is SkinnableComponent && !string.IsNullOrEmpty(SkinClass) &&
                (null == component.SkinClass || SkinClass != component.SkinClass.FullName))
            {
                if (!GlobalTypeDictionary.Instance.ContainsKey(SkinClass))
                {
                    Debug.LogError(string.Format(@"Couldn't find reflected class [{0}] on adapter [{1}]. Maybe you have changed a class name or namespace? 
Click this message to select the problematic component.", SkinClass, this), this);
                    throw new Exception(string.Format(@"Couldn't find reflected class"));
                }

                var type = GlobalTypeDictionary.Instance[SkinClass];
                if (component.SkinClass != type)
                {
                    component.SkinClass = type;
                    SkinChanged(GetType(), SkinClass);
                }
            }

            #endregion
        }
Esempio n. 16
0
        public void Initialize(InvalidationManagerClient component)
        {
            Debug.Log("Draggable Initialize: _dragHandle: " + _dragHandle);

            if (_initialized)
            {
                return;
            }

            _initialized = true;

            _component = (Component)component;

            // subscribe to CAPTURE PHASE component events

            _constraintMode = null == _dragHandle;
            //Debug.Log("Constrain mode: " + _constraintMode);

            //if (null != _dragHandle && _dragHandle is InvalidationManagerClient)
            //    ((InvalidationManagerClient)_dragHandle).SetStyle("cursor", "move");

            DisplayObject target = _dragHandle ?? _component;

            target.AddEventListener(MouseEvent.MOUSE_MOVE, ComponentMouseMoveHandler, /*EventPhase.Capture | */ EventPhase.Target); // NOTE: Target phase must be present because of the simple components
            target.AddEventListener(MouseEvent.MOUSE_OUT, ComponentMouseOutHandler, /*EventPhase.Capture | */ EventPhase.Target);
            target.AddEventListener(MouseEvent.MOUSE_DOWN, ComponentMouseDownHandler, /*EventPhase.Capture | */ EventPhase.Target);
            target.AddEventListener(FrameworkEvent.REMOVE, ComponentRemovedHandler);
        }
Esempio n. 17
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            Stage.ZIndex = ZIndex;
            Stage.Matrix = Matrix;
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        private void StartSlot(object[] parameters)
        {
            Component component = parameters[0] as Component;

            if (null == component)
            {
                return;
            }

            Group container = component.Parent as Group;

            if (null == container)
            {
                return;
            }

            if (!_dict.ContainsKey(container))
            {
                _dict[container] = 0;
#if DEBUG
                //Debug.Log("container.AutoLayout: " + container.AutoLayout);

                if (DebugMode)
                {
                    Debug.Log(string.Format(@"Setting AutoLayout to {0} on {1}", container.AutoLayout, container));
                }
#endif
                container.AutoLayout  = false; // turn AutoLayout OFF
                container.ForceLayout = true;
            }

            _dict[container]++;
        }
Esempio n. 20
0
        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);
            }
        }
Esempio n. 21
0
        private void MouseDownHandler(Event e)
        {
            MouseEvent me = (MouseEvent)e;

            Component c = me.Target as Component;

            if (null == c)
            {
                return;
            }

            var targetComponent = (DisplayListMember)me.Target;

            var popup = _popups.Find(delegate(DisplayObject comp)
            {
                IChildList list = comp as IChildList;
                if (null != list)
                {
                    return(list.Contains(targetComponent, true));
                }

                return(false);
            });

            if (null != popup && _popups.IndexOf(popup) != -1)
            {
                var descriptor = _descriptors[popup];
                descriptor.Stage.BringChildToFront(descriptor.PopupRoot);

                //if (descriptor.Stage == _stage) // bring to front only popup manager stage children
                //    _stage.BringToFront(descriptor.PopupRoot);
            }
        }
Esempio n. 22
0
 /// <summary>
 /// Unregisters rollover component
 /// </summary>
 /// <param name="component"></param>
 public void UnregisterRollOverComponent(Component component)
 {
     if (_rollOveredComponents.ContainsKey(component))
     {
         _rollOveredComponents.Remove(component);
     }
 }
Esempio n. 23
0
    public string Trigger = MouseEvent.ROLL_OUT; // default

    // fires after the GUI component is instantiated
    void ComponentInstantiated(Component component)
    {
        //Slider slider = (Slider) component; // you can do a cast here
        component.AddEventListener(Trigger, delegate(Event e)
        {
            Factory.Play(e.Target);
        }, EventPhase.Target);
    }
Esempio n. 24
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            TextArea textField = (TextArea)component;
            textField.Text = Text;
            textField.Optimized = Optimized;
        }
Esempio n. 25
0
    public override void Apply(Component component)
    {
        base.Apply(component);

        ExampleControl2 exampleControl = (ExampleControl2)component;
        exampleControl.LabelWidth = LabelWidth;
        exampleControl.SendMode = SimulateSending;
    }
Esempio n. 26
0
    public string Trigger = MouseEvent.ROLL_OVER; // default

    // fires after the GUI component is instantiated
    void ComponentInstantiated(Component component)
    {
        //Slider slider = (Slider) component; // you can do a cast here
        component.AddEventListener(Trigger, delegate(Event e)
        {
            Factory.Play(e.Target);
        }, EventPhase.Target);
    }
Esempio n. 27
0
    public override void Apply(Component component)
    {
        base.Apply(component);

        ExampleControl exampleControl = (ExampleControl)component;
        exampleControl.Text = Text;
        exampleControl.ButtonText = ButtonText;
    }
Esempio n. 28
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            CheckBox checkBox = (CheckBox)component;
            checkBox.Selected = Selected;
            checkBox.Text = Text;
        }
Esempio n. 29
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            Label label = (Label)component;
            label.Text = Text;
            label.Multiline = Multiline;
        }
Esempio n. 30
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            var scroller = (Scroller)component;
            scroller.SetStyle("horizontalScrollPolicy", HorizontalScrollPolicy);
            scroller.SetStyle("verticalScrollPolicy", VerticalScrollPolicy);
        }
Esempio n. 31
0
    public override void Apply(Component component)
    {
        base.Apply(component);

        ExampleControl exampleControl = (ExampleControl)component;

        exampleControl.Text       = Text;
        exampleControl.ButtonText = ButtonText;
    }
Esempio n. 32
0
    public override void Apply(Component component)
    {
        base.Apply(component);

        ExampleControl2 exampleControl = (ExampleControl2)component;

        exampleControl.LabelWidth = LabelWidth;
        exampleControl.SendMode   = SimulateSending;
    }
Esempio n. 33
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            VSlider slider = (VSlider)component;
            slider.Minimum = Minimum;
            slider.Maximum = Maximum;
            slider.Value = Value;
        }
Esempio n. 34
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            var scroller = (Scroller)component;

            scroller.SetStyle("horizontalScrollPolicy", HorizontalScrollPolicy);
            scroller.SetStyle("verticalScrollPolicy", VerticalScrollPolicy);
        }
Esempio n. 35
0
        /// <summary>
        /// Populates the already instantiated container with children specified by component adapters
        /// </summary>
        /// <param name="thisComponent"></param>
        /// <param name="targetContainer"></param>
        /// <param name="componentAdapters"></param>
        /// <param name="assignToDescriptor"></param>
        /// <param name="muteEvents"></param>
        /// <param name="removeAllChildren"></param>
        public static void PopulateContainer(Component thisComponent, Group targetContainer, ComponentAdapter[] componentAdapters, bool assignToDescriptor, bool muteEvents, bool removeAllChildren)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log(string.Format(@"PopulateContainer: {0};
Child adapters: 
{1}", targetContainer, DescribeAdapterList(new List <ComponentAdapter>(componentAdapters))));
            }
#endif

            if (null == targetContainer && null == thisComponent)
            {
                return;
            }

            var list = thisComponent as IContentChildList; // Group, Panel, Window etc.

            if (removeAllChildren)
            {
                if (null != targetContainer)
                {
                    targetContainer.RemoveAllContentChildren();
                }
                else
                {
                    if (list != null)
                    {
                        list.RemoveAllContentChildren();
                    }
                }
            }

            foreach (ComponentAdapter adapter in componentAdapters)
            {
                if (null == adapter || !adapter.enabled || !adapter.gameObject.activeInHierarchy) // no descriptors on this node or descriptor disabled. skip
                {
                    continue;                                                                     // 20130426
                }
                Component component = adapter.Produce(!adapter.FactoryMode, assignToDescriptor);
                if (null != component)
                {
                    if (null != targetContainer)
                    {
                        targetContainer.AddContentChild(component);
                    }
                    else
                    {
                        if (list != null)
                        {
                            list.AddContentChild(component);
                        }
                    }
                }
            }
        }
Esempio n. 36
0
        /**
         *  Initiates a drag and drop operation.
         *
         *  Param: dragInitiator IUIComponent that specifies the component initiating
         *  the drag.
         *
         *  Param: dragSource DragSource object that contains the data
         *  being dragged.
         *
         *  Param: mouseEvent The MouseEvent that contains the mouse information
         *  for the start of the drag.
         *
         *  Param: dragImage The image to drag. This argument is optional.
         *  If omitted, a standard drag rectangle is used during the drag and
         *  drop operation. If you specify an image, you must explicitly set a
         *  height and width of the image or else it will not appear.
         *
         *  Param: xOffset Number that specifies the x offset, in pixels, for the
         *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
         *  is shown at the upper-left corner of the drag initiator. The offset is expressed
         *  in pixels from the left edge of the drag proxy to the left edge of the drag
         *  initiator, and is usually a negative number.
         *
         *  Param: yOffset Number that specifies the y offset, in pixels, for the
         *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
         *  is shown at the upper-left corner of the drag initiator. The offset is expressed
         *  in pixels from the top edge of the drag proxy to the top edge of the drag
         *  initiator, and is usually a negative number.
         *
         *  Param: imageAlpha Number that specifies the alpha value used for the
         *  drag image. This argument is optional. If omitted, the default alpha
         *  value is 0.5. A value of 0.0 indicates that the image is transparent;
         *  a value of 1.0 indicates it is fully opaque.
         *
         *  Param: allowMove Indicates if a drop target is allowed to move the dragged data.
         *
         */

        /// <summary>
        /// Starts a drag and drop operation
        /// </summary>
        /// <param name="dragInitiator"></param>
        /// <param name="dragSource"></param>
        /// <param name="mouseEvent"></param>
        /// <param name="dragImage"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="imageAlpha"></param>
        /// <param name="allowMove"></param>
        /// <param name="options"></param>
        public static void DoDrag(Component dragInitiator, DragSource dragSource, MouseEvent mouseEvent, Component dragImage, float xOffset, float yOffset, float imageAlpha, bool allowMove, params DragOption[] options)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("DragDropManager.DoDrag: " + dragInitiator);
            }
#endif
            _dragInitiator = dragInitiator;
            _dragSource    = dragSource;
            _mouseEvent    = mouseEvent;
            _dragImage     = dragImage;
            _imageAlpha    = imageAlpha;
            _allowMove     = allowMove;

            ApplyOptions(options);

            /**
             * 20130307
             * Found some glitches regarding the starting the new drag operation while the previous one hasn't been finished yet
             * Since I was dealing with a single proxy instance since, some of the old (custom) proxies were stale, e.g. never removed when the tween finished
             * Now I added the line to a tween callback which destroys the animation target
             * */
            _proxy = dragImage ?? new DragProxy();

            DragProxy.Proxify(_proxy);

            _xOffset = xOffset;
            _yOffset = yOffset;

            DragDropStage.Instance.AddChild(_proxy); // TODO: cleanup after the drag operaion

            var dragInitiatorGlobalBounds = dragInitiator.Parent.LocalToGlobal(dragInitiator.Position);

            _proxy.X = dragInitiatorGlobalBounds.X;
            _proxy.Y = dragInitiatorGlobalBounds.Y;
            //_proxy.Bounds = (Rectangle)dragInitiator.Transform.GlobalBounds.Clone();
            _proxy.Visible = _proxyShouldBeVisible;
            _proxy.Alpha   = imageAlpha;

            Offset = dragInitiatorGlobalBounds.Subtract(mouseEvent.GlobalPosition);

            if (_feedbackShouldBeVisible)
            {
                ChangeCursorTo(CursorType.RejectDrop);
            }

            /**
             * Subscribe to drag and mouse up events on system manager
             * */
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, OnMouseUp);

            //DragEvent dragStartEvent = BuildEvent(DragEvent.DRAG_START);
            //_dragInitiator.DispatchEvent(dragStartEvent);
        }
Esempio n. 37
0
        /// <summary>
        /// Returns the target based on the folowing logic:
        /// If target is supplied - as object - return it
        /// If target is supplied - as string - find a target (object) and return it
        /// If target is not supplied - get the parent object
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        protected object GetTarget(object target, Component parent)
        {
            if (target == null)
                return parent;

            if (target is string)
                return new MemberProxy(parent, (string)target).GetValue();

            return target;
        }
Esempio n. 38
0
        /**
         * 
         * Param: parent The document level context for this override.
         * Param: target The component level context for this override.
         */
        /// <summary>
        /// Gets the targeted member based on the folowing logic:
        /// If target is supplied - as object - get its member using name
        /// If target is supplied - as string - find a target (object) and then get its member using name
        /// If target is not supplied - get the member on parent using name
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected MemberProxy GetMember(object target, Component parent, string name)
        {
            if (target == null)
                return new MemberProxy(parent, name);

            if (target is string)
                target = new MemberProxy(parent, (string) target).GetValue();

            return new MemberProxy(target, name);
        }
Esempio n. 39
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            VScrollBar scrollBar = (VScrollBar)component;
            scrollBar.Minimum = Minimum;
            scrollBar.Maximum = Maximum;
            scrollBar.Value = Value;
            scrollBar.PageSize = PageSize;
        }
Esempio n. 40
0
        /// <summary>
        /// Initializes event handlers if mappings on component enabled
        /// </summary>
        /// <param name="component">The component dispatching events</param>
        internal void InitEvents(Component component)
        {
            if (!EventMap.Enabled)
            {
                return;
            }

            // map descriptor is enabled, so process event handlers!
            EventMappingDescriptor.ProcessListeners(this, component, true);
        }
Esempio n. 41
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            TextField textField = (TextField)component;
            textField.Text = Text;
            textField.PasswordMode = PasswordMode;
            textField.PasswordCharMask = PasswordCharMask.Length > 0 ? PasswordCharMask[0] : '*';
            textField.Optimized = Optimized;
        }
Esempio n. 42
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        public override void Apply(Component parent)
        {
            //Debug.Log("SetStyle->Apply: Name: " + Name + "; Value: " + Value);

            _appliedTarget = GetTarget(Target, parent);

            IStyleClient obj = ((IStyleClient)_appliedTarget);

            if (!Applied)
            {
                /**
                 * IMPORTANT: obj.StyleDeclaration.GetStyle(Name) returns UNDEFINED
                 * UNDEFINED is a flag indicating that the style ISN'T DEFINED in the style declaration (overrides)
                 * That's because the null is a valid style value, so it cannot return null because we couldn't be
                 * able to differentiate between the null (value) or undefined style
                 * */
                _wasInline = null != obj.StyleDeclaration &&
                             //StyleDeclaration.UNDEFINED != obj.StyleDeclaration.GetStyle(Name);
                             !StyleDeclaration.UNDEFINED.Equals(obj.StyleDeclaration.GetStyle(Name));

                // if it is the inline style remember its value, null otherwise (it doesn't metter, we won't use the old value in "Remove")
                _oldValue = _wasInline ? obj.GetStyle(Name) : null;
            }

            _relatedProps = GetRelatedProperties(_appliedTarget, Name);
            if (_relatedProps.Count > 0)
            {
                if (null == _oldRelatedValues)
                {
                    _oldRelatedValues = new List <object>();                    // lazily
                }
                else
                {
                    _oldRelatedValues.Clear();
                }

                foreach (string property in _relatedProps)
                {
                    _oldRelatedValues.Add(new MemberProxy(_appliedTarget, property).GetValue());
                }
            }

            // Set new value
            if (null == Value)
            {
                obj.ClearStyle(Name);         // (??? why setting it to UNDEFINED? Does null for SetStyle object mean "clear property?")
            }
            else
            {
                obj.SetStyle(Name, Value);
            }

            Applied = true;
        }
Esempio n. 43
0
    protected HGroup WrapHBox(Component parent, params DisplayListMember[] children)
    {
        HGroup wrapper = new HGroup { HorizontalAlign = HorizontalAlign.Left, VerticalAlign = VerticalAlign.Middle };
        parent.AddChild(wrapper);

        foreach (DisplayListMember child in children)
        {
            wrapper.AddChild(child);
        }
        return wrapper;
    }
Esempio n. 44
0
    protected VGroup WrapVBox(Component parent, params DisplayListMember[] children)
    {
        VGroup wrapper = new VGroup { HorizontalAlign = HorizontalAlign.Center, Gap = 10 };
        parent.AddChild(wrapper);

        foreach (DisplayListMember child in children)
        {
            wrapper.AddChild(child);
        }
        return wrapper;
    }
Esempio n. 45
0
        private static void OnMouseUp(Event e)
        {
            SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_UP, OnMouseUp);
            SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            ChangeCursorTo(CursorType.Normal);

            MouseEvent me = (MouseEvent)e;

            bool dropAccepted = null != _acceptedTarget;

            //_proxy.Visible = false;
            _overlay.Visible = false;

            var newBounds = dropAccepted
                ? Rectangle.FromPositionAndSize(me.GlobalPosition, new Point(0, 0))
                : _dragInitiator.Transform.GlobalBounds;

            DragProxyTween tween = new DragProxyTween(_proxy, _proxy.Bounds, newBounds)
            {
                Callback = delegate(IAnimation anim)
                {
                    //Debug.Log("*** Finished");
                    Component proxy = (Component)anim.Target;
                    proxy.Visible = false;
                    DragDropStage.Instance.RemoveChild(proxy);
                }
            };

            tween.Play(_proxy);

            RemoveCursor();

            if (null != _acceptedTarget)
            {
#if DEBUG
                if (DebugMode)
                {
                    Debug.Log("DragEvent.DRAG_DROP: " + _acceptedTarget.GetType().Name);
                }
#endif
                DragEvent de = BuildEvent(DragEvent.DRAG_DROP);
                _acceptedTarget.DispatchEvent(de);
            }

            DragEvent dragCompleteEvent = BuildEvent(DragEvent.DRAG_COMPLETE);
            _dragInitiator.DispatchEvent(dragCompleteEvent);

            _acceptedTarget        = null;
            _lastDragOverComponent = null;

            _dragging          = false;
            _dragInitiator     = null;
            _dragOverComponent = null;
        }
Esempio n. 46
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            Button button = (Button)component;
            button.Text = Text;
            button.ToggleMode = ToggleMode;
            button.Selected = Selected;
            button.Icon = Icon;
            button.HighlightOnFocus = HighlightOnFocus;
        }
Esempio n. 47
0
        void InitializeComponent(Component component)
        // ReSharper restore UnusedMember.Local
        {
            if (!enabled)
            {
                //Debug.Log("StringDataProvider not enabled");
                return;
            }

            Apply(component);
        }
Esempio n. 48
0
        void InitializeComponent(Component component)
        // ReSharper restore UnusedMember.Local
        {
            if (!enabled)
            {
                //Debug.Log("StringDataProvider not enabled");
                return;
            }

            Apply(component);
        }
Esempio n. 49
0
        /// <summary>
        /// Gets the appropriate form adapter for the supplied component
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        public static IFormAdapter GetAdapter(Component component)
        {
            Type type = component.GetType();

            if (!Adapters.ContainsKey(type))
            {
                Debug.LogWarning("Unknown form adapter for: " + component.GetType());
                return(null);
            }
            return(Adapters[type]);
        }
Esempio n. 50
0
        public override void Apply(Component component)
        {
            base.Apply(component);

            NumericStepper numericStepper = (NumericStepper)component;
            numericStepper.Minimum = Minimum;
            numericStepper.Maximum = Maximum;
            numericStepper.Value = Value;
            numericStepper.Mode = Mode;
            numericStepper.Step = Step;
        }
Esempio n. 51
0
    public override void Apply(Component component)
    {
        base.Apply(component);

        Login login = (Login)component;
        login.LabelWidth = LabelWidth;
        login.Username = Username;
        login.Password = Password;
        login.UsernameLabel = UsernameLabel;
        login.PasswordLabel = PasswordLabel;
        login.SubmitText = SubmitText;
        login.SendMode = SendMode;
    }
Esempio n. 52
0
    // fires after the GUI component is instantiated
    void ComponentInstantiated(Component component)
    {
        //Slider slider = (Slider) component; // you can do a cast here
        component.AddEventListener(Trigger, delegate(Event e)
        {
            ExpandRightDownAlpha tween = new ExpandRightDownAlpha { Bounds = Bounds };
            tween.Play(e.Target);
            e.CancelAndStopPropagation();

            //Factory.Blueprint = tween;
            //Factory.Play(e.Target);
        }, EventPhase.Capture | EventPhase.Target);
    }
Esempio n. 53
0
        public void Initialize(InvalidationManagerClient component)
        {
            if (_initialized)
                return;

            _initialized = true;
            _component = (Component) component;

            // subscribe to TARGET PHASE component events
            _component.AddEventListener(LoadingEvent.START, StartHandler, EventPhase.Target);
            _component.AddEventListener(LoadingEvent.PROGRESS, ProgressHandler, EventPhase.Target);
            _component.AddEventListener(LoadingEvent.END, EndHandler, EventPhase.Target);
            _component.AddEventListener(LoadingEvent.ERROR, ErrorHandler, EventPhase.Target);

            //if (null == AnimationId)
            //    AnimationId = AnimationId;
        }
        public void Initialize(InvalidationManagerClient component)
        {
            if (_initialized)
                return;

            _initialized = true;

            _component = (Component) component;

            // subscribe to CAPTURE PHASE component events

            // listening for mouse move over the component border
            _component.AddEventListener(MouseEvent.MOUSE_OVER, MouseOverHandler, EventPhase.Capture | EventPhase.Target); // NOTE: Target phase must be present because of the simple components
            
            // listening for mouse out to remove the overlay
            _component.AddEventListener(MouseEvent.MOUSE_OUT, MouseOutHandler, EventPhase.Capture | EventPhase.Target);
        }
Esempio n. 55
0
        public void Initialize(InvalidationManagerClient component)
        {
            if (_initialized)
                return;

            _initialized = true;

            _component = (Component) component;

            _component.OptimizeMeasureCalls = false;

            // subscribe to CAPTURE PHASE component events
            // listening for mouse move over the component border
            //_component.AddEventListener(MouseEvent.MOUSE_MOVE, IdleMouseMoveHandler, EventPhase.Capture | EventPhase.Target, EventPriority.CURSOR_MANAGEMENT); // NOTE: Target phase must be present because of the simple components
            _component.AddEventListener(MouseEvent.ROLL_OVER, IdleRollOverHandler, EventPhase.Capture | EventPhase.Target); //, EventPriority.CURSOR_MANAGEMENT); // NOTE: Target phase must be present because of the simple components
            _component.AddEventListener(MouseEvent.ROLL_OUT, IdleRollOutHandler, EventPhase.Capture | EventPhase.Target); //, EventPriority.CURSOR_MANAGEMENT); // NOTE: Target phase must be present because of the simple components

            //// listening for mouse click just to cancel it if being over the border
            //// TODO: implement priority and use the highest one
            //_component.AddEventListener(MouseEvent.CLICK, ClickHandler, EventPhase.Capture | EventPhase.Target);
        }
Esempio n. 56
0
        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);
        }
Esempio n. 57
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parent"></param>
		public override void Remove(Component parent)
		{
			//Debug.Log("SetStyle->Remove: Name: " + Name + "; Value: " + Value);

		    var obj = (IStyleClient) _appliedTarget;

            // ovo je fakat čudno, njihova logika ne radi (ili ima bug)
            // što znači "clearate" style - maknut ga iz style deklaracije ili ga staviti unutra s vrijednosti "undefined"???

            if (_wasInline)
            {
                // Restore the old value
                /*if (_oldValue == null)
                    obj.ClearStyle(Name);
                else*/
                obj.SetStyle(Name, _oldValue); // apply whatever the old value is
            }
            else
            {
                obj.ClearStyle(Name);
            }

            //obj.SetStyle(Name, _oldValue);

            //_relatedProps = GetRelatedProperties(_appliedTarget, _pseudonym);
            if (null != _relatedProps)
            {
                for (var i = 0; i < _relatedProps.Count; i++)
                {
                    _mp = new MemberProxy(_appliedTarget, _relatedProps[i]);
                    _mp.SetValue(_oldRelatedValues[i]);
                }
            }

			Applied = false;
			_appliedTarget = null;
		}
Esempio n. 58
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parent"></param>
		public override void Apply(Component parent)
		{
            //Debug.Log("SetStyle->Apply: Name: " + Name + "; Value: " + Value);

			_appliedTarget = GetTarget(Target, parent);
			
            IStyleClient obj = ((IStyleClient)_appliedTarget);

			if (!Applied)
			{
                /**
                 * IMPORTANT: obj.StyleDeclaration.GetStyle(Name) returns UNDEFINED
                 * UNDEFINED is a flag indicating that the style ISN'T DEFINED in the style declaration (overrides)
                 * That's because the null is a valid style value, so it cannot return null because we couldn't be
                 * able to differentiate between the null (value) or undefined style
                 * */
                _wasInline = null != obj.StyleDeclaration && 
                    //StyleDeclaration.UNDEFINED != obj.StyleDeclaration.GetStyle(Name);
                    !StyleDeclaration.UNDEFINED.Equals(obj.StyleDeclaration.GetStyle(Name));

                // if it is the inline style remember its value, null otherwise (it doesn't metter, we won't use the old value in "Remove")
                _oldValue = _wasInline ? obj.GetStyle(Name) : null;
			}

			_relatedProps = GetRelatedProperties(_appliedTarget, Name);
			if (_relatedProps.Count > 0)
			{
				if (null == _oldRelatedValues)
					_oldRelatedValues = new List<object>(); // lazily
				else
					_oldRelatedValues.Clear();

				foreach (string property in _relatedProps) {
					_oldRelatedValues.Add(new MemberProxy(_appliedTarget, property).GetValue());
				}
			}

            // Set new value
		    if (null == Value)
		    {
		        obj.ClearStyle(Name); // (??? why setting it to UNDEFINED? Does null for SetStyle object mean "clear property?")
		    }
		    else
		    {
		        obj.SetStyle(Name, Value);
		    }

            Applied = true;
		}
Esempio n. 59
0
        private static void OnMouseUp(Event e)
        {
            SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_UP, OnMouseUp);
            SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            ChangeCursorTo(CursorType.Normal);

            MouseEvent me = (MouseEvent) e;

            bool dropAccepted = null != _acceptedTarget;

            //_proxy.Visible = false;
            _overlay.Visible = false;

            var newBounds = dropAccepted
                ? Rectangle.FromPositionAndSize(me.GlobalPosition, new Point(0, 0))
                : _dragInitiator.Transform.GlobalBounds;

            DragProxyTween tween = new DragProxyTween(_proxy, _proxy.Bounds, newBounds)
                                       {
                                           Callback = delegate(IAnimation anim)
                                           {
                                               //Debug.Log("*** Finished");
                                               Component proxy = (Component) anim.Target;
                                               proxy.Visible = false;
                                               DragDropStage.Instance.RemoveChild(proxy);
                                           }
                                       };
            tween.Play(_proxy);

            RemoveCursor();

            if (null != _acceptedTarget)
            {
#if DEBUG
                if (DebugMode)
                    Debug.Log("DragEvent.DRAG_DROP: " + _acceptedTarget.GetType().Name);
#endif
                DragEvent de = BuildEvent(DragEvent.DRAG_DROP);
                _acceptedTarget.DispatchEvent(de);
            }

            DragEvent dragCompleteEvent = BuildEvent(DragEvent.DRAG_COMPLETE);
            _dragInitiator.DispatchEvent(dragCompleteEvent);

            _acceptedTarget = null;
            _lastDragOverComponent = null;

            _dragging = false;
            _dragInitiator = null;
            _dragOverComponent = null;
        }
Esempio n. 60
0
        private static void OnMouseDrag(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("DragDropManager.OnMouseDrag: " + _dragInitiator);
#endif

            MouseEvent input = (MouseEvent)e;

            DragEvent de;

            /**
             * 1) Check for drag start
             * */
            if (!_dragging) // if not yet dragging
            {
                _dragOverComponent = null;
                _dragging = true; // we're dragging now
                if (null != _dragInitiator) // if dragging something
                {
#if DEBUG
                    if (DebugMode)
                        Debug.Log("DragEvent.DRAG_START: " + _dragInitiator);
#endif
                    de = BuildEvent(DragEvent.DRAG_START);
                    _dragInitiator.DispatchEvent(de);
                }

                return;
            }

            _dragOverComponent = CoordinateProcessor.GetComponentUnderCoordinatesOnAllStages(input.GlobalPosition, delegate(DisplayListMember dlm)
            {
                Component component = dlm as Component;
                return null != component && component.MouseEnabled; // && !(component is Stage); // commented 20130307
            }, true, true) as Component; // stopOnDisabled, stopOnInvisible

            bool isDragEnter = null != _dragOverComponent && 
                               _dragOverComponent != _lastDragOverComponent &&
                               _dragInitiator != null &&
                               _dragInitiator != _dragOverComponent;

            /**
             * 2) Check for drag enter
             * */
            if (isDragEnter)
            {
                // nullify accepted target, and allow the user to react on DRAG_ENTER event (to call AcceptDragDrop)
                _acceptedTarget = null;
                _action = Action.None;
                //Debug.Log("DragEvent.DRAG_ENTER: " + _dragOverComponent.GetType().Name);
#if DEBUG
                if (DebugMode)
                    Debug.Log("DragEvent.DRAG_ENTER: " + _dragOverComponent.GetType().Name);
#endif
                // dispatch DragEvent.DRAG_EXIT on _lastDragOverComponent
                if (null != _lastDragOverComponent)
                {
                    de = BuildEvent(DragEvent.DRAG_EXIT);
                    _lastDragOverComponent.DispatchEvent(de);
                }

                // dispatch DragEvent.DRAG_ENTER on _dragOverComponent
                de = BuildEvent(DragEvent.DRAG_ENTER);
                _dragOverComponent.DispatchEvent(de);

                // set _lastDragOverComponent
                _lastDragOverComponent = _dragOverComponent;
            }

            /**
             * 3) Handle feedback to the user
             * By this point, if the user was subscribed to DragEvent.DRAG_ENTER, he could have react with AcceptDragDrop() and (optionally) ShowFeedback()
             * */

            // check if the user has accepted drag and drop
            if (null != _acceptedTarget)
            {
                // if drop is accepted, show overlay, and show CursorType.AcceptDrop cursor
                Overlay.Visible = _overlayShouldBeVisible;
                //_overlay.SetBounds(_acceptedTarget.GlobalBounds); // fix? .MoveBy(new Point(-1, 0)),
                //Overlay.Bounds = (Rectangle)_acceptedTarget.Transform.GlobalBounds.Clone(); // consider cloning bounds 20120415
                
                if (_feedbackShouldBeVisible)
                {
                    if (Action.None == _action)
                        ChangeCursorTo(CursorType.AcceptDrop);
                    else
                        ProcessFeedback(_action);
                }
                else
                    ChangeCursorTo(CursorType.Normal);
            }
            else
            {
                // if drop is rejected (meaning not accepted by developer), hide overlay, and show CursorType.RejectDrop cursor
                Overlay.Visible = false;
                if (_feedbackShouldBeVisible)
                    ChangeCursorTo(CursorType.RejectDrop);
                else
                    ChangeCursorTo(CursorType.Normal);
            }

            /**
             * 4) Move proxy
             * */
            _proxy.X = input.GlobalPosition.X + Offset.X;
            _proxy.Y = input.GlobalPosition.Y + Offset.Y;
            _proxy.ValidateNow();
        }