layouts: Fixed spacing
This commit is contained in:
@ -199,32 +199,21 @@ void
|
||||
_eek_rounded_polygon (cairo_t *cr,
|
||||
gdouble radius,
|
||||
EekPoint *points,
|
||||
gint num_points)
|
||||
guint num_points)
|
||||
{
|
||||
gint i, j;
|
||||
|
||||
cairo_move_to (cr,
|
||||
(gdouble) (points[num_points - 1].x +
|
||||
points[0].x) / 2,
|
||||
(gdouble) (points[num_points - 1].y +
|
||||
points[0].y) / 2);
|
||||
|
||||
|
||||
#ifdef KBDRAW_DEBUG
|
||||
printf (" rounded polygon of radius %f:\n", radius);
|
||||
#endif
|
||||
for (i = 0; i < num_points; i++) {
|
||||
j = (i + 1) % num_points;
|
||||
for (guint i = 0; i < num_points; i++) {
|
||||
guint j = (i + 1) % num_points;
|
||||
rounded_corner (cr, (gdouble) points[i].x,
|
||||
(gdouble) points[i].y,
|
||||
(gdouble) (points[i].x + points[j].x) / 2,
|
||||
(gdouble) (points[i].y + points[j].y) / 2,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ typedef struct _TextProperty TextProperty;
|
||||
extern void _eek_rounded_polygon (cairo_t *cr,
|
||||
gdouble radius,
|
||||
EekPoint *points,
|
||||
gint num_points);
|
||||
guint num_points);
|
||||
|
||||
static void eek_renderer_real_render_key_label (EekRenderer *self,
|
||||
PangoLayout *layout,
|
||||
@ -116,8 +116,8 @@ create_keyboard_surface_key_callback (EekElement *element,
|
||||
cairo_rectangle (data->cr,
|
||||
0.0,
|
||||
0.0,
|
||||
bounds.width * priv->scale,
|
||||
bounds.height * priv->scale);
|
||||
bounds.width * priv->scale + 100,
|
||||
bounds.height * priv->scale + 100);
|
||||
cairo_clip (data->cr);
|
||||
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);
|
||||
EekOutline *outline;
|
||||
EekBounds bounds;
|
||||
gdouble scale;
|
||||
gint i;
|
||||
guint oref;
|
||||
EekThemeNode *theme_node;
|
||||
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,
|
||||
EEK_SIDE_TOP);
|
||||
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,
|
||||
&border_color);
|
||||
} else {
|
||||
foreground = priv->default_foreground_color;
|
||||
background = priv->default_background_color;
|
||||
gradient_type = EEK_GRADIENT_NONE;
|
||||
border_width = priv->border_width;
|
||||
border_width = (gint)round(priv->border_width);
|
||||
border_radius = -1;
|
||||
border_color.red = ABS(background.red - foreground.red) * 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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
for (i = 0; i < outline->num_points; i++) {
|
||||
outline->points[i].x *= priv->scale * scale;
|
||||
outline->points[i].y *= priv->scale * scale;
|
||||
for (guint i = 0; i < outline->num_points; i++) {
|
||||
outline->points[i].x *= priv->scale;
|
||||
outline->points[i].y *= priv->scale;
|
||||
}
|
||||
|
||||
cairo_translate (cr,
|
||||
border_width * priv->scale * scale,
|
||||
border_width * priv->scale * scale);
|
||||
border_width * priv->scale,
|
||||
border_width * priv->scale);
|
||||
|
||||
if (gradient_type != EEK_GRADIENT_NONE) {
|
||||
cairo_pattern_t *pat;
|
||||
@ -340,6 +332,10 @@ render_key_outline (EekRenderer *renderer,
|
||||
outline->num_points);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_translate (cr,
|
||||
-border_width * priv->scale,
|
||||
-border_width * priv->scale);
|
||||
|
||||
eek_outline_free (outline);
|
||||
}
|
||||
|
||||
@ -464,10 +460,11 @@ render_key (EekRenderer *self,
|
||||
if (!outline_surface) {
|
||||
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 =
|
||||
cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
bounds.width,
|
||||
bounds.height);
|
||||
(int)ceil(bounds.width) + 10,
|
||||
(int)ceil(bounds.height) + 10);
|
||||
cr = cairo_create (outline_surface);
|
||||
|
||||
/* 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) {
|
||||
double *current_offset = user_data;
|
||||
|
||||
@ -1141,6 +1141,8 @@ struct place_data {
|
||||
EekKeyboard *keyboard;
|
||||
};
|
||||
|
||||
const double section_spacing = 7.0;
|
||||
|
||||
static void section_placer(EekElement *element, gpointer 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);
|
||||
section_bounds.y = data->current_offset;
|
||||
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) {
|
||||
double *total_height = user_data;
|
||||
EekBounds section_bounds = {0};
|
||||
eek_element_get_bounds(element, §ion_bounds);
|
||||
*total_height += section_bounds.height + 2.0;
|
||||
*total_height += section_bounds.height + section_spacing;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
Reference in New Issue
Block a user