Go to most recent revision |
Compare with Previous |
Blame |
View Log
import "Turbine";
Turbine.Shell.WriteLine("TabCardStack demo");
-- Import the source code. If you would like to move the source code to a
-- different directory, edit the global 'Thurallor' variable.
ThurallorDir = "Thurallor.Common";
import (ThurallorDir .. ".UI.Tabs");
-- First let's create a container window.
testWindow = Turbine.UI.Lotro.Window();
testWindow:SetVisible(true);
testWindow:SetSize(400, 400);
testWindow:SetResizable(true);
-- Create a TabCardStack.
tabCardStack = Thurallor.UI.TabCardStack();
tabCardStack:SetParent(testWindow);
tabCardStack:SetPosition(25, 40);
-- Create a tab to go in the stack.
tabCard1 = Thurallor.UI.TabCard();
tabCard1:SetTabWidth(100);
tabCard1:SetTabLeft(0);
tabCard1:SetTabText("First tab");
-- Create a control to go inside the tab.
insideControl1 = Turbine.UI.Control();
insideControl1:SetSize(500, 500);
insideControl1:SetBackColor(Turbine.UI.Color(1, 0.5, 0, 0));
tabCard1:SetInteriorControl(insideControl1);
tabCard1:SetInteriorAlignment(Turbine.UI.ContentAlignment.MiddleCenter);
-- Create another tab to go in the stack.
tabCard2 = Thurallor.UI.TabCard();
tabCard2:SetTabWidth(120);
tabCard2:SetTabLeft(105);
tabCard2:SetTabText("Second tab");
-- Create a control to go inside the tab.
insideControl2 = Turbine.UI.Label();
insideControl2:SetSize(100, 20);
insideControl2:SetText("Hello!");
insideControl2:SetBackColor(Turbine.UI.Color.DimGray);
tabCard2:SetInteriorControl(insideControl2);
-- Add the tabs to the stack.
tabCardStack:AddTabCard(tabCard1);
tabCardStack:AddTabCard(tabCard2);
-- When the tab's title is clicked, bring the tab to the front.
tabCard1.Click = function(sender, args)
Puts("Clicked " .. sender:GetTabText());
if (args.Button == Turbine.UI.MouseButton.Left) then
tabCardStack:BringToFront(sender);
end
end
tabCard2.Click = tabCard1.Click;
-- When the window resizes, resize the TabCard also.
testWindow.SizeChanged = function(w)
tabCardStack:SetSize(w:GetWidth() - 50, w:GetHeight() - 65);
end
testWindow:SizeChanged();
Go to most recent revision |
Compare with Previous |
Blame
All times are GMT -5. The time now is 02:13 AM.