gtk-3.0/widgets/_scales.scss 9.9 K raw
1
/************
2
 * GtkScale *
3
 ************/
4
%scale_trough {
5
  background-color: $scale_bg;
6
  border: none;
7
  border-radius: 3px;
8
  margin: 0;
9
10
  &:disabled { background-color: $scale_disabled_bg; }
11
12
  &:backdrop {
13
    background-color: $scale_disabled_bg; 
14
    transition: $backdrop_transition;
15
16
    &:disabled { background-color: $scale_disabled_bg;  }
17
  }
18
}
19
20
%scale_highlight {
21
  border: none;
22
  background-color: $selected_bg_color;
23
  border-radius: 3px;
24
  margin: 0;
25
26
  &:disabled {
27
    border: none;
28
    background-color: $scale_bg;
29
  }
30
31
  &:backdrop,
32
  &:active:backdrop {
33
    border-color: lighten($selected_bg_color, 5%);
34
    background-color: lighten($selected_bg_color, 5%);
35
    &:disabled {
36
      background-color: $scale_disabled_bg;
37
    }
38
  }
39
}
40
41
scale {
42
  // sizing
43
  $_marks_lenght: 6px;
44
  $_marks_distance: 6px;
45
46
  min-height: 16px;
47
  min-width: 16px;
48
  padding: 8px;
49
50
  &.horizontal {
51
    trough,
52
    progress { min-height: 6px; }
53
  }
54
55
  &.vertical {
56
    trough,
57
    progress { min-width: 6px; }
58
  }
59
60
  // the slider is inside the trough, so to have make it bigger there's a negative margin
61
62
  slider {
63
    min-height: 16px;
64
    min-width: 16px;
65
    margin: -7px;
66
67
    background-color: $base_color;
68
    box-shadow: inset 0 1px $top_highlight,
69
                0px 0px 1px 1px rgba(0,0,0,0.1);
70
    border-radius: 12px;
71
72
    transition: $button_transition;
73
    transition-property: background, border, box-shadow;
74
75
    &:active {
76
      background-color: $selected_bg_color;
77
78
      &:disabled {
79
        background-color: $insensitive_bg_color;
80
        box-shadow: inset 0 1px $top_highlight,
81
                    0px 0px 1px 1px rgba(0,0,0,0.05);
82
      }
83
    }
84
  }
85
86
  // click-and-hold the slider to activate
87
  &.fine-tune {
88
    &.horizontal {
89
      padding-top: 9px;
90
      padding-bottom: 9px;
91
      min-height: 16px;
92
    }
93
94
    &.vertical {
95
      padding-left: 9px;
96
      padding-right: 9px;
97
      min-width: 16px;
98
    }
99
100
    // to make the trough grow in fine-tune mode
101
    slider { margin: -6px; }
102
103
    fill,
104
    highlight,
105
    trough {
106
      border-radius: 5px;
107
      -gtk-outline-radius: 7px;
108
    }
109
  }
110
111
  // the backing bit
112
  trough {
113
    @extend %scale_trough;
114
115
    outline-offset: 2px;
116
    -gtk-outline-radius: 5px;
117
    outline-color: transparent;
118
  }
119
120
  // the colored part of the backing bit
121
  highlight { @extend %scale_highlight; }
122
123
  // this is another differently styled part of the backing bit, the most relevant use case is for example
124
  // in media player to indicate how much video stream as been cached
125
  fill {
126
    @extend %scale_trough;
127
128
    &:backdrop, & { background-color: $borders_color; }
129
130
    &:disabled {
131
      &:backdrop, & {
132
        border-color: transparent;
133
        background-color: transparent;
134
      }
135
    }
136
137
    // OSD
138
    .osd & {
139
      background-color: mix($osd_fg_color, $osd_borders_color, 25%);
140
141
      &:disabled {
142
        &:backdrop, & {
143
          border-color: transparent;
144
          background-color: transparent;
145
        }
146
      }
147
    }
148
  }
149
150
  $_scale_bg: if($variant == 'light', $base_color, darken(#fefefe, 5%));
151
  $_scale_disabled_bg: darken($_scale_bg, 25%);
152
  slider {
153
    border-color: $_scale_bg;
154
    border: none;
155
    border-radius: 12px;
156
157
    background-color: $_scale_bg;
158
159
    &:hover { @include button(hover-alt, $edge: $shadow_color); }
160
161
    &:active { border-color: $selected_borders_color; }
162
163
    &:disabled {
164
      background-color: $_scale_disabled_bg;
165
      box-shadow: inset 0 1px $top_highlight,
166
                  0px 0px 1px 1px rgba(0,0,0,0.1);
167
      }
168
169
    &:backdrop,
170
    &:backdrop:disabled {
171
      transition: $backdrop_transition;
172
173
      background-color: $_scale_disabled_bg;
174
      box-shadow: inset 0 1px $top_highlight,
175
                  0px 0px 1px 1px rgba(0,0,0,0.1);
176
    }
177
178
    // ...on selected list rows
179
    row:selected & { &:disabled, & { border-color: $selected_borders_color; } }
180
181
    // OSD
182
    .osd & {
183
      @include button(osd);
184
      border-color: darken($osd_borders_color, 3%);
185
      background-color: opacify($_scale_bg, 1); // solid background needed here
186
187
      &:hover {
188
        @include button(osd-hover);
189
        background-color: opacify($_scale_bg, 1); // solid background needed here
190
      }
191
192
      &:active {
193
        @include button(osd-active);
194
        background-color: opacify($_scale_bg, 1); // solid background needed here
195
      }
196
197
      &:disabled {
198
        @include button(osd-insensitive);
199
        background-color: opacify($_scale_bg, 1); // solid background needed here
200
      }
201
202
      &:backdrop {
203
        @include button(osd-backdrop, $_scale_disabled_bg);
204
        background-color: opacify($_scale_disabled_bg, 1); // solid background needed here
205
206
        &:disabled {
207
          @include button(osd-backdrop-insensitive);
208
          background-color: opacify($_scale_bg, 1); // solid background needed here
209
        }
210
      }
211
    }
212
  }
213
214
  value { color: gtkalpha(currentColor, 0.4); }
215
216
  marks {
217
    color: gtkalpha(currentColor, 0.4);
218
219
    @each $marks_class, $marks_pos, $marks_margin in (top, top, bottom),
220
                                                     (bottom, bottom, top),
221
                                                     (top, left, right),
222
                                                     (bottom, right, left) {
223
      &.#{$marks_class} {
224
        margin-#{$marks_margin}: $_marks_distance;
225
        margin-#{$marks_pos}: -($_marks_distance + $_marks_lenght);
226
      }
227
    }
228
  }
229
230
  &.fine-tune marks {
231
    @each $marks_class, $marks_pos, $marks_margin in (top, top, bottom),
232
                                                     (bottom, bottom, top),
233
                                                     (top, left, right),
234
                                                     (bottom, right, left) {
235
      &.#{$marks_class} {
236
        margin-#{$marks_margin}: $_marks_distance;
237
        margin-#{$marks_pos}: -($_marks_distance + $_marks_lenght - 3px);
238
      }
239
    }
240
  }
241
242
  &.horizontal {
243
    indicator {
244
      min-height: $_marks_lenght;
245
      min-width: 1px;
246
    }
247
248
    &.fine-tune indicator { min-height: ($_marks_lenght - 3px); }
249
  }
250
251
  &.vertical {
252
    indicator {
253
      min-height: 1px;
254
      min-width: $_marks_lenght;
255
    }
256
257
    &.fine-tune indicator { min-width: ($_marks_lenght - 3px); }
258
  }
259
260
  // *WARNING* scale with marks madness following
261
262
  // FIXME: OSD and selected list rows missing, I don't feel like adding the other 144 assets needed for those...
263
  $suffix: if($variant == 'light', '', '-dark');
264
265
  @each $dir_class, $dir_infix in ('horizontal', 'horz'),
266
                                  ('vertical', 'vert') {
267
    @each $marks_infix, $marks_class in ('scale-has-marks-above', 'marks-before:not(.marks-after)'),
268
                                        ('scale-has-marks-below', 'marks-after:not(.marks-before)') {
269
      @each $state, $state_infix in ('', ''),
270
                                    (':hover', '-hover'),
271
                                    (':active', '-active'),
272
                                    (':disabled', '-insensitive'),
273
                                    (':backdrop', '-backdrop'),
274
                                    (':backdrop:disabled', '-backdrop-insensitive') {
275
        &.#{$dir_class}.#{$marks_class} {
276
277
          slider {
278
            &#{$state} {
279
              // an asymmetric slider asset is used here, so the margins are uneven, the smaller
280
              // margin is set on the point side.
281
              min-height: 16px;
282
              min-width: 16px;
283
              margin: -7px;
284
              border: none;
285
              border-radius: 50%;
286
287
              background-color: $_scale_bg;
288
              box-shadow: none;
289
              }
290
          }
291
292
          &.fine-tune slider {
293
            // bigger negative margins to make the trough grow here as well
294
            margin: -7px;
295
          }
296
        }
297
      }
298
    }
