widgets: Adapt brush previews to theme

We now check the current theme and 
draw the brush preview color and
background to match.
This commit is contained in:
Alx Sa 2025-01-20 05:41:25 +00:00 committed by Jehan
parent 7add94f868
commit 59685ce621
7 changed files with 60 additions and 10 deletions

View file

@ -26,6 +26,9 @@
#include "core-types.h"
#include "config/gimpguiconfig.h"
#include "gimp.h"
#include "gimpbezierdesc.h"
#include "gimpbrush.h"
#include "gimpbrush-boundary.h"
@ -37,6 +40,7 @@
#include "gimpbrushcache.h"
#include "gimpbrushgenerated.h"
#include "gimpbrushpipe.h"
#include "gimpcontext.h"
#include "gimptagged.h"
#include "gimptempbuf.h"
@ -366,13 +370,21 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
}
else
{
GimpGuiConfig *config;
guint8 rgb[3] = {0, 0, 0};
config = GIMP_GUI_CONFIG (context->gimp->config);
if (config->theme_scheme == GIMP_THEME_DARK)
rgb[0] = rgb[1] = rgb[2] = 255;
for (y = 0; y < mask_height; y++)
{
for (x = 0; x < mask_width ; x++)
{
*buf++ = 0;
*buf++ = 0;
*buf++ = 0;
*buf++ = rgb[0];
*buf++ = rgb[1];
*buf++ = rgb[2];
*buf++ = *mask++;
}
}

View file

@ -81,11 +81,14 @@ gimp_brush_editor_class_init (GimpBrushEditorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpDataEditorClass *editor_class = GIMP_DATA_EDITOR_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = gimp_brush_editor_constructed;
editor_class->set_data = gimp_brush_editor_set_data;
editor_class->title = _("Brush Editor");
gtk_widget_class_set_css_name (widget_class, "GimpBrushEditor");
}
static void

View file

@ -164,6 +164,8 @@ gimp_view_class_init (GimpViewClass *klass)
klass->clicked = NULL;
klass->double_clicked = NULL;
klass->context = NULL;
gtk_widget_class_set_css_name (widget_class, "GimpView");
}
static void

View file

@ -1176,6 +1176,29 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
case GIMP_VIEW_BG_WHITE:
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
break;
case GIMP_VIEW_BG_USE_STYLE:
{
GtkStyleContext *style;
GdkRGBA *color = NULL;
style = gtk_widget_get_style_context (widget);
gtk_style_context_get (style, gtk_style_context_get_state (style),
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &color,
NULL);
if (color)
{
cairo_set_source_rgb (cr, color->red, color->green, color->blue);
gdk_rgba_free (color);
}
else
{
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
}
}
break;
}
cairo_paint (cr);
@ -1205,6 +1228,10 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
case GIMP_VIEW_BG_WHITE:
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
break;
case GIMP_VIEW_BG_USE_STYLE:
default:
break;
}
cairo_fill (cr);

View file

@ -119,8 +119,8 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
gimp_view_renderer_render_temp_buf (renderer, widget, temp_buf,
temp_buf_x, temp_buf_y,
-1,
GIMP_VIEW_BG_WHITE,
GIMP_VIEW_BG_WHITE);
GIMP_VIEW_BG_USE_STYLE,
GIMP_VIEW_BG_USE_STYLE);
gimp_temp_buf_unref (temp_buf);
@ -139,8 +139,8 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
gimp_view_renderer_render_temp_buf (renderer, widget, temp_buf,
temp_buf_x, temp_buf_y,
-1,
GIMP_VIEW_BG_WHITE,
GIMP_VIEW_BG_WHITE);
GIMP_VIEW_BG_USE_STYLE,
GIMP_VIEW_BG_USE_STYLE);
gimp_temp_buf_unref (temp_buf);
}
@ -193,8 +193,8 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
gimp_view_renderer_render_temp_buf (renderer, renderbrush->widget, temp_buf,
temp_buf_x, temp_buf_y,
-1,
GIMP_VIEW_BG_WHITE,
GIMP_VIEW_BG_WHITE);
GIMP_VIEW_BG_USE_STYLE,
GIMP_VIEW_BG_USE_STYLE);
gimp_temp_buf_unref (temp_buf);

View file

@ -128,7 +128,8 @@ typedef enum
typedef enum /*< skip >*/
{
GIMP_VIEW_BG_CHECKS,
GIMP_VIEW_BG_WHITE
GIMP_VIEW_BG_WHITE,
GIMP_VIEW_BG_USE_STYLE
} GimpViewBG;
typedef enum /*< skip >*/

View file

@ -67,6 +67,11 @@ GimpDock .view:drop(active) {
border-top-color: @dimmed-fg-color;
}
/* Widget for various previews and icon tabs */
GimpView {
background-color: @extreme-bg-color;
}
/* Define the mouse-over color for the path
* buttons in the various file dialogs.
*/