Class: Rabbit::Frame

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ScreenInfo
Defined in:
lib/rabbit/frame.rb

Direct Known Subclasses

EmbedFrame

Constant Summary collapse

FALLBACK_LIMIT =
250

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ScreenInfo

default_screen, mm_to_inch, screen_depth, screen_height, screen_height_mm, screen_width, screen_width_mm, screen_x_resolution, screen_y_resolution

Constructor Details

#initialize(logger, canvas) ⇒ Frame

Returns a new instance of Frame.



32
33
34
35
36
37
# File 'lib/rabbit/frame.rb', line 32

def initialize(logger, canvas)
  @logger = logger
  @canvas = canvas
  @geometry = nil
  @force_keep_above = nil
end

Instance Attribute Details

#force_keep_aboveObject

Returns the value of attribute force_keep_above.



30
31
32
# File 'lib/rabbit/frame.rb', line 30

def force_keep_above
  @force_keep_above
end

#geometryObject

Returns the value of attribute geometry.



30
31
32
# File 'lib/rabbit/frame.rb', line 30

def geometry
  @geometry
end

#loggerObject (readonly)

Returns the value of attribute logger.



29
30
31
# File 'lib/rabbit/frame.rb', line 29

def logger
  @logger
end

#windowObject (readonly)

Returns the value of attribute window.



29
30
31
# File 'lib/rabbit/frame.rb', line 29

def window
  @window
end

Instance Method Details

#destroyed?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rabbit/frame.rb', line 39

def destroyed?
  @window.nil? or @window.destroyed?
end

#fullscreenObject



61
62
63
64
65
66
# File 'lib/rabbit/frame.rb', line 61

def fullscreen
  @fullscreen_toggled = false
  @fullscreen = true
  @window.fullscreen
  fallback_fullscreen
end

#fullscreen?Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
# File 'lib/rabbit/frame.rb', line 83

def fullscreen?
  if @window.respond_to?(:fullscreen?)
    @window.fullscreen?
  else
    @fullscreen
  end
end

#fullscreen_available?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/rabbit/frame.rb', line 114

def fullscreen_available?
  true
end

#heightObject



53
54
55
# File 'lib/rabbit/frame.rb', line 53

def height
  @window.size[1]
end

#iconify_available?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/rabbit/frame.rb', line 118

def iconify_available?
  true
end

#init_gui(width, height, main_window, window_type = nil) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rabbit/frame.rb', line 99

def init_gui(width, height, main_window, window_type=nil)
  init_window(width, height, window_type)
  @fullscreen_toggled = false
  @fullscreen = false
  @iconify = false
  @main_window = main_window
  if @main_window
    @window.keep_above = @force_keep_above unless @force_keep_above.nil?
  else
    @window.keep_above = true
  end
  @window.show
  @canvas.post_init_gui
end

#main_window?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/rabbit/frame.rb', line 91

def main_window?
  @main_window
end

#parse(source, callback = nil, &block) ⇒ Object



57
58
59
# File 'lib/rabbit/frame.rb', line 57

def parse(source, callback=nil, &block)
  @canvas.parse(source, callback, &block)
end

#quitObject



43
44
45
46
47
# File 'lib/rabbit/frame.rb', line 43

def quit
  @window.destroy unless destroyed?
  @window = nil
  true
end

#toggle_fullscreenObject



75
76
77
78
79
80
81
# File 'lib/rabbit/frame.rb', line 75

def toggle_fullscreen
  if fullscreen?
    unfullscreen
  else
    fullscreen
  end
end

#unfullscreenObject



68
69
70
71
72
73
# File 'lib/rabbit/frame.rb', line 68

def unfullscreen
  @fullscreen_toggled = false
  @fullscreen = false
  @window.unfullscreen
  fallback_unfullscreen
end

#update_title(new_title) ⇒ Object



95
96
97
# File 'lib/rabbit/frame.rb', line 95

def update_title(new_title)
  @window.title = Utils.unescape_title(new_title)
end

#widthObject



49
50
51
# File 'lib/rabbit/frame.rb', line 49

def width
  @window.size[0]
end