static bool DoDispatch(BaseVisualElementPanel panel) { bool usesEvent; if (s_EventInstance.type == EventType.Repaint) { panel.Repaint(s_EventInstance); // TODO get rid of this when we wrap every GUIView inside IMGUIContainers // here we pretend to use the repaint event // in order to suspend to suspend OnGUI() processing on the native side // since we've already run it if we have an IMGUIContainer usesEvent = panel.IMGUIContainersCount > 0; } else { panel.ValidateLayout(); using (EventBase evt = CreateEvent(s_EventInstance)) { bool immediate = s_EventInstance.type == EventType.Used || s_EventInstance.type == EventType.Layout || s_EventInstance.type == EventType.ExecuteCommand || s_EventInstance.type == EventType.ValidateCommand; panel.SendEvent(evt, immediate ? DispatchMode.Immediate : DispatchMode.Queued); // FIXME: we dont always have to repaint if evt.isPropagationStopped. if (evt.isPropagationStopped) { panel.visualTree.IncrementVersion(VersionChangeType.Repaint); } usesEvent = evt.isPropagationStopped; } } return(usesEvent); }
void ChangePanel(BaseVisualElementPanel p) { if (panel == p) { return; } if (panel != null) { using (var e = DetachFromPanelEvent.GetPooled(panel, p)) { e.target = this; elementPanel.SendEvent(e, DispatchMode.Immediate); } } IPanel prevPanel = panel; elementPanel = p; if (panel != null) { using (var e = AttachToPanelEvent.GetPooled(prevPanel, p)) { e.target = this; elementPanel.SendEvent(e, DispatchMode.Immediate); } } // styles are dependent on topology IncrementVersion(VersionChangeType.StyleSheet | VersionChangeType.Layout | VersionChangeType.Transform); // persistent data key may have changed or needs initialization if (!string.IsNullOrEmpty(persistenceKey)) { IncrementVersion(VersionChangeType.PersistentData); } }