Repository navigation
Conversation
Add optional middle color stops to St background gradients, so themes can draw Clearlooks-style glossy faces (a fade, a hard step across the middle, then another fade), as GTK themes do with a four-stop CSS linear-gradient(): background-gradient-middle-start: <color>; arriving at the middle background-gradient-middle-end: <color>; leaving the middle background-gradient-middle-position: <percentage>; default 50% The two middle colors are added as cairo stops at the same offset, which gives a hard step. If only one of them is set, it is used for both, giving a three-stop gradient with no step. This works for vertical, horizontal and radial gradients (for radial, the position is a fraction of the radius). Themes that don't set the new properties draw exactly as before. The middle colors are taken into account by the translucency and visible-outline checks, and by st_theme_node_paint_equal(), so a change to only the middle repaints. Add an interactive test, tests/interactive/background-gradient.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Seems like implementing a linear-gradient function would be better than this mess of properties. Of course, I'm also not a huge fan of all the AI code that you may or may not even understand. |
Replace the background-gradient-middle-* properties from the previous
commit with CSS linear-gradient(), as suggested in review:
background-image: linear-gradient(to bottom, #c8d8f0,
#9ab4dc 50%, #5a7cb0 50%, #88a4d0);
It takes an optional direction, either an angle (deg, rad, grad) or
"to" with one or two sides, then two or more colors, each with
optional percentages. As in CSS, stops without a position are spread
evenly, a position before an earlier one is moved up to it, and two
stops at the same position draw a hard step. "to <corner>" and angles
use the CSS gradient line, so the corners get the first and last
colors. It is also read from the background shorthand. A
linear-gradient() that can't be read is ignored with a warning.
linear-gradient() takes precedence over the background-gradient-*
properties, so a theme can give both and Cinnamon versions without
linear-gradient() draw the two-color gradient: they ignore the
function term without a warning. Its first and last stops fill in the
gradient start and end, so st_theme_node_get_background_gradient() and
other code that only knows two-color gradients keep working. Radial
gradients still use the background-gradient-* properties.
The stops are included in the translucency and visible-outline checks
and in st_theme_node_paint_equal(). A background-image url() or none,
or the background shorthand, clears them.
Also set background_image to NULL after freeing it when a
background-image url() doesn't resolve, rather than leaving it
pointing at freed memory.
Update tests/interactive/background-gradient.js for linear-gradient().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reworked it as linear-gradient() as you suggested. Testing it on the Mint 27 beta tonight or possibly tomorrow, screenshots to follow. |
|
Thanks for the quick response and suggesting linear-gradient(). It's a cleaner solution for those writing themes and allows for any number of stops. The first properties solution was suggested only because it made a smaller patch. It's reworked and updated in the description above. It reads I understand your concern about ai driven code. My intention is to not throw around AI code loosely. I genuinely want to contribute to Mint in a positive way. I spent a decade as a hardware design and validation engineer. Owning my own business and building a few ecommerce websites I picked up on writing CSS and UI/UX design. I have also written a suite of python scripts over the years for my needs within my business. I'm not a professional software developer. Theming my own computer has always been a hobby, going back to the Clearlooks GTK 2 days. I even forked the Clearlooks engine and changed its C code to make things draw the way I liked. My recent project, Theme Roller, I could not have made without using the Robot as a tool. And, at least not yet, the robot couldn't have made it on it's own. What I bring is attention to detail and thorough testing. I have spent way more hours on that tool than I care to admit. It's the least I can do for Mint. I've used it for free ever since Ubuntu introduced Unity. |
St's background gradients currently take two colors, which only allow Cinnamon themes to have smooth gradients. In the interest of creating Cinnamon themes with a glass style panel a multi-stop
linear-gradient()is desired. This adds CSSlinear-gradient()to St backgrounds:It follows the CSS
linear-gradient()syntax, so a gradient copied from a GTK theme works as it is:to bottom):to top,to right, a corner such asto bottom right, or an angle such as90deg.rgba()), each with an optional percentage. Two colors at the same percentage make a hard step.background-imageand thebackgroundshorthand.A
linear-gradient()St can't read is ignored with a warning.Compatibility
background-gradient-*properties work as they previously did, and radial gradients still use them. Neither Cinnamon's own theme nor Mint-Y useslinear-gradient()today.linear-gradient()takes precedence overbackground-gradient-*, so a theme can write both. Cinnamon versions without this patch ignorelinear-gradient()without a warning and draw the two-color gradient. I checked this on stock Cinnamon (screenshot below).st_theme_node_get_background_gradient()and other code that only knows two-color gradients keep working.st_theme_node_paint_equal(), so a change to any stop repaints.background-image: url()ornone, or thebackgroundshorthand, clears them.The first commit used separate
background-gradient-middle-*properties. The second replaces them withlinear-gradient(), as suggested in review. Also included:background_imageis set to NULL after it's freed when abackground-image: url()doesn't resolve, rather than left pointing at freed memory.tests/interactive/background-gradient.jshas each case.Testing
Built from this branch and run on the Linux Mint 27 beta (Cinnamon 6.8), Wayland session.
Before (stock Cinnamon:
linear-gradient()is ignored; "both given" falls back to the redbackground-gradient-*):After:
A real theme with a glass style on the panel and its buttons (Gradients were exaggerated for demonstration):
Why
I'm working on a tool called Theme Roller so users can generate fully custom themes for Cinnamon. A couple of the themes I've included were derived from the old Clearlooks style. One is the older smooth gradient version and another was the slightly reworked Clearlooks Gummy which contained the glass effect on the panel and widgets. I have a light and dark version of the glossy theme and they are both updated to use
linear-gradient()and the two-color properties, so it works on Cinnamon with and without this patch.It's also a small, fun thing for anyone making Cinnamon themes by hand: a glossy panel or button takes one line of standard CSS, with nothing to draw in an image editor, and the same
linear-gradient()they already write for GTK.🤖 Generated with Claude Code