Ejemplo n.º 1
0
        public override void Run(Window window)
        {
            _background = new Background(window);
            var windowSize = window.ScreenSize;

            _background.Color = Color.White;
            _background.Resize(windowSize.Width, windowSize.Height);
            _background.Show();

            _box1 = new Rectangle(window)
            {
                Color = Color.Yellow
            };
            _box1.Resize(400, 600);
            _box1.Move(160, 160);
            _box1.Show();

            _log = new Label(window);
            _log.Resize(700, 1280 - 780);
            _log.Move(10, 770);
            _log.Show();
            _logEntries = new List <string>();
            Log("Double tap to register additional gestures. Tripple tap to unregister them.");

            _glayer = new GestureLayer(_box1);
            _glayer.Attach(_box1);

            _glayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) => {
                Log("Tap {0},{1}", info.X, info.Y);
            });

            _glayer.SetTapCallback(GestureLayer.GestureType.DoubleTap, GestureLayer.GestureState.End, (info) => {
                Log("DoubleTap {0},{1} {2}", info.X, info.Y, info.FingersCount);
                _glayer.SetLineCallback(GestureLayer.GestureState.End, (line) => {
                    Log("Line {0},{1}-{2},{3}, M:{4},{5}", line.X1, line.Y1, line.X2, line.Y2, line.HorizontalMomentum, line.VerticalMomentum);
                });
                _glayer.SetFlickCallback(GestureLayer.GestureState.End, (flick) => {
                    Log("Flick {0},{1}-{2},{3}, M:{4},{5}", flick.X1, flick.Y1, flick.X2, flick.Y2, flick.HorizontalMomentum, flick.VerticalMomentum);
                });
                _glayer.RotateStep = 3;
                _glayer.SetRotateCallback(GestureLayer.GestureState.Move, (rotate) => {
                    Log("Rotation {0},{1} a:{2:F3} ba:{3:F3}", rotate.X, rotate.Y, rotate.Angle, rotate.BaseAngle);
                });
                _glayer.SetZoomCallback(GestureLayer.GestureState.End, (zoom) => {
                    Log("Zoom {0},{1} r:{2} z:{3:F3}", zoom.X, zoom.Y, zoom.Radius, zoom.Zoom);
                });
                Log("Line, Flick, Rotate, and Zoom callbacks enabled.");
            });

            _glayer.SetTapCallback(GestureLayer.GestureType.TripleTap, GestureLayer.GestureState.End, (info) => {
                Log("TrippleTap {0},{1} {2}", info.X, info.Y, info.FingersCount);
                _glayer.SetLineCallback(GestureLayer.GestureState.End, null);
                _glayer.SetFlickCallback(GestureLayer.GestureState.End, null);
                _glayer.SetRotateCallback(GestureLayer.GestureState.Move, null);
                _glayer.SetZoomCallback(GestureLayer.GestureState.End, null);
                Log("Cleared Line, Flick, Rotate, and Zoom callbacks.");
            });
            // Momentum is not used, it seems that it conflicts with Rotate and Zoom
        }
