ToolbarItem.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using bs;
  5. namespace bs.Editor
  6. {
  7. /** @addtogroup Window
  8. * @{
  9. */
  10. /// <summary>
  11. /// Adds an entry to the main tool. Clicking on that entry will trigger the method the attribute is attached to.
  12. /// The method must be static, have no parameters or return values otherwise the attribute will be ignored.
  13. /// </summary>
  14. [AttributeUsage(AttributeTargets.Method)]
  15. class ToolbarItem : Attribute
  16. {
  17. /// <summary>
  18. /// Creates a new toolbar item attribute. Selecting the item in the toolbar will trigger the callback.
  19. /// </summary>
  20. /// <param name="name">Path that determines where in the menu to add the element. All path elements must be
  21. /// separated by /, for example "View/Toolbars/Find".</param>
  22. /// <param name="icon">Path to the sprite texture to display on the toolbar entry. Relative to project library
  23. /// resources folder.</param>
  24. /// <param name="tooltip">Optional tooltip to display when the user hovers over the toolbar entry.</param>
  25. /// <param name="priority">Priority determines the position of the toolbar item relative to its siblings.
  26. /// Higher priority means it will be placed earlier.</param>
  27. /// <param name="separator">Determines should a separator be inserted just before this element.</param>
  28. public ToolbarItem(string name, string icon, string tooltip = "", int priority = 0, bool separator = false)
  29. {
  30. this.name = name;
  31. this.icon = icon;
  32. this.tooltip = tooltip;
  33. this.priority = priority;
  34. this.separator = separator;
  35. this.builtinIcon = -1;
  36. }
  37. /// <summary>
  38. /// Creates a new toolbar item attribute. Selecting the item in the toolbar will trigger the callback.
  39. /// </summary>
  40. /// <param name="name">Path that determines where in the menu to add the element. All path elements must be
  41. /// separated by /, for example "View/Toolbars/Find".</param>
  42. /// <param name="icon">Type of builtin icon to display on the toolbar entry.</param>
  43. /// <param name="tooltip">Optional tooltip to display when the user hovers over the toolbar entry.</param>
  44. /// <param name="priority">Priority determines the position of the toolbar item relative to its siblings.
  45. /// Higher priority means it will be placed earlier.</param>
  46. /// <param name="separator">Determines should a separator be inserted just before this element.</param>
  47. internal ToolbarItem(string name, ToolbarIcon icon, string tooltip = "", int priority = 0, bool separator = false)
  48. {
  49. this.name = name;
  50. this.icon = null;
  51. this.tooltip = tooltip;
  52. this.priority = priority;
  53. this.separator = separator;
  54. this.builtinIcon = (int)icon;
  55. }
  56. #pragma warning disable 0414
  57. private string name;
  58. private string icon;
  59. private int builtinIcon;
  60. private string tooltip;
  61. private int priority;
  62. private bool separator;
  63. #pragma warning restore 0414
  64. }
  65. /** @} */
  66. }