mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Prevent command panel title flash (#8710)
This commit is contained in:
+41
-25
@@ -279,6 +279,7 @@ namespace eagle {
|
||||
Selector.CurrentLayoutMode = mode;
|
||||
Selector.UpdateAvailableCommand(Model, AvailableCommand);
|
||||
headerLabel.text = Selector.HeaderString;
|
||||
RebuildHeaderLayout();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +299,8 @@ namespace eagle {
|
||||
if (AvailableCommand == null) {
|
||||
Selector = null;
|
||||
headerLabel.text = null;
|
||||
UpdateCommandControls();
|
||||
RebuildHeaderLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,6 +308,8 @@ namespace eagle {
|
||||
Selector.CurrentLayoutMode = mainController.CurrentLayoutMode;
|
||||
Selector.UpdateAvailableCommand(Model, AvailableCommand);
|
||||
headerLabel.text = Selector.HeaderString;
|
||||
UpdateCommandControls();
|
||||
RebuildHeaderLayout();
|
||||
|
||||
// If help was showing for previous command, show help for new command
|
||||
if (helpWasShowing) { ShowCurrentCommandHelp(); }
|
||||
@@ -314,6 +319,41 @@ namespace eagle {
|
||||
}
|
||||
}
|
||||
|
||||
private void RebuildHeaderLayout() {
|
||||
// The title's width depends on the active header controls. Rebuild both now so the
|
||||
// old text geometry cannot render for a frame in the new layout.
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(
|
||||
(RectTransform)headerLabel.transform.parent);
|
||||
headerLabel.ForceMeshUpdate();
|
||||
}
|
||||
|
||||
private void UpdateCommandControls() {
|
||||
if (Selector == null) {
|
||||
commitCommandButton.gameObject.SetActive(false);
|
||||
if (infoButton != null) { infoButton.gameObject.SetActive(false); }
|
||||
return;
|
||||
}
|
||||
|
||||
bool clearWarningPanel = !commitCommandButton.gameObject.activeSelf;
|
||||
|
||||
if (Selector.WarnOnCommitButton) {
|
||||
commitButtonText.text = $"<color=#FF0000FF>{Selector.CommitButtonString}</color>";
|
||||
} else {
|
||||
commitButtonText.text = Selector.CommitButtonString;
|
||||
}
|
||||
commitCommandButton.gameObject.SetActive(true);
|
||||
commitCommandButton.interactable = Selector.EnableCommitButton;
|
||||
|
||||
if (infoButton != null) { infoButton.gameObject.SetActive(true); }
|
||||
|
||||
if (clearWarningPanel) {
|
||||
MainQueue.Q.EnqueueForNextUpdate(() => {
|
||||
commandWarningPanelController.ClearWarning();
|
||||
_commandInfoShowing = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows help for the current command (used when switching commands while help is open).
|
||||
/// </summary>
|
||||
@@ -437,31 +477,7 @@ namespace eagle {
|
||||
public void OnGUI() {
|
||||
var eventType = Event.current.type;
|
||||
try {
|
||||
if (Selector == null) {
|
||||
commitCommandButton.gameObject.SetActive(false);
|
||||
if (infoButton != null) { infoButton.gameObject.SetActive(false); }
|
||||
} else {
|
||||
bool disableWarningPanel = !commitCommandButton.gameObject.activeSelf;
|
||||
|
||||
if (Selector.WarnOnCommitButton) {
|
||||
commitButtonText.text =
|
||||
$"<color=#FF0000FF>{Selector.CommitButtonString}</color>";
|
||||
} else {
|
||||
commitButtonText.text = Selector.CommitButtonString;
|
||||
}
|
||||
commitCommandButton.gameObject.SetActive(true);
|
||||
commitCommandButton.interactable = Selector.EnableCommitButton;
|
||||
|
||||
// Show info button when a command is selected
|
||||
if (infoButton != null) { infoButton.gameObject.SetActive(true); }
|
||||
|
||||
if (disableWarningPanel) {
|
||||
MainQueue.Q.EnqueueForNextUpdate(() => {
|
||||
commandWarningPanelController.ClearWarning();
|
||||
_commandInfoShowing = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
UpdateCommandControls();
|
||||
} catch (Exception e) {
|
||||
Debug.Log($"Event type is {eventType}");
|
||||
errorHandler.Add(e);
|
||||
|
||||
Reference in New Issue
Block a user