View Single Post
  #1  
Unread 04-22-2013, 07:54 AM
wmrojer wmrojer is offline
The Wary
 
Join Date: Nov 2012
Location: Sweden
Posts: 4
How to make a Window resizable

Since I see that a lot of plugins does not support rezising of there windows, and I really like to be able to resize them I'm writing a short guide on how to make windows resizable.

The Easy way:

First of the window must be of type Turbine.UI.Lotro.Window

This code is simplified and will not make a working window. It just shows the stuff that needed for the resizing to wrok.
Code:
ListWindow = class(Turbine.UI.Lotro.Window);

function ListWindow:Constructor()
	Turbine.UI.Lotro.Window.Constructor(self);

	self:SetSize(Settings.listWidth, Settings.listHeight);
	self:SetMaximumSize(500,1200);
	self:SetMinimumSize(300,200);
	self:SetResizable(true);
       --- Here should be the creation of our child controls
end

function ListWindow:SizeChanged(args)
	Settings.listWidth, Settings.listHeight = self:GetSize();
        -- Resize our child windows
	self.listTree:SetSize(Settings.listWidth-20,  Settings.listHeight-50);
	self.listScrollBar:SetHeight(Settings.listHeight-50);
	self.listScrollBar:SetLeft(Settings.listWidth-20);
end
self:SetMaximumSize(500,1200) defines the largest size we want to allow the window to be resized to.

self:SetMinimumSize(300,1200) defines the smallest size we want to all the window to be resized to.

self:SetResizable(true) is where the magic is. This tells Lotro that the user should be able to resize the window. Mouse pointer will automatically change when positioned over the lower and right border of the window.

function ListWindow:SeizeChanged(args) is where we catch the rezising of the window. Here we need to reposition and resize all our child controls.

It is actually this easy to make a window resizable. The biggest part is the SizeChanged method where we need to resize and reposition our child controls.

Last edited by wmrojer : 04-22-2013 at 08:06 AM.
Reply With Quote