Skip to content

Commit

Permalink
Change how colors are defined and used
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFenX committed Feb 20, 2024
1 parent f89a8a9 commit 465e43e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
40 changes: 15 additions & 25 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,21 @@

CATALOG = 'lang'

isDark = False
try:
isDark = wx.SystemAppearance().IsDark()
except (KeyboardInterrupt, SystemExit):
raise
except:
pass


if isDark:
slotColourMap = {
FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13
FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5
FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5
FittingSlot.RIG: '',
FittingSlot.SUBSYSTEM: ''}
errColor = wx.Colour(70, 20, 20)
else:
slotColourMap = {
FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots
FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots
FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots
FittingSlot.RIG: '',
FittingSlot.SUBSYSTEM: ''}
errColor = wx.Colour(204, 51, 51)

slotColourMapDark = {
FittingSlot.LOW: wx.Colour(44, 36, 19), # yellow = low slots 24/13
FittingSlot.MED: wx.Colour(28, 39, 51), # blue = mid slots 8.1/9.5
FittingSlot.HIGH: wx.Colour(53, 31, 34), # red = high slots 6.5/11.5
FittingSlot.RIG: '',
FittingSlot.SUBSYSTEM: ''}
errColorDark = wx.Colour(70, 20, 20)
slotColourMap = {
FittingSlot.LOW: wx.Colour(250, 235, 204), # yellow = low slots
FittingSlot.MED: wx.Colour(188, 215, 241), # blue = mid slots
FittingSlot.HIGH: wx.Colour(235, 204, 209), # red = high slots
FittingSlot.RIG: '',
FittingSlot.SUBSYSTEM: ''}
errColor = wx.Colour(204, 51, 51)


def getClientSecret():
Expand Down
4 changes: 3 additions & 1 deletion gui/builtinItemStatsViews/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# noinspection PyPackageRequirements
import wx.lib.mixins.listctrl as listmix

from gui.utils.dark import isDark


class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter):
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
listmix.ListCtrlAutoWidthMixin.__init__(self)
listmix.ListRowHighlighter.__init__(self)
if wx.SystemSettings.GetAppearance().IsDark():
if isDark():
listcol = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOX)
highlight = listcol.ChangeLightness(110)
listmix.ListRowHighlighter.SetHighlightColor(self, highlight)
Expand Down
10 changes: 7 additions & 3 deletions gui/builtinViews/fittingView.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
from gui.chrome_tabs import EVT_NOTEBOOK_PAGE_CHANGED
from gui.contextMenu import ContextMenu
from gui.utils.staticHelpers import DragDropHelper
from gui.utils.dark import isDark
from service.fit import Fit
from service.market import Market
from config import slotColourMap, errColor
from config import slotColourMap, slotColourMapDark, errColor, errColorDark
from gui.fitCommands.helpers import getSimilarModPositions

pyfalog = Logger(__name__)
Expand Down Expand Up @@ -729,7 +730,10 @@ def click(self, event):
event.Skip()

def slotColour(self, slot):
return slotColourMap.get(slot) or self.GetBackgroundColour()
if isDark():
return slotColourMapDark.get(slot) or self.GetBackgroundColour()
else:
return slotColourMap.get(slot) or self.GetBackgroundColour()

def refresh(self, stuff):
"""
Expand Down Expand Up @@ -774,7 +778,7 @@ def refresh(self, stuff):


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

Expand Down
10 changes: 10 additions & 0 deletions gui/utils/dark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import wx


def isDark():
try:
return wx.SystemSettings.GetAppearance().IsDark()
except (KeyboardInterrupt, SystemExit):
raise
except:
return False

0 comments on commit 465e43e

Please sign in to comment.