Module: Rabbit::Renderer::Display::Mask

Included in:
ClutterEmbed, DrawingAreaBase
Defined in:
lib/rabbit/renderer/display/mask.rb

Constant Summary collapse

MASK_SIZE_STEP =
0.05

Instance Method Summary collapse

Instance Method Details

#expand_holeObject


14
15
16
17
18
19
20
21
# File 'lib/rabbit/renderer/display/mask.rb', line 14

def expand_hole
  if @mask_size < 0
    @mask_size = MASK_SIZE_STEP
  else
    @mask_size = [@mask_size + MASK_SIZE_STEP, 1.0].min
  end
  set_hole
end

#initialize(*args, &block) ⇒ Object


9
10
11
12
# File 'lib/rabbit/renderer/display/mask.rb', line 9

def initialize(*args, &block)
  super
  init_mask
end

#narrow_holeObject


23
24
25
26
27
28
29
30
# File 'lib/rabbit/renderer/display/mask.rb', line 23

def narrow_hole
  if @mask_size < 0
    @mask_size = 0
  else
    @mask_size = [@mask_size - MASK_SIZE_STEP, 0.0].max
  end
  set_hole
end

#set_holeObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rabbit/renderer/display/mask.rb', line 32

def set_hole
  if @mask_size <= 0
    @window.shape_combine_region(nil)
  else
    _size = size
    w, h = _size.real_width, _size.real_height
    @mask = Cairo::Region.new
    @mask.union!(0, 0, w, h)
    if @mask_size < 1.0
      mw = w * @mask_size
      mh = h * @mask_size
      mx = (w - mw) / 2
      my = (h - mh) / 2
      @mask.subtract!(mx, my, mw, mh)
    else
      @mask.subtract!(0, 0, w - 1, h)
    end
    @window.shape_combine_region(@mask)
  end
  redraw
  update_title # for xfwm
end