Page 1 of 1

LuaGui.overlay and LuaGuiElement.snap_to()

Posted: Wed Sep 21, 2016 3:37 pm
by aubergine18
Ability to create floating panels and align them with other GUI elements. Would be very useful for custom dialogs, drop-downs, etc. For example, we could create re-usable circuit network panels, similar to what the game has, but with our own custom stuff in them.

Would work in much same way as any other panel, only it would appear in a separate 'gui.overlay' layer. The panels default to hidden, but can be shown and aligned with new GUI method such as:

Code: Select all

local overlay = game.players[somePLayer].gui.overlay
overlay.somePopUp.snap_to( anotherGuiElement, position )
overlay.somePopUp.style.visible = true
Where `anotherGuiElement` is any visible element for that player and `position` would be things like "bottom-left" (default), "top-right", "center", "bottom-center" etc.

This way, when a button is clicked we could easily show a popup panel aligned to that button, for example:

Code: Select all

-- note: could also trigger on custom-input events
script.on_event(defines.events.on_gui_click, function(event)
  local popup = game.players[event.player_index].gui.overlay.myPopUp
  popup.snap_to( event.element, "bottom-left" )
  popup.style.visible = not popup.visible
end )
With styling we could use such a feature to add drop-down menus, color pickers, drop down lists, recipe grids, etc...

Re: LuaGui.overlay and LuaGuiElement.snap_to()

Posted: Wed Sep 21, 2016 5:07 pm
by ssilk
Moved from Suggestions to Modding Interface Requests

Re: LuaGui.overlay and LuaGuiElement.snap_to()

Posted: Mon Jul 22, 2019 9:58 am
by Boodals
You can create popups using the LuaGui::screen that is coming out in the next version of 0.17.