protected override void ValidateChild(DisplayObject child)
        {
            _childBounds = child.Transform.Bounds;

            _isClippingGroup = null != _group && _group.ClipAndEnableScrolling;

            _childRenderingPosition = _isClippingGroup ?
                                    child.Transform.Position : // parent is clipping. Origin is the distance from (0, 0) of the parent
                                    _imc.Transform.RenderingPosition.Add(child.Transform.Position); // add to rendering position

            _childGlobalPosition = _imc.Transform.GlobalPosition.Add(child.Transform.Position);

            _childRenderingRect = new Rect(_childRenderingPosition.X, _childRenderingPosition.Y, _childBounds.Width, _childBounds.Height);
            _childLocalRenderingRect = new Rect(0, 0, _childBounds.Width, _childBounds.Height);

            child.Transform.Apply(_childRenderingPosition, _childGlobalPosition, _childRenderingRect, _childLocalRenderingRect);

            child.Transform.ValidateChildren(); // RECURSION! (skin etc.)
        }
Example #2
0
        /// <summary>
        /// Centers the popup after it is created
        /// </summary>
        /// <param name="popup">The popup to center</param>
        /// <param name="keepCenter">Should the popup manager take care of centering the popup while it's instantiated</param>
        public void CenterPopUp(DisplayObject popup, bool keepCenter)
        {
            if (popup is IInvalidating)
                ((IInvalidating)popup).ValidateNow();
            
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("CenterPopUp");
            }
#endif

            //popup.SetBounds(popup.Bounds.CenterInside(popup.Owner.Bounds));
            
            if (_descriptors.ContainsKey(popup))
            {
                var descriptor = _descriptors[popup];
                
                if (keepCenter != descriptor.KeepCenter)
                    descriptor.KeepCenter = keepCenter;

                //Debug.Log("Stage.Bounds: " + ((Component)popup).Stage.Bounds);
                //Debug.Log("popup.Bounds: " + popup.Bounds);
                var imc = popup as InvalidationManagerClient;
                if (null != imc)
                {
                    var bounds = popup.Bounds.CenterInside(null != descriptor.Owner ? descriptor.Owner.Bounds : descriptor.Stage.Bounds);
                    imc.Move(Mathf.Round(bounds.X), Mathf.Round(bounds.Y));
                }
            }
            else
            {
                throw new Exception("No popup to center");
            }
        }
Example #3
0
 ///<summary>
 /// Invalidates the transform, meaning it has to be validated somehow<br/>
 /// This method has to be implemented by subclass<br/>
 /// The subclass might choose will it update immediatelly or later
 ///</summary>
 protected abstract void InvalidateChild(DisplayObject child);
        internal void DoShowOverlay(DisplayObject target)
        {
            if (null == target)
                return;

            DisplayListMember dlm = target as DisplayListMember;
            // do not analyze anything from this stage
            if (null != dlm && !GuiInspector.IsInspectable(dlm))
                return;

            if (null != _overlay)
            {
                _overlay.Visible = true;
                _overlay.Redraw(target.Transform.GlobalBounds, Bounds, NamingUtil.DisplayListMemberToString((DisplayListMember)target));
            }
            //InspectorDetailsWindow.Instance.Inform();
        }
        internal void Select(DisplayObject target)
        {
            var dlm = target as DisplayListMember;
            // do not analyze anything from this stage
            if (null != dlm && !DesignerOverlay.IsInspectable(dlm))
                return; 
            
            var go = GuiLookup.GetGameObject((Component) target);
            
            if (null != go)
            {
                _selectionOverlay.Visible = true;
                var bounds = target.Transform.GlobalBounds;
                
                /**
                 * 1. Expand around component
                 * */
                bounds = bounds.Expand(PlayModeOverlaySelectionBorderStyle.BorderWidth);

                /**
                 * 2. Constrain with stage bounds
                 * */
                bounds.ConstrainWithin(Rectangle.FromSize(SystemManager.Instance.ScreenSize));

                _selectionOverlay.Redraw(bounds, Bounds, GuiLookup.PathToString(go.transform, " -> "));
                _selectionOverlay.ValidateNow();
            }
        }
 protected virtual bool IsOurFocus(DisplayObject target)
 {
     return target == this;
 }
Example #7
0
 /**
  *  
  *  Capture any mouse down event and listen for a mouse up event
  */  
 private void MouseDownHandler(Event e)
 {
     //var sm = SystemEventDispatcher.Instance;
     var dispatcher = MouseEventDispatcher.Instance;
     dispatcher.AddEventListener(MouseEvent.MOUSE_UP, SystemMouseUpSomewhereHandler, EventPhase.CaptureAndTarget);
     _mouseDownTarget = (DisplayObject) e.Target;
 }
Example #8
0
        /// <summary>
        /// Returns true if popup is displayed
        /// </summary>
        /// <param name="popup">A popup to remove</param>
        public bool HasPopup(DisplayObject popup)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("HasPopup");
            }
