Skip to content

Commit

Permalink
Style update
Browse files Browse the repository at this point in the history
  • Loading branch information
mlau154 committed Jan 28, 2024
1 parent 251ea06 commit 53cecdd
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 18 deletions.
30 changes: 21 additions & 9 deletions pymead/gui/constraint_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ def show(self):
def update(self):
pass

def setStyle(self, theme: dict):
for item in self.canvas_items:
if isinstance(item, pg.ArrowItem):
item.setStyle(brush=theme["main-color"])
elif isinstance(item, pg.TextItem):
item.setColor(theme["main-color"])
elif isinstance(item, pg.PlotDataItem) or isinstance(item, pg.PlotCurveItem):
pen = item.opts["pen"]
if isinstance(pen, QPen):
pen.setColor(QColor(theme["main-color"]))
item.setPen(pen)


class DistanceConstraintItem(ConstraintItem):
def __init__(self, constraint: DistanceConstraint):
self.arrow_style = {"brush": (150, 150, 150), "headLen": 10}
self.text_style = {"color": (255, 255, 255), "anchor": (0.5, 0.5)}
self.arrow_style = {"headLen": 10}
self.text_style = {"anchor": (0.5, 0.5)}
canvas_items = [
pg.ArrowItem(**self.arrow_style),
pg.ArrowItem(**self.arrow_style),
Expand Down Expand Up @@ -136,7 +148,7 @@ def update(self):
class AntiParallel3ConstraintItem(ConstraintItem):
def __init__(self, constraint: AntiParallel3Constraint):
self.text_style = dict(anchor=(0.5, 0.5))
pen = pg.mkPen(color="#ffffff", width=1, style=Qt.DashLine)
pen = pg.mkPen(width=1, style=Qt.DashLine)
canvas_items = [
pg.TextItem("\u2225", **self.text_style),
pg.TextItem("\u2225", **self.text_style),
Expand Down Expand Up @@ -168,12 +180,12 @@ def update(self):

class RelAngle3ConstraintItem(ConstraintItem):
def __init__(self, constraint: RelAngle3Constraint):
pen = pg.mkPen(color="#ffffff", width=1, style=Qt.DashLine)
pen = pg.mkPen(width=1, style=Qt.DashLine)
canvas_items = [
pg.PlotDataItem(color="#ffffff"),
pg.PlotDataItem(),
pg.PlotDataItem(pen=pen),
pg.PlotDataItem(pen=pen),
pg.TextItem(anchor=(0, 0.5), color="#ffffff"),
pg.TextItem(anchor=(0, 0.5)),
]
canvas_items[3].setFont(QFont("DejaVu Sans Mono", 10))
super().__init__(constraint=constraint, canvas_items=canvas_items)
Expand Down Expand Up @@ -210,10 +222,10 @@ def update(self):

class Perp3ConstraintItem(ConstraintItem):
def __init__(self, constraint: Perp3Constraint):
pen = pg.mkPen(color="#ffffff", width=1, style=Qt.DashLine)
pen = pg.mkPen(width=1, style=Qt.DashLine)
canvas_items = [
pg.PlotDataItem(color="#ffffff"),
pg.PlotDataItem(color="#ffffff"),
pg.PlotDataItem(),
pg.PlotDataItem(),
pg.PlotDataItem(pen=pen),
pg.PlotDataItem(pen=pen)
]
Expand Down
14 changes: 13 additions & 1 deletion pymead/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,18 @@ def set_theme(self, theme_name: str):
""")
self.parameter_tree.setAutoFillBackground(True)
self.parameter_tree.setStyleSheet(
f"""QTreeWidget::item {{ background-color: {theme['background-color']}; }}
f"""QTreeWidget::item {{ background-color: {theme['tree-background-color']}; }}
QTreeWidget::item:selected {{ background-color: {theme['menu-item-selected-color']}; color: {theme['main-color']} }}
QTreeWidget::item:hover {{ color: #edb126 }}
QTreeWidget {{ background-color: {theme['tree-background-color']} }}
QTreeWidget::branch {{ background: {theme['tree-background-color']} }}
QTreeWidget::branch::closed::has-children {{
image: url(../icons/closed-arrow-{self.current_theme}.png);
}}
QTreeWidget::branch::open::has-children {{
image: url(../icons/opened-arrow-{self.current_theme}.png);
}}
""")
self.parameter_tree.setForegroundColorAllItems(theme['main-color'])
self.airfoil_canvas.setAxisLabels(theme)
Expand All @@ -513,6 +522,9 @@ def set_theme(self, theme_name: str):
# if self.param_tree_instance is not None:
# self.param_tree_instance.set_theme(theme)

for cnstr in self.geo_col.container()["geocon"].values():
cnstr.canvas_item.setStyle(theme)

def set_color_bar_style(self, new_values: dict = None):
if self.cbar is None:
return
Expand Down
6 changes: 3 additions & 3 deletions pymead/gui/gui_settings/themes/dark_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"progress-color": "#6495e3",
"graph-background-color": "#2a2a2b",
"console-background-color": "#2a2a2b",
"tree-background-color": "#3e3f40",
"tree-alternate-color": "#3e3f40",
"tree-selection-color": "#3e3f40",
"tree-background-color": "#2a2a2b",
"tree-alternate-color": "#2a2a2b",
"tree-selection-color": "#2a2a2b",
"tree-hover-color": "#3944bcdd",
"tree-item-color": "#dce1e6",
"tree-item-selected-color": "#3944bcdd",
Expand Down
6 changes: 3 additions & 3 deletions pymead/gui/gui_settings/themes/light_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"progress-color": "#6495e3",
"graph-background-color": "#faf9f6",
"console-background-color": "#faf9f6",
"tree-background-color": "#ffffff",
"tree-alternate-color": "#ffffff",
"tree-selection-color": "#ffffff",
"tree-background-color": "#faf9f6",
"tree-alternate-color": "#faf9f6",
"tree-selection-color": "#faf9f6",
"tree-hover-color": "#3944bcdd",
"tree-item-color": "#000000",
"tree-item-selected-color": "#3944bcdd",
Expand Down
8 changes: 7 additions & 1 deletion pymead/gui/input_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ class PymeadDialog(QDialog):
"""This subclass of QDialog forces the selection of a WindowTitle and matches the visual format of the GUI"""
def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or PymeadDialogVTabWidget):
super().__init__(parent=parent)
self.setWindowTitle(window_title)
self.setWindowTitle(" " + window_title)
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
if self.parent() is not None:
self.setFont(self.parent().font())
Expand All @@ -2065,6 +2065,7 @@ def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or Pyme
# mandatory for cursor updates
self.setMouseTracking(True)

