@SelectionClass.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class SelectionClass
  4. {
  5. enum SEL_MODE // Selection Mode
  6. {
  7. SM_TOGGLE , // toggle element in selection
  8. SM_INCLUDE, // include element in selection
  9. SM_SET , // set element as selection
  10. SM_EXCLUDE, // exclude element from selection
  11. SM_KEEP , // keep only highlighted elements in selection
  12. SM_NUM ,
  13. };
  14. enum SEL_SCOPE // Selection Scope
  15. {
  16. SS_NONE ,
  17. SS_HIGHLIGHT, // highlighted
  18. SS_SCREEN , // visible on the screen
  19. SS_LOADED , // all loaded
  20. };
  21. class TouchSelTabs : GuiCustom
  22. {
  23. int sel , // currently selected mode
  24. keep, // mode activated through tapping
  25. keep_on_touch_start; // value of 'keep' at the moment of new touch start
  26. Mems<ImagePtr> images;
  27. Mems<Rect > rects;
  28. // get / set
  29. SEL_MODE selMode ( );
  30. int operator()( );
  31. C Rect& tabRect (int i );
  32. int tabIndex (C Vec2 &pos);
  33. void image(int i, C ImagePtr &image);
  34. void clear(); // clear 'keep' and store 'keep_on_touch_start' as 'sel' for the case of (button press->do quick selection->release button, doing everything so quickly that tap is triggered on release) making the tap not enable 'keep'
  35. // manage
  36. TouchSelTabs& create(int elms);
  37. C Rect& rect()C;
  38. virtual TouchSelTabs& rect(C Rect&rect)override;
  39. virtual TouchSelTabs& move(C Vec2&delta)override;
  40. // update / draw
  41. virtual void update(C GuiPC &gpc)override;
  42. virtual void draw(C GuiPC &gpc)override;
  43. public:
  44. TouchSelTabs();
  45. };
  46. bool selecting, disable_selection, tsm_side, sel_changed;
  47. Vec sel_pos;
  48. Edit::Viewport4::View *sel_view;
  49. Memc<Obj*> objs, highlighted;
  50. TouchSelTabs tsm; // touch selection mode
  51. // get
  52. int elms ( )C;
  53. Obj& operator[](int i);
  54. bool has (C UID &world_obj_instance_id)C;
  55. bool selRect(Rect &rect);
  56. // manage
  57. void create();
  58. void resize();
  59. // operations
  60. void select (Obj &obj);
  61. void deselect (Obj &obj);
  62. void selectToggle(Obj &obj);
  63. void highlight(Obj &obj);
  64. void unhighlight(Obj &obj);
  65. SelectionClass& clearSelect ();
  66. SelectionClass& clearHighlight();
  67. void highlightScreenObjs(Obj&base);
  68. void removed(Obj &obj);
  69. void setUndo();
  70. // update
  71. void update();
  72. void draw(Edit::Viewport4::View &view);
  73. void drawSelLit();
  74. ~SelectionClass();
  75. public:
  76. SelectionClass();
  77. };
  78. /******************************************************************************/
  79. /******************************************************************************/
  80. extern SelectionClass Selection;
  81. /******************************************************************************/