mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: tweak marks drawing
This commit is contained in:
71
src/libsysprof-ui/sysprof-cairo.c
Normal file
71
src/libsysprof-ui/sysprof-cairo.c
Normal file
@ -0,0 +1,71 @@
|
||||
/* sysprof-cairo.c
|
||||
*
|
||||
* Copyright 2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-ui-private.h"
|
||||
|
||||
void
|
||||
_sysprof_rounded_rectangle (cairo_t *cr,
|
||||
const GdkRectangle *rect,
|
||||
gint x_radius,
|
||||
gint y_radius)
|
||||
{
|
||||
gint x;
|
||||
gint y;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, x2;
|
||||
gint y1, y2;
|
||||
gint xr1, xr2;
|
||||
gint yr1, yr2;
|
||||
|
||||
g_return_if_fail (cr);
|
||||
g_return_if_fail (rect);
|
||||
|
||||
x = rect->x;
|
||||
y = rect->y;
|
||||
width = rect->width;
|
||||
height = rect->height;
|
||||
|
||||
x1 = x;
|
||||
x2 = x1 + width;
|
||||
y1 = y;
|
||||
y2 = y1 + height;
|
||||
|
||||
x_radius = MIN (x_radius, width / 2.0);
|
||||
y_radius = MIN (y_radius, width / 2.0);
|
||||
|
||||
xr1 = x_radius;
|
||||
xr2 = x_radius / 2.0;
|
||||
yr1 = y_radius;
|
||||
yr2 = y_radius / 2.0;
|
||||
|
||||
cairo_move_to (cr, x1 + xr1, y1);
|
||||
cairo_line_to (cr, x2 - xr1, y1);
|
||||
cairo_curve_to (cr, x2 - xr2, y1, x2, y1 + yr2, x2, y1 + yr1);
|
||||
cairo_line_to (cr, x2, y2 - yr1);
|
||||
cairo_curve_to (cr, x2, y2 - yr2, x2 - xr2, y2, x2 - xr1, y2);
|
||||
cairo_line_to (cr, x1 + xr1, y2);
|
||||
cairo_curve_to (cr, x1 + xr2, y2, x1, y2 - yr2, x1, y2 - yr1);
|
||||
cairo_line_to (cr, x1, y1 + yr1);
|
||||
cairo_curve_to (cr, x1, y1 + yr2, x1 + xr2, y1, x1 + xr1, y1);
|
||||
cairo_close_path (cr);
|
||||
}
|
||||
@ -23,6 +23,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-cell-renderer-duration.h"
|
||||
#include "sysprof-ui-private.h"
|
||||
#include "sysprof-zoom-manager.h"
|
||||
|
||||
#define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L)
|
||||
@ -99,13 +100,32 @@ sysprof_cell_renderer_duration_render (GtkCellRenderer *renderer,
|
||||
x2 = x1;
|
||||
|
||||
r.x = cell_area->x + x1;
|
||||
r.height = 10;
|
||||
r.y = cell_area->y + (cell_area->height - r.height) / 2.0;
|
||||
r.height = 12;
|
||||
r.y = cell_area->y + (cell_area->height - r.height) / 2;
|
||||
r.width = MAX (1.0, x2 - x1);
|
||||
|
||||
gdk_cairo_rectangle (cr, &r);
|
||||
if ((cell_area->height - r.height) % 2 == 1)
|
||||
r.height++;
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &rgba);
|
||||
cairo_fill (cr);
|
||||
|
||||
if (r.width > 3)
|
||||
{
|
||||
_sysprof_rounded_rectangle (cr, &r, 2, 2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else if (r.width > 1)
|
||||
{
|
||||
gdk_cairo_rectangle (cr, &r);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_line_width (cr, 1);
|
||||
cairo_move_to (cr, r.x, r.y);
|
||||
cairo_line_to (cr, r.x, r.y + r.height);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
str = g_string_new (priv->text);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user