I made a spilitter systeam with luaRT.
-- Import the UI library
local ui = require "ui"
-- Create a Window
local window = ui.Window("Splitter Example", 320, 200)
-- Create panels
local leftPanel = ui.Panel(window, 0, 0, 0, 0)
local splitterPanel = ui.Panel(window, 0, 0, 0, 0)
local rightPanel = ui.Panel(window, 0, 0, 0, 0)
-- Set styles for panels
leftPanel.bgcolor = 0x00FF00 -- Green
splitterPanel.bgcolor = 0x0000FF -- Blue
splitterPanel.cursor = "horizontal" -- Horizontal cursor
rightPanel.bgcolor = 0xFF0000 -- Red
-- Track original cursor styles for left and right panels
local leftPanelOldCursor
local rightPanelOldCursor
-- Default panel widths
local leftPanelWidth = 247
local splitterWidth = 8
-- Function to update the layout
function updateLayout()
local windowHeight = window.height
local windowWidth = window.width
-- Adjust left panel dimensions
leftPanel.width = leftPanelWidth
leftPanel.height = windowHeight
-- Adjust splitter panel dimensions and position
splitterPanel.x = leftPanelWidth
splitterPanel.width = splitterWidth
splitterPanel.height = windowHeight
-- Adjust right panel dimensions and position
rightPanel.x = leftPanelWidth + splitterWidth
rightPanel.width = windowWidth - (leftPanelWidth + splitterWidth)
rightPanel.height = windowHeight
end
-- State to track if the splitter is being dragged
local isDraggingSplitter = false
-- Event: Mouse down on the splitter panel
function splitterPanel:onMouseDown(button, x, y)
-- Adjust panel widths while dragging the splitter
if isDraggingSplitter then
leftPanelWidth = leftPanelWidth + splitterWidth + x
updateLayout()
end
-- Store the old cursor styles
leftPanelOldCursor = leftPanel.cursor
rightPanelOldCursor = rightPanel.cursor
-- Set both panels to use a horizontal cursor during dragging
leftPanel.cursor = "horizontal"
rightPanel.cursor = "horizontal"
isDraggingSplitter = true
end
-- Events for spilitter
function splitterPanel:onMouseUp(button, x, y)
-- Restore the original cursor styles
leftPanel.cursor = leftPanelOldCursor
rightPanel.cursor = rightPanelOldCursor
isDraggingSplitter = false
end
function rightPanel:onHover(x, y)
-- Adjust panel widths while dragging the splitter
if isDraggingSplitter == true then
leftPanelWidth = leftPanelWidth + x
updateLayout()
end
end
function rightPanel:onMouseUp(button, x, y)
isDraggingSplitter = false
-- Restore the original cursor styles
leftPanel.cursor = leftPanelOldCursor
rightPanel.cursor = rightPanelOldCursor
end
function leftPanel:onHover(x, y)
-- Adjust panel widths while dragging the splitter
if isDraggingSplitter then
leftPanelWidth = x
updateLayout()
end
end
function leftPanel:onMouseUp(button, x, y)
isDraggingSplitter = false
-- Restore the original cursor styles
leftPanel.cursor = leftPanelOldCursor
rightPanel.cursor = rightPanelOldCursor
end
-- Events for update layout
function window:onResize() updateLayout() end
function window:onMove() updateLayout() end
-- Initialize the layout and show the window
updateLayout()
window:show()
-- Run the UI loop
ui.run(window):wait()