It looks like simple issue but I failed to figure out how to do it.
I have a TabControl inside window with two TabItem. One of the TabItem has a fixed size content while the other TabItem's content is changing by the user mode.
I don't want to set the size of the window fixed to the biggest content.
I want the window to extend and shrink by the mode user chooses, but when user chooses a mode, I want both tabs to be the same size.
The TabControl HorizontalElignment was set to Streach.This didn't help because the window width itself changes by the content. Is there any way to set the smaller TabItem size and bind to the Larger one? Or maybe there is other solution?
Related
A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.
I am making a web browser with gtk-rs. I am trying to do a check for fullscreen. I can get the screen size and compare that to the window size, if they are the same it is in fullscreen and I can hide the unnecessary widgets. Though this works, I can only get it to work when I bind it some key event (so when I press a key it will check if the window and screen sizes are the same again). I want to be able to get this to work by simply noticing the window size has changed.
I would like to make sure that no widget in a jface Dialog is ever disappearing.
Scrollability would be an easy solution, but I would prefer a resizable window that is always at least as large as to display all contents. Do you know of any setting to enable this functionality?
In my application, I have two toggle buttons which can change the layout of a window. They will remove or add buttons to it effectively changing the total requested size. Since the Resizeable property of that window is set to false, normally the window would automatically resize to fit it's contents, whether they are larger than before or smaller.
However if I change the layout while the window is hidden, after I make it visible the dimensions of the window won't have changed to fit the layout. It will auto resize after I move it around though.
//Code example
Window.Hide();
ChangeLayout(Window);
Window.Show();
I assume GTK skips to check for size changes while a container is invisible. Is there a way to force it to recalculate it's size?
Thank you.
P.S: It seems that only happens in Windows. Perhaps this is OS related?
I don't have a windows machine to test it on, but try this as a workaround:
Window.Hide();
ChangeLayout(Window);
Window.Unrealize();
Window.Show();
You might also try setting the window resizable before changing the layout and then setting it unresizable:
Window.Hide();
Window.Resizable = true;
ChangeLayout(Window);
Window.Resizable = false;
Window.Show();
I'm new to Macs and iOS, I got my app running on webOS, Android, and WPF/Windows. In all cases the size of, say, a 'widget' to display a bunch of text, can change depending on the dimension of the text to be displayed, as well as the position can be up against another widget. As the text size changes, the position will change so that all the widgets are crammed together nicely.
I've been searching for this capability in IOS4 in books and on-line, and it's starting to look like in iOS, you have to actually calculate the size of the text to be displayed in ViewText and then change the dimensions of ViewText, which of course then bumps other Views around to accommodate this size change. It sounds like a nightmare. Isn't there some other way to do this (like all the other GUIs can do) to size based on content, and to position relative to other Views like stacking them all together whatever size they are?
Same with ScrollView, it looks like the size of the window you actually see has to be manually specified as well, instead of, say, taking up the entire viewable window and then you can populate the ScrollView with a bunch of sub-views, some of which are below the initially viewable area? I tried this in Xcode4, but so far, haven't gotten it to work.
Similarly with creating an object with a NIB and instantiating that NIB onto an existing View, how does it determine where to position this NIB onto the existing screen?
Thanks!
Paul,
For the scrollview you need to set the bounds so it fills the screen or the area you wish it to occupy, it will then automatically generate scrollbars based on the layout within it. In the land of iOS you do have to do extensive layout work such as positioning and sizing your controls but you can also use the UIAutoResize (if I remember correctly) masks such as if they are anchored to a size, fill the area, etc. It's a little complicated to learn initially but you'll get the hang of it.
As for text you just need to use the right control, I believe what you want is a UITextView and set the options on it as needed.
When you view a XIB it's going to layout initially as you have it, again, you need to position your controls AND set their anchors (autoresize masks) so they adjust based on the screen size (phone vs. pad) and orientation: landscape vs. portrait.
HTH