Class: Blanker

Inherits:
Object
  • Object
show all
Defined in:
lib/blanker.rb,
lib/fake_blanker.rb

Constant Summary collapse

JFrame =
javax.swing.JFrame
JLabel =
javax.swing.JLabel
SW_MINIMIZE =
6
@@use_mouse =
false
@@use_foreground_window_minimize =
false

Class Method Summary collapse

Class Method Details

.blank_full_screen!(text) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/blanker.rb', line 65

def self.blank_full_screen! seconds
  
  if @@use_mouse
    Mouse.single_click_left_mouse_button
  elsif @@use_foreground_window_minimize
    @foreground_hwnd ||= Win32::Screenshot::BitmapMaker.foreground_window
    minimize_hwnd @foreground_hwnd
  else
    # somewhat hacky work around for doze: http://www.experts-exchange.com/Programming/Languages/Java/Q_22977145.html
    @fr.setAlwaysOnTop(false) 
    @fr.setAlwaysOnTop(true)
    @fr.set_location(0,0)
    @fr.repaint # early paint, just in case that helps it pop up faster :)
    if seconds
      @label.set_text "   #{seconds} s" 
    else
      @label.set_text "  Blank section"
    end
  end
end

.minimize_hwnd(hwnd) ⇒ Object



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

def self.minimize_hwnd hwnd
  Win32::Screenshot::BitmapMaker.show_window(hwnd, SW_MINIMIZE)
end

.restore_hwnd(hwnd) ⇒ Object



61
62
63
# File 'lib/blanker.rb', line 61

def self.restore_hwnd hwnd
  Win32::Screenshot::BitmapMaker.restore(hwnd)
end

.shutdownObject



98
99
100
# File 'lib/blanker.rb', line 98

def self.shutdown
  @fr.dispose
end

.startupObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/blanker.rb', line 29

def self.startup
  @fr = JFrame.new("Sensible Cinema blanker-outer overlay window")
  @fr.default_close_operation = JFrame::EXIT_ON_CLOSE
  @fr.set_size(2000, 2000) # ltodo better size ?
  cp = @fr.getContentPane
  cp.setBackground(java.awt.Color.black);      
  
  @label = JLabel.new
  @label.set_text 'blanked'
  @fr.add(@label)
  @label.setForeground(java.awt.Color.white);
  @label.repaint
  @label.revalidate
  
  @fr.set_resizable(false)
  @fr.set_visible(true) # have to do this once, to ever see the thing
  # lodo does this really speed things up to pre-create it? that icon is a bit ugly in the taskbar...
  @fr.repaint
  @fr.set_visible(false) # hide it to start
end

.unblank_full_screen!Object



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/blanker.rb', line 86

def self.unblank_full_screen!
  if @@use_mouse
    Mouse.single_click_left_mouse_button
  elsif @@use_foreground_window_minimize
    restore_hwnd @foreground_hwnd
  else
    # just move it off screen...lodo
    @fr.set_location(-2100, -2100)
    @fr.repaint 0
  end
end