ToolbarItem.cs 3.2 KB

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