Jump to content

clip text/image in scrollpane


Fist

Recommended Posts

Posted

how can i clip text/image in scrollpane that if it's too long it doesn't go further than scrollpane width but instead it goes down in height?

Posted (edited)
5 minutes ago, Mr.Loki said:

If i wasn't clear enough sorry, but i mean't that i'm using guiCreateScrollPane and i want text/image that is bigger in width than actual scroll pane go down instead, like clip them.

Edited by Fist
Posted (edited)

Oh, you want to wrap the GUI elements not clip.

Try using the size of the scrollpane to decide whether the element should be placed under.

Edited by Mr.Loki
Posted
1 minute ago, Mr.Loki said:

Oh, you want to wrap the GUI elements not clip.

try using the size off the scrollpane to decide whether the element should be placed under.

any examples? 

Posted
8 minutes ago, Mr.Loki said:

Oh wait you are using cegui lol use the scrollpane properties here there should be something to sort them.

can't find any, i don't think there is such property as that or i can't find it.

Posted

You should just calculate the X and Y positions of the elements.

 

local scrollPane = guiCreateScrollPane(500, 200, 500, 300, false)
local things = {
	{"Test Test Test Test", "text"},
	{"test.png", "image", 100, 50} 
}

function drawThings()
	local x, y = 0, 0
	local nextY = 0
	for i, k in ipairs(things) do
		if k[2] == "text" then
			if x + dxGetTextWidth(k[1]) > 300 then
				x = 0
				y = nextY
			end
			guiCreateLabel(x, y, dxGetTextWidth(k[1]), 15, false, scrollPane)
			if nextY < y + 15 then
				nextY = nextY + 15
			end
		elseif k[2] == "image" then
			if x + k[3] > 300 then
				x = 0
				y = nextY
			end
			guiCreateStaticImage(x, y, k[3], k[4], k[1], false, scrollPane)
			if nextY < y + k[4] then
				nextY = y + k[4]
			end
		end
	end
end

Should work, not tested tho.

Posted
10 minutes ago, NeXuS™ said:

You should just calculate the X and Y positions of the elements.

 


local scrollPane = guiCreateScrollPane(500, 200, 500, 300, false)
local things = {
	{"Test Test Test Test", "text"},
	{"test.png", "image", 100, 50} 
}

function drawThings()
	local x, y = 0, 0
	local nextY = 0
	for i, k in ipairs(things) do
		if k[2] == "text" then
			if x + dxGetTextWidth(k[1]) > 300 then
				x = 0
				y = nextY
			end
			guiCreateLabel(x, y, dxGetTextWidth(k[1]), 15, false, scrollPane)
			if nextY < y + 15 then
				nextY = nextY + 15
			end
		elseif k[2] == "image" then
			if x + k[3] > 300 then
				x = 0
				y = nextY
			end
			guiCreateStaticImage(x, y, k[3], k[4], k[1], false, scrollPane)
			if nextY < y + k[4] then
				nextY = y + k[4]
			end
		end
	end
end

Should work, not tested tho.

doesn't work

Posted
local guiWindow = guiCreateWindow(500, 200, 500, 300, "Test panel", false) 
local scrollPane = guiCreateScrollPane(0, 20, 500, 300, false, guiWindow)
local things = {
	{"Test Test Test Test", "text"},
	{"Test2 Test2 Test2 Test2", "text"},
	{"Test3 Test3 Test3 Test3", "text"},
	{"Test4 Test4 Test4 Test4", "text"}
}

function drawThings()
	local x, y = 0, 0
	local nextY = 0
	for i, k in ipairs(things) do
		if k[2] == "text" then
			if x + dxGetTextWidth(k[1]) > 500 then
				x = 0
				y = nextY
			end
			guiCreateLabel(x, y, dxGetTextWidth(k[1]), 15, k[1], false, scrollPane)
			if nextY < y + 15 then
				nextY = nextY + 15
			end
			x = x + dxGetTextWidth(k[1]) + 10
		elseif k[2] == "image" then
			if x + k[3] > 500 then
				x = 0
				y = nextY
			end
			guiCreateStaticImage(x, y, k[3], k[4], k[1], false, scrollPane)
			if nextY < y + k[4] then
				nextY = y + k[4]
			end
			x = x + k[3] + 10
		end
	end
end
drawThings()

This one is tested with texts, and worked. Can ya test it with pictures?

  • Like 1
Posted
3 minutes ago, NeXuS™ said:

local guiWindow = guiCreateWindow(500, 200, 500, 300, "Test panel", false) 
local scrollPane = guiCreateScrollPane(0, 20, 500, 300, false, guiWindow)
local things = {
	{"Test Test Test Test", "text"},
	{"Test2 Test2 Test2 Test2", "text"},
	{"Test3 Test3 Test3 Test3", "text"},
	{"Test4 Test4 Test4 Test4", "text"}
}

function drawThings()
	local x, y = 0, 0
	local nextY = 0
	for i, k in ipairs(things) do
		if k[2] == "text" then
			if x + dxGetTextWidth(k[1]) > 500 then
				x = 0
				y = nextY
			end
			guiCreateLabel(x, y, dxGetTextWidth(k[1]), 15, k[1], false, scrollPane)
			if nextY < y + 15 then
				nextY = nextY + 15
			end
			x = x + dxGetTextWidth(k[1]) + 10
		elseif k[2] == "image" then
			if x + k[3] > 500 then
				x = 0
				y = nextY
			end
			guiCreateStaticImage(x, y, k[3], k[4], k[1], false, scrollPane)
			if nextY < y + k[4] then
				nextY = y + k[4]
			end
			x = x + k[3] + 10
		end
	end
end
drawThings()

This one is tested with texts, and worked. Can ya test it with pictures?

Yup works!!! Thank you man alot.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...