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-3.0.1 lib/teacup-osx/core_extensions/ns_view.rb
teacup-3.0.0 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.3.0 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.2.2 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.2.0 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.16 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.15 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.14 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.13 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.12 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.11 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.10 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.9 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.8 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.7 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.6 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.5 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.4 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.3 lib/teacup-osx/core_extensions/ns_view.rb
teacup-2.1.2 lib/teacup-osx/core_extensions/ns_view.rb