Esempio n. 1
0
        void OnEnable() {
            TouchInputUpdater.EventTouchBegan.AddListener( OnTouchBegan );
            TouchInputUpdater.EventTouchMoved.AddListener( OnTouchMoved );
            TouchInputUpdater.EventTouchStationary.AddListener( OnTouchStationary );
            TouchInputUpdater.EventTouchEnd.AddListener( OnTouchEnd );

            if ( EnableGestureSwipe == true ) {
                cachedSwipeComponent = GetComponent<GestureSwipe>();

                AddGestureEvent( cachedSwipeComponent );
                
            }
            if ( EnableGestureDrag == true ) {
                cachedDragComponent = GetComponent<GestureDrag>();
                AddGestureEvent( cachedDragComponent );
            }            

        }
Esempio n. 2
0
        public CircuitEditor()
        {
            DrawingArea = new DrawingArea();

            Offset = DisplayOffset = new Vector2d(0, 0);

            DrawingArea.Drawn += CircuitEditor_Drawn;

            DrawingArea.AddEvents((int)EventMask.PointerMotionMask);
            DrawingArea.AddEvents((int)EventMask.ScrollMask);

            DragGesture = new GestureDrag(DrawingArea);

            // Sets middle click as the pan button.
            // This should be configurable later!
            DragGesture.Button = 2;

            DragGesture.DragBegin  += DragGesture_DragBegin;
            DragGesture.DragEnd    += DragGesture_DragEnd;
            DragGesture.DragUpdate += DragGesture_DragUpdate;

            DragGestureCreate = new GestureDrag(DrawingArea);
            // Sets middle click as the wire creation button.
            // This should be configurable later!
            DragGestureCreate.Button      = 1;
            DragGestureCreate.DragBegin  += DragGestureCreate_DragBegin;
            DragGestureCreate.DragUpdate += DragGestureCreate_DragUpdate;
            DragGestureCreate.DragEnd    += DragGestureCreate_DragEnd;

            DrawingArea.MotionNotifyEvent += DrawingArea_MotionNotifyEvent;

            DrawingArea.ScrollEvent += CircuitEditor_ScrollEvent;

            DrawingArea.QueryTooltip += CircuitEditor_QueryTooltip;

            DrawingArea.HasTooltip = true;

            DrawingArea.CanFocus     = true;
            DrawingArea.FocusOnClick = true;

            DrawingArea.AddEvents((int)EventMask.KeyPressMask);
            DrawingArea.KeyPressEvent += DrawingArea_KeyPressEvent;

            // So that we can grab focus. Without focus we won't get any KeyPressEvents...
            // FIXME: We want to figure out how to do this in a good way where the user doesn't really
            // need to know where the current focus is for stuff like ctrl+z to work.
            DrawingArea.ParentSet        += DrawingArea_ParentSet;
            DrawingArea.ButtonPressEvent += DrawingArea_ButtonPressEvent;

            var wiresArr = new Wire[]
            {
                /*new Wire(new Vector2i(3, 3), 10, Direction.Vertical),
                 * new Wire(new Vector2i(3, 13), 10, Direction.Horizontal),
                 * new Wire(new Vector2i(0, 3), 3, Direction.Horizontal),
                 * new Wire(new Vector2i(3, 0), 3, Direction.Vertical),
                 * new Wire(new Vector2i(0, 13), 3, Direction.Horizontal),
                 * new Wire(new Vector2i(13, 12), -9, Direction.Vertical),
                 * new Wire(new Vector2i(4, 3), 9, Direction.Horizontal),
                 * new Wire(new Vector2i(13, 3), 4, Direction.Horizontal),*/
            };

            var gates = new Gates();

            var wires = new Wires(gates, wiresArr);

            var labels = new TextLabels(new TextLabel[]
            {
                new TextLabel(new Vector2d(0, 0), "This is some cool text.", 14),
                new TextLabel(new Vector2d(40, 10), "Even more cool text :O", 24),
                new TextLabel(new Vector2d(40, 40), "Woahhh :OOOoooO", 72),
            });

            Scene = new Scene(wires, gates, labels);
        }
