diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2021-04-18 17:25:55 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-06-01 07:46:30 -0400 |
commit | 763cc2fcab85fa01b1135e77c90eb40ebda571f4 (patch) | |
tree | 1ef0a80bb73d6b74a00033dccc155bd3082d797b /grc/gui | |
parent | a26f0b0620fa285936f1992e1a4b30d5f4b6550b (diff) |
GRC: Distinguishing colors for deprecated blocks
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/canvas/block.py | 42 | ||||
-rw-r--r-- | grc/gui/canvas/colors.py | 6 |
2 files changed, 38 insertions, 10 deletions
diff --git a/grc/gui/canvas/block.py b/grc/gui/canvas/block.py index 3b8f479413..42a3fe0ba9 100644 --- a/grc/gui/canvas/block.py +++ b/grc/gui/canvas/block.py @@ -1,5 +1,6 @@ """ Copyright 2007, 2008, 2009 Free Software Foundation, Inc. +Copyright 2020-2021 GNU Radio Contributors This file is part of GNU Radio SPDX-License-Identifier: GPL-2.0-or-later @@ -95,17 +96,38 @@ class Block(CoreBlock, Drawable): self.states['rotation'] = rot def _update_colors(self): - self._bg_color = ( - colors.MISSING_BLOCK_BACKGROUND_COLOR if self.is_dummy_block else - colors.BLOCK_BYPASSED_COLOR if self.state == 'bypassed' else - colors.BLOCK_ENABLED_COLOR if self.state == 'enabled' else - colors.BLOCK_DISABLED_COLOR - ) + def get_bg(): + """ + Get the background color for this block + + Explicit is better than a chain of if/else expressions, + so this was extracted into a nested function. + """ + if self.is_dummy_block: + return colors.MISSING_BLOCK_BACKGROUND_COLOR + if self.state == 'bypassed': + return colors.BLOCK_BYPASSED_COLOR + if self.state == 'enabled': + if self.deprecated: + return colors.BLOCK_DEPRECATED_BACKGROUND_COLOR + return colors.BLOCK_ENABLED_COLOR + return colors.BLOCK_DISABLED_COLOR + + def get_border(): + """ + Get the border color for this block + """ + if self.is_dummy_block: + return colors.MISSING_BLOCK_BORDER_COLOR + if self.deprecated: + return colors.BLOCK_DEPRECATED_BORDER_COLOR + if self.state == 'enabled': + return colors.BORDER_COLOR + return colors.BORDER_COLOR_DISABLED + + self._bg_color = get_bg() self._font_color[-1] = 1.0 if self.state == 'enabled' else 0.4 - self._border_color = ( - colors.MISSING_BLOCK_BORDER_COLOR if self.is_dummy_block else - colors.BORDER_COLOR_DISABLED if not self.state == 'enabled' else colors.BORDER_COLOR - ) + self._border_color = get_border() def create_shapes(self): """Update the block, parameters, and ports when a change occurs.""" diff --git a/grc/gui/canvas/colors.py b/grc/gui/canvas/colors.py index e6dadf8f6d..2ab4933761 100644 --- a/grc/gui/canvas/colors.py +++ b/grc/gui/canvas/colors.py @@ -34,6 +34,12 @@ FONT_COLOR = get_color('#000000') MISSING_BLOCK_BACKGROUND_COLOR = get_color('#FFF2F2') MISSING_BLOCK_BORDER_COLOR = get_color('#FF0000') +# Deprecated blocks +# a light warm yellow +BLOCK_DEPRECATED_BACKGROUND_COLOR = get_color('#FED86B') +# orange +BLOCK_DEPRECATED_BORDER_COLOR = get_color('#FF540B') + # Flow graph color constants FLOWGRAPH_BACKGROUND_COLOR = get_color('#FFFFFF') COMMENT_BACKGROUND_COLOR = get_color('#F3F3F3') |