예제 #1
0
        public FrView(Window window, Fridget fr, IListener l)
        {
            StreamSink <MouseEvent> sMouse = new StreamSink <MouseEvent>();
            StreamSink <KeyEvent>   sKey   = new StreamSink <KeyEvent>();

            this.MouseDown += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            this.MouseUp   += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            this.MouseMove += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            DiscreteCellSink <Maybe <Size> > size = new DiscreteCellSink <Maybe <Size> >(Maybe.None);

            this.SizeChanged += (sender, args) => size.Send(Maybe.Some(args.NewSize));
            window.KeyDown   += (sender, args) =>
            {
                Key key = args.Key == Key.System ? args.SystemKey : args.Key;
                if (key == Key.Back)
                {
                    sKey.Send(new BackspaceKeyEvent());
                }
            };
            window.TextInput += (sender, args) => sKey.Send(new StringKeyEvent(args.Text));
            DiscreteCellLoop <long> focus = new DiscreteCellLoop <long>();

            Fridget.Output fo = fr.Reify(size, sMouse, sKey, focus, new Supply());
            focus.Loop(fo.SChangeFocus.Hold(-1));
            this.drawable = fo.Drawable;
            this.l        = new CompositeListener(new[] { l, this.drawable.Updates.Listen(d => this.InvalidateVisual()) });
        }
예제 #2
0
 public FrTranslate(Fridget fr, Cell<Point> offset)
     : base((size, sMouse, sKey, focus, idSupply) =>
     {
         Stream<MouseEvent> sMouseNew =
             sMouse.Snapshot(offset, (e, o) =>
                 new MouseEvent(e.Args, () =>
                 {
                     Point p = e.GetPosition();
                     return new Point(p.X - o.X, p.Y - o.Y);
                 }));
         Output fo = fr.Reify(size, sMouseNew, sKey, focus, idSupply);
         Cell<DrawableDelegate> drawableNew = fo.Drawable.Lift(offset,
             (dr, o) => new DrawableDelegate(d =>
             {
                 d.PushTransform(new TranslateTransform(o.X, o.Y));
                 dr(d);
                 d.Pop();
             }));
         return new Output(drawableNew, fo.DesiredSize, fo.SChangeFocus);
     })
 {
 }
예제 #3
0
 public FrTranslate(Fridget fr, Cell <Point> offset)
     : base((size, sMouse, sKey, focus, idSupply) =>
 {
     Stream <MouseEvent> sMouseNew =
         sMouse.Snapshot(offset, (e, o) =>
                         new MouseEvent(e.Args, () =>
     {
         Point p = e.GetPosition();
         return(new Point(p.X - o.X, p.Y - o.Y));
     }));
     Output fo = fr.Reify(size, sMouseNew, sKey, focus, idSupply);
     Cell <DrawableDelegate> drawableNew = fo.Drawable.Lift(offset,
                                                            (dr, o) => new DrawableDelegate(d =>
     {
         d.PushTransform(new TranslateTransform(o.X, o.Y));
         dr(d);
         d.Pop();
     }));
     return(new Output(drawableNew, fo.DesiredSize, fo.SChangeFocus));
 })
 {
 }
예제 #4
0
파일: FrView.cs 프로젝트: Angeldude/sodium
 public FrView(Window window, Fridget fr, IListener l)
 {
     StreamSink<MouseEvent> sMouse = new StreamSink<MouseEvent>();
     StreamSink<KeyEvent> sKey = new StreamSink<KeyEvent>();
     this.MouseDown += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
     this.MouseUp += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
     this.MouseMove += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
     CellSink<IMaybe<Size>> size = new CellSink<IMaybe<Size>>(Maybe.Nothing<Size>());
     this.SizeChanged += (sender, args) => size.Send(Maybe.Just(args.NewSize));
     window.KeyDown += (sender, args) =>
     {
         Key key = args.Key == Key.System ? args.SystemKey : args.Key;
         if (key == Key.Back)
         {
             sKey.Send(new BackspaceKeyEvent());
         }
     };
     window.TextInput += (sender, args) => sKey.Send(new StringKeyEvent(args.Text));
     CellLoop<long> focus = new CellLoop<long>();
     Fridget.Output fo = fr.Reify(size, sMouse, sKey, focus, new Supply());
     focus.Loop(fo.SChangeFocus.Hold(-1));
     this.drawable = fo.Drawable;
     this.l = new ImmutableCompositeListener(new[] { l, Operational.Updates(this.drawable).Listen(d => this.InvalidateVisual()) });
 }