Sha256: 9e57c054b7e8b1d488cb4c1c532de212cfed4ba2f50914f33c9fa9899acbdc1f

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

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
        @y = parent_scroll_top + @parent.y + @parent.height

        @y = (parent_scroll_top + @parent.y) - height if @y + height > window.height
      end

      def show
        recalculate

        root.gui_state.show_menu(self)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cyberarm_engine-0.24.4 lib/cyberarm_engine/ui/elements/menu.rb
cyberarm_engine-0.24.3 lib/cyberarm_engine/ui/elements/menu.rb