theme = self.parent().themes[self.parent().current_theme]
self.title_bar = DialogTitleBar(self, theme=self.parent().themes[self.parent().current_theme])

self.sideGrips = [
Expand All @@ -2080,6 +2081,11 @@ def __init__(self, parent, window_title: str, widget: PymeadDialogWidget or Pyme

self.resize(self.width(), self.title_bar.height() + self.height())

self.title_bar.title.setStyleSheet(
f"""background-color: qlineargradient(x1: 0.0, y1: 0.5, x2: 1.0, y2: 0.5,
stop: 0 {theme['title-gradient-color']},
stop: 1 {theme['background-color']})""")

# def setInputs(self):
# self.w.setInputs()

Expand Down
1 change: 0 additions & 1 deletion pymead/gui/parameter_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,4 +1135,3 @@ def contextMenuEvent(self, a0):
self.geo_col.demote_desvar_to_param(pymead_obj)

self.geo_col.clear_selected_objects()
# TODO: extend this logic to be more general (e.g., clear_selected_objs())
Binary file removed pymead/icons/add_image.png
Binary file not shown.
Binary file added pymead/icons/closed-arrow-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pymead/icons/closed-arrow-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed pymead/icons/closed-arrow.png
Binary file not shown.
Binary file added pymead/icons/opened-arrow-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pymead/icons/opened-arrow-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed pymead/icons/opened-arrow.png
Binary file not shown.
Binary file removed pymead/icons/symmetry.png
Binary file not shown.
Binary file removed pymead/icons/target_icon.png
Binary file not shown.
Binary file removed pymead/icons/thickness_icon.png
Binary file not shown.

0 comments on commit 53cecdd

Please sign in to comment.