From 8f1eac61a91ee911d9cf5cc57615796fe772967a Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 18 Nov 2009 14:47:30 +0000 Subject: [PATCH] Now color-bar shows FG/BG indicators (Ilija Melentijevic idea). --- src/widgets/colbar.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/widgets/colbar.cpp b/src/widgets/colbar.cpp index 3b109ce90..2b63daff9 100644 --- a/src/widgets/colbar.cpp +++ b/src/widgets/colbar.cpp @@ -297,7 +297,7 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg) h = (y2-y1+1-(4+FGBGSIZE*2+4)); - /* draw gradient */ + /* draw range */ for (c=beg; c<=end; c++) { v1 = y1 + h*(c-beg )/(end-beg+1); v2 = y1 + h*(c-beg+1)/(end-beg+1) - 1; @@ -309,6 +309,25 @@ static bool colorbar_msg_proc(JWidget widget, JMessage msg) c == colorbar->hot_editing), (colorbar->hot_drag == c && colorbar->hot_drag != colorbar->hot_drop)); + + if (color_equals(colorbar->fgcolor, colorbar->color[c])) { + int neg = blackandwhite_neg(color_get_red(imgtype, colorbar->fgcolor), + color_get_green(imgtype, colorbar->fgcolor), + color_get_blue(imgtype, colorbar->fgcolor)); + + textout_ex(doublebuffer, widget->font(), "FG", + x1+4, v1+2, neg, -1); + } + + if (color_equals(colorbar->bgcolor, colorbar->color[c])) { + int neg = blackandwhite_neg(color_get_red(imgtype, colorbar->bgcolor), + color_get_green(imgtype, colorbar->bgcolor), + color_get_blue(imgtype, colorbar->bgcolor)); + + textout_ex(doublebuffer, widget->font(), "BG", + x2-3-text_length(widget->font(), "BG"), + v2-jwidget_get_text_height(widget), neg, -1); + } } /* draw foreground color */