GDL
About building parametric objects with GDL.
SOLVED!

Array - Boolean Text Input

Lingwisyer
Guru

Hi All,

 

How might you go about creating a scrollable UI list that has 3 columns based on two array parameters? A [i][2] text array, and a [i] boolean array.

 

Lingwisyer_0-1678262737695.png

 

I currently just have it adding lines as it loops based on the top input, but that can hit the limitations of the bounding box. I can extend it to two columns, which would meet the majority of use cases, but I figured it would be better to make it more flexible.

 

 

 

Ling.

 

ps. Though, now I get array dimension errors since I merged one of the parameters into a second column of the array...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Lingwisyer
Guru

I decided to use ui_listitem and got it working within a loop, though it does not preview properly with x/y being inverted... The down side is that my text input is on a second line below the checkbox.

 

 

ui_listfield 1, 10, 60,	432, 200
		ui_listitem		1,		1,	"",							0,	"",	"Storey Levels"
	FOR i = 2 to (sg_noStoreyAbove + 1)
		IF sg_base_toggle then
				IF i = 2 then
						name = "Reference Offset"
					ELSE
						name = sg_name_prefix + STR ("%2.0", i-2)
				endIF
			ELSE
				name = sg_name_prefix + STR ("%2.0", i-1)
		endIF
		ui_listitem{2}	i,				1,	sg_styToSty[i-1],				1,	"",	name
	next i	

		ui_listitem		i+2,			1,	"",								0,	"",	"Basement Levels"
	FOR j = 2 to (sg_noBasement + 1)
		name = sg_nameBase_prefix + STR ("%2.0", j-1)
		ui_listitem{2}	i+2+j*j,		1,	sg_basementHTs[j-1],			1,	"",	name
	next j

 

Lingwisyer_0-1679370592506.png

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

View solution in original post

3 REPLIES 3
MF BIM
Enthusiast

Hello @Lingwisyer ,

 

I have one way of doing it but it isn't really a scrollbar, just the UI redisplaying lines depending on a specific position.

 

Using your 2 array parameters :

ui_array_bool as a 1 dimensional array

ui_array_text as a 2 dimensional array

 

Requires 3 additional parameters :

ui_pos as an integer param

ui_checkbox_plus as a bool parameter

ui_checkbox_minus as a bool parameter

 

In Main script :

 

LINES_MAX = 5 ! Max number of displayed lines
POS = ui_pos
LINES = vardim1(ui_array_bool)

if LINES > LINES_MAX then
	NUM = LINES - LINES_MAX
else
	NUM = LINES_MAX
endif
MINI_UI = -int(NUM)

! Increments, decrements position and update checkboxes
if ui_checkbox_plus then
	POS = POS + 1
	parameters ui_checkbox_plus = 0
ENDIF
if ui_checkbox_minus then
	POS = POS - 1
	parameters ui_checkbox_minus = 0
ENDIF

! Prevents the pos to go out of the min and max possible position
if POS < MINI_UI then
	POS = MINI_UI
else
	if POS > 0 then
		POS = 0
	endif
endif
ui_pos = POS

if not(LINES > LINES_MAX) then
	ui_pos = 0
endif

 

 

In Parameters script :

 

parameters ui_pos = ui_pos

if ui_pos = 0 then lock "ui_checkbox_plus"
if ui_pos = MINI_UI then lock "ui_checkbox_minus"

 

 

In UI script :

 

x0 = 5
y0 = 5
dy = 20

x = x0
y = y0

if LINES > LINES_MAX then
	ROW_MIN = (LINES - LINES_MAX) + ui_pos
else
	ROW_MIN = 0
endif
ROW_MAX = LINES + ui_pos

for row = ROW_MAX-ROW_MIN to 1 step -1
	ACTUAL_ROW = ROW_MAX + 1 - row
	ui_outfield		"Level "+str(ACTUAL_ROW,1,0), x, y : x = x + 50
	ui_infield{3}	ui_array_bool[ACTUAL_ROW], x, y-4, 20, 20 : x = x + 20
	ui_infield{3}	ui_array_text[ACTUAL_ROW][2], x, y-4, 20, 20
	x = x0
	y = y + dy
next row

ui_infield{3}	ui_checkbox_minus, x+100, y0-4, 20, 20
ui_infield{3}	ui_checkbox_plus, x+100, y-dy-4, 20, 20

 

 

https://mfbim.fr | https://youtube.com/@mfbim | https://bsky.app/profile/mfbim.fr
AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro

I made UI that can change display width and height (little buttons on top and left) plus its generate new page if content can't fit current page - look at Material button. Originally object had opportunity to change each letter material in 3D to whatever user choose. Here's only UI script.

Tbh object is messy, because it was made long ago, when i only started learning. That's why some part for UI is in master script and many others issues. But it works, so you can see if you need this kind of approach.

 

link 

 

AC 22, 24 | Win 10
Solution
Lingwisyer
Guru

I decided to use ui_listitem and got it working within a loop, though it does not preview properly with x/y being inverted... The down side is that my text input is on a second line below the checkbox.

 

 

ui_listfield 1, 10, 60,	432, 200
		ui_listitem		1,		1,	"",							0,	"",	"Storey Levels"
	FOR i = 2 to (sg_noStoreyAbove + 1)
		IF sg_base_toggle then
				IF i = 2 then
						name = "Reference Offset"
					ELSE
						name = sg_name_prefix + STR ("%2.0", i-2)
				endIF
			ELSE
				name = sg_name_prefix + STR ("%2.0", i-1)
		endIF
		ui_listitem{2}	i,				1,	sg_styToSty[i-1],				1,	"",	name
	next i	

		ui_listitem		i+2,			1,	"",								0,	"",	"Basement Levels"
	FOR j = 2 to (sg_noBasement + 1)
		name = sg_nameBase_prefix + STR ("%2.0", j-1)
		ui_listitem{2}	i+2+j*j,		1,	sg_basementHTs[j-1],			1,	"",	name
	next j

 

Lingwisyer_0-1679370592506.png

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!