LibraryDropDown.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /** @addtogroup Library
  7. * @{
  8. */
  9. /// <summary>
  10. /// Drop down window that displays options used by the library window.
  11. /// </summary>
  12. internal class LibraryDropDown : DropDownWindow
  13. {
  14. private LibraryWindow parent;
  15. /// <summary>
  16. /// Constructs the drop down window.
  17. /// </summary>
  18. public LibraryDropDown()
  19. : base(150, 30)
  20. { }
  21. /// <summary>
  22. /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
  23. /// use.
  24. /// </summary>
  25. /// <param name="parent">Libary window that this drop down window is a part of.</param>
  26. internal void Initialize(LibraryWindow parent)
  27. {
  28. this.parent = parent;
  29. GUIToggleGroup group = new GUIToggleGroup();
  30. GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  31. GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  32. GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  33. GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  34. ProjectViewType activeType = parent.ViewType;
  35. switch (activeType)
  36. {
  37. case ProjectViewType.List16:
  38. list16.Value = true;
  39. break;
  40. case ProjectViewType.Grid32:
  41. grid32.Value = true;
  42. break;
  43. case ProjectViewType.Grid48:
  44. grid48.Value = true;
  45. break;
  46. case ProjectViewType.Grid64:
  47. grid64.Value = true;
  48. break;
  49. }
  50. list16.OnToggled += (active) =>
  51. {
  52. if (active)
  53. ChangeViewType(ProjectViewType.List16);
  54. };
  55. grid32.OnToggled += (active) =>
  56. {
  57. if (active)
  58. ChangeViewType(ProjectViewType.Grid32);
  59. };
  60. grid48.OnToggled += (active) =>
  61. {
  62. if (active)
  63. ChangeViewType(ProjectViewType.Grid48);
  64. };
  65. grid64.OnToggled += (active) =>
  66. {
  67. if (active)
  68. ChangeViewType(ProjectViewType.Grid64);
  69. };
  70. GUILayoutY vertLayout = GUI.AddLayoutY();
  71. vertLayout.AddFlexibleSpace();
  72. GUILayoutX contentLayout = vertLayout.AddLayoutX();
  73. contentLayout.AddFlexibleSpace();
  74. contentLayout.AddElement(list16);
  75. contentLayout.AddElement(grid32);
  76. contentLayout.AddElement(grid48);
  77. contentLayout.AddElement(grid64);
  78. contentLayout.AddFlexibleSpace();
  79. vertLayout.AddFlexibleSpace();
  80. }
  81. /// <summary>
  82. /// Changes the icon view type in the library window.
  83. /// </summary>
  84. /// <param name="viewType">Type of icons to display in the library window.</param>
  85. private void ChangeViewType(ProjectViewType viewType)
  86. {
  87. parent.ViewType = viewType;
  88. }
  89. }
  90. /** @} */
  91. }