Esempio n. 1
0
        public override void DoGUI()
        {
            bool was = PressedVisible;

            base.DoGUI();
            if (Event.current.type == EventType.Repaint)
            {
                Rect r = GUILayoutUtility.GetLastRect();
                popupRect.position = GUIUtility.GUIToScreenPoint(r.position) + new Vector2(0, r.height);
                popupRect.width    = r.width;

                popupRect.height = CalcPopupViewHeight();
            }
            if (was != PressedVisible)
            {
                GUIWidgets gui = FindGUI();
                if (gui != null)
                {
                    if (PressedVisible)
                    {
                        gui.SetCurrentPopup(this);
                    }
                    else
                    {
                        gui.UnsetCurrentPopup(this);
                    }
                }
            }
        }
Esempio n. 2
0
        public void PopDown()
        {
            SetPressedVisible(false);
            GUIWidgets gui = FindGUI();

            if (gui != null)
            {
                gui.UnsetCurrentPopup(this);
            }
        }
Esempio n. 3
0
        public WidgetStyle FindStyle(string name)
        {
            GUIWidgets gui = FindGUI();

            if (gui != null)
            {
                var s = gui.Skin.GetStyle(name);
                return(new WidgetStyle(s.ReadOnly));
            }
            return(new WidgetStyle(HighLogic.Skin.GetStyle(name))); // fallback; shouldn't happen
        }
Esempio n. 4
0
        virtual protected void Communicate(Action a)
        {
            GUIWidgets gui = FindGUI();

            if (gui != null)
            {
                gui.Communicate(this, ToString(), a);
            }
            else
            {
                a();
            }
        }
Esempio n. 5
0
 virtual public void Dispose()
 {
     Shown = false;
     if (parent != null)
     {
         parent.Remove(this);
         GUIWidgets gui = FindGUI();
         if (gui != null)
         {
             gui.ClearCommunication(this);
         }
     }
 }
Esempio n. 6
0
 private void PopulateToolTipText()
 {
     // Walk up the parent list till I find the GUI() object I'm inside of, and get its tip value.
     // Put that in my label text.
     while (parent != null)
     {
         GUIWidgets p = parent as GUIWidgets;
         if (p != null)
         {
             SetText(p.RecentToolTip);
             break;
         }
         parent = parent.GetParent();
     }
     if (parent == null)
     {
         SetText("");
     }
 }
Esempio n. 7
0
 // Find all instances of me and wipe them all out:
 public static void ClearAll(SharedObjects shared)
 {
     // Iterating in inverse order so the deletions
     // tend to happen in nested order from the
     // creations:
     for (int i = instances.Count - 1; i >= 0; --i)
     {
         if (instances[i].IsAlive)
         {
             GUIWidgets g = instances[i].Target as GUIWidgets;
             if (g.window.IsForShared(shared))
             {
                 if (g != null) // should always be true
                 {
                     g.Hide();
                     g.Dispose();
                 }
             }
         }
     }
 }