public void UpdateTouches() { lock (TouchLock) { if (!RawTouchesUpdated) { return; } foreach (var rawTouch in RawTouches) { Touch prevTouch = touches.Find(s => s.Id == rawTouch.Id); Touch thisTouch = prevTouch != null ? prevTouch : new Touch(rawTouch); if (!rawTouch.Up) { newTouches.Add(thisTouch); } DownListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); if (prevTouch == null) { // New touch PressListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); } else if (!rawTouch.Up) { // Existing touch touches.Remove(thisTouch); thisTouch.Update(rawTouch); } } for (int i = 0; i < touches.Count; i++) { // Released touch ReleaseListeners.ForEach(dl => dl.CheckAndInvoke(touches[i])); } DownListeners.UpdateChanges(); PressListeners.UpdateChanges(); ReleaseListeners.UpdateChanges(); touches.Clear(); var empty = touches; touches = newTouches; newTouches = empty; RawTouches.Clear(); RawTouchesUpdated = false; } }
private void InitLayers() { Layers = new SynchronousList <Layer>(-3); Layers.ItemAdded += OnLayerAdded; Layers.ItemRemoved += OnLayerRemoved; for (int i = 0; i < 7; i++) { Layers.Add(new Layer()); } // This is the widget layer Layers.Add(Layer.CreateStaticLayer()); Layers.UpdateChanges(); }
public void UpdateTouches() { var xnaTouches = XnaTouchPanel.GetState(); for (int i = 0; i < xnaTouches.Count; i++) { Touch prevTouch = touches.Find(s => s.Id == xnaTouches[i].Id); Touch thisTouch = prevTouch != null ? prevTouch : new Touch(screen, xnaTouches[i]); newTouches.Add(thisTouch); DownListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); if (prevTouch == null) { // New touch PressListeners.ForEach(dl => dl.CheckAndInvoke(thisTouch)); } else { // Existing touch touches.Remove(thisTouch); thisTouch.Update(xnaTouches[i]); } } for (int i = 0; i < touches.Count; i++) { // Released touch ReleaseListeners.ForEach(dl => dl.CheckAndInvoke(touches[i])); } DownListeners.UpdateChanges(); PressListeners.UpdateChanges(); ReleaseListeners.UpdateChanges(); touches.Clear(); var empty = touches; touches = newTouches; newTouches = empty; }
public override void Update(Time time) { if (_touch != null) { _indexDelta = (_touch.PositionOnScreen.Y - _touchStart) / TextSize.Y; } else if (_indexVelocity > 0) { _indexDelta += Math.Sign(_indexDelta) * _indexVelocity * time.SinceLastUpdate.TotalSeconds; _indexVelocity *= 0.95; if (_indexVelocity < 1.5) { SelectedIndex += (int)Math.Round(_indexDelta); _indexDelta = 0; _indexVelocity = 0; } } _controls.UpdateChanges(); base.Update(time); }
/// <summary> /// Instantly applies changes made to the layer's objects. /// </summary> public void ApplyChanges() { Effects.UpdateChanges(); Objects.UpdateChanges(); }