Ok, so here is what I am doing: I have a research button on the side of the screen. When clicks it expands and displays available items.
NOW I have thought of 2 methods to handle this:
A: Dispose
I have see the method using dispose to dump the root item and kill the tree(not sure if I need to delete all children or suffer or it is actually managed?) This will hide all the items and give the appearance of a collapsed menu.
Cons: everything has to be rebuilt every time I expand the menu
Pros: would be done already.
B: Alter all children to be nonclickable and transparent
The idea is to literally hide the menu, it is still there you just don't know it

Cons: I have to Invalidate all objects in order for their properties to refresh.
Pros: No costly rebuild like the dispose option.
C: Just shrink the window
I noticed that if I resize a chilli window smaller than a child element the window will cut off the child element.
Cons: doesn't work if you resize the window it has to be click to refresh and show elements as properly hidden.
Pros: no display lists, no rebuild :)
So what I am asking you chili gurus is what option should I do. If I can get C working it might be pretty awesome, I mean I have the code for it right here, but I can always do B or A if I really am desperate. Thoughts?
Code: Select all
function widget:GetInfo()
return {
name = "Chili Research Bars",
desc = "",
author = "Smoth",
date = "2011",
license = "PD",
layer = 0,
experimental = false,
enabled = true
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local Chili
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local researchBar
local researchBarSubExp
local butt_show_research
local butt_hide_research
local primer = true
local vsx,vsy = gl.GetViewSizes()
local windowExpanded = false
local WindowExpand
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local function WindowExpand()
if windowExpanded == false then
windowExpanded = true
Spring.Echo("show")
researchBar.width = 350
researchBar.height = 400
--researchBar:Invalidate()
else
windowExpanded = false
researchBar.width = 30
researchBar.height = 70
--researchBar:Invalidate()
Spring.Echo("hide")
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:Initialize()
Chili = WG.Chili
if (not Chili) then
widgetHandler:RemoveWidget()
return
end
researchBar = Chili.Window:New{
color = {1,0,0,0.2},
parent = Chili.Screen0,
left = 0,
y = (vsx * 0.14)+4,
padding = {0,0,0,0},
dockable = true,
clientWidth = 30,
clientHeight = 70,
draggable = true,
resizable = true,
}
butt_show_research = Chili.Button:New{
parent = researchBar,
left = 0,
y = 0,
height = 70,
width = 30,
caption = "",
OnMouseUp = {WindowExpand},
}
researchBarSubExp = Chili.Window:New{
parent = researchBar,
draggable = false,
resizable = false,
x = 30,
width = 350,
height = 400,
}
local gridSet1 = Chili.ScrollPanel:New{
parent = researchBarSubExp,
width = 300,
height = 400,
children = {
Chili.Button:New{
caption = "Tech item",
width = "26%",
height = "20%",
},
Chili.Button:New{
x = "30%",
y = "10%",
width = "20%",
height = "15%",
caption = "item A"
},
Chili.Button:New{
x = "60%",
y = "10%",
width = "20%",
height = "15%",
caption = "item B"
},
}
}
end