mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-05-06 16:08:16 +00:00
28 lines
698 B
Ruby
28 lines
698 B
Ruby
module CyberarmEngine
|
|
class Element
|
|
class Menu < Stack
|
|
def recalculate
|
|
super
|
|
|
|
recalculate_menu
|
|
end
|
|
|
|
def recalculate_menu
|
|
# FIXME: properly find scrollable parent, if any.
|
|
parent_scroll_top = parent&.parent ? parent.parent.scroll_top : 0
|
|
|
|
@x = @parent.x + @parent.styled(:border_thickness_left)
|
|
@y = parent_scroll_top + @parent.y + @parent.height + @parent.styled(:border_thickness_top)
|
|
|
|
@y = (parent_scroll_top + @parent.y + @parent.styled(:border_thickness_top)) - height if @y + height > window.height
|
|
end
|
|
|
|
def show
|
|
recalculate
|
|
|
|
root.gui_state.show_menu(self)
|
|
end
|
|
end
|
|
end
|
|
end
|