uh-layout 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5eb173000501f534469ab6801bd388d44d309f3
4
- data.tar.gz: 014263683a19cedca1cb588cbc65d5cfaafb0254
3
+ metadata.gz: 3b068d5ba61ed20730d5bd7fc9a28f63db1695d6
4
+ data.tar.gz: da418aef2a7c8a918ed448a8c56a2c4b1dba7cfb
5
5
  SHA512:
6
- metadata.gz: 7a188d97b67af33cacf8466fb7216364ec782b74dc1688d1e27a0a08df31989c656e647a395dc03839b012d6412de4208a37f84a8f1095f20567d82e38a7a646
7
- data.tar.gz: 8003a17f7f10d7a35df2510a9913b104f1ef4295873689d36cc8874926087d5590266588d01fde91fd38d28d5f16418e19f7ad9667192dfc1c9e159336e0a2ca
6
+ metadata.gz: 691f8d9fcef6d65d269de2385a9adecd525a07c92552d4caf664254c6842aa9f5693d3945820da8474ec68e3e35f78866b9b591e41eaf77696422178f3a36dc4
7
+ data.tar.gz: 49c221e1a5e1c9e7c6581b13577ab1016165cdb1bfd4963e6ca78bd589c4c07ed1b873a0d57545c26920cd8f7c2282c6f6492d841118a0da95a1319df7e76b64
data/lib/uh/layout/bar.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  module Uh
2
2
  class Layout
3
3
  class Bar
4
- TEXT_PADDING_X = 1
4
+ TEXT_PADDING_X = 3
5
5
  TEXT_PADDING_Y = 1
6
- COLUMN_MARGIN_TOP = 0
7
- COLUMN_HEIGHT = 2
6
+ BORDER_HEIGHT = 2
7
+ BORDER_PADDING_Y = 0
8
8
  COLUMN_PADDING_X = 1
9
9
  TAG_PADDING_X = 5
10
10
 
@@ -36,9 +36,10 @@ module Uh
36
36
 
37
37
  def redraw
38
38
  draw_background
39
- draw_columns @screen.current_tag.columns,
40
- @screen.current_tag.current_column
41
- draw_tags @screen.tags, @screen.current_tag
39
+ draw_columns BORDER_HEIGHT + BORDER_PADDING_Y,
40
+ @screen.current_tag.columns, @screen.current_tag.current_column
41
+ draw_tags BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
42
+ @screen.tags, @screen.current_tag
42
43
  blit
43
44
  end
44
45
 
@@ -61,7 +62,7 @@ module Uh
61
62
  end
62
63
 
63
64
  def build_geo(layout_geo)
64
- bar_height = text_line_height * 2 + COLUMN_HEIGHT + 1
65
+ bar_height = text_line_height * 2 + BORDER_HEIGHT + BORDER_PADDING_Y
65
66
 
66
67
  Uh::Geo.new(
67
68
  layout_geo.x,
@@ -79,14 +80,6 @@ module Uh
79
80
  @display.font.height + TEXT_PADDING_Y * 2
80
81
  end
81
82
 
82
- def column_widget_text_y
83
- COLUMN_MARGIN_TOP + COLUMN_HEIGHT
84
- end
85
-
86
- def column_widget_height
87
- column_widget_text_y + text_line_height + 1
88
- end
89
-
90
83
  def column_offset_x(column)
91
84
  column.x - x
92
85
  end
@@ -103,28 +96,29 @@ module Uh
103
96
  def draw_background
104
97
  @pixmap.gc_color @colors[:bg]
105
98
  @pixmap.draw_rect 0, 0, width, height
99
+ @pixmap.gc_color active_color
100
+ @pixmap.draw_rect 0, 0, width, BORDER_HEIGHT
106
101
  end
107
102
 
108
- def draw_columns(columns, current_column)
103
+ def draw_columns(y_offset, columns, current_column)
109
104
  columns.each do |column|
110
- draw_column column, column == current_column
105
+ draw_column y_offset, column, column == current_column
111
106
  end
112
107
  end
113
108
 
114
- def draw_column(column, current)
115
- @pixmap.gc_color current ? active_color : @colors[:hi]
116
- @pixmap.draw_rect column_offset_x(column) + COLUMN_PADDING_X,
117
- COLUMN_MARGIN_TOP,
118
- column.width - COLUMN_PADDING_X, COLUMN_HEIGHT
119
- @pixmap.gc_color @colors[:fg]
120
- text_y =
121
- column_widget_text_y + @display.font.ascent + TEXT_PADDING_Y
122
- @pixmap.draw_string column_offset_x(column) + TEXT_PADDING_Y,
123
- text_y, column_text(column)
109
+ def draw_column(y_offset, column, current)
110
+ x_offset = column_offset_x(column)
111
+ if current
112
+ @pixmap.gc_color @colors[:sel]
113
+ @pixmap.draw_rect x_offset, y_offset, column.width, text_line_height
114
+ end
115
+ text_y = y_offset + @display.font.ascent + TEXT_PADDING_Y
116
+ draw_text column_text(column), x_offset, y_offset,
117
+ bg: current ? @colors[:hi] : @colors[:bg]
124
118
  end
125
119
 
126
- def draw_tags(tags, current_tag)
127
- tags.sort_by(&:id).inject(0) do |offset, tag|
120
+ def draw_tags(y_offset, tags, current_tag)
121
+ tags.sort_by(&:id).inject(0) do |x_offset, tag|
128
122
  color = if tag == current_tag
129
123
  active_color
130
124
  elsif tag.clients.any?
@@ -133,24 +127,22 @@ module Uh
133
127
  @colors[:bg]
134
128
  end
135
129
 
136
- offset + draw_text(
137
- tag.id, offset, column_widget_height,
138
- @colors[:fg], color,
139
- TAG_PADDING_X
130
+ x_offset + draw_text(tag.id, x_offset, y_offset,
131
+ bg: color,
132
+ padding_x: TAG_PADDING_X
140
133
  )
141
134
  end
142
135
  end
143
136
 
144
- def draw_text(text, x, y, color_fg = @colors[:fg], color_bg = nil,
145
- padding_x = TEXT_PADDING_X)
137
+ def draw_text(text, x, y, bg: nil, padding_x: TEXT_PADDING_X)
146
138
  text = text.to_s
147
139
  text_width = text.length * @display.font.width + padding_x * 2
148
140
  text_y = y + @display.font.ascent + TEXT_PADDING_Y
149
- if color_bg
150
- @pixmap.gc_color color_bg
141
+ if bg
142
+ @pixmap.gc_color bg
151
143
  @pixmap.draw_rect x, y, text_width, text_line_height
152
144
  end
153
- @pixmap.gc_color color_fg
145
+ @pixmap.gc_color @colors[:fg]
154
146
  @pixmap.draw_string x + padding_x, text_y, text
155
147
  text_width
156
148
  end
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  class Layout
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan