From 4d3c134e493956c7dc3def5eb69f903444cd7409 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Fri, 4 Dec 2020 22:24:11 +0100 Subject: [PATCH] gui improvements --- katrain/__main__.py | 8 +++++--- katrain/gui.kv | 12 +++++++----- katrain/gui/controlspanel.py | 4 ++-- katrain/gui/kivyutils.py | 2 +- katrain/gui/widgets/movetree.py | 4 +++- katrain/popups.kv | 1 - 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/katrain/__main__.py b/katrain/__main__.py index 418db75..97f24cb 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -413,7 +413,7 @@ class KaTrainGui(Screen, KaTrainBase): try: msg = self.game.write_sgf(filename) self.log(msg, OUTPUT_INFO) - self.controls.set_status(msg, STATUS_INFO) + self.controls.set_status(msg, STATUS_INFO, check_level=False) except Exception as e: self.log(f"Failed to save SGF to {filename}: {e}", OUTPUT_ERROR) @@ -428,12 +428,14 @@ class KaTrainGui(Screen, KaTrainBase): if not filename.lower().endswith(".sgf"): filename += ".sgf" save_game_popup.dismiss() - path, file = os.path.split(filename) + path, file = os.path.split(filename.strip()) + if not path: + path = popup_contents.filesel.path # whatever dir is shown if path != self.config("general/sgf_save"): self.log(f"Updating sgf save path default to {path}", OUTPUT_DEBUG) self._config["general"]["sgf_save"] = path self.save_config("general") - self._do_save_game(filename) + self._do_save_game(os.path.join(path,file)) popup_contents.filesel.on_success = readfile popup_contents.filesel.on_submit = readfile diff --git a/katrain/gui.kv b/katrain/gui.kv index 2cab646..eb5b3a3 100644 --- a/katrain/gui.kv +++ b/katrain/gui.kv @@ -14,6 +14,7 @@ #:import WHITE katrain.gui.style.WHITE #:import BLACK katrain.gui.style.BLACK #:import LIGHTGREY katrain.gui.style.LIGHTGREY +#:import LIGHTERGREY katrain.gui.style.LIGHTERGREY #:import GREEN katrain.gui.style.GREEN #:import YELLOW katrain.gui.style.YELLOW #:import RED katrain.gui.style.RED @@ -534,7 +535,7 @@ TimerOrMoveTree: id: timer_or_movetree size_hint_y: None - height: root.timer_box_height + height: root.timer_box_height + max(0,int(self.mode != MODE_PLAY) * (root.tab_option_height + root.graph_height - graph_panel.height)) BoxLayout: size_hint_x: EPSILON if self.parent.mode != MODE_PLAY else 1 opacity: 0 if self.parent.mode != MODE_PLAY else 1 @@ -557,11 +558,12 @@ on_left_release: root.katrain("resign") MoveTree: id: move_tree + min_height: root.timer_box_height size_hint_x: EPSILON if self.parent.mode == MODE_PLAY else 1 opacity: 0 if self.parent.mode == MODE_PLAY else 1 CollapsablePanel: id: graph_panel - content_height: graph.height # + rank_graph.height + content_height: graph.height options_height: root.tab_option_height closed_label: 'closedlabel:scoregraph' options: ['score','winrate'] @@ -574,7 +576,7 @@ id: graph opacity: 0 if self.hidden else 1 size_hint_y: None - height: EPSILON if self.hidden else root.graph_height + height: root.graph_height CollapsablePanel: id: stats_panel num_active: 3 @@ -626,7 +628,7 @@ padding: 0 id: notebox size_hint: 1,0 - IMETextField: + LabelledTextInput: id: note font_size: NOTES_FONT_SIZE multiline: True @@ -637,7 +639,7 @@ size_hint: 1, 1 canvas.before: Color: - rgba: LIGHTGREY + rgba: LIGHTERGREY Line: points: self.x, self.y+self.height, self.x+self.width, self.y+self.height width: 1 diff --git a/katrain/gui/controlspanel.py b/katrain/gui/controlspanel.py index 652a84d..8d70461 100644 --- a/katrain/gui/controlspanel.py +++ b/katrain/gui/controlspanel.py @@ -90,9 +90,9 @@ class ControlsPanel(BoxLayout): else rank_label(player_info.calculated_rank) ) - def set_status(self, msg, status_type, at_node=None): + def set_status(self, msg, status_type, at_node=None, check_level=True): at_node = at_node or self.katrain and self.katrain.game and self.katrain.game.current_node - if at_node != self.status_state[2] or int(status_type) >= int(self.status_state[1]) or msg == "": + if at_node != self.status_state[2] or not check_level or int(status_type) >= int(self.status_state[1]) or msg == "": if self.status_state != (msg, status_type, at_node): # prevent loop if error in update eval Clock.schedule_once(self.update_evaluation, 0) self.status_state = (msg, status_type, at_node) diff --git a/katrain/gui/kivyutils.py b/katrain/gui/kivyutils.py index c024a74..7a31005 100644 --- a/katrain/gui/kivyutils.py +++ b/katrain/gui/kivyutils.py @@ -372,7 +372,7 @@ class PlayerInfo(MDBoxLayout, BackgroundMixin): active = BooleanProperty(True) -class TimerOrMoveTree(BoxLayout): +class TimerOrMoveTree(MDBoxLayout): mode = StringProperty(MODE_PLAY) diff --git a/katrain/gui/widgets/movetree.py b/katrain/gui/widgets/movetree.py index 7d90e6b..b907632 100644 --- a/katrain/gui/widgets/movetree.py +++ b/katrain/gui/widgets/movetree.py @@ -3,6 +3,7 @@ from collections import defaultdict from kivy.graphics.context_instructions import Color from kivy.graphics.vertex_instructions import Line, Rectangle from kivy.lang import Builder +from kivy.metrics import dp from kivy.properties import BooleanProperty, Clock, NumericProperty, ObjectProperty from kivy.uix.dropdown import DropDown from kivy.uix.scrollview import ScrollView @@ -115,7 +116,7 @@ class MoveTreeCanvas(Widget): return spacing = 5 moves_vert = 3 - self.move_size = (self.scroll_view_widget.height - (moves_vert + 1) * spacing) / moves_vert + self.move_size = (self.scroll_view_widget.min_height - (moves_vert + 1) * spacing) / moves_vert root = current_node.root @@ -186,6 +187,7 @@ class MoveTreeCanvas(Widget): class MoveTree(ScrollView, BackgroundMixin): current_node = ObjectProperty(None) + min_height = NumericProperty(dp(50)) # non-expanded height, to determine the node size def __init__(self, **kwargs): super().__init__(**kwargs) diff --git a/katrain/popups.kv b/katrain/popups.kv index 82937bc..f02c488 100644 --- a/katrain/popups.kv +++ b/katrain/popups.kv @@ -11,7 +11,6 @@ #:set INPUT_FONT_SIZE sp(25) #:set DESC_FONT_SIZE sp(20) -#:set LIGHTGREY [0.7,0.7,0.7,1] #:import BACKGROUND_COLOR katrain.gui.style.BACKGROUND_COLOR #:import LIGHTGREY katrain.gui.style.LIGHTGREY #:import TEXT_COLOR katrain.gui.style.TEXT_COLOR