Esempio n. 3
0
        public CircuitEditor()
        {
            DrawingArea = new DrawingArea();

            Offset = DisplayOffset = new Vector2d(0, 0);

            DrawingArea.Drawn += CircuitEditor_Drawn;

            DrawingArea.AddEvents((int)EventMask.PointerMotionMask);
            DrawingArea.AddEvents((int)EventMask.ScrollMask);

            DragGesture = new GestureDrag(DrawingArea);

            // Sets middle click as the pan button.
            // This should be configurable later!
            DragGesture.Button = 2;

            DragGesture.DragBegin  += DragGesture_DragBegin;
            DragGesture.DragEnd    += DragGesture_DragEnd;
            DragGesture.DragUpdate += DragGesture_DragUpdate;

            DragGestureCreate = new GestureDrag(DrawingArea);
            // Sets middle click as the wire creation button.
            // This should be configurable later!
            DragGestureCreate.Button      = 1;
            DragGestureCreate.DragBegin  += DragGestureCreate_DragBegin;
            DragGestureCreate.DragUpdate += DragGestureCreate_DragUpdate;
            DragGestureCreate.DragEnd    += DragGestureCreate_DragEnd;


            DrawingArea.ScrollEvent += CircuitEditor_ScrollEvent;

            DrawingArea.QueryTooltip += CircuitEditor_QueryTooltip;

            DrawingArea.HasTooltip = true;

            DrawingArea.CanFocus     = true;
            DrawingArea.FocusOnClick = true;

            DrawingArea.AddEvents((int)EventMask.KeyPressMask);
            DrawingArea.KeyPressEvent += DrawingArea_KeyPressEvent;

            // So that we can grab focus. Without focus we won't get any KeyPressEvents...
            // FIXME: We want to figure out how to do this in a good way where the user doesn't really
            // need to know where the current focus is for stuff like ctrl+z to work.
            DrawingArea.ParentSet        += DrawingArea_ParentSet;
            DrawingArea.ButtonPressEvent += DrawingArea_ButtonPressEvent;

            var powered = new Wire[]
            {
                new Wire(new Vector2i(3, 3), 10, Direction.Vertical),
                new Wire(new Vector2i(3, 13), 10, Direction.Horizontal),
                new Wire(new Vector2i(0, 3), 3, Direction.Horizontal),
                new Wire(new Vector2i(3, 0), 3, Direction.Vertical),
                new Wire(new Vector2i(0, 13), 3, Direction.Horizontal),
            };
            var unpowered = new Wire[]
            {
                new Wire(new Vector2i(13, 12), -9, Direction.Vertical),
                new Wire(new Vector2i(4, 3), 9, Direction.Horizontal),
                new Wire(new Vector2i(13, 3), 4, Direction.Horizontal),
            };

            Wires = new Wires(
                powered,
                unpowered,
                // For wires to connect their start/end point must be at the same location
                // A wire that start/ends in the middle of another wires doesn't connect
                // (We might want to change that but it becomes more complicated then...)
                Wires.FindConnectionPoints(powered).ToArray(),
                Wires.FindConnectionPoints(unpowered).ToArray());

            Gates = new Gates(/*new AndGate[]
                               * {
                               * new AndGate(new Vector2i(2, 2), Orientation.South),
                               * new AndGate(new Vector2i(3, 7), Orientation.East),
                               * new AndGate(new Vector2i(3, 10), Orientation.West),
                               * new AndGate(new Vector2i(5, 3), Orientation.North),
                               * }*/);

            Labels = new TextLabels(new TextLabel[]
            {
                new TextLabel(new Vector2d(0, 0), "This is some cool text.", 14),
                new TextLabel(new Vector2d(40, 10), "Even more cool text :O", 24),
                new TextLabel(new Vector2d(40, 40), "Woahhh :OOOoooO", 72),
            });
        }