/// <summary>
    /// Draw the list of all items
    /// </summary>
    void DrawList()
    {
        itsScrollPosition = GUILayout.BeginScrollView(itsScrollPosition);
        {
            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
            {
                foreach (ListItem aListItem in itsData)
                {
                    if (aListItem.itsFiltered)
                    {
                        continue;
                    }

                    bool aValue = KGFGUIUtility.Toggle(aListItem.itsSelected, aListItem.GetString(), KGFGUIUtility.eStyleToggl.eTogglSuperCompact);
                    if (aValue != aListItem.itsSelected)
                    {
                        aListItem.itsSelected = aValue;
                        if (EventItemChanged != null)
                        {
                            EventItemChanged(this, null);
                        }
                    }
                }
            }
            KGFGUIUtility.EndVerticalBox();
        }
        GUILayout.EndScrollView();
    }
Exemple #2
0
    private bool DrawBoolean(string theTitle, bool theValue)
    {
        //rotation left limit
        GUILayout.BeginHorizontal();
        KGFGUIUtility.Label(theTitle);
        GUILayout.FlexibleSpace();
        bool aValue = KGFGUIUtility.Toggle(theValue, "", KGFGUIUtility.eStyleToggl.eTogglCompact);

        GUILayout.EndHorizontal();
        return(aValue);
    }
    /// <summary>
    /// Render this control
    /// </summary>
    public void Render()
    {
        if (itsUpdateWish)
        {
            UpdateList();
        }

        int itsNumberOfPages = (int)Math.Ceiling((float)itsData.Rows.Count / (float)itsItemsPerPage);

        if (itsCurrentPage >= itsNumberOfPages)
        {
            itsCurrentPage = 0;
        }

        itsRepaintWish = false;
        itsGuiData.SetDisplayRowCount((uint)itsItemsPerPage);

        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
        {
            // categories view
            GUILayout.BeginVertical(GUILayout.Width(180));
            {
                itsListViewCategories.Render();
            }
            GUILayout.EndVertical();

            KGFGUIUtility.SpaceSmall();

            GUILayout.BeginVertical();
            {
                // item table
                itsGuiData.SetStartRow((uint)(itsCurrentPage * (uint)itsItemsPerPage));
                itsGuiData.Render();

                KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVerticalInteractive);
                {
                    // enum filter boxes
                    int aColumnNo = 0;
//						KGFGUIUtility.SpaceSmall();
                    foreach (KGFObjectListColumnItem anItem in itsListFieldCache)
                    {
                        aColumnNo++;

                        if (!anItem.itsDisplay)
                        {
                            continue;
                        }
                        if (!itsGuiData.GetColumnVisible(aColumnNo))
                        {
                            continue;
                        }

                        if (anItem.itsSearchable && (anItem.GetReturnType().IsEnum ||
                                                     anItem.GetReturnType() == typeof(bool) ||
                                                     anItem.GetReturnType() == typeof(string)))
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(itsGuiData.GetColumnWidth(aColumnNo)));
                            {
                                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
                                DrawFilterBox(anItem, itsGuiData.GetColumnWidth(aColumnNo) - 4);
                                KGFGUIUtility.EndVerticalBox();
                            }
                            GUILayout.EndHorizontal();
                            KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);
                        }
                        else
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(itsGuiData.GetColumnWidth(aColumnNo)));
                            {
                                GUILayout.Label(" ");
                            }
                            GUILayout.EndHorizontal();
                            KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox);
                            continue;
                        }
                    }
                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndHorizontalBox();

                KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkMiddleVertical);
                {
                    GUILayout.Label("");
                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndHorizontalBox();

                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom);
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (!Application.isPlaying)
                        {
                            if (EventNew != null)
                            {
                                if (KGFGUIUtility.Button("New", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(75)))
                                {
                                    EventNew(this, null);
                                }
                            }
                            if (EventDelete != null)
                            {
                                if (KGFGUIUtility.Button("Delete", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(75)))
                                {
                                    EventDelete(this, null);
                                }
                            }

                            GUILayout.FlexibleSpace();
                        }

                        // full text search box
                        if (itsDisplayFullTextSearch)
                        {
                            GUI.SetNextControlName(itsControlSearchName);
                            string aNewString = KGFGUIUtility.TextField(itsFulltextSearch, KGFGUIUtility.eStyleTextField.eTextField, GUILayout.Width(200));
                            if (aNewString != itsFulltextSearch)
                            {
                                itsFulltextSearch = aNewString;
                                UpdateList();
                            }
                        }

                        KGFGUIUtility.Space();

                        bool anIncludeAll = KGFGUIUtility.Toggle(itsIncludeAll, "all Tags", KGFGUIUtility.eStyleToggl.eTogglSuperCompact, GUILayout.Width(70));
                        if (anIncludeAll != itsIncludeAll)
                        {
                            itsIncludeAll = anIncludeAll;
                            UpdateList();
                        }

                        if (KGFGUIUtility.Button("clear filters", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(100)))
                        {
                            itsFulltextSearch = "";
                            ClearFilters();
                            UpdateList();
                        }

                        GUILayout.FlexibleSpace();

                        KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
                        {
                            if (GetDisplayEntriesPerPage())
                            {
                                //number of items in List
                                if (KGFGUIUtility.Button("<", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.Width(25)))
                                {
                                    switch (itsItemsPerPage)
                                    {
                                    case KGFeItemsPerPage.e25:
                                        itsItemsPerPage = KGFeItemsPerPage.e10;
                                        break;

                                    case KGFeItemsPerPage.e50:
                                        itsItemsPerPage = KGFeItemsPerPage.e25;
                                        break;

                                    case KGFeItemsPerPage.e100:
                                        itsItemsPerPage = KGFeItemsPerPage.e50;
                                        break;

                                    case KGFeItemsPerPage.e250:
                                        itsItemsPerPage = KGFeItemsPerPage.e100;
                                        break;

                                    case KGFeItemsPerPage.e500:
                                        itsItemsPerPage = KGFeItemsPerPage.e250;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleHorizontal);
                                {
                                    string aLogsPerPageString = itsItemsPerPage.ToString().Substring(1) + " entries per page";
                                    KGFGUIUtility.Label(aLogsPerPageString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                                }
                                KGFGUIUtility.EndVerticalBox();

                                if (KGFGUIUtility.Button(">", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.Width(25)))
                                {
                                    switch (itsItemsPerPage)
                                    {
                                    case KGFeItemsPerPage.e10:
                                        itsItemsPerPage = KGFeItemsPerPage.e25;
                                        break;

                                    case KGFeItemsPerPage.e25:
                                        itsItemsPerPage = KGFeItemsPerPage.e50;
                                        break;

                                    case KGFeItemsPerPage.e50:
                                        itsItemsPerPage = KGFeItemsPerPage.e100;
                                        break;

                                    case KGFeItemsPerPage.e100:
                                        itsItemsPerPage = KGFeItemsPerPage.e250;
                                        break;

                                    case KGFeItemsPerPage.e250:
                                        itsItemsPerPage = KGFeItemsPerPage.e500;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }

                            GUILayout.Space(10.0f);

                            // page control
                            if (KGFGUIUtility.Button("<", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.Width(25)) && itsCurrentPage > 0)
                            {
                                itsCurrentPage--;
                            }

                            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxMiddleHorizontal);
                            {
                                string aString = string.Format("page {0}/{1}", itsCurrentPage + 1, Math.Max(itsNumberOfPages, 1));
                                KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                            }
                            KGFGUIUtility.EndVerticalBox();

                            if (KGFGUIUtility.Button(">", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.Width(25)) && itsData.Rows.Count > ((itsCurrentPage + 1) * (int)itsItemsPerPage))
                            {
                                itsCurrentPage++;
                            }
                        }
                        KGFGUIUtility.EndHorizontalBox();
                    }
                    GUILayout.EndHorizontal();
                }
                KGFGUIUtility.EndVerticalBox();
            }
            GUILayout.EndVertical();
        }
        KGFGUIUtility.EndHorizontalBox();

        if (GUI.GetNameOfFocusedControl().Equals(itsControlSearchName))
        {
            if (itsFulltextSearch.Equals(itsTextSearch))
            {
                itsFulltextSearch = string.Empty;
            }
        }

        if (!GUI.GetNameOfFocusedControl().Equals(itsControlSearchName))
        {
            if (itsFulltextSearch.Equals(string.Empty))
            {
                itsFulltextSearch = itsTextSearch;
            }
        }
    }
