[gtk+/gtk-3-22] LevelBar: Really fix underallocation of blocks
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] LevelBar: Really fix underallocation of blocks
- Date: Mon, 28 Aug 2017 23:35:01 +0000 (UTC)
commit c85f34b6fcfdd671a9af714064f5b92f2ae4a5d6
Author: Daniel Boles <dboles src gnome org>
Date: Sat Aug 12 15:51:45 2017 +0100
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 78b4885fe8850e132d8bb06df8ab90ac6c2033e0
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
gtk/gtklevelbar.c | 14 ++++++++++-
gtk/theme/Adwaita/_common.scss | 28 ++++++++++++++--------
gtk/theme/Adwaita/gtk-contained-dark.css | 12 ++++----
gtk/theme/Adwaita/gtk-contained.css | 12 ++++----
gtk/theme/HighContrast/_common.scss | 28 +++++++++++++++------
gtk/theme/HighContrast/gtk-contained-inverse.css | 8 +++---
gtk/theme/HighContrast/gtk-contained.css | 8 +++---
7 files changed, 71 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index 8cb46ce..7924b70 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -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;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index f1e0cea..7a76663 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -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;
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 9241893..7ad9b23 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -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; }
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 9fa66b7..7367fc2 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -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; }
diff --git a/gtk/theme/HighContrast/_common.scss b/gtk/theme/HighContrast/_common.scss
index 715ac76..d53f38b 100644
--- a/gtk/theme/HighContrast/_common.scss
+++ b/gtk/theme/HighContrast/_common.scss
@@ -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;
diff --git a/gtk/theme/HighContrast/gtk-contained-inverse.css
b/gtk/theme/HighContrast/gtk-contained-inverse.css
index d79fa1a..7ed1c64 100644
--- a/gtk/theme/HighContrast/gtk-contained-inverse.css
+++ b/gtk/theme/HighContrast/gtk-contained-inverse.css
@@ -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; }
diff --git a/gtk/theme/HighContrast/gtk-contained.css b/gtk/theme/HighContrast/gtk-contained.css
index bcdf77d..e67ce48 100644
--- a/gtk/theme/HighContrast/gtk-contained.css
+++ b/gtk/theme/HighContrast/gtk-contained.css
@@ -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; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]