Class: Rabbit::Frame

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

Direct Known Subclasses

EmbedFrame

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.



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

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.



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

def force_keep_above
  @force_keep_above
end

#geometryObject

Returns the value of attribute geometry.



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

def geometry
  @geometry
end

#loggerObject (readonly)

Returns the value of attribute logger.



27
28
29
# File 'lib/rabbit/frame.rb', line 27

def logger
  @logger
end

#windowObject (readonly)

Returns the value of attribute window.



27
28
29
# File 'lib/rabbit/frame.rb', line 27

def window
  @window
end

Instance Method Details

#destroyed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rabbit/frame.rb', line 37

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

#fullscreenObject



59
60
61
62
63
# File 'lib/rabbit/frame.rb', line 59

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

#fullscreen?Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
# File 'lib/rabbit/frame.rb', line 79

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

#fullscreen_available?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/rabbit/frame.rb', line 110

def fullscreen_available?
  true
end

#heightObject



51
52
53
# File 'lib/rabbit/frame.rb', line 51

def height
  @window.size[1]
end

#iconify_available?Boolean

Returns:

  • (Boolean)


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

def iconify_available?
  true
end

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



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rabbit/frame.rb', line 95

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)


87
88
89
# File 'lib/rabbit/frame.rb', line 87

def main_window?
  @main_window
end

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



55
56
57
# File 'lib/rabbit/frame.rb', line 55

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

#quitObject



41
42
43
44
45
# File 'lib/rabbit/frame.rb', line 41

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

#toggle_fullscreenObject



71
72
73
74
75
76
77
# File 'lib/rabbit/frame.rb', line 71

def toggle_fullscreen
  if fullscreen?
    unfullscreen
  else
    fullscreen
  end
end

#unfullscreenObject



65
66
67
68
69
# File 'lib/rabbit/frame.rb', line 65

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

#update_title(new_title) ⇒ Object



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

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

#widthObject



47
48
49
# File 'lib/rabbit/frame.rb', line 47

def width
  @window.size[0]
end