Skip to content

Conversation

AGulev
Copy link
Contributor

@AGulev AGulev commented Sep 10, 2025

Added new functions gui.set_layout() and gui.get_layouts():

local ok = gui.set_layout("Portrait")
  if not ok then
      print("Portrait layout not found in this scene")
  end
local layouts = gui.get_layouts()
for id, size in pairs(layouts) do
    print(id, size.x, size.y)
end

A new checkbox, Auto Layout Selection, has been added to Display Profiles. It disables automatic layout detection in the project:

Fix #5889

@AGulev AGulev requested review from vlaaad and britzl September 10, 2025 16:56
(g/defnode DisplayProfilesNode
(inherits resource-node/ResourceNode)
(property auto-layout-selection g/Bool (default true)
(dynamic visible (g/constantly false)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I started, I was sure that there should be a way to avoid property creation and operate directly with protobuf. But I didn't figure out how to do so. Please let me know if it can be simlified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can't be simplified; we typically assign all protobuf fields to node properties.

* @name gui.get_layouts
* @return [type:table] layout_id_hash -> vmath.vector3(width, height, 0)
*/
static int LuaGetLayouts(lua_State* L)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project contains many GUIs, and it might be hard to write a universal logic, that switches layouts without an ability to get all the layouts of the GUI component.

scene->m_DestroyRenderConstantsCallback = params->m_DestroyRenderConstantsCallback;
scene->m_CloneRenderConstantsCallback = params->m_CloneRenderConstantsCallback;
scene->m_OnWindowResizeCallback = params->m_OnWindowResizeCallback;
scene->m_ApplyLayoutCallback = params->m_ApplyLayoutCallback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all of these called something with Callback? Seems strange... Shouldn't it be ApplyLayoutFn, SetMaterialPropertyFn etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't communicate gui<->gamesys another way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean naming: I agree it should be Fn, but I in this PR I just adapt to what we already have

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I was only referring to naming.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rename all the functions all over the code, ofc. but I'm not sure if we should do that as part of that PR

vlaaad
vlaaad previously approved these changes Sep 11, 2025
Copy link
Contributor

@vlaaad vlaaad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor changes look good!

(g/defnode DisplayProfilesNode
(inherits resource-node/ResourceNode)
(property auto-layout-selection g/Bool (default true)
(dynamic visible (g/constantly false)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can't be simplified; we typically assign all protobuf fields to node properties.

@AGulev AGulev merged commit 5eb6396 into dev Sep 11, 2025
24 checks passed
@AGulev AGulev deleted the issue-5889-set_layout branch September 11, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New function: gui.set_layout()
3 participants