panel
This commit is contained in:
1 parent
ee14597314
commit
96f1cc8a2e
4 files changed
+65
-37
No files matched your search
+9
-10
@@ -181,14 +181,13 @@
|
||||
mipmap: True
|
||||
|
||||
|
||||
<TransparentIconButton@Button>:
|
||||
<TransparentIconButton>:
|
||||
background_normal: ''
|
||||
background_color: (0,0,0,0)
|
||||
icon_size: min(self.size[0],self.size[1])
|
||||
icon: ''
|
||||
icon_size: self.icon_size or [min(self.size[0],self.size[1]),min(self.size[0],self.size[1])]
|
||||
Image:
|
||||
size: (root.icon_size or 0,root.icon_size or 0) # square
|
||||
pos: [root.pos[i] + (root.size[i] - root.icon_size)/2 for i in [0,1]] if root.icon_size else [0,0]
|
||||
size: root.icon_size
|
||||
pos: [root.pos[i] + (root.size[i] - root.icon_size[i])/2 for i in [0,1]]
|
||||
source: root.icon
|
||||
mipmap: True
|
||||
|
||||
@@ -232,11 +231,10 @@
|
||||
text: root.label
|
||||
font_size: self.size[1] * 0.8
|
||||
on_press: value.opacity = 1 if value.opacity==0 else 0
|
||||
MDLabel:
|
||||
Label:
|
||||
size_hint: 0.4,1
|
||||
text: root.text
|
||||
theme_text_color: 'Custom'
|
||||
text_color: root.color
|
||||
color: root.color
|
||||
font_size: desc.font_size
|
||||
id: value
|
||||
bold: True
|
||||
@@ -250,7 +248,7 @@
|
||||
size: (root.min_size,root.min_size)
|
||||
source: 'img/white.png' if root.player=='White' else 'img/black.png'
|
||||
mipmap: True
|
||||
MDLabel:
|
||||
Label:
|
||||
text: root.text
|
||||
bold: True
|
||||
color: BLACK if root.player=='White' else WHITE
|
||||
@@ -316,6 +314,7 @@
|
||||
size_hint: 0.06, 0.5
|
||||
pos_hint: {'center_y': 0.5}
|
||||
|
||||
|
||||
<BadukPanControls>:
|
||||
katrain: app.gui
|
||||
circles: [black_circle,white_circle]
|
||||
@@ -667,7 +666,7 @@
|
||||
size_hint_x: 0.7
|
||||
CollapsablePanel:
|
||||
size_hint_y: GRAPH_BOX_HEIGHT
|
||||
options: ['Score','Win Rate','Points Lost']
|
||||
options: ['Score','Win Rate','PtLoss']
|
||||
option_colors: [SCORE_COLOR,WINRATE_COLOR,POINTLOSS_COLOR]
|
||||
option_active: [True,False,False]
|
||||
options_height: root.tab_option_height
|
||||
|
||||
@@ -2,10 +2,10 @@ import math
|
||||
|
||||
from kivy.properties import ListProperty, NumericProperty
|
||||
|
||||
from katrain.gui.kivyutils import BackgroundLabel
|
||||
from katrain.gui.kivyutils import BackgroundColor
|
||||
|
||||
|
||||
class ScoreGraph(BackgroundLabel):
|
||||
class ScoreGraph(BackgroundColor):
|
||||
nodes = ListProperty([])
|
||||
score_points = ListProperty([])
|
||||
winrate_points = ListProperty([])
|
||||
|
||||
+52
-23
@@ -4,6 +4,7 @@ import re
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.core.text import Label as CoreLabel
|
||||
from kivy.uix.label import Label
|
||||
from kivy.core.window import Window
|
||||
from kivy.graphics import *
|
||||
from kivy.properties import BooleanProperty, ListProperty, NumericProperty, StringProperty, OptionProperty, ObjectProperty
|
||||
@@ -23,7 +24,6 @@ from kivymd.uix.behaviors import RectangularRippleBehavior
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
from kivymd.uix.button import BasePressedButton, BaseFlatButton
|
||||
from kivymd.uix.floatlayout import MDFloatLayout
|
||||
from kivymd.uix.label import MDLabel
|
||||
from kivymd.uix.navigationdrawer import MDNavigationDrawer
|
||||
|
||||
# --- new mixins
|
||||
@@ -69,6 +69,7 @@ class SizedMDBaseButton(BasePressedButton, BaseFlatButton, LeftButtonBehavior):
|
||||
label = ObjectProperty(None)
|
||||
height = NumericProperty(33)
|
||||
|
||||
|
||||
class SizedMDFlatButton(RectangularRippleBehavior, SizedMDBaseButton):
|
||||
pass
|
||||
|
||||
@@ -83,18 +84,20 @@ class SizedMDFlatRectangleToggleButton(SizedMDFlatRectangleButton, ToggleButtonB
|
||||
@property
|
||||
def active(self):
|
||||
return self.state == "down"
|
||||
return self.state == "down"
|
||||
|
||||
|
||||
class AutoSizedMDFlatRectangleToggleButton(SizedMDFlatRectangleToggleButton):
|
||||
hor_padding = NumericProperty(3)
|
||||
|
||||
|
||||
class TransparentIconButton(Button):
|
||||
icon_size = ListProperty([25, 25])
|
||||
icon = StringProperty("")
|
||||
|
||||
|
||||
# -- basic styles
|
||||
class LightLabel(MDLabel):
|
||||
pass
|
||||
|
||||
|
||||
class BackgroundLabel(MDLabel, BackgroundColor):
|
||||
class LightLabel(Label):
|
||||
pass
|
||||
|
||||
|
||||
@@ -104,7 +107,7 @@ class CensorableLabel(MDBoxLayout):
|
||||
color = ListProperty([1, 1, 1, 1])
|
||||
|
||||
|
||||
class MyNavigationDrawer(MDNavigationDrawer): # in PR
|
||||
class MyNavigationDrawer(MDNavigationDrawer): # in PR - closes NavDrawer on any outside click
|
||||
def on_touch_down(self, touch):
|
||||
return super().on_touch_down(touch)
|
||||
|
||||
@@ -121,7 +124,7 @@ class CircleWithText(MDFloatLayout):
|
||||
min_size = NumericProperty(50)
|
||||
|
||||
|
||||
# -- gui elements
|
||||
# -- new gui elements
|
||||
|
||||
|
||||
class MainMenuItem(RectangularRippleBehavior, LeftButtonBehavior, MDBoxLayout):
|
||||
@@ -145,42 +148,68 @@ class CollapsablePanel(MDBoxLayout):
|
||||
options_height = NumericProperty(25)
|
||||
option_active = ListProperty([])
|
||||
option_colors = ListProperty([])
|
||||
state = OptionProperty("open", options=["open", "close"])
|
||||
close_icon = "img/flaticon/previous999.png"
|
||||
open_icon = "img/flaticon/next999.png"
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.contents = None
|
||||
self.header = MDBoxLayout(adaptive_height=True, padding=[4, 0, 0, 0], spacing=2)
|
||||
self.option_buttons = []
|
||||
super().__init__(**kwargs)
|
||||
self.orientation = "vertical"
|
||||
self.bind(options=self.build, option_colors=self.build, options_height=self.build, option_active=self.build)
|
||||
|
||||
def build(self, *args, **kwargs):
|
||||
print(args, kwargs, "b")
|
||||
print(args, kwargs, "b",self.size,self.pos)
|
||||
self.clear_widgets()
|
||||
header = MDBoxLayout(adaptive_height=True, padding=[4, 0, 0, 0],spacing=2)
|
||||
option_colors = self.option_colors
|
||||
for opt, opt_col, active in zip(self.options, option_colors, self.option_active):
|
||||
header.add_widget(AutoSizedMDFlatRectangleToggleButton(text=opt, color=opt_col,
|
||||
height=self.options_height,
|
||||
on_press=lambda _:print(self.size,_.size),
|
||||
state="down" if active else "normal"))
|
||||
header.add_widget(SizedMDFlatRectangleButton(text="x",height=self.options_height))
|
||||
super().add_widget(header)
|
||||
if self.contents:
|
||||
super().add_widget(self.contents)
|
||||
|
||||
self.header.clear_widgets()
|
||||
self.option_buttons = []
|
||||
for opt, opt_col, active in zip(self.options, self.option_colors, self.option_active):
|
||||
button = AutoSizedMDFlatRectangleToggleButton(text=opt, color=opt_col, height=self.options_height, on_press=self.trigger_select, state="down" if active else "normal")
|
||||
self.option_buttons.append(button)
|
||||
self.header.add_widget(button)
|
||||
self.header.add_widget(Label()) # spacer
|
||||
open_close_button = TransparentIconButton( # << / >> collapse button
|
||||
icon=self.open_close_icon(),
|
||||
icon_size=[0.5 * self.options_height, 0.5 * self.options_height],
|
||||
size=[0.6 * self.options_height, self.options_height],
|
||||
on_press=self.set_state,
|
||||
)
|
||||
#self.bind(state=lambda _: open_close_button.setter("icon")(self.open_close_icon()))
|
||||
#self.header.add_widget(open_close_button)
|
||||
|
||||
def open_close_icon(self):
|
||||
return self.open_icon if self.state == "open" else self.close_icon
|
||||
|
||||
def add_widget(self, widget, index=0, **_kwargs):
|
||||
if self.contents:
|
||||
raise ValueError("CollapsablePanel can only have one child")
|
||||
self.contents = widget
|
||||
self.build()
|
||||
super().add_widget(self.header)
|
||||
super().add_widget(self.contents)
|
||||
print(self.children,"CHILDREN!",self.size,self.pos)
|
||||
|
||||
def on_option_select(self, states):
|
||||
def set_state(self, state="toggle"):
|
||||
if state == "toggle":
|
||||
state = "close" if self.state == "open" else "open"
|
||||
self.state = state
|
||||
if self.state == "open":
|
||||
self.trigger_select()
|
||||
|
||||
def trigger_select(self, *_args):
|
||||
if self.state == "open":
|
||||
self.on_option_select({opt: btn.state == "down" for opt, btn in zip(self.options, self.option_buttons)})
|
||||
|
||||
def on_option_select(self, options):
|
||||
pass
|
||||
|
||||
|
||||
# --- not checked
|
||||
|
||||
|
||||
class ToolTipLabel(MDLabel):
|
||||
class ToolTipLabel(Label):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from katrain.core.common import OUTPUT_DEBUG, OUTPUT_ERROR
|
||||
from katrain.core.engine import KataGoEngine
|
||||
from katrain.core.game import Game, GameNode
|
||||
from katrain.gui.kivyutils import (
|
||||
BackgroundLabel,
|
||||
BackgroundColor,
|
||||
LabelledCheckBox,
|
||||
LabelledFloatInput,
|
||||
LabelledIntInput,
|
||||
@@ -215,7 +215,7 @@ class ConfigTeacherPopup(QuickConfigGui):
|
||||
for i, (thr, undos, color) in enumerate(zip(thresholds, undos, colors)):
|
||||
thrbox.add_widget(LabelledFloatInput(text=str(thr), input_property=f"eval_thresholds::{i}"))
|
||||
thrbox.add_widget(LabelledFloatInput(text=str(undos), input_property=f"num_undo_prompts::{i}"))
|
||||
thrbox.add_widget(BackgroundLabel(background_color=color[:3]))
|
||||
thrbox.add_widget(BackgroundColor(background_color=color[:3]))
|
||||
thrbox.add_widget(LabelledCheckBox(text=str(color[3] == 1), input_property=f"alpha::{i}"))
|
||||
thrbox.add_widget(LabelledCheckBox(size_hint=(0.5, 1), text=str(self.sgf_settings["save_feedback"][i]), input_property=f"save_feedback::{i}"))
|
||||
self.add_widget(thrbox)
|
||||
|
||||
Reference in new issue
Block a user