256 |
Gdk::Cairo::set_source_rgba(cr, red); |
Gdk::Cairo::set_source_rgba(cr, red); |
257 |
int dr = (dimregno >> bitpos) & |
int dr = (dimregno >> bitpos) & |
258 |
((1 << region->pDimensionDefinitions[i].bits) - 1); |
((1 << region->pDimensionDefinitions[i].bits) - 1); |
259 |
|
|
260 |
|
int x1 = -1, x2 = -1; |
261 |
if (customsplits) { |
if (customsplits) { |
262 |
int x1 = label_width; |
x1 = label_width; |
263 |
for (int j = 0 ; j < nbZones && x1 + 1 < clipx2 ; j++) { |
for (int j = 0 ; j < nbZones && x1 + 1 < clipx2 ; j++) { |
264 |
gig::DimensionRegion* d = |
gig::DimensionRegion* d = |
265 |
region->pDimensionRegions[c + (j << bitpos)]; |
region->pDimensionRegions[c + (j << bitpos)]; |
268 |
upperLimit = d->VelocityUpperLimit; |
upperLimit = d->VelocityUpperLimit; |
269 |
} |
} |
270 |
int v = upperLimit + 1; |
int v = upperLimit + 1; |
271 |
int x2 = int((w - label_width - 1) * v / 128.0 + |
x2 = int((w - label_width - 1) * v / 128.0 + |
272 |
0.5) + label_width; |
0.5) + label_width; |
273 |
if (j == dr && x1 < x2) { |
if (j == dr && x1 < x2) { |
274 |
cr->rectangle(x1 + 1, y + 1, |
cr->rectangle(x1 + 1, y + 1, |
275 |
(x2 - x1) - 1, h - 2); |
(x2 - x1) - 1, h - 2); |
280 |
} |
} |
281 |
} else { |
} else { |
282 |
if (dr < nbZones) { |
if (dr < nbZones) { |
283 |
int x1 = int((w - label_width - 1) * dr / |
x1 = int((w - label_width - 1) * dr / |
284 |
double(nbZones) + 0.5); |
double(nbZones) + 0.5); |
285 |
int x2 = int((w - label_width - 1) * (dr + 1) / |
x2 = int((w - label_width - 1) * (dr + 1) / |
286 |
double(nbZones) + 0.5); |
double(nbZones) + 0.5); |
287 |
cr->rectangle(label_width + x1 + 1, y + 1, |
cr->rectangle(label_width + x1 + 1, y + 1, |
288 |
(x2 - x1) - 1, h - 2); |
(x2 - x1) - 1, h - 2); |
289 |
cr->fill(); |
cr->fill(); |
290 |
} |
} |
291 |
} |
} |
292 |
|
|
293 |
|
// draw text showing the beginning of the dimension zone |
294 |
|
// as numeric value to the user |
295 |
|
if (x1 >= 0) { |
296 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
297 |
|
int v = roundf(float(x1 - label_width) / float(w - label_width) * 127.f); |
298 |
|
if (dr > 0) v++; |
299 |
|
layout->set_text(Glib::Ascii::dtostr(v)); |
300 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
301 |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
302 |
|
|
303 |
|
int text_width, text_height; |
304 |
|
// get the text dimensions |
305 |
|
layout->get_pixel_size(text_width, text_height); |
306 |
|
// move text to the right end of the dimension zone |
307 |
|
cr->move_to(x1 + 1, y + 1); |
308 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
309 |
|
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
310 |
|
#else |
311 |
|
layout->show_in_cairo_context(cr); |
312 |
|
#endif |
313 |
|
} |
314 |
|
// draw text showing the end of the dimension zone |
315 |
|
// as numeric value to the user |
316 |
|
if (x2 >= 0) { |
317 |
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
318 |
|
const int v = roundf(float(x2 - label_width) / float(w - label_width) * 127.f); |
319 |
|
layout->set_text(Glib::Ascii::dtostr(v)); |
320 |
|
Gdk::Cairo::set_source_rgba(cr, black); |
321 |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
322 |
|
|
323 |
|
int text_width, text_height; |
324 |
|
// get the text dimensions |
325 |
|
layout->get_pixel_size(text_width, text_height); |
326 |
|
// move text to the right end of the dimension zone |
327 |
|
cr->move_to(x2 - text_width - 1, y + 1); |
328 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2 |
329 |
|
pango_cairo_show_layout(cr->cobj(), layout->gobj()); |
330 |
|
#else |
331 |
|
layout->show_in_cairo_context(cr); |
332 |
|
#endif |
333 |
|
} |
334 |
} |
} |
335 |
} |
} |
336 |
|
|