Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row should implement the Component interface #375

Open
colearendt opened this issue Nov 29, 2023 · 11 comments
Open

Row should implement the Component interface #375

colearendt opened this issue Nov 29, 2023 · 11 comments
Labels
discussion v2 will be solved in v2

Comments

@colearendt
Copy link

The Row Render() method is very close to the proper Component interface, but not using a pointer properly

func (r *row) Render(provider core.Provider, cell entity.Cell) {

Which should be:

Render(provider Provider, cell *entity.Cell)

@johnfercher
Copy link
Owner

There is a reason for that, I want to differentiate the objects from Row, Col and Components (Line, Image, Codes and etc). This is to improve lib usage by avoiding the wrong usage by someone passing an Image inside a Col, which will not work.

@johnfercher johnfercher added discussion v2 will be solved in v2 labels Nov 29, 2023
@colearendt
Copy link
Author

colearendt commented Nov 29, 2023

Ahhh interesting. Good to know! So does that mean that nesting rows / columns is not possible or expected? I.e.

Row > Col > Row

There are certain layouts that this recursion is quite helpful for 😄

For what it's worth image-in-col seems to be working for me - am I misunderstanding something?

			col.New(6).Add(
				image.NewFromFile(g.ImageFile, props.Rect{Top: 3, Left: 25, Percent: 70}),
				text.New(g.ImageExplain[0], props.Text{Top: 50, Size: 10, Align: "CM"}),
				text.New(g.ImageExplain[1], props.Text{Top: 56, Size: 10, Align: "CM"}),
			),

@ekosilviawan
Copy link

I also need this nested functionality

@johnfercher
Copy link
Owner

Could you provide a clear example of how do this nested feature would help you and also why is not possible to achieve with the today implementation? currently you can add more than one component inside a col.

@james7272
Copy link

james7272 commented Jan 15, 2024

This is the first page I'm creating so I'm probably missing some simple way of doing it.
V2 beta 12

I'm trying to achieve a layout as below.

image

The page is split into two columns with a header row, Each column has different height rows, the colored blocks. Each row has two equal width columns. If I could nest rows in columns it will be simple to achieve.
e.g For the LH column

col := col.New()
row := row.New(3).Add(text.NewCol(6, "Label"), text.NewCol(6,"Value"))
col.Add(row)   <---
cannot use row (variable of type core.Row) as core.Component value in argument to col.Add: core.Row does not implement core.Component (wrong type for method Render)
		have Render(core.Provider, entity.Cell)
		want Render(core.Provider, *entity.Cell)

@GreatGodApollo
Copy link

This type of nesting feature would be greatly appreciated by me as well. I'm looking to automatically generate inventory labels, adhering to the format we already use:

image

From what I can gather, there is currently no easy way to achieve this layout with the tools currently at our disposal (specifically the background color of the location). If I'm wrong, feel free to correct me.

@arochadaniel
Copy link

I would also appreciate consideration on this feature. I need to use it in this type of layout:

image

Where the empty checkbox is an image, and the paragraph at the right is a slice of rows. So it would go like this:

Row > Col 1 | Col 2
Col 1 > Image
Col 2 > []core.Row

Let me know what you think and if I can do something to help!

@akissa
Copy link

akissa commented May 18, 2024

I think this would solve the issue i have as well of creating rows inside a column to be able to create a rowspan #434

@Fernando-hub527
Copy link
Collaborator

@johnfercher Do you think this feature should be implemented?
Maybe with this feature it is possible to solve this problem #140

@vljukap98
Copy link

Hello, I also think this can be really useful. From your comment @johnfercher I tried doing this:

m.AddRows(row.New().Add(
		col.New(3).
			Add(text.New("test1")).
			Add(text.New("test2")),
		col.New(3).
			Add(text.New("test3")).
			Add(text.New("test4")),
	),

but test1 and test2 are overlapping, also test3 and test4:
image
From your explanation and expectation each "test" should've gone below each other like so:
image

Maybe I'm doing something wrong?

@danielalexis
Copy link

+1 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion v2 will be solved in v2
Projects
None yet
Development

No branches or pull requests

10 participants