List.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /******************************************************************************
  2. Use 'List' to display a list of elements (with custom columns) in a gui object.
  3. List supports 2 types of indexes:
  4. -absolute indexes (known as 'abs') it is the order in which elements are stored in original memory containers
  5. -visible indexes (known as 'vis') it is the order in which elements are displayed in the list, this order is affected by: sorting, element visibility
  6. Elements that are hidden will have their visible index set to -1.
  7. /******************************************************************************/
  8. enum LIST_COLUMN_WIDTH_MODE // List Column Width Mode
  9. {
  10. LCW_DATA =-1, // set List Column width from data width
  11. LCW_PARENT =-2, // set List Column width from Lists GuiObj parent width
  12. LCW_MAX_DATA_PARENT=-3, // set List Column width from Max(Lists GuiObj parent width, data width)
  13. };
  14. /******************************************************************************/
  15. STRUCT(ListColumn , Button) // List Column
  16. //{
  17. Int precision ; // data number precision, default=3
  18. Flt width , // column width (can also be set to LCW_DATA, LCW_PARENT or LCW_MAX_DATA_PARENT)
  19. text_align; // text aligning
  20. MemberDesc md , // member description
  21. *sort ; // member description used for sorting (if null then 'md' will be used instead, default=null)
  22. T1(TYPE) explicit ListColumn(TYPE &member , Flt width, C Str &name); // create using member auto-detection , 'member' =custom class member - 'MEMBER' macro usage is required , 'width'=column width (can also be set to LCW_DATA, LCW_PARENT or LCW_MAX_DATA_PARENT), 'name'=column name
  23. T1(TYPE) explicit ListColumn(Str (*data_to_text)(C TYPE &data), Flt width, C Str &name); // create using manual conversion function, 'data_to_text'=custom function converting data to text , 'width'=column width (can also be set to LCW_DATA, LCW_PARENT or LCW_MAX_DATA_PARENT), 'name'=column name
  24. explicit ListColumn(DATA_TYPE type, Int offset, Int size, Flt width, C Str &name); // create using manual member description , 'type'=data type, 'offset'=member offset in class, 'size'=sizeof member, 'width'=column width (can also be set to LCW_DATA, LCW_PARENT or LCW_MAX_DATA_PARENT), 'name'=column name
  25. ListColumn( ); // create empty
  26. ListColumn(ListColumn &&lc );
  27. #if EE_PRIVATE
  28. void create(C ListColumn &src, _List &list);
  29. Int resizeEdge()C {return _resize_edge;}
  30. void pushed();
  31. #endif
  32. virtual void update(C GuiPC &gpc);
  33. private:
  34. Int _resize_edge;
  35. void create(Str (*data_to_text)(CPtr data), Flt width, C Str &name);
  36. };
  37. /******************************************************************************/
  38. enum LIST_CUR_MODE : Byte // List Cursor Mode
  39. {
  40. LCM_DEFAULT, // default, cursor is hidden when not active
  41. LCM_MOUSE , // cursor is always under mouse
  42. LCM_ALWAYS , // cursor is always visible
  43. };
  44. enum LIST_DRAW_MODE : Byte // List Draw Mode
  45. {
  46. LDM_LIST , // standard list, one element per line
  47. LDM_RECTS, // elements are displayed in rectangle areas, can be multiple elements per line, used for displaying images
  48. };
  49. enum LIST_SEL_MODE : Byte // List Selection Mode
  50. {
  51. LSM_SET , // set element as selection
  52. LSM_TOGGLE , // toggle element in selection
  53. LSM_INCLUDE , // include element in selection
  54. LSM_EXCLUDE , // exclude element from selection
  55. LSM_EXCLUDE_MULTI, // exclude elements from selection
  56. };
  57. enum LIST_FLAG // List Flag
  58. {
  59. LIST_SORTABLE =0x001, // if list is sortable
  60. LIST_SCALABLE =0x002, // if list is scalable (zoomable)
  61. LIST_ROLLABLE =0x004, // if list is rollable (moving the cursor up while being at the top will move it to the bottom and vice-versa)
  62. LIST_SEARCHABLE =0x008, // if list is searchable (typing keys will change cursor position)
  63. LIST_IMMEDIATE_DESC =0x010, // if immediately show description without any delays
  64. LIST_TYPE_SORT =0x020, // if elements will be sorted by their "types" first (types are set using 'setElmType' method)
  65. LIST_TYPE_LINE =0x040, // if elements of different "types" won't be displayed in the same line in LDM_RECTS mode
  66. LIST_MULTI_SEL =0x080, // if list supports selection of multiple elements at one time (by using Shift, Ctrl, ..)
  67. LIST_RESIZABLE_COLUMNS=0x100, // if list columns can be resized using mouse
  68. };
  69. /******************************************************************************/
  70. const_mem_addr STRUCT(_List , GuiObj) // Gui List !! must be stored in constant memory address !!
  71. //{
  72. // columns
  73. Bool sort_swap [3]; // swap order of sorting (true/false) , default={false, false, false}
  74. Int sort_column[3], // index of sorting columns (-1=none) , default={ -1, -1, -1}
  75. draw_column ; // index of column which toggles drawing mode, default=-1, this is automatically set to first column of Image type
  76. // elements
  77. Int cur, // current element (in visible indexing mode)
  78. lit; // highlighted element (in visible indexing mode)
  79. Memc<Int> sel; // selected elements (in absolute indexing mode to allow selecting hidden elements), this allows to obtain all selected elements, this is valid only if 'flag' has LIST_MULTI_SEL option enabled
  80. // misc
  81. LIST_CUR_MODE cur_mode ; // cursor mode , default=LCM_DEFAULT
  82. LIST_SEL_MODE sel_mode ; // selection mode , default=LSM_SET affects the default action for handling selection of an element upon its clicking for lists with LIST_MULTI_SEL option enabled
  83. ALPHA_MODE image_alpha; // images alpha blending, default=ALPHA_BLEND
  84. UInt flag ; // LIST_FLAG , default=LIST_SORTABLE|LIST_SEARCHABLE
  85. Flt zoom_min , // minimum zoom , default=0.58
  86. zoom_max ; // maximum zoom , default=1.44
  87. Vec2 padding ; // list padding , default=(0, 0) amount of padding applied to the list size
  88. // manage
  89. _List& del ( ); // delete
  90. _List& clear (SET_MODE mode=SET_DEFAULT ); // clear list elements, if 'mode'=QUIET then 'curChanged', 'selChanged' and 'selChanging' callbacks will not be called
  91. _List& create( ); // create
  92. _List& create(C ListColumn *column, Int columns, Bool columns_hidden=false) {return create().setColumns(column, columns, columns_hidden);} // create and set columns, list columns are copied internally
  93. _List& create(C _List &src ); // create from 'src'
  94. // set / get
  95. _List& setColumns(C ListColumn *column, Int columns, Bool columns_hidden=false); // set columns, list columns are copied internally
  96. T1(TYPE) _List& setData ( TYPE *data, Int elms, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from continuous memory !! after any change in source data, 'setData' must be called again !!
  97. T1(TYPE) _List& setData ( Mems<TYPE> &mems, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Mems !! after any change in source data, 'setData' must be called again !!
  98. _List& setData (_Memc &memc, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Memc !! after any change in source data, 'setData' must be called again !!
  99. _List& setData (_Memb &memb, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Memb !! after any change in source data, 'setData' must be called again !!
  100. _List& setData (_Memx &memx, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Memx !! after any change in source data, 'setData' must be called again !!
  101. _List& setData (_Meml &meml, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Meml !! after any change in source data, 'setData' must be called again !!
  102. _List& setData (_Map &map , C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Map !! after any change in source data, 'setData' must be called again !!
  103. T1(TYPE) _List& setDataNode( Memx<TYPE> &memx, C MemPtr<Bool> &visible=null, Bool keep_cur=false); // set list data from Memx with children !! after any change in source data, 'setData' must be called again !! TYPE must have a "Memx<TYPE> children" member, for example: "struct TYPE { Memx<TYPE> children; }", in that case 'setDataNode' will add all elements including children recursively
  104. _List& columnsHidden(Bool hidden ); Bool columnsHidden ()C {return _columns_hidden;} // set/get if all columns are hidden
  105. _List& columnHeight(Flt height ); Flt columnHeight ()C {return _column_height;} // set/get columns height, 0..Inf , default= 0.055
  106. _List& elmHeight(Flt height ); Flt elmHeight ()C {return _elm_height;} // set/get elements height, 0..Inf , default= 0.050
  107. _List& textSize(Flt base, Flt relative=0 ); Flt textSizeBase ()C {return _text_base;} // set/get text size , 0..Inf , default=(0.050, 0.0 ), final text size = "zoom * elmHeight() * textSizeRel() + textSizeBase() "
  108. Flt textSizeRel ()C {return _text_rel ;} // set/get text size , 0..Inf , default=(0.050, 0.0 ), final text size = "zoom * elmHeight() * textSizeRel() + textSizeBase() "
  109. Flt textSizeActual ()C; // get text size actual = "zoom * elmHeight() * textSizeRel() + textSizeBase() "
  110. _List& imageSize(C Vec2 &base, Flt relative, C Rect &padding=Vec2(0)); C Vec2& imageSizeBase ()C {return _image_base;} // set/get image size , 0..Inf , default=(0.0 , 0.1/64), final text size = "zoom * (image.xy * imageSizeRel() + imageSizeBase())", 'padding'=padding applied to the whole element rectangle
  111. Flt imageSizeRel ()C {return _image_rel ;} // set/get image size , 0..Inf , default=(0.0 , 0.1/64), final image size = "zoom * (image.xy * imageSizeRel() + imageSizeBase())"
  112. C Rect& imageSizePadding()C {return _image_padd;} // set/get image size , 0..Inf , default=(0.0 , 0.1/64), final image size = "zoom * (image.xy * imageSizeRel() + imageSizeBase())"
  113. _List& zoom(Flt zoom ); Flt zoom()C {return _zoom;} // set/get list zoom , zoom_min..zoom_max, default= 1.0
  114. _List& skin(C GuiSkinPtr &skin ); C GuiSkinPtr& skin()C {return _skin;} // set/get skin override, default=null (if set to null then current value of 'Gui.skin' is used), changing this value will automatically change the skin of the list columns
  115. GuiSkin * getSkin()C {return _skin ? _skin() : Gui.skin();} // get actual skin
  116. TextStyle * getTextStyle()C; // get actual text style
  117. _List& horizontal(Bool horizontal ); Bool horizontal()C {return _horizontal;} // set/get if LDM_RECTS mode should be displayed horizontally, default=false
  118. _List& vertical(Bool vertical ); Bool vertical()C {return !_horizontal;} // set/get if LDM_RECTS mode should be displayed vertically, default=true
  119. _List& drawMode(LIST_DRAW_MODE mode ); LIST_DRAW_MODE drawMode()C {return _draw_mode;} // set/get draw mode , LIST_DRAW_MODE , default=LDM_LIST
  120. LIST_SEL_MODE selMode()C; // get selection mode affected by keyboard modifiers
  121. Int totalElms()C {return _total_elms;} // get number of total elements
  122. Int visibleElms()C {return _visible_elms;} // get number of visible elements
  123. Int elms()C {return _visible_elms;} // get number of visible elements
  124. Int pageElms(C GuiPC *gpc=null)C; // get number of elements to skip when using PageUp/PageDn keys, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  125. VecI2 visibleElmsOnScreen(C GuiPC *gpc=null)C; // get range of elements that are currently visible on the screen, this range covers visible elements from VecI2.x to VecI2.y inclusive, this function is useful if you want to draw additional graphics on top of visible elements (if the range is empty then VecI2(0, -1) is returned), if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  126. Rect elmsScreenRect (C GuiPC *gpc=null)C; // get screen rectangle used for displaying elements, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  127. Ptr operator()( )C {return visToData(cur );} // convert visible index to data
  128. Ptr operator()(Int visible )C {return visToData(visible);} // convert visible index to data
  129. Ptr visToData (Int visible )C; // convert visible index to data
  130. Int visToAbs (Int visible )C; // convert visible index to absolute index
  131. Ptr absToData (Int absolute)C; // convert absolute index to data
  132. Int absToVis (Int absolute)C; // convert absolute index to visible index
  133. Int dataToVis (CPtr data )C; // convert data to visible index
  134. Int dataToAbs (CPtr data )C; // convert data to absolute index
  135. Int screenToVisX ( Flt x , C GuiPC *gpc=null)C; // convert screen position X to visible index , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  136. Int screenToVisY ( Flt y , C GuiPC *gpc=null)C; // convert screen position Y to visible index , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  137. virtual Int screenToVis (C Vec2 &pos , C GuiPC *gpc=null)C; // convert screen position to visible index , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  138. Ptr screenToData ( Flt y , C GuiPC *gpc=null)C; // convert screen position Y to data , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  139. Ptr screenToData (C Vec2 &pos , C GuiPC *gpc=null)C; // convert screen position to data , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  140. Int screenToColumnX ( Flt x , C GuiPC *gpc=null)C; // convert screen position X to column index , if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  141. Vec2 visToScreenPos ( Int visible, C GuiPC *gpc=null)C; // convert visible index to top left corner position of the element on the screen, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  142. Rect visToScreenRect( Int visible, C GuiPC *gpc=null)C; // convert visible index to rectangle of the element on the screen, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  143. Flt visToLocalY ( Int visible )C; // convert visible index to top position of the element in local space
  144. Vec2 visToLocalPos ( Int visible )C; // convert visible index to top left corner position of the element in local space
  145. Rect visToLocalRect ( Int visible )C; // convert visible index to rectangle of the element in local space
  146. Int columns( )C {return _columns.elms();} // number of columns
  147. ListColumn& column (Int i) {return _columns[i] ;} // get i-th column
  148. Flt columnOffset (Int i)C; // get i-th column horizontal offset
  149. _List& columnWidth (Int i, Flt width ); Flt columnWidth (Int i)C; // set/get i-th column width, ('width' can also be set to LCW_DATA, LCW_PARENT or LCW_MAX_DATA_PARENT)
  150. _List& columnVisible(Int i, Bool visible); Bool columnVisible(Int i)C; // set/get i-th column visibility
  151. Int firstColumn (DATA_TYPE type); // return index of first 'ListColumn' which is of 'type' , -1 on fail
  152. Int firstColumnText( ); // return index of first 'ListColumn' which is of text type, -1 on fail
  153. _List& curChanged(void (*func)(Ptr user), Ptr user=null); // set function called when list 'cur' cursor has changed, with 'user' as its parameter
  154. T1(TYPE) _List& curChanged(void (*func)(TYPE *user), TYPE *user ) {return curChanged((void(*)(Ptr))func, user);} // set function called when list 'cur' cursor has changed, with 'user' as its parameter
  155. T1(TYPE) _List& curChanged(void (*func)(TYPE &user), TYPE &user ) {return curChanged((void(*)(Ptr))func, &user);} // set function called when list 'cur' cursor has changed, with 'user' as its parameter
  156. _List& selChanged(void (*func)(Ptr user), Ptr user=null); // set function called when list 'sel' selection has changed, with 'user' as its parameter
  157. T1(TYPE) _List& selChanged(void (*func)(TYPE *user), TYPE *user ) {return selChanged((void(*)(Ptr))func, user);} // set function called when list 'sel' selection has changed, with 'user' as its parameter
  158. T1(TYPE) _List& selChanged(void (*func)(TYPE &user), TYPE &user ) {return selChanged((void(*)(Ptr))func, &user);} // set function called when list 'sel' selection has changed, with 'user' as its parameter
  159. _List& selChanging(void (*func)(Ptr user), Ptr user=null); // set function called when list 'sel' selection is about to change, with 'user' as its parameter
  160. T1(TYPE) _List& selChanging(void (*func)(TYPE *user), TYPE *user ) {return selChanging((void(*)(Ptr))func, user);} // set function called when list 'sel' selection is about to change, with 'user' as its parameter
  161. T1(TYPE) _List& selChanging(void (*func)(TYPE &user), TYPE &user ) {return selChanging((void(*)(Ptr))func, &user);} // set function called when list 'sel' selection is about to change, with 'user' as its parameter
  162. // per element parameters
  163. _List& clearElmType ( ); // clear per element type
  164. _List& clearElmDesc ( ); // clear per element description
  165. _List& clearElmImageColor( ); // clear per element image color
  166. _List& clearElmTextColor ( ); // clear per element text color
  167. _List& clearElmTextShadow( ); // clear per element text shadow
  168. _List& clearElmAlphaMode ( ); // clear per element ALPHA_MODE
  169. _List& clearElmOffset ( ); // clear per element offset
  170. _List& clearElmGroup ( ); // clear per element group
  171. _List& setElmType (UInt &member); // set per element type , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  172. _List& setElmDesc (CChar* &member); // set per element description , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  173. _List& setElmDesc (Str &member); // set per element description , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  174. _List& setElmImageColor(Color &member); // set per element image color , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  175. _List& setElmTextColor (Color &member); // set per element text color , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  176. _List& setElmTextShadow(Byte &member); // set per element text shadow, from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  177. _List& setElmAlphaMode (ALPHA_MODE &member); // set per element ALPHA_MODE , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  178. _List& setElmOffset (Flt &member); // set per element offset , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  179. _List& setElmGroup (Str &member); // set per element group , from list data elements member, for 'member' parameter 'MEMBER' macro usage is required
  180. _List& offsetAllColumns(Bool on); // if apply per element offset to all columns, if set to false then only first column is offsetted, default=false
  181. // operations
  182. _List& scrollTo (Int i , Bool immediate=false, Flt center=0.0f); // scroll to i-th visible element, 'center'=how much (0..1) to center on the element (0=no centering, 0.5=half centering, 1=full centering)
  183. _List& sort (Int column, Int swap =-1 ); // sort according to 'column' column
  184. _List& setCur (Int i ); // set cursor to specified index, and if list has 'LIST_MULTI_SEL' enabled then set 'sel' accordingly
  185. _List& processSel(Int absolute, Int sel_mode=-1 ); // process selection of specified 'absolute' element index, 'sel_mode'=selection mode (use -1 for 'selMode')
  186. _List& addChild(GuiObj &child, Int abs, Int column=0); // add 'child' to the list, 'abs'=absolute element index, 'column'=list column
  187. virtual Bool sorting() {return true;} // this is called when list is about to be sorted, you can override this method and perform custom processing, return true if you want to proceed with sorting, or false to abort it
  188. // main
  189. virtual GuiObj* test (C GuiPC &gpc, C Vec2 &pos, GuiObj* &mouse_wheel); // test if 'pos' screen position intersects with the object, by returning pointer to object or its children upon intersection and null in case no intersection, 'mouse_wheel' may be modified upon intersection either to the object or its children or null
  190. virtual void update(C GuiPC &gpc); // update object
  191. virtual void draw (C GuiPC &gpc); // draw object
  192. #if EE_PRIVATE
  193. Bool columnsVisible ()C {return !_columns_hidden && _columns.elms();}
  194. void zero ();
  195. void init (Int elms, C MemPtr<Bool> &visible, Bool keep_cur);
  196. void setRects ();
  197. Bool setCurEx (Int cur, Int dir=0, Bool pushed=false, UInt touch_id=0);
  198. Bool setSel (Int visible);
  199. Int localToVirtualX ( Flt local_x )C; // this is a visible index without clamping to existing elements (-Inf..Inf)
  200. Int localToVirtualY ( Flt local_y )C; // this is a visible index without clamping to existing elements (-Inf..Inf)
  201. Int localToVisX ( Flt local_x )C; // this is a visible index with clamping to existing elements ( -1..elms()-1) -1 on fail
  202. Int localToVisY ( Flt local_y )C; // this is a visible index with clamping to existing elements ( -1..elms()-1) -1 on fail
  203. Int localToVis (C Vec2 &local_pos)C; // this is a visible index with clamping to existing elements ( -1..elms()-1) -1 on fail
  204. Int localToColumnX ( Flt local_x )C; // -1 on fail
  205. Int screenToVirtualY (Flt y, C GuiPC *gpc=null)C; // convert screen position Y to virtual index, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  206. void sort ();
  207. void removeChild ( GuiObj &child);
  208. Vec2 childOffset (C GuiObj &child)C;
  209. void callCurChanged ();
  210. void callSelChanged ();
  211. void callSelChanging ();
  212. Flt parentWidth ()C;
  213. Flt columnWidthActual(Int i)C;
  214. Flt columnDataWidth (Int i, Bool visible=true)C; // get i-th column data width, 'visible'=if check only visible or all elements
  215. Flt columnDataWidthEx(Int i )C; // get i-th column data width including column text and padding
  216. #endif
  217. ~_List() {del();}
  218. _List();
  219. #if !EE_PRIVATE
  220. private:
  221. #endif
  222. struct Children : GuiObjChildren
  223. {
  224. struct Child : GuiObjChildren::Child
  225. {
  226. VecI2 abs_col; // x=abs, y=column
  227. };
  228. Children();
  229. #if EE_PRIVATE
  230. Child* add (GuiObj &child, GuiObj &parent);
  231. Child& operator[](Int i);
  232. C Child& operator[](Int i)C;
  233. #endif
  234. };
  235. Int _total_elms, _visible_elms, _elm_size;
  236. Int *_vis_to_abs , *_abs_to_vis;
  237. Ptr *_vis_to_data, *_abs_to_data;
  238. Rect *_rects;
  239. Children _children;
  240. Mems<ListColumn> _columns;
  241. Ptr _data;
  242. _Memb *_memb;
  243. _Memx *_memx;
  244. _Meml *_meml;
  245. _Map *_map ;
  246. _Memx *_node;
  247. Bool _horizontal, _columns_hidden, _offset_first_column, _kb_action;
  248. Byte _search_i;
  249. LIST_DRAW_MODE _draw_mode;
  250. Char _search[32];
  251. Int _type_offset, _desc_offset, _image_color_offset, _text_color_offset, _text_shadow_offset, _alpha_mode_offset, _offset_offset, _group_offset, _children_offset, _tap_vis;
  252. UInt _tap_touch_id;
  253. Flt _column_height, _elm_height, _text_base, _text_rel, _image_rel, _zoom, _height_ez, _search_t;
  254. Vec2 _image_base;
  255. Rect _image_padd;
  256. Ptr _cur_changed_user , _sel_changed_user , _sel_changing_user;
  257. void (*_cur_changed)(Ptr user), (*_sel_changed)(Ptr user), (*_sel_changing)(Ptr user);
  258. GuiSkinPtr _skin;
  259. protected:
  260. _List& _setData(Ptr data, Int elms, Int elm_size, C MemPtr<Bool> &visible=null, Bool keep_cur=false);
  261. _List& _setData(_Memx &node, Int children_offset, C MemPtr<Bool> &visible=null, Bool keep_cur=false);
  262. virtual void parentClientRectChanged(C Rect *old_client, C Rect *new_client);
  263. virtual void childRectChanged(C Rect *old_rect , C Rect *new_rect , GuiObj &child);
  264. NO_COPY_CONSTRUCTOR(_List);
  265. #if EE_PRIVATE
  266. friend struct Menu;
  267. #endif
  268. };
  269. /******************************************************************************/
  270. const_mem_addr T1(TYPE) struct List : _List // Gui List Template !! must be stored in constant memory address !!
  271. {
  272. TYPE* operator()( )C {return visToData(cur );} // convert visible index to data
  273. TYPE* operator()( Int visible )C {return visToData(visible );} // convert visible index to data
  274. TYPE* visToData ( Int visible )C {return (TYPE*)_List:: visToData(visible );} // convert visible index to data
  275. Int visToAbs ( Int visible )C {return _List:: visToAbs (visible );} // convert visible index to absolute index
  276. TYPE* absToData ( Int absolute)C {return (TYPE*)_List:: absToData(absolute);} // convert absolute index to data
  277. Int absToVis ( Int absolute)C {return _List:: absToVis (absolute);} // convert absolute index to visible index
  278. Int dataToVis (C TYPE *data )C {return _List::dataToVis (data );} // convert data to visible index
  279. Int dataToAbs (C TYPE *data )C {return _List::dataToAbs (data );} // convert data to absolute index
  280. TYPE* screenToData( Flt y , C GuiPC *gpc=null)C {return (TYPE*)_List::screenToData(y , gpc);} // convert screen position Y to data, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  281. TYPE* screenToData(C Vec2 &pos, C GuiPC *gpc=null)C {return (TYPE*)_List::screenToData(pos, gpc);} // convert screen position to data, if you know the 'GuiPC' then pass it to 'gpc' which will speed up calculations (otherwise leave it to null)
  282. List& setData ( TYPE *data, Int elms, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (data, elms, visible, keep_cur); return T;} // set list data from continuous memory !! after any change in source data, 'setData' must be called again !!
  283. List& setData (Mems< TYPE> &mems, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (mems, visible, keep_cur); return T;} // set list data from Mems !! after any change in source data, 'setData' must be called again !!
  284. List& setData (Memc< TYPE> &memc, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (memc, visible, keep_cur); return T;} // set list data from Memc !! after any change in source data, 'setData' must be called again !!
  285. List& setData (Memb< TYPE> &memb, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (memb, visible, keep_cur); return T;} // set list data from Memb !! after any change in source data, 'setData' must be called again !!
  286. List& setData (Memx< TYPE> &memx, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (memx, visible, keep_cur); return T;} // set list data from Memx !! after any change in source data, 'setData' must be called again !!
  287. List& setData (Meml< TYPE> &meml, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (meml, visible, keep_cur); return T;} // set list data from Meml !! after any change in source data, 'setData' must be called again !!
  288. T1(KEY) List& setData (Map <KEY, TYPE> &map , C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setData (map , visible, keep_cur); return T;} // set list data from Map !! after any change in source data, 'setData' must be called again !!
  289. List& setDataNode(Memx< TYPE> &memx, C MemPtr<Bool> &visible=null, Bool keep_cur=false) {_List::setDataNode(memx, visible, keep_cur); return T;} // set list data from Memx with children !! after any change in source data, 'setData' must be called again !! TYPE must have a "Memx<TYPE> children" member, for example: "struct TYPE { Memx<TYPE> children; }", in that case 'setDataNode' will add all elements including children recursively
  290. };
  291. /******************************************************************************/
  292. inline Int Elms(C _List &list) {return list.elms();}
  293. /******************************************************************************/