Exemple #4
0
    public static void Render()
    {
        if (itsInstance != null && itsInstance.itsDataModuleCustomGUI.itsBarVisible)
        {
            if (itsCustomGUIImplementations.Count == 0)
            {
                return;
            }

            GUIStyle aTogglStyle = KGFGUIUtility.GetStyleToggl(KGFGUIUtility.eStyleToggl.eTogglRadioStreched);
            GUIStyle aBoxStyle   = KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
            int      aWidth      = (int)(aTogglStyle.contentOffset.x + aTogglStyle.padding.horizontal + (KGFGUIUtility.GetSkinHeight() - aTogglStyle.padding.vertical));
            int      aHeight     = (int)(aBoxStyle.margin.top + aBoxStyle.margin.bottom + aBoxStyle.padding.top + aBoxStyle.padding.bottom
                                         + (aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count);
            //(int)(aTogglStyle.margin.bottom + aBoxStyle.margin.vertical + aBoxStyle.padding.vertical);
            //(aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count)

            GUILayout.BeginArea(new Rect(Screen.width - aWidth, (Screen.height - aHeight) / 2, aWidth, aHeight));
            {
                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                {
                    GUILayout.FlexibleSpace();

                    foreach (KGFICustomGUI aCustomGUI in itsCustomGUIImplementations)
                    {
                        bool aValue;

                        if (itsCurrentSelectedGUI != null && itsCurrentSelectedGUI == aCustomGUI)
                        {
                            aValue = true;
                        }
                        else
                        {
                            aValue = false;
                        }

                        Texture2D aIcon = aCustomGUI.GetIcon();

                        if (aIcon == null)
                        {
                            aIcon = itsInstance.itsDataModuleCustomGUI.itsUnknownIcon;
                        }

                        if (aValue != KGFGUIUtility.Toggle(aValue, aIcon, KGFGUIUtility.eStyleToggl.eTogglRadioStreched))
                        {
                            if (aValue)
                            {
                                itsCurrentSelectedGUI = null;
                            }
                            else
                            {
                                itsCurrentSelectedGUI = aCustomGUI;
                            }
                        }
                    }

                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndVerticalBox();

                //Draw the Custom GUI
                if (itsCurrentSelectedGUI != null)
                {
                    itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI, itsCurrentSelectedGUI.GetName(), GUILayout.MinHeight(200), GUILayout.MinWidth(300));

                    // check if the window is still visible in screen
                    if (itsWindowRectangle.x < -itsWindowRectangle.width + 20)
                    {
                        itsWindowRectangle.x = -itsWindowRectangle.width + 20;
                    }
                    else if (itsWindowRectangle.x > Screen.width - 20)
                    {
                        itsWindowRectangle.x = Screen.width - 20;
                    }

                    if (itsWindowRectangle.y < -itsWindowRectangle.height + 20)
                    {
                        itsWindowRectangle.y = -itsWindowRectangle.height + 20;
                    }
                    else if (itsWindowRectangle.y > Screen.height - 20)
                    {
                        itsWindowRectangle.y = Screen.height - 20;
                    }
                }
            }
            GUILayout.EndArea();

            #region old render code

            /*
             *
             * float aButtonSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * float aButtonSpaceVertical = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * int aBoxSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.horizontal + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.horizontal, 24);
             * int aBoxSpaceVertical = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical, 24);
             *
             * GUILayout.BeginArea(new Rect(Screen.width - (aBoxSpaceHorizontal + aButtonSpaceHorizontal / 2),
             *                           Screen.height / 2 - ((itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceHorizontal) / 2,
             *                           aButtonSpaceHorizontal + aBoxSpaceHorizontal,
             *                           (itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceVertical));
             *
             * {
             *      KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.MinWidth(24));
             *      {
             *              foreach(KGFICustomGUI aCustomGUI in itsCustomGUIImplementations)
             *              {
             *                      bool selected = false;
             *                      float aWidth = Mathf.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             *
             *                      if(aCustomGUI.GetIcon() != null)
             *                      {
             *                              if(KGFGUIUtility.Button(aCustomGUI.GetIcon(), KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                              {
             *                                      selected = true;
             *                              }
             *                      }
             *                      else
             *                      {
             *                              if(itsUnknownIcon != null)
             *                              {
             *                                      if(KGFGUIUtility.Button(itsUnknownIcon, KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                              else
             *                              {
             *                                      if(KGFGUIUtility.Button("?", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                      }
             *
             *                      // check if one of the Buttons was clicked
             *                      if(selected && aCustomGUI != itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = aCustomGUI;
             *                      }
             *                      else if(selected && aCustomGUI == itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = null;
             *                      }
             *              }
             *      }
             *      KGFGUIUtility.EndVerticalBox();
             * }
             * GUILayout.EndArea();
             *
             * //Draw the Custom GUI
             * if(itsCurrentSelectedGUI != null)
             * {
             *      itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI,string.Empty, GUILayout.MinHeight(200), GUILayout.MinWidth(300));
             *
             *      // check if the window is still visible in screen
             *      if(itsWindowRectangle.x < -itsWindowRectangle.width + 20)
             *      {
             *              itsWindowRectangle.x = -itsWindowRectangle.width + 20;
             *      }
             *      else if(itsWindowRectangle.x > Screen.width - 20)
             *      {
             *              itsWindowRectangle.x = Screen.width - 20;
             *      }
             *
             *      if(itsWindowRectangle.y < -itsWindowRectangle.height + 20)
             *      {
             *              itsWindowRectangle.y = -itsWindowRectangle.height + 20;
             *      }
             *      else if(itsWindowRectangle.y > Screen.height - 20)
             *      {
             *              itsWindowRectangle.y = Screen.height - 20;
             *      }
             * }
             * }
             */
            #endregion
        }
    }