Ejemplo n.º 2
0
        void Initialize()
        {
            Window window = new Window("ElmSharpApp")
            {
                AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90
            };

            window.BackButtonPressed += (s, e) =>
            {
                Exit();
            };
            window.Show();

            var conformant = new Conformant(window);

            conformant.Show();

            var view = new SKCanvasView(conformant);

            conformant.SetContent(view);
            view.Show();

            view.PaintSurface += OnRender;

            loop            = new AnimatorLoop();
            loop.Processed += (s, e) =>
            {
                view.Invalidate();
            };

            root = new World((int)(1 / loop.FrameTime * 3));

            loop.Start();

            gestureLayer = new GestureLayer(conformant);
            gestureLayer.Attach(view);
            gestureLayer.SetTapCallback(GestureType.Tap, GestureState.Start, data => {
                var args = new TouchEventArgs {
                    X = data.X, Y = data.Y, State = TouchState.Start
                };
                root.DispatchEvent(args);
            });
            gestureLayer.SetTapCallback(GestureType.Tap, GestureState.End, data => {
                var args = new TouchEventArgs {
                    X = data.X, Y = data.Y, State = TouchState.End
                };
                root.DispatchEvent(args);
            });
            gestureLayer.SetTapCallback(GestureType.Tap, GestureState.Abort, data => {
                var args = new TouchEventArgs {
                    X = data.X, Y = data.Y, State = TouchState.Abort
                };
                root.DispatchEvent(args);
            });

            //Drawable.DebugSquare = true;
        }
        protected override void OnAttached()
        {
            Console.WriteLine("Tizen OnAttached()");
            _view = Control ?? Container;

            if (_view == null)
            {
                Console.WriteLine("_view is null. leaving");
                return;
            }

            Console.WriteLine($"_view is {_view}");

            if (Element is ITouchAndPressEffectConsumer touchAndPressEffectConsumer)
            {
                var gestureRecognizer = new GestureLayer(_view);
                gestureRecognizer.Attach(_view);

                Console.WriteLine("Attaching gesture recognizer to _view");

                gestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap,
                                                 GestureLayer.GestureState.Start,
                                                 arg =>
                {
                    touchAndPressEffectConsumer.ConsumeEvent(EventType.Pressing);
                    Console.WriteLine("Tizen: Tap Start");
                });

                gestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap,
                                                 GestureLayer.GestureState.End,
                                                 arg =>
                {
                    touchAndPressEffectConsumer.ConsumeEvent(EventType.Released);
                    Console.WriteLine("Tizen: Tap End");
                });

                gestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap,
                                                 GestureLayer.GestureState.Abort,
                                                 arg =>
                {
                    touchAndPressEffectConsumer.ConsumeEvent(EventType.Cancelled);
                    Console.WriteLine("Tizen: Tap Abort");
                });
            }
            else
            {
                Console.WriteLine("Element is NOT ITouchAndPressEffectConsumer");
            }
        }
Ejemplo n.º 4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Image> args)
        {
            base.OnElementChanged(args);

            if (Control == null)
            {
                return;
            }

            if (GestureRecognizer == null)
            {
                GestureRecognizer = new GestureLayer(Control);
                GestureRecognizer.Attach(Control);
            }

            if (args.NewElement == null)
            {
                GestureRecognizer.ClearCallbacks();
                return;
            }
            else
            {
                Control.Clicked += SendClicked;
            }

            if (!(args.NewElement is ImageButton button))
            {
                return;
            }

            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.Start, x => {
                KeyDown();
            });
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, x => {
                KeyUp();
            });
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.LongTap, GestureLayer.GestureState.End, x => {
                KeyUp();
            });
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.LongTap, GestureLayer.GestureState.Abort, x => {
                KeyUp();
            });
        }
Ejemplo n.º 5
0
        public DrawerBox(EvasObject parent) : base(parent)
        {
            _drawerBox = new EBox(this);
            _drawerBox.SetAlignment(-1.0, -1.0);
            _drawerBox.SetWeight(1.0, 1.0);
            _drawerBox.Show();

            _contentBox = new EBox(this);
            _contentBox.SetAlignment(-1.0, -1.0);
            _contentBox.SetWeight(1.0, 1.0);
            _contentBox.Show();

            _dimArea = new EBox(this)
            {
                BackgroundColor = ThemeConstants.Shell.ColorClass.DefaultDrawerDimBackgroundColor,
                Opacity         = ThemeConstants.Shell.Resources.DefaultDrawerDimOpacity
            };

            _gestureOnDimArea = new GestureLayer(_dimArea);
            _gestureOnDimArea.SetTapCallback(GestureType.Tap, GestureLayer.GestureState.Start, OnTapped);
            _gestureOnDimArea.Attach(_dimArea);

            _splitPane = new Panes(this)
            {
                AlignmentX   = -1,
                AlignmentY   = -1,
                WeightX      = 1,
                WeightY      = 1,
                IsFixed      = true,
                IsHorizontal = false,
            };

            _panel = new Panel(this);
            _panel.SetScrollable(_isGestureEnabled);
            _panel.SetScrollableArea(1.0);
            _panel.Direction = PanelDirection.Left;
            _panel.Toggled  += (object?sender, EventArgs e) =>
            {
                if (_panel.IsOpen)
                {
                    _dimArea.Show();
                }

                Toggled?.Invoke(this, EventArgs.Empty);
            };

            _mainWidget = _contentBox;

            ConfigureLayout();
            SetLayoutCallback(OnLayout);
        }
