forked from AuroraMiddleware/gtk
LevelBar: Really fix underallocation of blocks
Themes should not enforce min sizes on blocks in continuous mode; in this case, the filled block should be as large as it needs to be to reflect the current value, and no larger or smaller than that. So, the fact that the minimal size was selected on just levelbar block is wrong: we should also require the levelbar.discrete class to apply min sizes. The widget should enforce whatever correct minimum size results from the above fix, by reapplying commit78b4885fe8
Except: we should not allocate/draw the filled block if the value is 0, as in this case, the LevelBar should be empty, not have a min-size fill. This partially reverts commit96062ffeae
, as it makes sense to set min sizes for discrete blocks, so keep that in. https://bugzilla.gnome.org/show_bug.cgi?id=783649
This commit is contained in:
parent
bc3968d2ff
commit
87c67e6ed3
@ -345,6 +345,7 @@ gtk_level_bar_render_trough (GtkGizmo *gizmo,
|
||||
gtk_widget_snapshot_child (widget, self->priv->block_widget[inverted ? 0 : 1], snapshot);
|
||||
|
||||
/* now render the filled part on top of it */
|
||||
if (self->priv->cur_value != 0)
|
||||
gtk_widget_snapshot_child (widget, self->priv->block_widget[inverted ? 1 : 0], snapshot);
|
||||
}
|
||||
else
|
||||
@ -430,6 +431,7 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self,
|
||||
GtkAllocation block_area, clip;
|
||||
gdouble fill_percentage;
|
||||
gboolean inverted;
|
||||
int block_min;
|
||||
|
||||
inverted = gtk_level_bar_get_real_inverted (self);
|
||||
|
||||
@ -439,14 +441,23 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self,
|
||||
baseline,
|
||||
out_clip);
|
||||
|
||||
if (self->priv->cur_value == 0)
|
||||
return;
|
||||
|
||||
/* now allocate the filled part */
|
||||
block_area = *allocation;
|
||||
fill_percentage = (self->priv->cur_value - self->priv->min_value) /
|
||||
(self->priv->max_value - self->priv->min_value);
|
||||
|
||||
gtk_widget_measure (self->priv->block_widget[inverted ? 1 : 0],
|
||||
self->priv->orientation, -1,
|
||||
&block_min, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
block_area.width = (gint) floor (block_area.width * fill_percentage);
|
||||
block_area.width = MAX (block_area.width, block_min);
|
||||
|
||||
if (inverted)
|
||||
block_area.x += allocation->width - block_area.width;
|
||||
@ -454,6 +465,7 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self,
|
||||
else
|
||||
{
|
||||
block_area.height = (gint) floor (block_area.height * fill_percentage);
|
||||
block_area.height = MAX (block_area.height, block_min);
|
||||
|
||||
if (inverted)
|
||||
block_area.y += allocation->height - block_area.height;
|
||||
|
@ -3331,9 +3331,27 @@ progressbar {
|
||||
* Level Bar *
|
||||
*************/
|
||||
levelbar {
|
||||
block { min-height: 1px; }
|
||||
&.horizontal {
|
||||
block {
|
||||
min-height: 1px;
|
||||
}
|
||||
|
||||
&.vertical block { min-width: 1px; }
|
||||
&.discrete block {
|
||||
margin: 0 1px;
|
||||
min-width: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
&.vertical {
|
||||
block {
|
||||
min-width: 1px;
|
||||
}
|
||||
|
||||
&.discrete block {
|
||||
margin: 1px 0;
|
||||
min-height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
&:backdrop { transition: $backdrop_transition; }
|
||||
|
||||
@ -3346,10 +3364,6 @@ levelbar {
|
||||
&:backdrop { @include entry(backdrop); }
|
||||
}
|
||||
|
||||
&.horizontal.discrete block { margin: 0 1px; }
|
||||
|
||||
&.vertical.discrete block { margin: 1px 0; }
|
||||
|
||||
block {
|
||||
border: 1px solid;
|
||||
border-radius: 1px;
|
||||
|
@ -1441,20 +1441,20 @@ progressbar.osd progress { border-style: none; border-radius: 0; }
|
||||
progressbar trough.empty progress { all: unset; }
|
||||
|
||||
/************* Level Bar * */
|
||||
levelbar block { min-height: 1px; }
|
||||
levelbar.horizontal block { min-height: 1px; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; min-width: 32px; }
|
||||
|
||||
levelbar.vertical block { min-width: 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
|
||||
|
||||
levelbar:backdrop { transition: 200ms ease-out; }
|
||||
|
||||
levelbar trough { border: 1px solid; padding: 2px; border-radius: 3px; color: white; border-color: #1b1f20; background-color: #232729; box-shadow: inset 0 0 0 1px rgba(33, 93, 156, 0); }
|
||||
|
||||
levelbar trough:backdrop { color: #d3d4d5; border-color: #202425; background-color: #252a2c; box-shadow: none; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; }
|
||||
|
||||
levelbar block { border: 1px solid; border-radius: 1px; }
|
||||
|
||||
levelbar block.low { border-color: #f57900; background-color: #f57900; }
|
||||
|
@ -1461,20 +1461,20 @@ progressbar.osd progress { border-style: none; border-radius: 0; }
|
||||
progressbar trough.empty progress { all: unset; }
|
||||
|
||||
/************* Level Bar * */
|
||||
levelbar block { min-height: 1px; }
|
||||
levelbar.horizontal block { min-height: 1px; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; min-width: 32px; }
|
||||
|
||||
levelbar.vertical block { min-width: 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
|
||||
|
||||
levelbar:backdrop { transition: 200ms ease-out; }
|
||||
|
||||
levelbar trough { border: 1px solid; padding: 2px; border-radius: 3px; color: black; border-color: #b6b6b3; background-color: #ffffff; box-shadow: inset 0 0 0 1px rgba(74, 144, 217, 0); }
|
||||
|
||||
levelbar trough:backdrop { color: #323232; border-color: #c0c0bd; background-color: #fcfcfc; box-shadow: none; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; }
|
||||
|
||||
levelbar block { border: 1px solid; border-radius: 1px; }
|
||||
|
||||
levelbar block.low { border-color: #8f4700; background-color: #f57900; }
|
||||
|
@ -2509,17 +2509,29 @@ levelbar {
|
||||
@include entry(backdrop);
|
||||
}
|
||||
}
|
||||
& block {
|
||||
min-width: 32px;
|
||||
|
||||
&.horizontal {
|
||||
block {
|
||||
min-height: 1px;
|
||||
}
|
||||
&.vertical block {
|
||||
min-width: 1px;
|
||||
min-height: 32px;
|
||||
|
||||
&.discrete block {
|
||||
margin: 0 1px;
|
||||
min-width: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
&.vertical {
|
||||
block {
|
||||
min-width: 1px;
|
||||
}
|
||||
|
||||
&.discrete block {
|
||||
margin: 1px 0;
|
||||
min-height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
&.horizontal.discrete block { margin: 0 1px; }
|
||||
&.vertical.discrete block { margin: 1px 0; }
|
||||
& block.filled.low {
|
||||
border-color: darken($warning_color,10%);
|
||||
background-color: $warning_color;
|
||||
|
@ -1114,13 +1114,13 @@ levelbar trough { padding: 2px; border-radius: 3px; background-color: transparen
|
||||
|
||||
levelbar trough:backdrop { background-color: transparent; border-style: solid; background-image: linear-gradient(to bottom, #090909, #111 90%); color: #fff; background-image: linear-gradient(to bottom, #111, #111); box-shadow: 0 1px rgba(255, 255, 255, 0); }
|
||||
|
||||
levelbar block { min-width: 32px; min-height: 1px; }
|
||||
levelbar.horizontal block { min-height: 1px; }
|
||||
|
||||
levelbar.vertical block { min-width: 1px; min-height: 32px; }
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; min-width: 32px; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; }
|
||||
levelbar.vertical block { min-width: 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; }
|
||||
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
|
||||
|
||||
levelbar block.filled.low { border-color: #c26000; background-color: #f57900; }
|
||||
|
||||
|
@ -1120,13 +1120,13 @@ levelbar trough { padding: 2px; border-radius: 3px; background-color: transparen
|
||||
|
||||
levelbar trough:backdrop { background-color: transparent; border-style: solid; background-image: linear-gradient(to bottom, #f7f7f7, #fff 90%); color: #000; background-image: linear-gradient(to bottom, #fff, #fff); box-shadow: 0 1px rgba(255, 255, 255, 0); }
|
||||
|
||||
levelbar block { min-width: 32px; min-height: 1px; }
|
||||
levelbar.horizontal block { min-height: 1px; }
|
||||
|
||||
levelbar.vertical block { min-width: 1px; min-height: 32px; }
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; min-width: 32px; }
|
||||
|
||||
levelbar.horizontal.discrete block { margin: 0 1px; }
|
||||
levelbar.vertical block { min-width: 1px; }
|
||||
|
||||
levelbar.vertical.discrete block { margin: 1px 0; }
|
||||
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
|
||||
|
||||
levelbar block.filled.low { border-color: #c26000; background-color: #f57900; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user