Exemplo n.º 1
0
 private static void EnsureEntryInLastMousePointerStates(Entity entity, MouseInteractionFeature feature)
 {
     if (!feature._lastEntityStates.ContainsKey(entity))
     {
         feature._lastEntityStates.Add(entity, MousePointerOverEntityState.Unknown);
     }
 }
Exemplo n.º 2
0
        private static bool IsLastMousePositionOverEntity(MouseInteractionFeature feature, Entity entity)
        {
            var transform = entity.GetImplementation <IReadOnlyTransform>();

            // TODO check bounding box instead of value and check for overlapping entities
            return(Vector3.Distance(transform.Position, feature._lastMousePosition) < 6.0f);
        }
Exemplo n.º 3
0
        private static bool IsMousePointerLeavingEntity(Entity entity, MouseInteractionFeature feature, EngineUpdateEventArgs args)
        {
            var isLeaving = !IsLastMousePositionOverEntity(feature, entity) && feature._lastEntityStates[entity] == MousePointerOverEntityState.Over;

            if (isLeaving)
            {
                feature._lastEntityStates[entity] = MousePointerOverEntityState.NotOver;
            }
            return(isLeaving);
        }
Exemplo n.º 4
0
 private static MouseMoveOverEngineEventArgs CreateMouseMoveOverEventArgs(Entity entity, MouseInteractionFeature feature, EnginePointerMovedEventArgs args)
 {
     return(new MouseMoveOverEngineEventArgs(Engine.Current, feature._lastMousePosition));
 }
Exemplo n.º 5
0
 private static IObservable <MouseEnterEngineEventArgs> CreateMouseEnterForEntity(Entity entity,
                                                                                  MouseInteractionFeature feature)
 {
     return(Engine.Current.Events.Update.Where(args => IsMousePointerEnteringEntity(entity, feature, args))
            .Select(args => CreateMouseEnterEventArgs(entity, feature, args))
            .Publish()
            .RefCount());
 }
Exemplo n.º 6
0
        private static bool IsMousePointerMovingOverEntity(Entity entity, MouseInteractionFeature feature, EnginePointerMovedEventArgs args)
        {
            var wasOver = feature._lastEntityStates[entity] == MousePointerOverEntityState.Over;

            return(IsLastMousePositionOverEntity(feature, entity) && wasOver);
        }
Exemplo n.º 7
0
 private static MouseLeaveEngineEventArgs CreateMouseLeaveEventArgs(Entity entity, MouseInteractionFeature feature, EngineUpdateEventArgs args)
 {
     return(new MouseLeaveEngineEventArgs(Engine.Current, feature._lastMousePosition));
 }