#endif

            return _descriptors.ContainsKey(popup);
        }
 protected virtual bool IsOurFocus(DisplayObject target)
 {
     return(target == this);
 }
 ///<summary>
 /// When InvalidationManagerClientTransform is invalidated, we are not updating immediatelly,<br/>
 /// but going throught the invalidation instead<br/>
 /// The ValidateTransform (on target) will be called later and our ValidateChild will be called from there
 ///</summary>
 protected override void InvalidateChild(DisplayObject child)
 {
     //_imc.InvalidateTransform();
     child.Transform.Invalidate();
 }
Example #11
0
        private void ShowOverlay(DisplayObject target)
        {
            if (null == _stage) // could be null on application recompile
                return;

            _stage.DoShowOverlay(target);
        }
 ///<summary>
 /// When DisplayObjectTransform is invalidated, we are updating immediatelly<br/>
 /// There's no invalidation available for DisplayObjects
 ///</summary>
 protected override void InvalidateChild(DisplayObject child)
 {
     ValidateChild(child);
 }
Example #13
0
 ///<summary>
 /// When InvalidationManagerClientTransform is invalidated, we are not updating immediatelly,<br/>
 /// but going throught the invalidation instead<br/>
 /// The ValidateTransform (on target) will be called later and our ValidateChild will be called from there
 ///</summary>
 protected override void InvalidateChild(DisplayObject child)
 {
     //_imc.InvalidateTransform();
     child.Transform.Invalidate();
 }
Example #14
0
 public void CenterPopUp(DisplayObject popup)
 {
     CenterPopUp(popup, false);
 }
Example #15
0
 public PopupDescriptor(DisplayObject owner)
 {
     Owner = owner;
 }
Example #16
0
        internal void MouseWheelOutsideHandler(DisplayObject popup, Point point)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("MouseDownOutsideHandler: " + popup);
            }
#endif
            // dispatch from here
            MouseEvent e = new MouseEvent(MouseEvent.MOUSE_WHEEL_OUTSIDE)
                               {
                                   GlobalPosition = point, Target = popup
                               };
            DispatchEvent(e);

            if (e.Canceled)
                return;

            // dispatch from popup
            e = new MouseEvent(MouseEvent.MOUSE_WHEEL_OUTSIDE)
            {
                GlobalPosition = point
            };
            popup.DispatchEvent(e);

            if (e.Canceled)
                return;

            // check auto remove
            if (_descriptors.ContainsKey(popup) && _descriptors[popup].RemoveOnMouseWheelOutside)
            {
                RemovePopup(popup);
                return;
            }
        }
Example #17
0
 public PopupDescriptor(DisplayObject owner, DisplayListMember overlay)
 {
     Owner = owner;
     Overlay = overlay;
 }
Example #18
0
        /// <summary>
        /// Removes a popup from popup stage
        /// </summary>
        /// <param name="popup">A popup to remove</param>
        public void RemovePopup(DisplayObject popup)
        {
#if TRIAL
            /* HACK CHECK */
            Acme acme = (Acme) Framework.GetComponent<Acme>(true);
            if (null == acme || !acme.gameObject.activeInHierarchy/*active*/ || !acme.enabled)
                return;
#endif

#if DEBUG
            if (DebugMode)
            {
                Debug.Log("RemovePopup");
            }
#endif

            if (!_descriptors.ContainsKey(popup))
                return;

            var descriptor = _descriptors[popup];

            //if (popup.HasFocus)
            //    FocusManager.Instance.Blur();

            if (HasEventListener(CLOSING))
            {
                Event e = new Event(CLOSING, popup, false, true); // cancelable
                DispatchEvent(e);

                if (e.Canceled)
                    return;
            }

            if (IsDefaultPrevented(CLOSING))
                return;

            var stage = descriptor.Stage;

            //Debug.Log(string.Format(@"Removing {0} from {1}", descriptor.PopupRoot, stage));

            // removing children
            //descriptor.PopupRoot.Parent.RemoveChild(descriptor.PopupRoot);
            stage.RemoveChild(descriptor.PopupRoot);

            //Debug.Log("Descriptors remove");
            _descriptors.Remove(popup);

            //FocusManager.Instance.Blur(); // TEMP disabled 2.1.2012.

            _popups.Remove(popup);

            if (descriptor.FocusPreviousOnHide)
            {
                if (_popups.Count > 0) // we have more opened popups
                {
                    DisplayObject lastPopup = _popups[_popups.Count - 1];
                    //Debug.Log("_popups.Count: " + _popups.Count);
                    if (lastPopup is InteractiveComponent)
                    {
                        ((InteractiveComponent)lastPopup).SetFocus();
                        /*lastPopup.Defer(delegate
                        {
                            ((InteractiveComponent)lastPopup).SetFocus();
                        }, 1);*/
                        //FocusManager.Instance.SetFocus((InteractiveComponent)lastPopup);
                    }

                    // TEMP disabled on 2.1.2012. because the overlay popup constantly 
                    // appears and dissapears and takes focus
                    // and raises "ArgumentException: You can only call GUI functions from inside OnGUI."
                    // should enable back when overlay will be in it's top stage, non run by popup manager
                }

                else // this was the only popup
                {
                    if (popup is Dialog)
                    {
                        Dialog dlg = (Dialog)popup;
                        if (null != dlg.Owner)
                        {
                            // if owner is defined, focus the owner
                            InteractiveComponent ic = dlg.Owner as InteractiveComponent;
                            /*if (null != ic)
                                ic.SetFocus();*/

                            if (null != ic)
                            {
                                //((InteractiveComponent)lastPopup).SetFocus();
                                /*ic.Defer(delegate
                                {
                                    //ic.SetFocus();
                                    FocusManager.Instance.SetFocus(ic);
                                }, 1);*/
                                //FocusManager.Instance.SetFocus(ic);
                                ic.SetFocus();
                            }

                        }
                        //else
                        //    FocusManager.Instance.Blur(); // else blur everything // commented 20130331 - because after closing th eallert, the SetFocus te TextField (via the callback) didn't work
                    }
                }
            }

            // disconnect
            if (_descriptors.Count == 0)
            {
                SystemManager.Instance.ResizeSignal.Disconnect(ResizeSlot);
                SystemManager.Instance.MouseDownSignal.Disconnect(MouseDownSlot);
                SystemManager.Instance.MouseWheelSignal.Disconnect(MouseWheelSlot);

                stage.RemoveEventListener(MouseEvent.MOUSE_DOWN, MouseDownHandler);
            }

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

            //_stage.ValidateNow();

            if (HasEventListener(CLOSE))
                DispatchEvent(new Event(CLOSE, popup));

            if (descriptor.Popup != descriptor.PopupRoot)
            {
                // this is a modal popup
                // the removed effect won't play on popup, because PopupRoot is being removed, not the popup
                // we have to handle this case and play the effect here
                Component component = popup as Component;
                if (null != component && component.HasStyle("removedEffect")) {
                    ITweenFactory removeEffect = (ITweenFactory)component.GetStyle("removedEffect");
                    removeEffect.Play(popup);
                }
            }
        }
