1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 09:39:42 +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_overlays; /* pop-up dialogs */
struct overlay *pop_underlays; struct overlay *pop_underlays;
int pop_x, pop_y; int pop_x, pop_y;
int pop_dx, pop_dy;
struct aoi *aois; /* areas of interest; in canvas coord */ struct aoi *aois; /* areas of interest; in canvas coord */
struct gui_sheet delta_a; 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); gtk_widget_get_allocation(ctx->da, &alloc);
mx = (sx + ex) / 2; mx = (sx + ex) / 2;
my = (sy + ey) / 2; my = (sy + ey) / 2;
ctx->pop_x = mx < alloc.width / 2 ? if (mx < alloc.width / 2) {
sx - CHEAT : -(alloc.width - ex) + CHEAT; ctx->pop_x = sx - CHEAT;
ctx->pop_y = my < alloc.height / 2 ? ctx->pop_dx = 1;
sy - CHEAT : -(alloc.height - ey) + CHEAT; } 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(); input_update();
redraw(ctx); redraw(ctx);

View File

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