Sha256: 8b449dad0826ae05efd42eb692e8915a19ccaa2976888b3fa7ae26d33868316a

Contents?: true

Size: 992 Bytes

Versions: 10

Compression:

Stored size: 992 Bytes

Contents

class AuthorEngine
  class View
    include Support
    include AuthorEngine::Part::Colors

    def self.instance
      @instance
    end

    def self.instance=(klass)
      @instance = klass
    end

    attr_reader :x, :y, :width, :height, :background
    def initialize(x:, y:, width:, height:, background: Gosu::Color::BLACK)
      @x, @y, @width, @height, @background = x, y, width, height, background

      @x_padding = Button::PADDING * window.scale_x
      @y_padding = Button::PADDING * window.scale_y

      self.class.instance = self
      setup
    end

    def setup
    end

    def focus
    end

    def blur
    end

    def draw
      Gosu.draw_rect(@x, @y, @width, @height, @background)
    end

    def mouse_inside_view?
      if window.mouse_x.between?(@x, @x+@width)
        if window.mouse_y.between?(@y, @y+@height)
          return true
        end
      end
    end

    def update
    end

    def button_down(id)
    end

    def button_up(id)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
author_engine-0.9.0 lib/author_engine/view.rb
author_engine-0.8.0 lib/author_engine/view.rb
author_engine-0.7.0 lib/author_engine/view.rb
author_engine-0.6.1 lib/author_engine/view.rb
author_engine-0.6.0 lib/author_engine/view.rb
author_engine-0.5.0 lib/author_engine/view.rb
author_engine-0.4.0 lib/author_engine/view.rb
author_engine-0.3.1 lib/author_engine/view.rb
author_engine-0.3.0 lib/author_engine/view.rb
author_engine-0.1.0 lib/author_engine/view.rb