Commit c85f34b6 authored by Daniel Boles's avatar Daniel Boles

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 commit 78b4885f

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.

https://bugzilla.gnome.org/show_bug.cgi?id=783649
parent bd7c87c7
......@@ -342,7 +342,8 @@ gtk_level_bar_draw_fill_continuous (GtkLevelBar *self,
gtk_css_gadget_draw (self->priv->block_gadget[inverted ? 0 : 1], cr);
/* now render the filled part on top of it */
gtk_css_gadget_draw (self->priv->block_gadget[inverted ? 1 : 0], cr);
if (self->priv->cur_value != 0)
gtk_css_gadget_draw (self->priv->block_gadget[inverted ? 1 : 0], cr);
}
static void
......@@ -458,6 +459,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);
......@@ -467,14 +469,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_css_gadget_get_preferred_size (self->priv->block_gadget[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;
......@@ -482,6 +493,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;
......
......@@ -3368,14 +3368,26 @@ progressbar {
* Level Bar *
*************/
levelbar {
block {
min-width: 32px;
min-height: 1px;
&.horizontal {
block {
min-height: 1px;
}
&.discrete block {
margin: 0 1px;
min-width: 32px;
}
}
&.vertical block {
min-width: 1px;
min-height: 32px;
&.vertical {
block {
min-width: 1px;
}
&.discrete block {
margin: 1px 0;
min-height: 32px;
}
}
&:backdrop { transition: $backdrop_transition; }
......@@ -3389,10 +3401,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;
......
......@@ -1445,9 +1445,13 @@ progressbar.osd progress { border-style: none; border-radius: 0; }
progressbar trough.empty progress { all: unset; }
/************* Level Bar * */
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.vertical block { min-width: 1px; }
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
levelbar:backdrop { transition: 200ms ease-out; }
......@@ -1455,10 +1459,6 @@ levelbar trough { border: 1px solid; padding: 2px; border-radius: 3px; color: wh
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; }
......
......@@ -1465,9 +1465,13 @@ progressbar.osd progress { border-style: none; border-radius: 0; }
progressbar trough.empty progress { all: unset; }
/************* Level Bar * */
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.vertical block { min-width: 1px; }
levelbar.vertical.discrete block { margin: 1px 0; min-height: 32px; }
levelbar:backdrop { transition: 200ms ease-out; }
......@@ -1475,10 +1479,6 @@ levelbar trough { border: 1px solid; padding: 2px; border-radius: 3px; color: bl
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; }
......
......@@ -2525,17 +2525,29 @@ levelbar {
@include entry(backdrop);
}
}
& block {
min-width: 32px;
min-height: 1px;
&.horizontal {
block {
min-height: 1px;
}
&.discrete block {
margin: 0 1px;
min-width: 32px;
}
}
&.vertical block {
min-width: 1px;
min-height: 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; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment