Jump to content

Recommended Posts

Posted

Hello, 

I am working on something that requires a menu and I decided to use a list for it instead of just buttons. The question is how can I change the dimensions of the items in the list (specifically speaking; height).

Basically I have allocated a height H to the list, I have 3 items in the list and I want their total height to equal H without the need to increase the font size of the text (since that will make the text go wider than the width I have assigned the list). 

Any idea how I can go about getting that to work out?

Thank you,

Maytham

Posted

The easiest, most flexible & best solution for a use case like this is to write a custom rendering routine. That gives you complete control over how your list gets rendered. There's a guide on that: https://wiki.ugfx.io/index.php/Creating_a_custom_rendering_routine
However, depending on your needs (if the features provided by the list widget are not exactly what you want), you might want to write a custom widget instead: https://wiki.ugfx.io/index.php/Creating_a_widget

Don't hesitate to ask when you have any questions. We are happy to help wherever we can.

Posted

Hi Joel, 

Thank you for the reply. I looked into the custom rendering routine and had trouble with it. However, I figured that by changing the LST_VERT_PAD value in the gwin_list.c file I can increase the height each item in the list is allocated and keep everything else as is, since the list provides everything I need, creating another widget is also not needed. 

For now, I believe this gets what I needed to do, if I find issues with it, I will resort back to custom rendering. 

Regards,

Posted
11 minutes ago, Maytham said:

I looked into the custom rendering routine and had trouble with it.

What kind of troubles did you have with it? We are happy to help wherever we can.

 

11 minutes ago, Maytham said:

However, I figured that by changing the LST_VERT_PAD value in the gwin_list.c file I can increase the height each item in the list is allocated and keep everything else as is, since the list provides everything I need, creating another widget is also not needed. 

LST_VERT_PAD doesn't specify the height of an item, it's only padding. You will notice the difference once you start using a font with a different height. That is also the reason why the current implementation of the list widget doesn't have an absolute "list item height" setting.

Posted

Hi Joel, 

In terms of troubles with the custom rendering, I just don't really know what I am doing, still learning stuff. 

In terms of the LST_VERT_PAD, yes, I figured it is only adding vertical padding to each item. But this is pretty much all I need. I wanted to increase the padding without the need to increase the font size, and this solution is all I need for my initial question. 

Will ask specific questions about the rendering when/if I end up doing it!!!

Regards,

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
×
×
  • Create New...