Sha256: b90a8c57206c721d52da747c7c359c55dc4cd76b9688ee494c939ee4e2b44f2f

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

if RUBY_PLATFORM !~ /java/
  require_relative 'fake_blanker'
else
  
  require 'java'
  
  class Blanker 
    JFrame = javax.swing.JFrame
    JLabel = javax.swing.JLabel

    def self.startup
      @fr = JFrame.new("blanked section")
      @fr.default_close_operation = JFrame::EXIT_ON_CLOSE
      @fr.set_size(2000, 2000) # ltodo better size coords ?
      
      @label = JLabel.new("  Blank section")
      @fr.add(@label)
      @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...
      unblank_full_screen! # and hide it to start
    end

    def self.blank_full_screen! seconds
      if seconds
        @label.set_text "   #{seconds} s" 
      else
        @label.set_text "  Blank section"
      end
      # 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)
    end
    
    def self.unblank_full_screen!
      # off screen...
      @fr.set_location(-2100, -2100)
    end
    
    def self.shutdown
      @fr.dispose
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensible-cinema-0.9.3 lib/blanker.rb