ToolbarItem.cs 3.5 KB

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