2
0

fst_api.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. Formspec toolkit api 0.0.3
  2. ==========================
  3. Formspec toolkit is a set of functions to create basic ui elements.
  4. File: fst/ui.lua
  5. ----------------
  6. ui.lua adds base ui interface to add additional components to.
  7. ui.add(component) -> returns name of added component
  8. ^ add component to ui
  9. ^ component: component to add
  10. ui.delete(component) -> true/false if a component was deleted or not
  11. ^ remove a component from ui
  12. ^ component: component to delete
  13. ui.set_default(name)
  14. ^ set component to show if not a single component is set visible
  15. ^ name: name of component to set as default
  16. ui.find_by_name(name) --> returns component or nil
  17. ^ find a component within ui
  18. ^ name: name of component to look for
  19. File: fst/tabview.lua
  20. ---------------------
  21. tabview_create(name, size, tabheaderpos) --> returns tabview component
  22. ^ create a new tabview component
  23. ^ name: name of tabview (has to be unique per ui)
  24. ^ size: size of tabview
  25. {
  26. x,
  27. y
  28. }
  29. ^ tabheaderpos: upper left position of tabheader (relative to upper left fs corner)
  30. {
  31. x,
  32. y
  33. }
  34. Class reference tabview:
  35. methods:
  36. - add_tab(tab)
  37. ^ add a tab to this tabview
  38. ^ tab:
  39. {
  40. name = "tabname", -- name of tab to create
  41. caption = "tab caption", -- text to show for tab header. Either a string or a function: (tabview) -> string
  42. cbf_button_handler = function(tabview, fields, tabname, tabdata), -- callback for button events
  43. --TODO cbf_events = function(tabview, event, tabname), -- callback for events
  44. cbf_formspec = function(tabview, name, tabdata), -- get formspec
  45. tabsize =
  46. {
  47. x, -- x width
  48. y -- y height
  49. }, -- special size for this tab (only relevant if no parent for tabview set)
  50. on_change = function(type,old_tab,new_tab) -- called on tab change, type is "ENTER" or "LEAVE"
  51. }
  52. - set_autosave_tab(value)
  53. ^ tell tabview to automatically save current tabname as "tabview_name"_LAST
  54. ^ value: true/false
  55. - set_tab(name)
  56. ^ set's tab to tab named "name", returns true/false on success
  57. ^ name: name of tab to set
  58. - set_global_event_handler(handler)
  59. ^ set a handler to be called prior calling tab specific event handler
  60. ^ handler: function(tabview,event) --> returns true to finish event processing false to continue
  61. - set_global_button_handler(handler)
  62. ^ set a handler to be called prior calling tab specific button handler
  63. ^ handler: function(tabview,fields) --> returns true to finish button processing false to continue
  64. - set_parent(parent)
  65. ^ set parent to attach tabview to. TV's with parent are hidden if their parent
  66. is hidden and they don't set their specified size.
  67. ^ parent: component to attach to
  68. - show()
  69. ^ show tabview
  70. - hide()
  71. ^ hide tabview
  72. - delete()
  73. ^ delete tabview
  74. - set_fixed_size(state)
  75. ^ true/false set to fixed size, variable size
  76. - set_end_button(info)
  77. ^ info is a table with:
  78. * name: button name
  79. * label: tooltip text
  80. * icon: path to icon
  81. * on_click(tabview): callback function
  82. File: fst/dialog.lua
  83. ---------------------
  84. Only one dialog can be shown at a time. If a dialog is closed it's parent is
  85. gonna be activated and shown again.
  86. dialog_create(name, cbf_formspec, cbf_button_handler, cbf_events)
  87. ^ create a dialog component
  88. ^ name: name of component (unique per ui)
  89. ^ cbf_formspec: function to be called to get formspec
  90. function(dialogdata)
  91. ^ cbf_button_handler: function to handle buttons
  92. function(dialog, fields)
  93. ^ cbf_events: function to handle events
  94. function(dialog, event)
  95. messagebox(name, message)
  96. ^ creates a message dialog
  97. Class reference dialog:
  98. methods:
  99. - set_parent(parent)
  100. ^ set parent to attach a dialog to
  101. ^ parent: component to attach to
  102. - show()
  103. ^ show dialog
  104. - hide()
  105. ^ hide dialog
  106. - delete()
  107. ^ delete dialog from ui
  108. members:
  109. - data
  110. ^ variable data attached to this dialog
  111. - parent
  112. ^ parent component to return to on exit
  113. File: fst/buttonbar.lua
  114. -----------------------
  115. buttonbar_create(name, pos, size, bgcolor, cbf_buttonhandler)
  116. ^ create a buttonbar
  117. ^ name: name of component (unique per ui)
  118. ^ pos: position relative to upper left of current shown formspec
  119. {
  120. x,
  121. y
  122. }
  123. ^ size: size of bar
  124. {
  125. x,
  126. y
  127. }
  128. ^ bgcolor: background color as `ColorString`
  129. ^ cbf_buttonhandler: function to be called on button pressed
  130. function(fields)
  131. Class reference buttonbar:
  132. methods:
  133. - add_button(name, caption, image, tooltip)
  134. - show()
  135. ^ show buttonbar
  136. - hide()
  137. ^ hide buttonbar
  138. - delete()
  139. ^ delete buttonbar from ui
  140. Developer doc:
  141. ==============
  142. Skeleton for any component:
  143. {
  144. name = "some id", -- unique id
  145. type = "toplevel", -- type of component
  146. -- toplevel: component can be show without additional components
  147. -- addon: component is an addon to be shown along toplevel component
  148. hide = function(this) end, -- called to hide the component
  149. show = function(this) end, -- called to show the component
  150. delete = function(this) end, -- called to delete component from ui
  151. handle_buttons = function(this,fields) -- called upon button press
  152. handle_events = function(this,event) -- called upon event reception
  153. get_formspec = function(this) -- has to return formspec to be displayed
  154. }