Class: Crimson::Titlebar

Inherits:
Object
  • Object
show all
Defined in:
lib/crimson/widgets/titlebar.rb

Instance Attribute Summary collapse

Attributes inherited from Object

#added_children, #event_handlers, #id, #node, #removed_children, #tag

Attributes inherited from Model

#local, #observers, #revision_number, #revisions

Instance Method Summary collapse

Methods inherited from Object

#==, #add, #breadth_each, #children, #commit_tree!, #eql?, #find_descendant, #hash, #hidden?, #hide, #inspect, #move, #on, #on_event, #parent, #parent=, #postordered_each, #preordered_each, #remove, #root, #show, #shown?, #siblings, #to_s, #un

Methods inherited from Model

#add_observer, #apply_changes!, #changed?, #changes, #commit!, #master, #modify, #new_changes, #notify_observers, #reload!, #remove_observer, #rollback!

Constructor Details

#initialize(window_title) ⇒ Titlebar

Returns a new instance of Titlebar.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/crimson/widgets/titlebar.rb', line 9

def initialize(window_title)
  super(:div)

  @title = Object.new(:div)
  self.title = window_title
  title.style.color = 'white'
  title.style.fontFamily = 'Verdana'
  title.style.fontWeight = 'bold'
  title.style.textAlign = 'center'
  title.style.margin = 'auto'
  add(title)

  @hide_button = Object.new(:img)
  hide_button.src = 'crimson/icons/hide.png'
  hide_button.style.padding = '10px 20px'
  hide_button.on('mouseenter') do |_data|
    hide_button.style.backgroundColor = 'rgba(0, 0, 0, 0.6)'
    hide_button.commit!
  end
  hide_button.on('mouseleave') do |_data|
    hide_button.style.backgroundColor = 'rgba(0, 0, 0, 0.0)'
    hide_button.commit!
  end
  add(hide_button)

  @resize_button = Object.new(:img)
  resize_button.src = 'crimson/icons/resize.png'
  resize_button.style.padding = '8px 16px'
  resize_button.on('mouseenter') do |_data|
    resize_button.style.backgroundColor = 'rgba(0, 0, 0, 0.6)'
    resize_button.commit!
  end
  resize_button.on('mouseleave') do |_data|
    resize_button.style.backgroundColor = 'rgba(0, 0, 0, 0.0)'
    resize_button.commit!
  end
  add(resize_button)

  @close_button = Object.new(:img)
  close_button.src = 'crimson/icons/close.png'
  close_button.style.padding = '10px 20px'
  close_button.on('mouseenter') do |_data|
    close_button.style.backgroundColor = 'rgba(0, 0, 0, 0.6)'
    close_button.commit!
  end
  close_button.on('mouseleave') do |_data|
    close_button.style.backgroundColor = 'rgba(0, 0, 0, 0.0)'
    close_button.commit!
  end
  add(close_button)

  style.backgroundColor = '#2ecc71'
  style.width = '100%'
  style.height = '35px'
  style.display = 'flex'
  style.userSelect = 'none'
end

Instance Attribute Details

#close_buttonObject (readonly)

Returns the value of attribute close_button.



7
8
9
# File 'lib/crimson/widgets/titlebar.rb', line 7

def close_button
  @close_button
end

#hide_buttonObject (readonly)

Returns the value of attribute hide_button.



7
8
9
# File 'lib/crimson/widgets/titlebar.rb', line 7

def hide_button
  @hide_button
end

#resize_buttonObject (readonly)

Returns the value of attribute resize_button.



7
8
9
# File 'lib/crimson/widgets/titlebar.rb', line 7

def resize_button
  @resize_button
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/crimson/widgets/titlebar.rb', line 7

def title
  @title
end

Instance Method Details

#buttonsObject



71
72
73
# File 'lib/crimson/widgets/titlebar.rb', line 71

def buttons
  [hide_button, resize_button, close_button]
end