LibraryDropDown.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using BansheeEngine;
  2. namespace BansheeEditor
  3. {
  4. internal class LibraryDropDown : DropDownWindow
  5. {
  6. private LibraryWindow parent;
  7. public LibraryDropDown()
  8. : base(150, 30)
  9. { }
  10. internal void SetParent(LibraryWindow parent)
  11. {
  12. this.parent = parent;
  13. GUIToggleGroup group = new GUIToggleGroup();
  14. GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  15. GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  16. GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  17. GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
  18. ProjectViewType activeType = parent.ViewType;
  19. switch (activeType)
  20. {
  21. case ProjectViewType.List16:
  22. list16.Value = true;
  23. break;
  24. case ProjectViewType.Grid32:
  25. grid32.Value = true;
  26. break;
  27. case ProjectViewType.Grid48:
  28. grid48.Value = true;
  29. break;
  30. case ProjectViewType.Grid64:
  31. grid64.Value = true;
  32. break;
  33. }
  34. list16.OnToggled += (active) =>
  35. {
  36. if (active)
  37. ChangeViewType(ProjectViewType.List16);
  38. };
  39. grid32.OnToggled += (active) =>
  40. {
  41. if (active)
  42. ChangeViewType(ProjectViewType.Grid32);
  43. };
  44. grid48.OnToggled += (active) =>
  45. {
  46. if (active)
  47. ChangeViewType(ProjectViewType.Grid48);
  48. };
  49. grid64.OnToggled += (active) =>
  50. {
  51. if (active)
  52. ChangeViewType(ProjectViewType.Grid64);
  53. };
  54. GUILayoutY vertLayout = GUI.AddLayoutY();
  55. vertLayout.AddFlexibleSpace();
  56. GUILayoutX contentLayout = vertLayout.AddLayoutX();
  57. contentLayout.AddFlexibleSpace();
  58. contentLayout.AddElement(list16);
  59. contentLayout.AddElement(grid32);
  60. contentLayout.AddElement(grid48);
  61. contentLayout.AddElement(grid64);
  62. contentLayout.AddFlexibleSpace();
  63. vertLayout.AddFlexibleSpace();
  64. }
  65. private void ChangeViewType(ProjectViewType viewType)
  66. {
  67. parent.ViewType = viewType;
  68. }
  69. }
  70. }