Module: MiniGL::FormUtils
- Defined in:
- lib/minigl/forms.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.check_anchor(anchor, x, y, w, h, area_w = G.window.width, area_h = G.window.height) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/minigl/forms.rb', line 5 def self.check_anchor(anchor, x, y, w, h, area_w = G.window.width, area_h = G.window.height) if anchor case anchor when /^top(_center)?$|^north$/i then anchor_alias = :top_center; x += (area_w - w) / 2 when /^top_right$|^northeast$/i then anchor_alias = :top_right; x = area_w - w - x when /^(center_)?left$|^west$/i then anchor_alias = :center_left; y += (area_h - h) / 2 when /^center$/i then anchor_alias = :center; x += (area_w - w) / 2; y += (area_h - h) / 2 when /^(center_)?right$|^east$/i then anchor_alias = :center_right; x = area_w - w - x; y += (area_h - h) / 2 when /^bottom_left$|^southwest$/i then anchor_alias = :bottom_left; y = area_h - h - y when /^bottom(_center)?$|^south$/i then anchor_alias = :bottom_center; x += (area_w - w) / 2; y = area_h - h - y when /^bottom_right$|^southeast$/i then anchor_alias = :bottom_right; x = area_w - w - x; y = area_h - h - y else anchor_alias = :top_left end else anchor_alias = :top_left end [anchor_alias, x, y] end |