This commit is contained in:
yumoqing 2020-12-02 12:38:53 +08:00
parent 8b0edbcaed
commit c7d993e5ad
8 changed files with 58 additions and 31 deletions

View File

@ -1,14 +1,16 @@
from kivy.logger import Logger
from kivy.graphics import Color, Rectangle
from kivy.graphics import Color, Rectangle, RoundedRectangle
from kivy.properties import ListProperty
from .color_definitions import getColors
_logcnt = 0
class BGColorBehavior(object):
def __init__(self, color_level=-1,**kwargs):
def __init__(self, color_level=-1,radius=[],**kwargs):
self.color_level = color_level
self.radius = radius
self.bgcolor = []
self.fgcolor = []
self.useOwnColor = False
if color_level != -1:
fg,bg= getColors(color_level)
self.fgcolor = fg
@ -59,7 +61,12 @@ class BGColorBehavior(object):
if self.canvas:
with self.canvas.before:
Color(*self.bgcolor)
self.rect = Rectangle(pos=self.pos,
if self.radius != []:
self.rect = RoundedRectangel(pos=self.pos,
size=self.size,
radius=self.radius)
else:
self.rect = Rectangle(pos=self.pos,
size=self.size)
else:
print('on_bgcolor():self.canvas is None')

View File

@ -22,6 +22,7 @@ from .paging import Paging, RelatedLoader
from .ready import WidgetReady
from .toolbar import Toolbar
from .i18n import I18nText
from .bgcolorbehavior import BGColorBehavior
class BLabel(ButtonBehavior, Text):
def __init__(self, **kw):
@ -118,11 +119,12 @@ class Row(GridLayout):
self.part.datagrid.select_rowid = self.row_id
self.part.datagrid.dispatch('on_selected',self)
class Header(WidgetReady, ScrollWidget):
def __init__(self,part,**kw):
class Header(WidgetReady, BGColorBehavior, ScrollWidget):
def __init__(self,part,color_level=-1,**kw):
self.part = part
ScrollWidget.__init__(self,**kw)
WidgetReady.__init__(self)
BGColorBehavior.__init__(self,color_level=color_level)
self.init(1)
self.bind(on_scroll_stop=self.part.datagrid.on_scrollstop)
@ -220,14 +222,18 @@ class DataGridPart(WidgetReady, BoxLayout):
def addRow(self,id, data):
return self.body.addRow(id, data)
class DataGrid(WidgetReady, BoxLayout):
class DataGrid(WidgetReady, BGColorBehavior, BoxLayout):
row_selected = BooleanProperty(False)
def __init__(self,**options):
def __init__(self,color_level=-1,radius=[],**options):
kw = DictObject()
kw = setSizeOptions(options,kw)
kw.orientation = 'vertical'
self.color_level = color_level
self.radius = radius
WidgetReady.__init__(self)
BoxLayout.__init__(self,**kw)
BGColorBehavior.__init__(self,color_level=color_level,
radius=radius)
self.parenturl = options.get('parenturl',None)
self.options = options
self.noheader = options.get('noheader',False)

View File

@ -259,7 +259,9 @@ class Form(BGColorBehavior, BoxLayout):
self.options = options
BoxLayout.__init__(self, orientation='vertical')
self.color_level = self.options.get('color_level', 0)
BGColorBehavior.__init__(self,color_level=self.color_level)
BGColorBehavior.__init__(self,
color_level=self.options.get('color_level',-1),
radius=self.options.get('radius',[]))
self.readiedInput = 0
self.cols = self.options_cols = self.options.get('cols',1)
if isHandHold() and Window.width < Window.height:

View File

@ -15,9 +15,11 @@ logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
class NewVideo(BGColorBehavior, Video):
def __init__(self,**kw):
def __init__(self,color_level=-1,radius=[],**kw):
Video.__init__(self, **kw)
BGColorBehavior.__init__(self)
BGColorBehavior.__init__(self,
color_level=color_level,
radius=radius)
Window.allow_screensaver = False
set_log_callback(self.ffplayerLog)

View File

@ -26,12 +26,13 @@ from kivy.factory import Factory
from .bgcolorbehavior import BGColorBehavior
class TabsPanel(BGColorBehavior, TabbedPanel):
def __init__(self,**options):
def __init__(self,color_level=-1,
radius=[],
**options):
self.tabs_list = options.get('tabs')
self.color_level = options.get('color_level',0)
opts = {k:v for k,v in options.items() if k not in ['tabs','color_level']}
TabbedPanel.__init__(self,**opts)
BGColorBehavior.__init__(self)
TabbedPanel.__init__(self,**options)
BGColorBehavior.__init__(self,color_level=color_level,
radius=radius)
Clock.schedule_once(self.add_tabs,0)
def add_tab(self,text,desc):

View File

@ -60,11 +60,14 @@ class PressableBox(TouchRippleButtonBehavior, BoxLayout):
class ToggleItems(BGColorBehavior, BoxLayout):
def __init__(self,
color_level=1,
radius=[],
items_desc=[],
border_width=1,
**kw):
BoxLayout.__init__(self, **kw)
BGColorBehavior.__init__(self,color_level=color_level)
BGColorBehavior.__init__(self,
color_level=color_level,
radius=radius)
self.item_widgets = []
for desc in items_desc:
c = PressableBox(border_width=border_width,

View File

@ -41,7 +41,8 @@ class Tool(ButtonBehavior, BGColorBehavior, BoxLayout):
ButtonBehavior.__init__(self)
BoxLayout.__init__(self,
size_hint_y=None)
BGColorBehavior.__init__(self,color_level=ancestor.color_level)
BGColorBehavior.__init__(self,color_level=ancestor.color_level,
radius=ancestor.radius)
self.bl = BoxLayout(orientation='vertical',
size_hint_y=None)
self.add_widget(self.bl)
@ -134,12 +135,6 @@ class Toolbar(BGColorBehavior, GridLayout):
tool.bind(on_press=self.tool_press)
self.height = tool.height * 1.1
def on_size(self,obj,size):
return
with self.canvas.before:
Color(0.3,0.3,0.3,1)
Rectangle(pos=self.pos,size=self.size)
def tool_press(self,o,v=None):
for n,w in self.tool_widgets.items():
active = False
@ -166,16 +161,18 @@ Toolpage options
"""
class ToolPage(BGColorBehavior, BoxLayout):
def __init__(self,**opts):
def __init__(self,color_level=-1,radius=[],**opts):
self.opts = DictObject(**opts)
self.parenturl = opts.get('parenturl',None)
if self.opts.tool_at in [ 'top','bottom']:
orient = 'vertical'
else:
orient = 'horizontal'
color_level=self.opts.color_level or 0
self.color_level=self.opts.color_level or 0
self.radius = self.opts.radius
BoxLayout.__init__(self,orientation=orient)
BGColorBehavior.__init__(self,color_level=color_level)
BGColorBehavior.__init__(self,
color_level=color_level,
radius=radius)
self.content = None
self.toolbar = None
self.init()

View File

@ -69,8 +69,10 @@ class NodeTrigger(ButtonBehavior, EmptyBox):
Triangle(points=points)
# print('pos=',self.pos,'size=',self.size)
class TreeNode(BoxLayout):
class TreeNode(BGColorBehavior,BoxLayout):
def __init__(self,data,tree=None,
color_level=-1,
radius=[],
parentNode=None,
):
"""
@ -79,7 +81,11 @@ class TreeNode(BoxLayout):
if children miss, it is a leaf node,if children is a empty array, is mean need load at it is first expanded.
}
"""
self.color_level = color_level if color_level != -1 else tree.color_level + 1
self.radius = radius if radius!=[] else tree.audius
BoxLayout.__init__(self,orientation='vertical',size_hint=(None,None))
BGColorBehavior.__init__(self,color=self.color_level,
radius=self.radius)
self.treeObj = tree
self.parentNode = parentNode
self.data = data
@ -282,10 +288,13 @@ tree options
}
"""
class Tree(BGColorBehavior, ScrollWidget):
def __init__(self,**options):
self.color_level = options.get('color_level',0)
def __init__(self,color_level=-1,radius=[],**options):
self.color_level = color_level
self.radius = radius
ScrollWidget.__init__(self)
BGColorBehavior.__init__(self,color_level=self.color_level)
BGColorBehavior.__init__(self,
color_level=self.color_level,
radius = self.radius)
self.options = DictObject(**options)
self.nodes = []
self.initflag = False