antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.42k stars 79 forks source link

Property "property_max_width" on Box #221

Closed MGlolenstine closed 4 years ago

MGlolenstine commented 4 years ago

Is there a way to set maximum width on a Box element? I cannot find a property for setting max width within Box object.

I see that GTK doesn't provide any similar options by itself, but I was wondering if maybe it's possible with the RELM.

I'm currently working with some dynamic widgets (Labels and TextViews), which could overflow the width of the screen (480x272). I'd like to either cut them off or do something else with them.

I'm currently thinking of just setting a negative margin, but I'm unsure if that'll even work or if it would still expand the window. I'll test that out now.

EDIT

I've noticed that there's not even a width parameter for getting the current widget's width.

antoyo commented 4 years ago

As relm is based on gtk, it can only do what gtk can do.

As for your problem, you might have to use some widget specific properties, like this one.

You might find more help on gtk channels.

MGlolenstine commented 4 years ago

You're right. Just wanted to clarify one more thing... Does anything similar to this exist in the RELM? The answer is to get the size by calling gtk_widget_set_size_request.

antoyo commented 4 years ago

Yes, relm can do everything that gtk can do.

If it's not possible using the view! macro, you can also do it in the init_view() method.

MGlolenstine commented 4 years ago

Thanks once again, I'll keep on playing around with it, I might get it working in the end ;)