[gtk+] LevelBar: Really fix underallocation of blocks
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] LevelBar: Really fix underallocation of blocks
- Date: Mon, 28 Aug 2017 23:35:05 +0000 (UTC)
commit 87c67e6ed308f3e287feda1237bf7cba899304e0
Author: Daniel Boles <dboles src gnome org>
Date: Sat Aug 12 16:13:11 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.
This partially reverts commit 96062ffeae5245fa165a96a2af86d5645f5e8569,
as it makes sense to set min sizes for discrete blocks, so keep that in.
https://bugzilla.gnome.org/show_bug.cgi?id=783649
gtk/gtklevelbar.c | 14 ++++++++++-
gtk/theme/Adwaita/_common.scss | 26 +++++++++++++++----
gtk/theme/Adwaita/gtk-contained-dark.css | 10 ++++----
gtk/theme/Adwaita/gtk-contained.css | 10 ++++----
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(+), 33 deletions(-)
---
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index 9c8637d..d9d6097 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -345,7 +345,8 @@ 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 */
- gtk_widget_snapshot_child (widget, self->priv->block_widget[inverted ? 1 : 0], snapshot);
+ 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;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 8f7c006..5d10791 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -3331,9 +3331,27 @@ progressbar {
* Level Bar *
*************/
levelbar {
- block { min-height: 1px; }
+ &.horizontal {
+ block {
+ min-height: 1px;
+ }
+
+ &.discrete block {
+ margin: 0 1px;
+ min-width: 32px;
+ }
+ }
+
+ &.vertical {
+ block {
+ min-width: 1px;
+ }
- &.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;
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 833518e..7f55367 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -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; }
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 9829f5a..50fab4c 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -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; }
diff --git a/gtk/theme/HighContrast/_common.scss b/gtk/theme/HighContrast/_common.scss
index dc7c7f8..396aff8 100644
--- a/gtk/theme/HighContrast/_common.scss
+++ b/gtk/theme/HighContrast/_common.scss
@@ -2509,17 +2509,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 05ec2f6..e2fd440 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 fbe1a72..d3d4280 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]