[solved] two [grid] tags

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

[solved] two [grid] tags

Post by ZombieKnight »

Hi
Can I put two [grid] tags insto my custom dialog?
(So they are on top of each other)
Last edited by ZombieKnight on April 27th, 2024, 2:43 pm, edited 1 time in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2253
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: two [grid] tags

Post by Celtic_Minstrel »

That's what [stacked_widget] is for.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

Thanks!
I can't find it in wiki...
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: two [grid] tags

Post by white_haired_uncle »

Your installation should have data/gui/widget/addon_list.cfg which uses it.

It looks like a stacked_widget contains layers, and each layer is something that looks like a grid.
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2253
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: two [grid] tags

Post by Celtic_Minstrel »

The default mode of a stacked widget is to stack its layers on top of one another. A lot of actual uses of it instead use it as a way to swap between different layers, showing only one layer at a time. I'm not sure if there's an example of its intended use in mainline. On the other hand, it's probably easier to use it that way compared to most of the mainline uses anyway.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

white_haired_uncle wrote: April 26th, 2024, 4:52 am Your installation should have data/gui/widget/addon_list.cfg which uses it.
What do you mean?
I have my add-on om different place.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

Celtic_Minstrel wrote: April 26th, 2024, 4:57 am The default mode of a stacked widget is to stack its layers on top of one another. A lot of actual uses of it instead use it as a way to swap between different layers, showing only one layer at a time. I'm not sure if there's an example of its intended use in mainline. On the other hand, it's probably easier to use it that way compared to most of the mainline uses anyway.
[story]?
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: two [grid] tags

Post by white_haired_uncle »

ZombieKnight wrote: April 26th, 2024, 5:00 am
white_haired_uncle wrote: April 26th, 2024, 4:52 am Your installation should have data/gui/widget/addon_list.cfg which uses it.
What do you mean?
I have my add-on om different place.
I mean relative to wherever you have wesnoth installed. For example

Code: Select all

/usr/share/games/wesnoth/1.16/data/gui/widget/addon_list.cfg
If you're using linux and have mlocate or plocate installed, you could just do

Code: Select all

$ locate addon_list.cfg
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

Ok, where should I look for examples?
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: two [grid] tags

Post by white_haired_uncle »

Celtic_Minstrel wrote: April 26th, 2024, 4:57 am The default mode of a stacked widget is to stack its layers on top of one another. A lot of actual uses of it instead use it as a way to swap between different layers, showing only one layer at a time. I'm not sure if there's an example of its intended use in mainline. On the other hand, it's probably easier to use it that way compared to most of the mainline uses anyway.
Do you have any examples of it being used?

Looking at the public member functions I think I have an idea of more or less what should be supported by the API. I tried wesnoth.print_attributes(), but I'm dumping core at the moment.
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2253
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: two [grid] tags

Post by Celtic_Minstrel »

I'm not aware of any examples of it being used outside of mainline. In mainline it's used in the following windows:

addon_list
mp_create_game
addon_manager
campaign_dialog
campaign_difficulty
game_stats
game_version
mp_create_game
preferences
server_info
story_viewer
title_screen

It's also used in a number of others for a hack that forces a widget to have a minimum size (that is, to prevent a widget from getting any smaller than the specified size). There's a macro in core that implements this hack, GUI_FORCE_WIDGET_MINIMUM_SIZE.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

How do you show two layers at once?
Putting there:

Code: Select all

		T.grid {
			T.row {
				T.column {
					T.stacked_widget{
						id = "narration",
						definition = "default",
						T.layer{...},
						T.layer{...}
Shows only the first defined layer
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: two [grid] tags

Post by white_haired_uncle »

Celtic_Minstrel wrote: April 26th, 2024, 1:59 pm
It's also used in a number of others for a hack that forces a widget to have a minimum size (that is, to prevent a widget from getting any smaller than the specified size). There's a macro in core that implements this hack, GUI_FORCE_WIDGET_MINIMUM_SIZE.
That sounds like exactly what I wanted it for. I was thinking if I used blank.png scaled to some size one on layer, then my actual data (on a different layer) couldn't be shrunk to near useless by another row which I can't seem to stop from growing out of control (described as issue#2 at):

viewtopic.php?t=58000

I'll have to look into that macro and see if I can do anything with it.

I found .cfg files that use stacked_widget, but I was hoping to find corresponding lua files that manipulate the widget so I could determine of its properties (select_layer(s), layer_selected, etc).
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 203
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: two [grid] tags

Post by ZombieKnight »

That's what I'm looking for... how to select layers?
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: two [grid] tags

Post by white_haired_uncle »

ZombieKnight wrote: April 26th, 2024, 2:41 pm How do you show two layers at once?
Putting there:

Code: Select all

		T.grid {
			T.row {
				T.column {
					T.stacked_widget{
						id = "narration",
						definition = "default",
						T.layer{...},
						T.layer{...}
Shows only the first defined layer
I don't know, but I did figure out that

dialog.narration.selected_index=2

would cause it to display your second layer INSTEAD of the first.

And now I'm wondering if you can use something like dialog.narration:add_item() to add layers. Completely off topic, but I either mess with that or mow the lawn.
Speak softly, and carry Doombringer.
Post Reply