internal bool Step(Actor <Animation> actor)
        {
            bool is_expired = actor.Percent == 1;

            //bool is_expired = false;

            /*if (Repeat > 0 && actor.Percent == 1) {
             *  if (++iterations >= Repeat) {
             *      is_expired = true;
             *  }
             * }*/

            Percent = Choreographer.Compose(actor.Percent, Easing);
            Update(this);

            if (is_expired && Finished != null)
            {
                Finished(this);
            }

            if (Item != null)
            {
                Item.InvalidateRender();
                //Item.Invalidate ();
            }

            return(!is_expired);
        }
Esempio n. 2
0
        protected Requisition SizeRequested()
        {
            var requisition = new Requisition();

            if (Widget != null)
            {
                Requisition req, nat;
                Widget.GetPreferredSize(out req, out nat);
                widget_alloc.Width  = req.Width;
                widget_alloc.Height = req.Height;
            }

            if (horizontal)
            {
                Width  = Choreographer.PixelCompose(percent, widget_alloc.Width + StartPadding + EndPadding, Easing);
                Height = widget_alloc.Height;
            }
            else
            {
                Width  = widget_alloc.Width;
                Height = Choreographer.PixelCompose(percent, widget_alloc.Height + StartPadding + EndPadding, Easing);
            }

            requisition.Width  = Width;
            requisition.Height = Height;
            return(requisition);
        }
Esempio n. 3
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnDrawn(cr));
            }

            double x     = Allocation.Width / 2;
            double y     = Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            Gdk.RGBA             rgba  = StyleContext.GetBackgroundColor(StateFlags.Selected);
            Cairo.Color          color = CairoExtensions.GdkRGBAToCairoColor(rgba);
            Cairo.RadialGradient fill  = new Cairo.RadialGradient(x, y, 0, x, y, r);
            color.A = alpha;
            fill.AddColorStop(0, color);
            fill.AddColorStop(0.5, color);
            color.A = 0;
            fill.AddColorStop(1, color);

            cr.Arc(x, y, r, 0, 2 * Math.PI);
            cr.Pattern = fill;
            cr.Fill();
            fill.Destroy();

            return(base.OnDrawn(cr));
        }
Esempio n. 4
0
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnExposeEvent(evnt));
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow);

            double x     = Allocation.X + Allocation.Width / 2;
            double y     = Allocation.Y + Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            var color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Selected));
            var fill  = new Cairo.RadialGradient(x, y, 0, x, y, r);

            color.A = alpha;
            fill.AddColorStop(0, color);
            fill.AddColorStop(0.5, color);
            color.A = 0;
            fill.AddColorStop(1, color);

            cr.Arc(x, y, r, 0, 2 * Math.PI);
            cr.SetSource(fill);
            cr.Fill();
            fill.Dispose();

            CairoExtensions.DisposeContext(cr);
            return(base.OnExposeEvent(evnt));
        }
Esempio n. 5
0
        partial void Initialize()
        {
            _handler     = new Handler(Looper.MainLooper);
            _implementor = new CoreDispatcherImplementor(DispatchItems);

            _choreographer        = Choreographer.Instance;
            _animationImplementor = new FrameCallbackImplementor(DispatchItemsToChoreographer);
        }
        public async Task <Choreographer> Update(Choreographer entity)
        {
            var res = (_context.Choreographers.Update(entity)).Entity;

            await _context.SaveChangesAsync();

            return(res);
        }
Esempio n. 7
0
 private void _TestComposeRange(int [] values, Easing easing)
 {
     for (double i = 0, n = 100, p = 0, j = 0; i <= n; i += 5, p = i / n, j++)
     {
         int value = Choreographer.PixelCompose(p, (int)n, easing);
         Assert.AreEqual(values[(int)j], value);
     }
 }
Esempio n. 8
0
 private ChoreographerCompat()
 {
     if (IS_JELLYBEAN_OR_HIGHER)
     {
         mChoreographer = getChoreographer();
     }
     else
     {
         mHandler = new Handler(Looper.MainLooper);
     }
 }
Esempio n. 9
0
        public override bool Step(Actor <Animation> actor)
        {
            double result = ComposeHandler == null
                ? StartState + (ToValue * actor.Percent)
                : ComposeHandler(this, actor.Percent);

            result = Easing == Easing.Linear
                ? result
                : Choreographer.Compose(result, Easing);

            Item.SetValue <double> (Property, result);

            return(base.Step(actor));
        }
