diff libgui/src/m-editor/file-editor-tab.cc @ 29220:ab8aa1bb3c2f

add gui utilities with first function for color interpolation * gui-utils.cc: new file; (interpolate_color): new function for deteriming a color similar to a first color but with less contrast to a second one * gui-utils.h: new file with declaration of interpolate_color * file-editor-tab.cc (update_lexer_settings): use new utility function for computing margin colors from given editor colors * led-indicator.cc (style_sheet): use new utility function for computing the colors for the led indicator * module.mk: added source gui.utils.cc with header gui-utils.h
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 27 Dec 2020 19:07:32 +0100
parents 5749eec4e2f2
children 7854d5752dd2
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Dec 25 17:13:14 2020 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Dec 27 19:07:32 2020 +0100
@@ -70,6 +70,7 @@
 #include "gui-preferences-cs.h"
 #include "gui-preferences-ed.h"
 #include "gui-preferences-global.h"
+#include "gui-utils.h"
 #include "marker.h"
 #include "octave-qobject.h"
 #include "octave-txt-lexer.h"
@@ -875,27 +876,19 @@
     QColor bg = lexer->paper (0);
     QColor fg = lexer->color (0);
 
-    int bh, bs, bv, fh, fs, fv, h, s, v;
-    bg.getHsv (&bh,&bs,&bv);
-    fg.getHsv (&fh,&fs,&fv);
-
     // margin colors
-    h = bh;
-    s = bs/2;
-    v = bv + (fv - bv)/5;
-
-    bg.setHsv (h,s,v);
-    m_edit_area->setEdgeColor (bg);
-
-    v = bv + (fv - bv)/8;
-    bg.setHsv (h,s,v);
-    v = bv + (fv - bv)/4;
-    fg.setHsv (h,s,v);
+    QColor bgm, fgm;
+
+    bgm = interpolate_color (bg, fg, 0.5, 0.2);
+    m_edit_area->setEdgeColor (bgm);
 
     m_edit_area->setMarkerForegroundColor (lexer->color (0));
     m_edit_area->setMarginsForegroundColor (lexer->color (0));
-    m_edit_area->setMarginsBackgroundColor (bg);
-    m_edit_area->setFoldMarginColors (bg,fg);
+
+    bgm = interpolate_color (bg, fg, 0.5, 0.125);
+    fgm = interpolate_color (bg, fg, 0.5, 0.25);
+    m_edit_area->setMarginsBackgroundColor (bgm);
+    m_edit_area->setFoldMarginColors (bgm, fgm);
 
     // color indicator for highlighting all occurrences:
     // applications highlight color with more transparency