SlabDebug.lua 17 KB

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