Esempio n. 10
0
        object OnCall(string typeName, string methodName, object thisObj, object[] args, IntPtr[] refArgs, int[] refIdxMatch)
        {
            bool snapToGrid = !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl);

            if (typeName == "Assets.TabletopUi.Scripts.Infrastructure.Choreographer" && methodName == "GetFreePosWithDebug")
            {
                if (snapToGrid)
                {
                    Choreographer choreo = (Choreographer)thisObj;
                    MethodInfo    getFreeTokenPositionMethod = choreo.GetType().GetMethod("GetFreeTokenPosition", BindingFlags.NonPublic | BindingFlags.Instance);
                    Vector2       pos      = (Vector2)getFreeTokenPositionMethod.Invoke(choreo, args);
                    Vector2       gridSize = GetGridSize((DraggableToken)args[0]);
                    pos.x = gridSize.x * (Mathf.Round(pos.x / gridSize.x));
                    pos.y = gridSize.y * (Mathf.Round(pos.y / gridSize.y));
                    return(pos);
                }
            }

            if (typeName == "Assets.CS.TabletopUI.DraggableToken" && methodName == "DelayedEndDrag")
            {
                if (snapToGrid)
                {
                    DraggableToken token    = (DraggableToken)thisObj;
                    Vector3        pos      = token.RectTransform.localPosition;
                    Vector2        gridSize = GetGridSize(token);
                    pos.x = gridSize.x * (Mathf.Round(pos.x / gridSize.x));
                    pos.y = gridSize.y * (Mathf.Round(pos.y / gridSize.y));
                    token.RectTransform.localPosition = pos;
                }
            }

            if (typeName == "Assets.TabletopUi.Scripts.Infrastructure.HotkeyWatcher" && methodName == "WatchForGameplayHotkeys")
            {
                if (Input.GetKeyDown(KeyCode.A))
                {
                    TabletopTokenContainer ttc = Registry.Retrieve <TabletopManager>()._tabletop;
                    foreach (DraggableToken token in ttc.GetTokens())
                    {
                        Vector3 pos      = token.transform.localPosition;
                        Vector2 gridSize = GetGridSize(token);
                        pos.x = gridSize.x * (Mathf.Round(pos.x / gridSize.x));
                        pos.y = gridSize.y * (Mathf.Round(pos.y / gridSize.y));
                        token.RectTransform.localPosition = pos;
                    }
                }
            }

            return(null);
        }
Esempio n. 11
0
 public ChoreographerAndroidSpringLooper(Choreographer choreographer)
 {
     mChoreographer = choreographer;
     mFrameCallback = new XFrameCallBack()
     {
         doFrame = (frameTimeNanos) =>
         {
             if (!mStarted || mSpringSystem == null)
             {
                 return;
             }
             long currentTime = SystemClock.UptimeMillis();
             mSpringSystem.loop(currentTime - mLastTime);
             mLastTime = currentTime;
             mChoreographer.PostFrameCallback(mFrameCallback);
         }
     };
 }
Esempio n. 12
0
        // Batch animate all outstanding slots to fill
        public static void DoFillSlots()
        {
            Choreographer choreographer = Registry.Retrieve <Choreographer>();

            foreach (var slotToFill in SlotsToFill)
            {
                if (Validator.Available(slotToFill) && StackMatchesSlot(slotToFill.ElementStackToken, slotToFill.TokenAndSlot.RecipeSlot))
                {
                    var stack = slotToFill.ElementStackToken;
                    // Force the stack to remember its last position as this param is not updated by the game reliably
                    stack.lastTablePos = new Vector2?(stack.RectTransform.anchoredPosition);
                    stack.SplitAllButNCardsToNewStack(1, new Context(Context.ActionSource.PlayerDrag));
                    choreographer.MoveElementToSituationSlot(stack, slotToFill.TokenAndSlot, new Action <ElementStackToken, TokenAndSlot>(choreographer.ElementGreedyAnimDone), -1f);
                }
            }

            SlotsToFill.Clear();
        }
Esempio n. 13
0
 private void OnBorderIteration(object sender, EventArgs args)
 {
     if (border_stage.Actor == null)
     {
         if (border_state == AnimationState.Coming)
         {
             start_border = start_padding;
             end_border   = end_padding;
         }
         else
         {
             start_border = end_border = 0;
         }
         border_state = AnimationState.Idle;
     }
     else
     {
         double percent = border_state == AnimationState.Coming ? Percent : 1.0 - Percent;
         start_border = Choreographer.PixelCompose(percent, start_padding, border_easing);
         end_border   = Choreographer.PixelCompose(percent, end_padding, border_easing);
     }
     QueueResizeNoRedraw();
 }
        protected override void OnSizeRequested(ref Requisition requisition)
        {
            if (Widget != null)
            {
                Requisition req = Widget.SizeRequest();
                widget_alloc.Width  = req.Width;
                widget_alloc.Height = req.Height;
            }

            if (horizontal)
            {
                Width  = Choreographer.PixelCompose(percent, widget_alloc.Width + StartPadding + EndPadding, Easing);
                Height = widget_alloc.Height;
            }
            else
            {
                Width  = widget_alloc.Width;
                Height = Choreographer.PixelCompose(percent, widget_alloc.Height + StartPadding + EndPadding, Easing);
            }

            requisition.Width  = Width;
            requisition.Height = Height;
        }
        public Task Delete(Choreographer entity)
        {
            _context.Choreographers.Remove(entity);

            return(_context.SaveChangesAsync());
        }