1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-22 14:55:55 +02:00

eeshow/gui/: use overlay_draw_all_d for glabels, due to offsets

The offsets can move the coordinates across zero, thus flipping the alignment.
overlay_draw_all_d is immune to this.
This commit is contained in:
Werner Almesberger 2016-08-19 05:22:42 -03:00
parent 85a47724d7
commit 7eff14b7cd
3 changed files with 21 additions and 8 deletions

View File

@ -81,6 +81,7 @@ struct gui_ctx {
struct overlay *pop_overlays; /* pop-up dialogs */
struct overlay *pop_underlays;
int pop_x, pop_y;
int pop_dx, pop_dy;
struct aoi *aois; /* areas of interest; in canvas coord */
struct gui_sheet delta_a;

View File

@ -220,10 +220,20 @@ static bool hover_glabel(void *user, bool on)
gtk_widget_get_allocation(ctx->da, &alloc);
mx = (sx + ex) / 2;
my = (sy + ey) / 2;
ctx->pop_x = mx < alloc.width / 2 ?
sx - CHEAT : -(alloc.width - ex) + CHEAT;
ctx->pop_y = my < alloc.height / 2 ?
sy - CHEAT : -(alloc.height - ey) + CHEAT;
if (mx < alloc.width / 2) {
ctx->pop_x = sx - CHEAT;
ctx->pop_dx = 1;
} else {
ctx->pop_x = ex + CHEAT;
ctx->pop_dx = -1;
}
if (my < alloc.height / 2) {
ctx->pop_y = sy - CHEAT;
ctx->pop_dy = 1;
} else {
ctx->pop_y = ey + CHEAT;
ctx->pop_dy = -1;
}
input_update();
redraw(ctx);

View File

@ -89,10 +89,12 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
VCS_OVERLAYS_X,
VCS_OVERLAYS_Y + (ctx->showing_history ? ctx->hist_y_offset : 0),
0, 1);
overlay_draw_all(ctx->pop_underlays, cr, ctx->pop_x, ctx->pop_y);
overlay_draw_all(ctx->pop_overlays, cr,
ctx->pop_x + sign1(ctx->pop_x) * GLABEL_STACK_PADDING,
ctx->pop_y + sign1(ctx->pop_y) * GLABEL_STACK_PADDING);
overlay_draw_all_d(ctx->pop_underlays, cr, ctx->pop_x, ctx->pop_y,
ctx->pop_dx, ctx->pop_dy);
overlay_draw_all_d(ctx->pop_overlays, cr,
ctx->pop_x + ctx->pop_dx * GLABEL_STACK_PADDING,
ctx->pop_y + ctx->pop_dy * GLABEL_STACK_PADDING,
ctx->pop_dx, ctx->pop_dy);
return FALSE;
}