Ejemplo n.º 6
0
        void Initialize()
        {
            Layout.KeyDown += (s, e) =>
            {
                if (e.KeyName == "Return")
                {
                    if (!_isTexstBlockFocused)
                    {
                        SetFocusOnTextBlock(true);
                        e.Flags |= EvasEventFlag.OnHold;
                    }
                }
            };

            var gesture = new GestureLayer(Layout);

            gesture.Attach(Layout);
            gesture.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (data) => SetFocusOnTextBlock(true));

            Clicked += (s, e) => SetFocusOnTextBlock(true);
        }
Ejemplo n.º 7
0
 void AddTapGesture(EGestureType type)
 {
     _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Start, (data) => { OnGestureStarted(type, data); });
     _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
     _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
 }
Ejemplo n.º 8
0
        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);

            conformant.Show();
            gParent = new Box(window)
            {
                BackgroundColor = Color.Yellow,
                PassEvents      = false,
                PropagateEvents = false,
            };
            conformant.SetContent(gParent);

            Box parent = new Box(gParent)
            {
                AlignmentX      = -1,
                AlignmentY      = -1,
                WeightX         = 1,
                WeightY         = 1,
                BackgroundColor = Color.Green,
                PassEvents      = false,
                PropagateEvents = false,
            };
            Box child = new Box(parent)
            {
                AlignmentX      = -1,
                AlignmentY      = -1,
                WeightX         = 1,
                WeightY         = 1,
                BackgroundColor = Color.Blue,
                PassEvents      = false,
                PropagateEvents = false,
            };

            Check ch = new Check(child)
            {
                AlignmentX      = -1,
                AlignmentY      = -1,
                WeightX         = 1,
                WeightY         = 1,
                BackgroundColor = Color.Silver,
                PassEvents      = false,
                PropagateEvents = false,
            };

            gParent.PackEnd(parent);
            parent.PackEnd(child);
            child.PackEnd(ch);

            gParent.Show();
            parent.Show();
            child.Show();
            ch.Show();

            _gParentLayer = new GestureLayer(gParent);
            _gParentLayer.Attach(gParent);
            _gParentLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
            {
                Debug.WriteLine($"@@@ Grand Parent Tap : {gParent.PassEvents}, {gParent.PropagateEvents}, {gParent.RepeatEvents}");
            });
            _parentLayer = new GestureLayer(parent);
            _parentLayer.Attach(parent);
            _parentLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
            {
                Debug.WriteLine($"@@@ Parent Tap : {parent.PassEvents}, {parent.PropagateEvents}, {parent.RepeatEvents}");
            });
            childLayer = new GestureLayer(child);
            childLayer.Attach(child);
            childLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
            {
                Debug.WriteLine($"@@@ Child Tap : {child.PassEvents}, {child.PropagateEvents}, {child.RepeatEvents}");
            });

            chLayer = new GestureLayer(ch);
            chLayer.Attach(ch);
            chLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
            {
                Debug.WriteLine($"@@@ Check1 Tap : {ch.PassEvents}, {ch.PropagateEvents}, {ch.RepeatEvents}");
            });

            EvasObjectEvent eventGrand = new EvasObjectEvent(gParent, EvasObjectCallbackType.MouseDown);

            eventGrand.On += (s, e) =>
            {
                Debug.WriteLine($"@@@ Grand Parent down : {gParent.PassEvents}, {gParent.PropagateEvents}, {gParent.RepeatEvents}");
            };
            EvasObjectEvent evnetParent = new EvasObjectEvent(parent, EvasObjectCallbackType.MouseDown);

            evnetParent.On += (s, e) =>
            {
                Debug.WriteLine($"@@@ Parent down : {parent.PassEvents}, {parent.PropagateEvents}, {parent.RepeatEvents}");
            };
            EvasObjectEvent eventChild = new EvasObjectEvent(child, EvasObjectCallbackType.MouseDown);

            eventChild.On += (s, e) =>
            {
                Debug.WriteLine($"@@@ Child down : {child.PassEvents}, {child.PropagateEvents}, {child.RepeatEvents}");
            };
            EvasObjectEvent eventCh = new EvasObjectEvent(ch, ch.RealHandle, EvasObjectCallbackType.MouseDown);

            eventCh.On += (s, e) =>
            {
                Debug.WriteLine($"@@@ Check down : {ch.PassEvents}, {ch.PropagateEvents}, {ch.RepeatEvents}");
            };
        }
 private void SetupTapGesture()
 {
     _gestureLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.Start, OnTapStart);
     _gestureLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, OnTapEnd);
 }