Sha256: d9ac69530d1378e7ddee4457f3fef748fe9e3a8860e8d7c47f73190cd4783062

Contents?: true

Size: 1006 Bytes

Versions: 28

Compression:

Stored size: 1006 Bytes

Contents

# Teacup's NSView extensions defines some utility functions for NSView that
# enable a lot of the magic for Teacup::Layout.
#
# Users of teacup should be able to ignore the contents of this file for
# the most part.
class NSView
  include Teacup::Layout
  include Teacup::View

  class << NSView
    attr :teacup_is_animating
  end

  def teacup_animation(options)
    NSAnimationContext.beginGrouping
    NSAnimationContext.currentContext.setDuration(options[:duration]) if options.key?(:duration)
    NSAnimationContext.currentContext.setTimingFunction(options[:timing]) if options.key?(:timing)
    NSView.teacup_is_animating = true
    yield
    NSView.teacup_is_animating = false
    NSAnimationContext.endGrouping
  end

  def apply_style_properties(properties)
    Teacup.apply_hash((NSView.teacup_is_animating ? self.animator : self), properties)
  end

  def style(properties)
    super

    self.setNeedsDisplay(true)
    self.setNeedsLayout(true)
  end

  def top_level_view
    self
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
teacup-2.1.1 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.0 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.6 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.5 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.4 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.3 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.2 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.0.0 lib/teacup-osx/core_extensions/ns_view.rb