I can think of two possibilities.
First, you could sense when the scrollable control moves, and then recalculate for each icon whether it should be visible. Example:
Code:
import "Turbine.UI";
import "Turbine.UI.Lotro";
window = Turbine.UI.Window();
window:SetSize(100, 100);
window:SetPosition(100, 100);
window:SetBackColor(Turbine.UI.Color(0,0,0));
window:SetVisible(true);
listbox = Turbine.UI.ListBox();
listbox:SetSize(90, 90);
listbox:SetBackColor(Turbine.UI.Color.Green);
listbox:SetParent(window);
inside = Turbine.UI.Control();
inside:SetSize(320, 320);
listbox:AddItem(inside);
hscroll = Turbine.UI.Lotro.ScrollBar();
hscroll:SetOrientation(Turbine.UI.Orientation.Horizontal);
hscroll:SetParent(window);
hscroll:SetPosition(0, 90);
hscroll:SetSize(90, 10);
vscroll = Turbine.UI.Lotro.ScrollBar();
vscroll:SetOrientation(Turbine.UI.Orientation.Vertical);
vscroll:SetParent(window);
vscroll:SetPosition(90, 0);
vscroll:SetSize(10, 90);
listbox:SetHorizontalScrollBar(hscroll);
listbox:SetVerticalScrollBar(vscroll);
icon = {};
for i = 1, 20, 1 do
icon[i] = Turbine.UI.Control();
icon[i]:SetParent(inside);
icon[i]:SetSize(32, 32);
icon[i]:SetBackground(0x4113a302);
icon[i]:SetStretchMode(1);
icon[i]:SetSize(16, 16);
icon[i]:SetPosition(16*(i-1),16*(i-1));
end
-- Each time the user moves one of the scrollbar, recalculate for each icon whether it should be visible
inside.PositionChanged = function()
x, y = listbox:PointToScreen(0, 0);
w, h = listbox:GetSize();
for i = 1, 20 do
left, top = inside:PointToScreen(icon[i]:GetPosition());
right, bottom = left + 16, top + 16;
if ((left < x) or (right > x + w) or (top < y) or (bottom > y + h)) then
icon[i]:SetVisible(false);
else
icon[i]:SetVisible(true);
end
end
end
Or alternatively, you could leave the icons unstretched, and instead, stretch the scrollable control that contains them. Example:
Code:
import "Turbine.UI";
import "Turbine.UI.Lotro";
window = Turbine.UI.Window();
window:SetSize(100, 100);
window:SetPosition(100, 100);
window:SetBackColor(Turbine.UI.Color(0,0,0));
window:SetVisible(true);
listbox = Turbine.UI.ListBox();
listbox:SetSize(180, 180);
listbox:SetBackColor(Turbine.UI.Color.Green);
listbox:SetParent(window);
inside = Turbine.UI.Control();
inside:SetSize(640, 640);
listbox:AddItem(inside);
hscroll = Turbine.UI.Lotro.ScrollBar();
hscroll:SetOrientation(Turbine.UI.Orientation.Horizontal);
hscroll:SetParent(window);
hscroll:SetPosition(0, 90);
hscroll:SetSize(90, 10);
vscroll = Turbine.UI.Lotro.ScrollBar();
vscroll:SetOrientation(Turbine.UI.Orientation.Vertical);
vscroll:SetParent(window);
vscroll:SetPosition(90, 0);
vscroll:SetSize(10, 90);
listbox:SetHorizontalScrollBar(hscroll);
listbox:SetVerticalScrollBar(vscroll);
icon = {};
for i = 1, 20, 1 do
icon[i] = Turbine.UI.Control();
icon[i]:SetParent(inside);
icon[i]:SetSize(32, 32);
icon[i]:SetBackground(0x4113a302);
icon[i]:SetPosition(32*(i-1),32*(i-1));
end
listbox:SetStretchMode(1);
listbox:SetSize(90, 90);