Skip to content

Commit cbce486

Browse files
authored
Styles/Gtk: add ProgressBar (#842)
1 parent 55587d5 commit cbce486

File tree

3 files changed

+89
-7
lines changed

3 files changed

+89
-7
lines changed

demo/Views/ControlsView.vala

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,37 @@ public class ControlsView : DemoPage {
126126

127127
var scale_header = new Granite.HeaderLabel ("Scale");
128128

129-
var hscale = new Gtk.Scale.with_range (HORIZONTAL, 0, 100, 1) {
129+
var hscale = new Gtk.Scale.with_range (HORIZONTAL, 0, 1, 0.01) {
130130
hexpand = true
131131
};
132-
hscale.adjustment.value = 50;
132+
hscale.adjustment.value = 0.5;
133133

134-
var vscale = new Gtk.Scale.with_range (VERTICAL, 0, 100, 1) {
134+
var hprogressbar = new Gtk.ProgressBar ();
135+
hscale.adjustment.bind_property ("value", hprogressbar, "fraction", SYNC_CREATE);
136+
137+
var hcontrol_box = new Granite.Box (VERTICAL, DOUBLE);
138+
hcontrol_box.append (hscale);
139+
hcontrol_box.append (hprogressbar);
140+
141+
var vscale = new Gtk.Scale.with_range (VERTICAL, 0, 1, 0.01) {
135142
height_request = 128,
136143
has_origin = false
137144
};
138-
vscale.adjustment.value = 50;
145+
vscale.adjustment.value = 0.5;
146+
147+
var vprogressbar = new Gtk.ProgressBar () {
148+
inverted = true,
149+
orientation = VERTICAL
150+
};
151+
vscale.adjustment.bind_property ("value", vprogressbar, "fraction", SYNC_CREATE);
152+
153+
var vcontrol_box = new Granite.Box (HORIZONTAL, DOUBLE);
154+
vcontrol_box.append (vscale);
155+
vcontrol_box.append (vprogressbar);
139156

140-
var scale_box = new Granite.Box (HORIZONTAL);
141-
scale_box.append (hscale);
142-
scale_box.append (vscale);
157+
var scale_box = new Granite.Box (HORIZONTAL, DOUBLE);
158+
scale_box.append (hcontrol_box);
159+
scale_box.append (vcontrol_box);
143160

144161
var box = new Granite.Box (VERTICAL, NONE) {
145162
halign = CENTER,

lib/Styles/Gtk/Index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@import 'ListBox.scss';
99
@import 'ListView.scss';
1010
@import 'Popover.scss';
11+
@import 'ProgressBar.scss';
1112
@import 'Scale.scss';
1213
@import 'ScrolledWindow.scss';
1314
@import 'Scrollbar.scss';

lib/Styles/Gtk/ProgressBar.scss

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
progressbar {
2+
$trough-width: rem(9px);
3+
4+
progress {
5+
background-color: #{'@accent_color'};
6+
@include border-interactive-roundrect;
7+
8+
&:backdrop {
9+
filter: grayscale(100%);
10+
}
11+
}
12+
13+
trough {
14+
@include trough;
15+
@include border-interactive-roundrect;
16+
17+
min-height: $trough-width;
18+
min-width: $trough-width;
19+
}
20+
21+
&.horizontal {
22+
progress {
23+
min-height: $trough-width;
24+
25+
&:not(.pulse) {
26+
animation: progress 1.5s easing() infinite;
27+
background-image:
28+
linear-gradient(
29+
to right,
30+
rgba(white, 0),
31+
rgba(white, 0.25) 60%,
32+
rgba(white, 0)
33+
);
34+
background-repeat: no-repeat;
35+
background-size: 48px 100%;
36+
37+
&.right {
38+
animation-direction: reverse;
39+
}
40+
41+
&:backdrop {
42+
animation: none;
43+
background-image: none;
44+
}
45+
}
46+
}
47+
}
48+
49+
&.vertical {
50+
progress {
51+
min-width: $trough-width;
52+
}
53+
}
54+
55+
@keyframes progress {
56+
from {
57+
background-position: calc(0% - 48px), 0%;
58+
}
59+
60+
to {
61+
background-position: calc(100% + 48px), 0%;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)