Class: NSView

Inherits:
Object
  • Object
show all
Includes:
Teacup::Layout, Teacup::View
Defined in:
lib/teacup-osx/core_extensions/ns_view.rb

Overview

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.

Direct Known Subclasses

DummyView

Class Attribute Summary collapse

Attributes included from Teacup::View

#debug, #style_classes, #stylename, #teacup_next_responder

Instance Method Summary collapse

Methods included from Teacup::View

#_teacup_check_stylename, #add_style_class, #add_uniq_constraints, #animate_to_style, #animate_to_stylename, #animate_to_styles, #apply_constraints, #apply_stylename, #get_ns_constraints, #remove_style_class, #reset_constraints, #restyle!, #stylesheet, #stylesheet=, #teacup_subviews, #viewWithStylename, #viewsWithStylename

Methods included from Teacup::Layout

#auto, included, #layout, #stylesheet, #stylesheet=, #subview

Class Attribute Details

.teacup_is_animatingObject (readonly)

Returns the value of attribute teacup_is_animating.



11
12
13
# File 'lib/teacup-osx/core_extensions/ns_view.rb', line 11

def teacup_is_animating
  @teacup_is_animating
end

Instance Method Details

#apply_style_properties(properties) ⇒ Object



24
25
26
# File 'lib/teacup-osx/core_extensions/ns_view.rb', line 24

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

#style(properties) ⇒ Object



28
29
30
31
32
33
# File 'lib/teacup-osx/core_extensions/ns_view.rb', line 28

def style(properties)
  super

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

#teacup_animation(options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/teacup-osx/core_extensions/ns_view.rb', line 14

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

#top_level_viewObject



35
36
37
# File 'lib/teacup-osx/core_extensions/ns_view.rb', line 35

def top_level_view
  self
end