VDBAbstractPresenter.st
changeset 230 f4495a7fdec1
parent 224 c828bd96ba14
child 240 c5450baf51cd
--- a/VDBAbstractPresenter.st	Thu Oct 14 13:57:06 2021 +0200
+++ b/VDBAbstractPresenter.st	Thu Oct 14 13:58:22 2021 +0200
@@ -81,15 +81,28 @@
 !
 
 foregroundColor
-    | app |
+    | app fg |
 
     app := self application.
     app notNil ifTrue:[ 
-        ^ app perform: #foregroundColorFor: with: self ifNotUnderstood: [ nil ].
+        fg := app perform: #foregroundColorFor: with: self ifNotUnderstood: [ nil ].
+        "/ If application does not specify foreground color but does specify
+        "/ background color, try to be helpful and choose either white or black
+        "/ foreground, whichever is more contrasting on given background.
+        "/ This helps especially with dark themes.
+        fg isNil ifTrue: [ 
+            | bg |
+
+            bg := self backgroundColor.
+            bg notNil ifTrue: [ 
+                fg := bg contrastingBlackOrWhite.
+            ].
+        ].
     ].
-    ^ nil
+    ^ fg
 
     "Created: / 26-06-2018 / 11:46:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-10-2021 / 13:49:35 / Jan Vrany <jan.vrany@labware.com>"
 !
 
 subject