uh-layout 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uh/layout/bar.rb +30 -38
- data/lib/uh/layout/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b068d5ba61ed20730d5bd7fc9a28f63db1695d6
|
|
4
|
+
data.tar.gz: da418aef2a7c8a918ed448a8c56a2c4b1dba7cfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 =
|
|
4
|
+
TEXT_PADDING_X = 3
|
|
5
5
|
TEXT_PADDING_Y = 1
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
40
|
-
@screen.current_tag.current_column
|
|
41
|
-
draw_tags
|
|
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 +
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
text_y =
|
|
121
|
-
|
|
122
|
-
|
|
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 |
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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,
|
|
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
|
|
150
|
-
@pixmap.gc_color
|
|
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
|
|
145
|
+
@pixmap.gc_color @colors[:fg]
|
|
154
146
|
@pixmap.draw_string x + padding_x, text_y, text
|
|
155
147
|
text_width
|
|
156
148
|
end
|
data/lib/uh/layout/version.rb
CHANGED