layouts: Fixed spacing
This commit is contained in:
@ -199,32 +199,21 @@ void
|
|||||||
_eek_rounded_polygon (cairo_t *cr,
|
_eek_rounded_polygon (cairo_t *cr,
|
||||||
gdouble radius,
|
gdouble radius,
|
||||||
EekPoint *points,
|
EekPoint *points,
|
||||||
gint num_points)
|
guint num_points)
|
||||||
{
|
{
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
cairo_move_to (cr,
|
cairo_move_to (cr,
|
||||||
(gdouble) (points[num_points - 1].x +
|
(gdouble) (points[num_points - 1].x +
|
||||||
points[0].x) / 2,
|
points[0].x) / 2,
|
||||||
(gdouble) (points[num_points - 1].y +
|
(gdouble) (points[num_points - 1].y +
|
||||||
points[0].y) / 2);
|
points[0].y) / 2);
|
||||||
|
|
||||||
|
for (guint i = 0; i < num_points; i++) {
|
||||||
#ifdef KBDRAW_DEBUG
|
guint j = (i + 1) % num_points;
|
||||||
printf (" rounded polygon of radius %f:\n", radius);
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < num_points; i++) {
|
|
||||||
j = (i + 1) % num_points;
|
|
||||||
rounded_corner (cr, (gdouble) points[i].x,
|
rounded_corner (cr, (gdouble) points[i].x,
|
||||||
(gdouble) points[i].y,
|
(gdouble) points[i].y,
|
||||||
(gdouble) (points[i].x + points[j].x) / 2,
|
(gdouble) (points[i].x + points[j].x) / 2,
|
||||||
(gdouble) (points[i].y + points[j].y) / 2,
|
(gdouble) (points[i].y + points[j].y) / 2,
|
||||||
radius);
|
radius);
|
||||||
#ifdef KBDRAW_DEBUG
|
}
|
||||||
printf (" corner (%d, %d) -> (%d, %d):\n",
|
|
||||||
points[i].x, points[i].y, points[j].x,
|
|
||||||
points[j].y);
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
cairo_close_path (cr);
|
cairo_close_path (cr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@ typedef struct _TextProperty TextProperty;
|
|||||||
extern void _eek_rounded_polygon (cairo_t *cr,
|
extern void _eek_rounded_polygon (cairo_t *cr,
|
||||||
gdouble radius,
|
gdouble radius,
|
||||||
EekPoint *points,
|
EekPoint *points,
|
||||||
gint num_points);
|
guint num_points);
|
||||||
|
|
||||||
static void eek_renderer_real_render_key_label (EekRenderer *self,
|
static void eek_renderer_real_render_key_label (EekRenderer *self,
|
||||||
PangoLayout *layout,
|
PangoLayout *layout,
|
||||||
@ -116,8 +116,8 @@ create_keyboard_surface_key_callback (EekElement *element,
|
|||||||
cairo_rectangle (data->cr,
|
cairo_rectangle (data->cr,
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
bounds.width * priv->scale,
|
bounds.width * priv->scale + 100,
|
||||||
bounds.height * priv->scale);
|
bounds.height * priv->scale + 100);
|
||||||
cairo_clip (data->cr);
|
cairo_clip (data->cr);
|
||||||
render_key (data->renderer, data->cr, EEK_KEY(element), FALSE);
|
render_key (data->renderer, data->cr, EEK_KEY(element), FALSE);
|
||||||
|
|
||||||
@ -205,8 +205,6 @@ render_key_outline (EekRenderer *renderer,
|
|||||||
EekRendererPrivate *priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
EekRendererPrivate *priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
||||||
EekOutline *outline;
|
EekOutline *outline;
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
gdouble scale;
|
|
||||||
gint i;
|
|
||||||
guint oref;
|
guint oref;
|
||||||
EekThemeNode *theme_node;
|
EekThemeNode *theme_node;
|
||||||
EekColor foreground, background, gradient_start, gradient_end, border_color;
|
EekColor foreground, background, gradient_start, gradient_end, border_color;
|
||||||
@ -233,14 +231,14 @@ render_key_outline (EekRenderer *renderer,
|
|||||||
border_width = eek_theme_node_get_border_width (theme_node,
|
border_width = eek_theme_node_get_border_width (theme_node,
|
||||||
EEK_SIDE_TOP);
|
EEK_SIDE_TOP);
|
||||||
border_radius = eek_theme_node_get_border_radius (theme_node,
|
border_radius = eek_theme_node_get_border_radius (theme_node,
|
||||||
EEK_SIDE_TOP);
|
EEK_CORNER_TOPLEFT);
|
||||||
eek_theme_node_get_border_color (theme_node, EEK_SIDE_TOP,
|
eek_theme_node_get_border_color (theme_node, EEK_SIDE_TOP,
|
||||||
&border_color);
|
&border_color);
|
||||||
} else {
|
} else {
|
||||||
foreground = priv->default_foreground_color;
|
foreground = priv->default_foreground_color;
|
||||||
background = priv->default_background_color;
|
background = priv->default_background_color;
|
||||||
gradient_type = EEK_GRADIENT_NONE;
|
gradient_type = EEK_GRADIENT_NONE;
|
||||||
border_width = priv->border_width;
|
border_width = (gint)round(priv->border_width);
|
||||||
border_radius = -1;
|
border_radius = -1;
|
||||||
border_color.red = ABS(background.red - foreground.red) * 0.7;
|
border_color.red = ABS(background.red - foreground.red) * 0.7;
|
||||||
border_color.green = ABS(background.green - foreground.green) * 0.7;
|
border_color.green = ABS(background.green - foreground.green) * 0.7;
|
||||||
@ -248,21 +246,15 @@ render_key_outline (EekRenderer *renderer,
|
|||||||
border_color.alpha = foreground.alpha;
|
border_color.alpha = foreground.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need to rescale so that the border fit inside the clipping
|
|
||||||
region */
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
|
||||||
scale = MIN((bounds.width - border_width * 2) / bounds.width,
|
|
||||||
(bounds.height - border_width * 2) / bounds.height);
|
|
||||||
|
|
||||||
outline = eek_outline_copy (outline);
|
outline = eek_outline_copy (outline);
|
||||||
for (i = 0; i < outline->num_points; i++) {
|
for (guint i = 0; i < outline->num_points; i++) {
|
||||||
outline->points[i].x *= priv->scale * scale;
|
outline->points[i].x *= priv->scale;
|
||||||
outline->points[i].y *= priv->scale * scale;
|
outline->points[i].y *= priv->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_translate (cr,
|
cairo_translate (cr,
|
||||||
border_width * priv->scale * scale,
|
border_width * priv->scale,
|
||||||
border_width * priv->scale * scale);
|
border_width * priv->scale);
|
||||||
|
|
||||||
if (gradient_type != EEK_GRADIENT_NONE) {
|
if (gradient_type != EEK_GRADIENT_NONE) {
|
||||||
cairo_pattern_t *pat;
|
cairo_pattern_t *pat;
|
||||||
@ -340,6 +332,10 @@ render_key_outline (EekRenderer *renderer,
|
|||||||
outline->num_points);
|
outline->num_points);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
|
cairo_translate (cr,
|
||||||
|
-border_width * priv->scale,
|
||||||
|
-border_width * priv->scale);
|
||||||
|
|
||||||
eek_outline_free (outline);
|
eek_outline_free (outline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,10 +460,11 @@ render_key (EekRenderer *self,
|
|||||||
if (!outline_surface) {
|
if (!outline_surface) {
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
|
// Outline will be drawn on the outside of the button, so the surface needs to be bigger than the button
|
||||||
outline_surface =
|
outline_surface =
|
||||||
cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
bounds.width,
|
(int)ceil(bounds.width) + 10,
|
||||||
bounds.height);
|
(int)ceil(bounds.height) + 10);
|
||||||
cr = cairo_create (outline_surface);
|
cr = cairo_create (outline_surface);
|
||||||
|
|
||||||
/* blank background */
|
/* blank background */
|
||||||
|
|||||||
@ -529,7 +529,7 @@ static void keycounter (EekElement *element, gpointer user_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double keyspacing = 2.0;
|
const double keyspacing = 3.0;
|
||||||
|
|
||||||
static void keyplacer(EekElement *element, gpointer user_data) {
|
static void keyplacer(EekElement *element, gpointer user_data) {
|
||||||
double *current_offset = user_data;
|
double *current_offset = user_data;
|
||||||
|
|||||||
@ -1141,6 +1141,8 @@ struct place_data {
|
|||||||
EekKeyboard *keyboard;
|
EekKeyboard *keyboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const double section_spacing = 7.0;
|
||||||
|
|
||||||
static void section_placer(EekElement *element, gpointer user_data) {
|
static void section_placer(EekElement *element, gpointer user_data) {
|
||||||
struct place_data *data = user_data;
|
struct place_data *data = user_data;
|
||||||
|
|
||||||
@ -1151,14 +1153,14 @@ static void section_placer(EekElement *element, gpointer user_data) {
|
|||||||
eek_element_get_bounds(element, §ion_bounds);
|
eek_element_get_bounds(element, §ion_bounds);
|
||||||
section_bounds.y = data->current_offset;
|
section_bounds.y = data->current_offset;
|
||||||
eek_element_set_bounds(element, §ion_bounds);
|
eek_element_set_bounds(element, §ion_bounds);
|
||||||
data->current_offset += section_bounds.height;
|
data->current_offset += section_bounds.height + section_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void section_counter(EekElement *element, gpointer user_data) {
|
static void section_counter(EekElement *element, gpointer user_data) {
|
||||||
double *total_height = user_data;
|
double *total_height = user_data;
|
||||||
EekBounds section_bounds = {0};
|
EekBounds section_bounds = {0};
|
||||||
eek_element_get_bounds(element, §ion_bounds);
|
eek_element_get_bounds(element, §ion_bounds);
|
||||||
*total_height += section_bounds.height + 2.0;
|
*total_height += section_bounds.height + section_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
Reference in New Issue
Block a user