mirror of
https://github.com/kepler155c/opus
synced 2025-01-05 21:30:28 +00:00
ui grid header sizing
This commit is contained in:
parent
712ffdb97c
commit
25031bfdc2
@ -1256,6 +1256,7 @@ UI.Grid.defaults = {
|
|||||||
index = 1,
|
index = 1,
|
||||||
inverseSort = false,
|
inverseSort = false,
|
||||||
disableHeader = false,
|
disableHeader = false,
|
||||||
|
headerHeight = 1,
|
||||||
marginRight = 0,
|
marginRight = 0,
|
||||||
textColor = colors.white,
|
textColor = colors.white,
|
||||||
textSelectedColor = colors.white,
|
textSelectedColor = colors.white,
|
||||||
@ -1300,7 +1301,7 @@ function UI.Grid:setParent()
|
|||||||
if self.disableHeader then
|
if self.disableHeader then
|
||||||
self.pageSize = self.height
|
self.pageSize = self.height
|
||||||
else
|
else
|
||||||
self.pageSize = self.height - 1
|
self.pageSize = self.height - self.headerHeight
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1311,7 +1312,7 @@ function UI.Grid:resize()
|
|||||||
if self.disableHeader then
|
if self.disableHeader then
|
||||||
self.pageSize = self.height
|
self.pageSize = self.height
|
||||||
else
|
else
|
||||||
self.pageSize = self.height - 1
|
self.pageSize = self.height - self.headerHeight
|
||||||
end
|
end
|
||||||
self:adjustWidth()
|
self:adjustWidth()
|
||||||
end
|
end
|
||||||
@ -1506,7 +1507,11 @@ function UI.Grid:drawHeadings()
|
|||||||
x = x + col.cw + 1
|
x = x + col.cw + 1
|
||||||
]]
|
]]
|
||||||
end
|
end
|
||||||
self:write(1, 1, sb:get(), self.headerBackgroundColor, self.headerTextColor)
|
local y = math.ceil(self.headerHeight / 2)
|
||||||
|
if self.headerHeight > 1 then
|
||||||
|
self:clear(self.headerBackgroundColor)
|
||||||
|
end
|
||||||
|
self:write(1, y, sb:get(), self.headerBackgroundColor, self.headerTextColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Grid:sortCompare(a, b)
|
function UI.Grid:sortCompare(a, b)
|
||||||
@ -1524,7 +1529,7 @@ function UI.Grid:drawRows()
|
|||||||
local sb = UI.StringBuffer(self.width)
|
local sb = UI.StringBuffer(self.width)
|
||||||
|
|
||||||
if not self.disableHeader then
|
if not self.disableHeader then
|
||||||
y = y + 1
|
y = y + self.headerHeight
|
||||||
end
|
end
|
||||||
|
|
||||||
local lastRow = math.min(startRow + self.pageSize - 1, #self.sorted)
|
local lastRow = math.min(startRow + self.pageSize - 1, #self.sorted)
|
||||||
@ -1638,7 +1643,7 @@ function UI.Grid:eventHandler(event)
|
|||||||
event.type == 'mouse_rightclick' or
|
event.type == 'mouse_rightclick' or
|
||||||
event.type == 'mouse_doubleclick' then
|
event.type == 'mouse_doubleclick' then
|
||||||
if not self.disableHeader then
|
if not self.disableHeader then
|
||||||
if event.y == 1 then
|
if event.y <= self.headerHeight then
|
||||||
local col = 2
|
local col = 2
|
||||||
for _,c in ipairs(self.columns) do
|
for _,c in ipairs(self.columns) do
|
||||||
if event.x < col + c.cw then
|
if event.x < col + c.cw then
|
||||||
@ -1657,7 +1662,7 @@ function UI.Grid:eventHandler(event)
|
|||||||
end
|
end
|
||||||
local row = self:getStartRow() + event.y - 1
|
local row = self:getStartRow() + event.y - 1
|
||||||
if not self.disableHeader then
|
if not self.disableHeader then
|
||||||
row = row - 1
|
row = row - self.headerHeight
|
||||||
end
|
end
|
||||||
if row > 0 and row <= Util.size(self.values) then
|
if row > 0 and row <= Util.size(self.values) then
|
||||||
self:setIndex(row)
|
self:setIndex(row)
|
||||||
@ -1719,7 +1724,7 @@ end
|
|||||||
function UI.ScrollingGrid:getViewArea()
|
function UI.ScrollingGrid:getViewArea()
|
||||||
local y = 1
|
local y = 1
|
||||||
if not self.disableHeader then
|
if not self.disableHeader then
|
||||||
y = 2
|
y = y + self.headerHeight
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
static = true, -- the container doesn't scroll
|
static = true, -- the container doesn't scroll
|
||||||
|
@ -50,11 +50,11 @@ local page = UI.Page {
|
|||||||
event = 'hide-action',
|
event = 'hide-action',
|
||||||
},
|
},
|
||||||
button = UI.Button {
|
button = UI.Button {
|
||||||
x = -10, y = 4,
|
x = -10, y = 3,
|
||||||
text = ' Begin ', event = 'begin',
|
text = ' Begin ', event = 'begin',
|
||||||
},
|
},
|
||||||
output = UI.Embedded {
|
output = UI.Embedded {
|
||||||
y = 6, ey = -2, x = 2, ex = -2,
|
y = 5, ey = -2, x = 2, ex = -2,
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
|
Loading…
Reference in New Issue
Block a user