From 44cc474d39e0cb385fb105f99117f8b9776aa9f0 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 5 May 2005 09:02:07 +0000 Subject: improve label rendering improve label rendering --- src/GipfelWidget.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/GipfelWidget.cxx') diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 49562cf..5710ad0 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -1,5 +1,5 @@ // -// "$Id: GipfelWidget.cxx,v 1.18 2005/05/03 21:36:39 hofmann Exp $" +// "$Id: GipfelWidget.cxx,v 1.19 2005/05/05 11:02:07 hofmann Exp $" // // PSEditWidget routines. // @@ -68,7 +68,7 @@ GipfelWidget::load_image(const char *file) { if (img == NULL) { return 1; } - + w(img->w()); h(img->h()); @@ -135,6 +135,12 @@ GipfelWidget::draw() { fl_pop_clip(); } + +static int +overlap(int m1, int n1, int m2, int n2) { + return m1 <= n2 && n1 >= m2; +} + void GipfelWidget::set_labels(Mountains *v) { int i, j, width, height; @@ -146,14 +152,14 @@ GipfelWidget::set_labels(Mountains *v) { m = v->get(i); fl_measure(m->name, width, height); - m->label_x = m->x + width; m->label_y = m->y; for (j=0; jget_num() && j < i; j++) { n = v->get(j); - if (n->label_x >= m->x && n->label_y >= m->label_y - 1 && n->label_y <= m->label_y + height + 1) { + if (overlap(m->x, m->label_x, n->x, n->label_x) && + overlap(m->label_y - height, m->label_y, n->label_y - height, n->label_y)) { m->label_y = n->label_y - height - 1; } } -- cgit v1.2.3