SlabDebug.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. --[[
  2. MIT License
  3. Copyright (c) 2019 Mitchell Davis <coding.jackalope@gmail.com>
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. --]]
  20. local Slab = require(SLAB_PATH .. '.Slab')
  21. local DrawCommands = require(SLAB_PATH .. '.Internal.Core.DrawCommands')
  22. local Input = require(SLAB_PATH .. '.Internal.UI.Input')
  23. local Keyboard = require(SLAB_PATH .. '.Internal.Input.Keyboard')
  24. local Mouse = require(SLAB_PATH .. '.Internal.Input.Mouse')
  25. local Region = require(SLAB_PATH .. '.Internal.UI.Region')
  26. local Stats = require(SLAB_PATH .. '.Internal.Core.Stats')
  27. local Style = require(SLAB_PATH .. '.Style')
  28. local Tab = require(SLAB_PATH .. '.Internal.UI.Tab')
  29. local Tooltip = require(SLAB_PATH .. '.Internal.UI.Tooltip')
  30. local Window = require(SLAB_PATH .. '.Internal.UI.Window')
  31. local SlabDebug = {}
  32. local SlabDebug_About = 'SlabDebug_About'
  33. local SlabDebug_Mouse = false
  34. local SlabDebug_Keyboard = false
  35. local SlabDebug_Windows = false
  36. local SlabDebug_Regions = false
  37. local SlabDebug_Tooltip = false
  38. local SlabDebug_DrawCommands = false
  39. local SlabDebug_Performance = false
  40. local SlabDebug_StyleEditor = false
  41. local SlabDebug_Input = false
  42. local SlabDebug_MultiLine = false
  43. local SlabDebug_MultiLine_FileDialog = false
  44. local SlabDebug_MultiLine_FileName = ""
  45. local SlabDebug_MultiLine_Contents = ""
  46. local SlabDebug_Windows_Categories = {"Inspector", "Stack"}
  47. local SlabDebug_Windows_Category = "Inspector"
  48. local SlabDebug_Regions_Selected = ""
  49. local Selected_Window = ""
  50. local Style_EditingColor = nil
  51. local Style_ColorStore = nil
  52. local Style_FileDialog = nil
  53. local function Window_Inspector()
  54. local Ids = Window.GetInstanceIds()
  55. if Slab.BeginComboBox('SlabDebug_Windows_Inspector', {Selected = Selected_Window}) then
  56. for I, V in ipairs(Ids) do
  57. if Slab.TextSelectable(V) then
  58. Selected_Window = V
  59. end
  60. end
  61. Slab.EndComboBox()
  62. end
  63. local Info = Window.GetInstanceInfo(Selected_Window)
  64. for I, V in ipairs(Info) do
  65. Slab.Text(V)
  66. end
  67. end
  68. local function Window_Stack()
  69. local Stack = Window.GetStackDebug()
  70. Slab.Text("Stack: " .. #Stack)
  71. for I, V in ipairs(Stack) do
  72. Slab.Text(V)
  73. end
  74. end
  75. local function DrawCommands_Item(Root, Label)
  76. if type(Root) == "table" then
  77. if Slab.BeginTree(Label) then
  78. for K, V in pairs(Root) do
  79. DrawCommands_Item(V, K)
  80. end
  81. Slab.EndTree()
  82. end
  83. else
  84. Slab.BeginTree(Label .. " " .. tostring(Root), {IsLeaf = true})
  85. end
  86. end
  87. local DrawPerformance_Category = nil
  88. local DrawPerformance_WinX = 50.0
  89. local DrawPerformance_WinY = 50.0
  90. local DrawPerformance_ResetPosition = false
  91. local DrawPerformance_Init = false
  92. local DrawPerformance_W = 200.0
  93. local function DrawPerformance()
  94. if not DrawPerformance_Init then
  95. Slab.EnableStats(true)
  96. DrawPerformance_Init = true
  97. end
  98. Slab.BeginWindow('SlabDebug_Performance', {
  99. Title = "Performance",
  100. X = DrawPerformance_WinX,
  101. Y = DrawPerformance_WinY,
  102. ResetPosition = DrawPerformance_ResetPosition
  103. })
  104. DrawPerformance_ResetPosition = false
  105. local Categories = Stats.GetCategories()
  106. if DrawPerformance_Category == nil then
  107. DrawPerformance_Category = Categories[1]
  108. end
  109. if Slab.BeginComboBox('DrawPerformance_Categories', {Selected = DrawPerformance_Category, W = DrawPerformance_W}) then
  110. for I, V in ipairs(Categories) do
  111. if Slab.TextSelectable(V) then
  112. DrawPerformance_Category = V
  113. end
  114. end
  115. Slab.EndComboBox()
  116. end
  117. if Slab.CheckBox(Slab.IsStatsEnabled(), "Enabled") then
  118. Slab.EnableStats(not Slab.IsStatsEnabled())
  119. end
  120. Slab.SameLine()
  121. if Slab.Button("Flush") then
  122. Slab.FlushStats()
  123. end
  124. Slab.Separator()
  125. if DrawPerformance_Category ~= nil then
  126. local Items = Stats.GetItems(DrawPerformance_Category)
  127. local Pad = 50.0
  128. local MaxW = 0.0
  129. for I, V in ipairs(Items) do
  130. MaxW = math.max(MaxW, Slab.GetTextWidth(V))
  131. end
  132. local CursorX, CursorY = Slab.GetCursorPos()
  133. Slab.SetCursorPos(MaxW * 0.5 - Slab.GetTextWidth("Stat") * 0.5)
  134. Slab.Text("Stat")
  135. local TimeX = MaxW + Pad
  136. local TimeW = Slab.GetTextWidth("Time")
  137. local TimeItemW = Slab.GetTextWidth(string.format("%.4f", 0.0))
  138. Slab.SetCursorPos(TimeX, CursorY)
  139. Slab.Text("Time")
  140. local MaxTimeX = TimeX + TimeW + Pad
  141. local MaxTimeW = Slab.GetTextWidth("Max Time")
  142. Slab.SetCursorPos(MaxTimeX, CursorY)
  143. Slab.Text("Max Time")
  144. local CallCountX = MaxTimeX + MaxTimeW + Pad
  145. local CallCountW = Slab.GetTextWidth("Call Count")
  146. Slab.SetCursorPos(CallCountX, CursorY)
  147. Slab.Text("Call Count")
  148. DrawPerformance_W = CallCountX + CallCountW
  149. Slab.Separator()
  150. for I, V in ipairs(Items) do
  151. local Time = Stats.GetTime(V, DrawPerformance_Category)
  152. local MaxTime = Stats.GetMaxTime(V, DrawPerformance_Category)
  153. local CallCount = Stats.GetCallCount(V, DrawPerformance_Category)
  154. CursorX, CursorY = Slab.GetCursorPos()
  155. Slab.SetCursorPos(MaxW * 0.5 - Slab.GetTextWidth(V) * 0.5)
  156. Slab.Text(V)
  157. Slab.SetCursorPos(TimeX + TimeW * 0.5 - TimeItemW * 0.5, CursorY)
  158. Slab.Text(string.format("%.4f", Time))
  159. Slab.SetCursorPos(MaxTimeX + MaxTimeW * 0.5 - TimeItemW * 0.5, CursorY)
  160. Slab.Text(string.format("%.4f", MaxTime))
  161. Slab.SetCursorPos(CallCountX + CallCountW * 0.5 - Slab.GetTextWidth(CallCount) * 0.5, CursorY)
  162. Slab.Text(CallCount)
  163. end
  164. end
  165. Slab.EndWindow()
  166. end
  167. local function EditColor(Color)
  168. Style_EditingColor = Color
  169. Style_ColorStore = {Color[1], Color[2], Color[3], Color[4]}
  170. end
  171. local function DrawStyleEditor()
  172. Slab.BeginWindow('SlabDebug_StyleEditor', {Title = "Style Editor", AutoSizeWindow = false, AllowResize = true, W = 700.0, H = 500.0})
  173. local X, Y = Slab.GetWindowPosition()
  174. local W, H = Slab.GetWindowSize()
  175. local Style = Slab.GetStyle()
  176. local Names = Style.API.GetStyleNames()
  177. local CurrentStyle = Style.API.GetCurrentStyleName()
  178. Slab.BeginLayout('SlabDebug_StyleEditor_Styles_Layout', {ExpandW = true})
  179. if Slab.BeginComboBox('SlabDebug_StyleEditor_Styles', {Selected = CurrentStyle}) then
  180. for I, V in ipairs(Names) do
  181. if Slab.TextSelectable(V) then
  182. Style.API.SetStyle(V)
  183. end
  184. end
  185. Slab.EndComboBox()
  186. end
  187. if Slab.Button("New") then
  188. Style_FileDialog = 'new'
  189. end
  190. Slab.SameLine()
  191. if Slab.Button("Load") then
  192. Style_FileDialog = 'load'
  193. end
  194. Slab.SameLine()
  195. local SaveDisabled = Style.API.IsDefaultStyle(CurrentStyle)
  196. if Slab.Button("Save", {Disabled = SaveDisabled}) then
  197. Style.API.SaveCurrentStyle()
  198. end
  199. Slab.EndLayout()
  200. Slab.Separator()
  201. Slab.BeginLayout('SlabDebug_StyleEditor_Content_Layout', {Columns = 2, ExpandW = true})
  202. for K, V in pairs(Style) do
  203. if type(V) == "table" and K ~= "Font" and K ~= "API" then
  204. Slab.SetLayoutColumn(1)
  205. Slab.Text(K)
  206. Slab.SetLayoutColumn(2)
  207. local W, H = Slab.GetLayoutSize()
  208. H = Slab.GetTextHeight()
  209. Slab.Rectangle({W = W, H = H, Color = V, Outline = true})
  210. if Slab.IsControlClicked() then
  211. EditColor(V)
  212. end
  213. end
  214. end
  215. for K, V in pairs(Style) do
  216. if type(V) == "number" and K ~= "FontSize" then
  217. Slab.SetLayoutColumn(1)
  218. Slab.Text(K)
  219. Slab.SetLayoutColumn(2)
  220. if Slab.Input('SlabDebug_Style_' .. K, {Text = tostring(V), ReturnOnText = false, NumbersOnly = true}) then
  221. Style[Label] = Slab.GetInputNumber()
  222. end
  223. end
  224. end
  225. Slab.EndLayout()
  226. Slab.EndWindow()
  227. if Style_EditingColor ~= nil then
  228. local Result = Slab.ColorPicker({Color = Style_ColorStore, X = X + W, Y = Y})
  229. Style_EditingColor[1] = Result.Color[1]
  230. Style_EditingColor[2] = Result.Color[2]
  231. Style_EditingColor[3] = Result.Color[3]
  232. Style_EditingColor[4] = Result.Color[4]
  233. if Result.Button ~= "" then
  234. if Result.Button == "OK" then
  235. Style.API.StoreCurrentStyle()
  236. end
  237. if Result.Button == "Cancel" then
  238. Style_EditingColor[1] = Style_ColorStore[1]
  239. Style_EditingColor[2] = Style_ColorStore[2]
  240. Style_EditingColor[3] = Style_ColorStore[3]
  241. Style_EditingColor[4] = Style_ColorStore[4]
  242. end
  243. Style_EditingColor = nil
  244. end
  245. end
  246. if Style_FileDialog ~= nil then
  247. local Type = Style_FileDialog == 'new' and 'savefile' or Style_FileDialog == 'load' and 'openfile' or nil
  248. if Type ~= nil then
  249. local Path = love.filesystem.getRealDirectory(SLAB_PATH) .. "/" .. SLAB_PATH .. "Internal/Resources/Styles"
  250. local Result = Slab.FileDialog({AllowMultiSelect = false, Directory = Path, Type = Type, Filters = {{"*.style", "Styles"}}})
  251. if Result.Button ~= "" then
  252. if Result.Button == "OK" then
  253. if Style_FileDialog == 'new' then
  254. Style.API.CopyCurrentStyle(Result.Files[1])
  255. else
  256. Style.API.LoadStyle(Result.Files[1], true)
  257. end
  258. end
  259. Style_FileDialog = nil
  260. end
  261. else
  262. Style_FileDialog = nil
  263. end
  264. end
  265. end
  266. function SlabDebug.About()
  267. if Slab.BeginDialog(SlabDebug_About, {Title = "About"}) then
  268. Slab.Text("Slab Version: " .. Slab.GetVersion())
  269. Slab.Text("Love Version: " .. Slab.GetLoveVersion())
  270. Slab.NewLine()
  271. Slab.BeginLayout(SlabDebug_About .. '.Buttons_Layout', {AlignX = 'center'})
  272. if Slab.Button("OK") then
  273. Slab.CloseDialog()
  274. end
  275. Slab.EndLayout()
  276. Slab.EndDialog()
  277. end
  278. end
  279. function SlabDebug.OpenAbout()
  280. Slab.OpenDialog(SlabDebug_About)
  281. end
  282. function SlabDebug.Mouse()
  283. Slab.BeginWindow('SlabDebug_Mouse', {Title = "Mouse"})
  284. local X, Y = Mouse.Position()
  285. Slab.Text("X: " .. X)
  286. Slab.Text("Y: " .. Y)
  287. local DeltaX, DeltaY = Mouse.GetDelta()
  288. Slab.Text("Delta X: " .. DeltaX)
  289. Slab.Text("Delta Y: " .. DeltaY)
  290. for I = 1, 3, 1 do
  291. Slab.Text("Button " .. I .. ": " .. (Mouse.IsPressed(I) and "Pressed" or "Released"))
  292. end
  293. Slab.Text("Hot Region: " .. Region.GetHotInstanceId())
  294. Slab.EndWindow()
  295. end
  296. function SlabDebug.Keyboard()
  297. Slab.BeginWindow('SlabDebug_Keyboard', {Title = "Keyboard"})
  298. Slab.BeginLayout('SlabDebug_Keyboard', {Columns = 2})
  299. local Keys = Keyboard.Keys()
  300. for I, V in ipairs(Keys) do
  301. Slab.SetLayoutColumn(1)
  302. Slab.Text(V)
  303. Slab.SetLayoutColumn(2)
  304. Slab.Text(tostring(Keyboard.IsDown(V)))
  305. end
  306. Slab.EndLayout()
  307. Slab.EndWindow()
  308. end
  309. function SlabDebug.Windows()
  310. Slab.BeginWindow('SlabDebug_Windows', {Title = "Windows"})
  311. if Slab.BeginComboBox('SlabDebug_Windows_Categories', {Selected = SlabDebug_Windows_Category}) then
  312. for I, V in ipairs(SlabDebug_Windows_Categories) do
  313. if Slab.TextSelectable(V) then
  314. SlabDebug_Windows_Category = V
  315. end
  316. end
  317. Slab.EndComboBox()
  318. end
  319. if SlabDebug_Windows_Category == "Inspector" then
  320. Window_Inspector()
  321. elseif SlabDebug_Windows_Category == "Stack" then
  322. Window_Stack()
  323. end
  324. Slab.EndWindow()
  325. end
  326. function SlabDebug.Regions()
  327. Slab.BeginWindow('SlabDebug_Regions', {Title = "Regions"})
  328. local Ids = Region.GetInstanceIds()
  329. if Slab.BeginComboBox('SlabDebug_Regions_Ids', {Selected = SlabDebug_Regions_Selected}) then
  330. for I, V in ipairs(Ids) do
  331. if Slab.TextSelectable(V) then
  332. SlabDebug_Regions_Selected = V
  333. end
  334. end
  335. Slab.EndComboBox()
  336. end
  337. local Info = Region.GetDebugInfo(SlabDebug_Regions_Selected)
  338. for I, V in ipairs(Info) do
  339. Slab.Text(V)
  340. end
  341. Slab.EndWindow()
  342. end
  343. function SlabDebug.Tooltip()
  344. Slab.BeginWindow('SlabDebug_Tooltip', {Title = "Tooltip"})
  345. local Info = Tooltip.GetDebugInfo()
  346. for I, V in ipairs(Info) do
  347. Slab.Text(V)
  348. end
  349. Slab.EndWindow()
  350. end
  351. function SlabDebug.DrawCommands()
  352. Slab.BeginWindow('SlabDebug_DrawCommands', {Title = "Draw Commands"})
  353. local Info = DrawCommands.GetDebugInfo()
  354. for K, V in pairs(Info) do
  355. DrawCommands_Item(V, K)
  356. end
  357. Slab.EndWindow()
  358. end
  359. function SlabDebug.Performance()
  360. DrawPerformance()
  361. end
  362. function SlabDebug.Performance_SetPosition(X, Y)
  363. DrawPerformance_WinX = X ~= nil and X or 50.0
  364. DrawPerformance_WinY = Y ~= nil and Y or 50.0
  365. DrawPerformance_ResetPosition = true
  366. end
  367. function SlabDebug.StyleEditor()
  368. DrawStyleEditor()
  369. end
  370. function SlabDebug.Input()
  371. Slab.BeginWindow('SlabDebug_Input', {Title = "Input"})
  372. local Info = Input.GetDebugInfo()
  373. Slab.Text("Focused: " .. Info['Focused'])
  374. Slab.Text("Width: " .. Info['Width'])
  375. Slab.Text("Height: " .. Info['Height'])
  376. Slab.Text("Cursor X: " .. Info['CursorX'])
  377. Slab.Text("Cursor Y: " .. Info['CursorY'])
  378. Slab.Text("Cursor Position: " .. Info['CursorPos'])
  379. Slab.Text("Character: " .. Info['Character'])
  380. Slab.Text("Line Position: " .. Info['LineCursorPos'])
  381. Slab.Text("Line Position Max: " .. Info['LineCursorPosMax'])
  382. Slab.Text("Line Number: " .. Info['LineNumber'])
  383. Slab.Text("Line Length: " .. Info['LineLength'])
  384. local Lines = Info['Lines']
  385. if Lines ~= nil then
  386. Slab.Text("Lines: " .. #Lines)
  387. end
  388. Slab.EndWindow()
  389. end
  390. local SlabDebug_MultiLine_Highlight = {
  391. ['function'] = {1, 0, 0, 1},
  392. ['end'] = {1, 0, 0, 1},
  393. ['if'] = {1, 0, 0, 1},
  394. ['then'] = {1, 0, 0, 1},
  395. ['local'] = {1, 0, 0, 1},
  396. ['for'] = {1, 0, 0, 1},
  397. ['do'] = {1, 0, 0, 1},
  398. ['not'] = {1, 0, 0, 1},
  399. ['while'] = {1, 0, 0, 1},
  400. ['repeat'] = {1, 0, 0, 1},
  401. ['until'] = {1, 0, 0, 1},
  402. ['break'] = {1, 0, 0, 1},
  403. ['else'] = {1, 0, 0, 1},
  404. ['elseif'] = {1, 0, 0, 1},
  405. ['in'] = {1, 0, 0, 1},
  406. ['and'] = {1, 0, 0, 1},
  407. ['or'] = {1, 0, 0, 1},
  408. ['true'] = {1, 0, 0, 1},
  409. ['false'] = {1, 0, 0, 1},
  410. ['nil'] = {1, 0, 0, 1},
  411. ['return'] = {1, 0, 0, 1}
  412. }
  413. local SlabDebug_MultiLine_ShouldHighlight = true
  414. function SlabDebug.MultiLine()
  415. Slab.BeginWindow('SlabDebug_MultiLine', {Title = "Multi-Line Input"})
  416. if Slab.Button("Load") then
  417. SlabDebug_MultiLine_FileDialog = true
  418. end
  419. Slab.SameLine()
  420. if Slab.Button("Save", {Disabled = SlabDebug_MultiLine_FileName == ""}) then
  421. local Handle, Error = io.open(SlabDebug_MultiLine_FileName, "w")
  422. if Handle ~= nil then
  423. Handle:write(SlabDebug_MultiLine_Contents)
  424. Handle:close()
  425. end
  426. end
  427. local ItemW, ItemH = Slab.GetControlSize()
  428. Slab.SameLine()
  429. if Slab.CheckBox(SlabDebug_MultiLine_ShouldHighlight, "Use Lua Highlight", {Size = ItemH}) then
  430. SlabDebug_MultiLine_ShouldHighlight = not SlabDebug_MultiLine_ShouldHighlight
  431. end
  432. Slab.Separator()
  433. Slab.Text("File: " .. SlabDebug_MultiLine_FileName)
  434. if Slab.Input('SlabDebug_MultiLine', {
  435. MultiLine = true,
  436. Text = SlabDebug_MultiLine_Contents,
  437. W = 500.0,
  438. H = 500.0,
  439. Highlight = SlabDebug_MultiLine_ShouldHighlight and SlabDebug_MultiLine_Highlight or nil
  440. }) then
  441. SlabDebug_MultiLine_Contents = Slab.GetInputText()
  442. end
  443. Slab.EndWindow()
  444. if SlabDebug_MultiLine_FileDialog then
  445. local Result = Slab.FileDialog({AllowMultiSelect = false, Type = 'openfile'})
  446. if Result.Button ~= "" then
  447. SlabDebug_MultiLine_FileDialog = false
  448. if Result.Button == "OK" then
  449. SlabDebug_MultiLine_FileName = Result.Files[1]
  450. local Handle, Error = io.open(SlabDebug_MultiLine_FileName, "r")
  451. if Handle ~= nil then
  452. SlabDebug_MultiLine_Contents = Handle:read("*a")
  453. Handle:close()
  454. end
  455. end
  456. end
  457. end
  458. end
  459. local SlabDebug_Tabs = false
  460. local SlabDebug_Tabs_Selected = nil
  461. function SlabDebug.Tabs()
  462. Slab.BeginWindow('SlabDebug.Tabs', {Title = "Tabs"})
  463. local Ids = Tab.GetIds()
  464. if Slab.BeginComboBox('SlabDebug.Tabs.Ids', {Selected = tostring(SlabDebug_Tabs_Selected)}) then
  465. for I, V in ipairs(Ids) do
  466. if Slab.TextSelectable(V) then
  467. SlabDebug_Tabs_Selected = V
  468. end
  469. end
  470. Slab.EndComboBox()
  471. end
  472. local Info = Tab.GetDebugInfo(SlabDebug_Tabs_Selected)
  473. for I, V in ipairs(Info) do
  474. Slab.Text(V)
  475. end
  476. Slab.EndWindow()
  477. end
  478. function SlabDebug.Menu()
  479. if Slab.BeginMenu("Debug") then
  480. if Slab.MenuItem("About") then
  481. SlabDebug.OpenAbout()
  482. end
  483. if Slab.MenuItemChecked("Mouse", SlabDebug_Mouse) then
  484. SlabDebug_Mouse = not SlabDebug_Mouse
  485. end
  486. if Slab.MenuItemChecked("Keyboard", SlabDebug_Keyboard) then
  487. SlabDebug_Keyboard = not SlabDebug_Keyboard
  488. end
  489. if Slab.MenuItemChecked("Windows", SlabDebug_Windows) then
  490. SlabDebug_Windows = not SlabDebug_Windows
  491. end
  492. if Slab.MenuItemChecked("Regions", SlabDebug_Regions) then
  493. SlabDebug_Regions = not SlabDebug_Regions
  494. end
  495. if Slab.MenuItemChecked("Tooltip", SlabDebug_Tooltip) then
  496. SlabDebug_Tooltip = not SlabDebug_Tooltip
  497. end
  498. if Slab.MenuItemChecked("Draw Commands", SlabDebug_DrawCommands) then
  499. SlabDebug_DrawCommands = not SlabDebug_DrawCommands
  500. end
  501. if Slab.MenuItemChecked("Performance", SlabDebug_Performance) then
  502. SlabDebug_Performance = not SlabDebug_Performance
  503. Stats.SetEnabled(SlabDebug_Performance)
  504. end
  505. if Slab.MenuItemChecked("Style Editor", SlabDebug_StyleEditor) then
  506. SlabDebug_StyleEditor = not SlabDebug_StyleEditor
  507. end
  508. if Slab.MenuItemChecked("Input", SlabDebug_Input) then
  509. SlabDebug_Input = not SlabDebug_Input
  510. end
  511. if Slab.MenuItemChecked("Multi-Line", SlabDebug_MultiLine) then
  512. SlabDebug_MultiLine = not SlabDebug_MultiLine
  513. end
  514. if Slab.MenuItemChecked("Tabs", SlabDebug_Tabs) then
  515. SlabDebug_Tabs = not SlabDebug_Tabs
  516. end
  517. Slab.EndMenu()
  518. end
  519. end
  520. function SlabDebug.Begin()
  521. SlabDebug.About()
  522. if SlabDebug_Mouse then
  523. SlabDebug.Mouse()
  524. end
  525. if SlabDebug_Keyboard then
  526. SlabDebug.Keyboard()
  527. end
  528. if SlabDebug_Windows then
  529. SlabDebug.Windows()
  530. end
  531. if SlabDebug_Regions then
  532. SlabDebug.Regions()
  533. end
  534. if SlabDebug_Tooltip then
  535. SlabDebug.Tooltip()
  536. end
  537. if SlabDebug_DrawCommands then
  538. SlabDebug.DrawCommands()
  539. end
  540. if SlabDebug_Performance then
  541. SlabDebug.Performance()
  542. end
  543. if SlabDebug_StyleEditor then
  544. SlabDebug.StyleEditor()
  545. end
  546. if SlabDebug_Input then
  547. SlabDebug.Input()
  548. end
  549. if SlabDebug_MultiLine then
  550. SlabDebug.MultiLine()
  551. end
  552. if SlabDebug_Tabs then
  553. SlabDebug.Tabs()
  554. end
  555. end
  556. return SlabDebug