Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local color = require("color")
  2. local GUI = require("GUI")
  3. local MineOSInterface = require("MineOSInterface")
  4.  
  5. -------------------------------------------------------------------------------
  6.  
  7. -- Create a tabbed window and register it in MineOS environment
  8. local mainContainer, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 88, 25))
  9.  
  10. -- Add some stuff into it's tab bar
  11. window.tabBar:addItem("Tab 1")
  12. window.tabBar:addItem("Tab 2")
  13. window.tabBar:addItem("Tab 3")
  14. window.tabBar:addItem("Yay another tab")
  15.  
  16. -- Add a single cell layout to window
  17. local layout = window:addChild(GUI.layout(1, 4, window.width, window.height - window.tabBar.height, 1, 1))
  18.  
  19. -- Add a horizontal slider to layout
  20. local slider = layout:addChild(GUI.slider(1, 1, 26, 0x66DB80, 0x0, 0x009200, 0xAAAAAA, 0, 100, 100, false, "Brightness: ", "%"))
  21. -- Attach callback-function .onValueChanged to it
  22. slider.onValueChanged = function()
  23.     -- Calculate "brightness" color value
  24.     local channelValue = math.floor(slider.value / slider.maximumValue * 255)
  25.     local newColor = color.RGBToInteger(channelValue, channelValue, channelValue)
  26.     -- Set new color to all required widgets
  27.     window.backgroundPanel.colors.background = newColor
  28.     window.tabBar.colors.selected.background = newColor
  29.     window.tabBar.colors.selected.text = 0xFFFFFF - newColor
  30.     -- Draw changes on screen
  31.     mainContainer:drawOnScreen()
  32. end
  33.  
  34. -- Call slider callback function once to calculate brightess and draw data on screen
  35. slider.onValueChanged()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement