Sha256: 06201934966e409dd1e2cc24c2697b5a250cf2427b41ac9c69ad00f7ac8ae31c

Contents?: true

Size: 1.74 KB

Versions: 8

Compression:

Stored size: 1.74 KB

Contents

module PurplishFrame
  module View
    def left
      view_frame.origin.x
    end

    def left=(x)
      f = frame
      f.origin.x = x
      self.frame = f
    end

    def right
      view_frame.origin.x + view_frame.size.width
    end

    def right=(right)
      f = frame
      f.origin.x = right - f.size.width
      self.frame = f
    end

    def center_x
      center.x
    end

    def center_x=(center_x)
      self.center = [center_x, center.y]
    end

    def center_y
      center.y
    end

    def center_y=(center_y)
      self.center = [center.x, center_y]
    end

    def width
      view_frame.size.width
    end

    def width=(width)
      f = frame
      f.size.width = width
      self.frame = f
    end

    def height
      view_frame.size.height
    end

    def size_width_to_fit
      h = height
      sizeToFit
      self.height = h
    end

    def size_width_to_fit_align_right
      x = right
      size_width_to_fit
      self.right = x
    end

    def size_width_to_fit_max(f)
      size_width_to_fit
      self.width = f if width > f
    end

    def size_width_to_fit_min(f)
      size_width_to_fit
      self.width = f if width < f
    end

    def size_height_to_fit
      w = width
      #Otherwise it doesn't expand short UILabel when it's too short to fit longer text
      self.height = 1000
      sizeToFit
      self.width = w
    end

    def size_height_to_fit_align_bottom
      y = bottom
      size_height_to_fit
      self.bottom = y
    end

    def size_height_to_fit_max(f)
      size_height_to_fit
      self.height = f if height > f
    end

    def size_height_to_fit_min(f)
      size_height_to_fit
      self.height = f if height < f
    end

    def inset!(dx, dy)
      self.frame = frame.inset(dx, dy)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
purplish-frame-0.0.12 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.11 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.10 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.9 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.8 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.7 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.6 lib/purplish-frame/ui/view.rb
purplish-frame-0.0.5 lib/purplish-frame/ui/view.rb