299
  }
300
301
  &.color {
302
    min-height: 0;
303
    min-width: 0;
304
305
    trough {
306
      background-image: image($borders_color);
307
      background-repeat: no-repeat;
308
    }
309
310
    &.horizontal {
311
      padding: 0 0 15px 0;
312
313
      trough {
314
        padding-bottom: 4px;
315
        background-position: 0 -3px;
316
        border-top-left-radius: 0;
317
        border-top-right-radius: 0;
318
      }
319
320
      slider {
321
        &:dir(ltr), &:dir(rtl) { // specificity bumb
322
          &:hover, &:backdrop, &:disabled, &:backdrop:disabled, & {
323
            margin-bottom: -15px;
324
            margin-top: 6px;
325
          }
326
        }
327
      }
328
    }
329
330
    &.vertical {
331
      &:dir(ltr) {
332
        padding: 0 0 0 15px;
333
334
        trough {
335
          padding-left: 4px;
336
          background-position: 3px 0;
337
          border-bottom-right-radius: 0;
338
          border-top-right-radius: 0;
339
        }
340
341
        slider {
342
          &:hover, &:backdrop, &:disabled, &:backdrop:disabled, & {
343
            margin-left: -15px;
344
            margin-right: 6px;
345
          }
346
        }
347
      }
348
349
      &:dir(rtl) {
350
        padding: 0 15px 0 0;
351
352
        trough {
353
          padding-right: 4px;
354
          background-position: -3px 0;
355
          border-bottom-left-radius: 0;
356
          border-top-left-radius: 0;
357
        }
358
359
        slider {
360
          &:hover, &:backdrop, &:disabled, &:backdrop:disabled, & {
361
            margin-right: -15px;
362
            margin-left: 6px;
363
          }
364
        }
365
      }
366
    }
367
368
    &.fine-tune {
369
      &.horizontal {
370
        &:dir(ltr), &:dir(rtl) { // specificity bump
371
          padding: 0 0 12px 0;
372
373
          trough {
374
            padding-bottom: 7px;
375
            background-position: 0 -6px;
376
          }
377
378
          slider {
379
            margin-bottom: -15px;
380
            margin-top: 6px;
381
          }
382
        }
383
      }
384
385
      &.vertical {
386
        &:dir(ltr) {
387
          padding: 0 0 0 12px;
388
389
          trough {
390
            padding-left: 7px;
391
            background-position: 6px 0;
392
          }
393
394
          slider {
395
            margin-left: -15px;
396
            margin-right: 6px;
397
          }
398
        }
399
400
        &:dir(rtl) {
401
          padding: 0 12px 0 0;
402
403
          trough {
404
            padding-right: 7px;
405
            background-position: -6px 0;
406
          }
407
408
          slider {
409
            margin-right: -15px;
410
            margin-left: 6px;
411
          }
412
        }
413
      }
414
    }
415
  }
416
}