Example #19
0
 public PopupDescriptor(DisplayObject owner, DisplayListMember overlay, DisplayListMember popupRoot)
 {
     Owner = owner;
     Overlay = overlay;
     PopupRoot = popupRoot;
 }
Example #20
0
        private void SystemMouseUpSomewhereHandler(Event e)
        {
            //Debug.Log("SystemMouseUpSomewhereHandler");
            //var sm = SystemEventDispatcher.Instance;
            var dispatcher = MouseEventDispatcher.Instance;
            dispatcher.RemoveEventListener(MouseEvent.MOUSE_UP, SystemMouseUpSomewhereHandler, EventPhase.CaptureAndTarget);

            //Debug.Log("e.Target: " + e.Target);
            var dlm = (DisplayListMember)e.Target;
            // If we got a mouse down followed by a mouse up on a different target in the skin, 
            // we want to dispatch a click event. 
            if (_mouseDownTarget != e.Target && e is MouseEvent && Contains(dlm))
            {
                MouseEvent mEvent = e as MouseEvent;
                // Convert the mouse coordinates from the target to the TrackBase
                Point mousePoint = new Point(mEvent.LocalPosition.X, mEvent.LocalPosition.Y);
                mousePoint = GlobalToLocal(dlm.LocalToGlobal(mousePoint));

                var me2 = new MouseEvent(MouseEvent.CLICK, mEvent.Bubbles, mEvent.Cancelable)
                {
                    LocalPosition = new Point(mousePoint.X, mousePoint.Y),
                    RelatedObject = null,
                    Control = mEvent.Control,
                    Shift = mEvent.Shift,
                    Alt = mEvent.Alt,
                    ButtonDown = mEvent.ButtonDown,
                    CurrentEvent = mEvent.CurrentEvent
                };
                DispatchEvent(me2);
            }

            _mouseDownTarget = null;
        }
Example #21
0
 /**
  *  
  *  Helper method for the mouseMove and mouseUp handlers to see if 
  *  the mouse is over a "valid" region.  This is used to help determine 
  *  when the dropdown should be closed.
  */ 
 private bool IsTargetOverDropDownOrOpenButton(DisplayObject target)
 {
     if (null != target)
     {
         // check if the target is the openButton or contained within the openButton
         if (OpenButton.Contains(target as DisplayListMember))
             return true;
         if (HitAreaAdditions != null)
         {
             foreach (DisplayObject displayObject in HitAreaAdditions)
             {
                 if (displayObject == target ||
                     ((displayObject is DisplayObjectContainer) && ((DisplayObjectContainer)displayObject).Contains(target as DisplayListMember)))
                     return true;
             }
         }
     
         // check if the target is the dropdown or contained within the dropdown
         var down = DropDown as DisplayObjectContainer;
         if (down != null)
         {
             if (down.Contains((DisplayListMember) target))
                 return true;
         }
         else
         {
             if (target == DropDown)
                 return true;
         }
     }
 
     return false;
 }
Example #22
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);
        }
Example #23
0
 protected override bool IsOurFocus(DisplayObject target)
 {
     return target == TextDisplay;
 }