forked from AuroraMiddleware/gtk
Add gtk_css_style_snapshot_layout
This function renders a PangoLayout at a given position, using text shadows and color from css.
This commit is contained in:
parent
0205caa371
commit
73f991a7fd
62
gtk/gtkrenderlayout.c
Normal file
62
gtk/gtkrenderlayout.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderlayoutprivate.h"
|
||||
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssshadowvalueprivate.h"
|
||||
#include "gtkpangoprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
|
||||
void
|
||||
gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
PangoLayout *layout)
|
||||
{
|
||||
GtkCssStyle *style;
|
||||
const GdkRGBA *color;
|
||||
gboolean has_shadow;
|
||||
|
||||
gtk_snapshot_push_debug (snapshot, "Layout");
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
}
|
||||
|
||||
style = boxes->style;
|
||||
color = gtk_css_color_value_get_rgba (style->core->color);
|
||||
has_shadow = gtk_css_shadow_value_push_snapshot (style->font->text_shadow, snapshot);
|
||||
|
||||
gtk_snapshot_append_layout (snapshot, layout, color);
|
||||
|
||||
if (has_shadow)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
39
gtk/gtkrenderlayoutprivate.h
Normal file
39
gtk/gtkrenderlayoutprivate.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_LAYOUT_PRIVATE_H__
|
||||
#define __GTK_RENDER_LAYOUT_PRIVATE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtktypes.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot,
|
||||
int x,
|
||||
int y,
|
||||
PangoLayout *layout);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_LAYOUT_PRIVATE_H__ */
|
@ -316,6 +316,7 @@ gtk_public_sources = files([
|
||||
'gtkrenderbackground.c',
|
||||
'gtkrenderborder.c',
|
||||
'gtkrendericon.c',
|
||||
'gtkrenderlayout.c',
|
||||
'gtkrendernodepaintable.c',
|
||||
'gtkrevealer.c',
|
||||
'gtkroot.c',
|
||||
|
Loading…
Reference in New Issue
Block a user