Skip to content

Commit 465e43e

Browse files
committed
Change how colors are defined and used
1 parent f89a8a9 commit 465e43e

4 files changed

Lines changed: 35 additions & 29 deletions

File tree

config.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,21 @@
5858

5959
CATALOG = 'lang'
6060

61-
isDark = False
62-
try:
63-
isDark = wx.SystemAppearance().IsDark()
64-
except (KeyboardInterrupt, SystemExit):
65-
raise
66-
except:
67-
pass
68-
69-
70-
if isDark:
71-
slotColourMap = {
72-
FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13
73-
FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5
74-
FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5
75-
FittingSlot.RIG: '',
76-
FittingSlot.SUBSYSTEM: ''}
77-
errColor = wx.Colour(70, 20, 20)
78-
else:
79-
slotColourMap = {
80-
FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots
81-
FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots
82-
FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots
83-
FittingSlot.RIG: '',
84-
FittingSlot.SUBSYSTEM: ''}
85-
errColor = wx.Colour(204, 51, 51)
61+
62+
slotColourMapDark = {
63+
FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13
64+
FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5
65+
FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5
66+
FittingSlot.RIG: '',
67+
FittingSlot.SUBSYSTEM: ''}
68+
errColorDark = wx.Colour(70, 20, 20)
69+
slotColourMap = {
70+
FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots
71+
FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots
72+
FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots
73+
FittingSlot.RIG: '',
74+
FittingSlot.SUBSYSTEM: ''}
75+
errColor = wx.Colour(204, 51, 51)
8676

8777

8878
def getClientSecret():

gui/builtinItemStatsViews/helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
# noinspection PyPackageRequirements
55
import wx.lib.mixins.listctrl as listmix
66

7+
from gui.utils.dark import isDark
8+
79

810
class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter):
911
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
1012
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
1113
listmix.ListCtrlAutoWidthMixin.__init__(self)
1214
listmix.ListRowHighlighter.__init__(self)
13-
if wx.SystemSettings.GetAppearance().IsDark():
15+
if isDark():
1416
listcol = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX)
1517
highlight = listcol.ChangeLightness(110)
1618
listmix.ListRowHighlighter.SetHighlightColor(self, highlight)

gui/builtinViews/fittingView.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
from gui.chrome_tabs import EVT_NOTEBOOK_PAGE_CHANGED
4040
from gui.contextMenu import ContextMenu
4141
from gui.utils.staticHelpers import DragDropHelper
42+
from gui.utils.dark import isDark
4243
from service.fit import Fit
4344
from service.market import Market
44-
from config import slotColourMap, errColor
45+
from config import slotColourMap, slotColourMapDark, errColor, errColorDark
4546
from gui.fitCommands.helpers import getSimilarModPositions
4647

4748
pyfalog = Logger(__name__)
@@ -729,7 +730,10 @@ def click(self, event):
729730
event.Skip()
730731

731732
def slotColour(self, slot):
732-
return slotColourMap.get(slot) or self.GetBackgroundColour()
733+
if isDark():
734+
return slotColourMapDark.get(slot) or self.GetBackgroundColour()
735+
else:
736+
return slotColourMap.get(slot) or self.GetBackgroundColour()
733737

734738
def refresh(self, stuff):
735739
"""
@@ -774,7 +778,7 @@ def refresh(self, stuff):
774778

775779

776780
if slotMap[mod.slot] or hasRestrictionOverriden: # Color too many modules as red
777-
self.SetItemBackgroundColour(i, errColor)
781+
self.SetItemBackgroundColour(i, errColorDark if isDark() else errColor)
778782
elif sFit.serviceFittingOptions["colorFitBySlot"]: # Color by slot it enabled
779783
self.SetItemBackgroundColour(i, self.slotColour(mod.slot))
780784

gui/utils/dark.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import wx
2+
3+
4+
def isDark():
5+
try:
6+
return wx.SystemSettings.GetAppearance().IsDark()
7+
except (KeyboardInterrupt, SystemExit):
8+
raise
9+
except:
10+
return False

0 commit comments

Comments
 (0)