diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-01-06 14:07:15 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-01-06 14:07:15 +0100 |
commit | ad49aedaad3acece200ea92fd5d5a5b3e19c143b (patch) | |
tree | 3f6833aa6f7a81f456e992cb7ea453cdcdf6c22e /tagit/tiles | |
parent | 079b4da93ea336b5bcc801cfd64c310aa7f8ddee (diff) | |
download | tagit-ad49aedaad3acece200ea92fd5d5a5b3e19c143b.tar.gz tagit-ad49aedaad3acece200ea92fd5d5a5b3e19c143b.tar.bz2 tagit-ad49aedaad3acece200ea92fd5d5a5b3e19c143b.zip |
desktop dependent widgets early port
Diffstat (limited to 'tagit/tiles')
-rw-r--r-- | tagit/tiles/__init__.py | 61 | ||||
-rw-r--r-- | tagit/tiles/decoration.kv | 58 | ||||
-rw-r--r-- | tagit/tiles/decoration.py | 68 |
3 files changed, 187 insertions, 0 deletions
diff --git a/tagit/tiles/__init__.py b/tagit/tiles/__init__.py new file mode 100644 index 0000000..3ed53b9 --- /dev/null +++ b/tagit/tiles/__init__.py @@ -0,0 +1,61 @@ +""" + +Part of the tagit module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# standard imports +import typing + +# tagit imports +from tagit.utils.builder import BuilderBase + +# inner-module imports +##from .anomalies import Anomalies # FIXME: skeleton only +#from .browser_tags import BrowserTags +#from .buttons import Buttons +#from .cursor_tags import CursorTags +#from .entity_histogram import EntityHistogram +#from .geo import Map +#from .hints import Hints +#from .info import Info +#from .libsummary import LibSummary +#from .searchtree import Searchtree +#from .selection_tags import SelectionTags +#from .suggested_tags import SuggestedTags +#from .tag_distribution import TagDistribution +#from .tag_histogram import TagHistogram +#from .tag_tree import TagTree +#from .tagcloud import Tagcloud +#from .venn import Venn + +# exports +__all__: typing.Sequence[str] = ( + 'TileBuilder', + ) + + +## code ## + +class TileBuilder(BuilderBase): + _factories = { +# #'Anomalies': Anomalies, +# 'BrowserTags': BrowserTags, +# 'Buttons': Buttons, +# 'CursorTags': CursorTags, +# 'EntityHistogram': EntityHistogram, +# 'Geo': Map, +# 'Hints': Hints, +# 'Info': Info, +# 'LibSummary': LibSummary, +# 'Searchtree': Searchtree, +# 'SelectionTags': SelectionTags, +# 'SuggestedTags': SuggestedTags, +# 'TagDistribution': TagDistribution, +# 'TagHistogram': TagHistogram, +# 'TagTree': TagTree, +# 'Tagcloud': Tagcloud, +# 'Venn': Venn, + } + +## EOF ## diff --git a/tagit/tiles/decoration.kv b/tagit/tiles/decoration.kv new file mode 100644 index 0000000..a53d013 --- /dev/null +++ b/tagit/tiles/decoration.kv @@ -0,0 +1,58 @@ + +# NOTE: +# TileDecoration assumes as *cbox* property that identifies the widget +# to which the main content will be added. + +<TileDecorationVanilla>: + cbox: cbox + + RelativeLayout: + id: cbox + +<TileDecorationBorder>: + cbox: cbox + + canvas.after: + # tile shadow + Color: + rgb: 0.2,0.2,0.2 + Line: + rectangle: self.x+5,self.y+5,self.width-10,self.height-10 + width: 2 + + Color: + rgb: 0.6,0.6,0.6 + Line: + rectangle: self.x+7,self.y+7,self.width-14,self.height-14 + width: 1 + + RelativeLayout: + id: cbox + pos: 15, 15 + size: root.width-30, root.height-30 + size_hint: None, None + +<TileDecorationFilledRectangle>: + cbox: cbox + + Label: + text: root.client.title + size: root.width, 20 + size_hint: None, None + pos: 0, root.height - self.height - 5 + + RelativeLayout: + id: cbox + pos: 5, 5 + size: root.width-10, root.height-30 + size_hint: None, None + + canvas.before: + Color: + rgba: 1,0,0,0.5 + Rectangle: + pos: 0, 0 + size: self.size + + +## EOF ## diff --git a/tagit/tiles/decoration.py b/tagit/tiles/decoration.py new file mode 100644 index 0000000..471058d --- /dev/null +++ b/tagit/tiles/decoration.py @@ -0,0 +1,68 @@ +""" + +Part of the tagit module. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# standard imports +import os +import typing + +# kivy imports +from kivy.lang import Builder +from kivy.uix.relativelayout import RelativeLayout +import kivy.properties as kp + +# exports +__all__: typing.Sequence[str] = ( + 'TileDecorationBorder', + 'TileDecorationFilledRectangle', + 'TileDecorationVanilla', + ) + + +## code ## + +# load kv +Builder.load_file(os.path.join(os.path.dirname(__file__), 'decoration.kv')) + +# classes +class TileDecoration(RelativeLayout): + + cbox = kp.ObjectProperty(None) + client = kp.ObjectProperty(None) + + def __repr__(self): + return f'{self.__class__.__name__}({self.client})' + + def on_cbox(self, wx, cbox): + if cbox is not None and len(cbox.children) == 0: + cbox.add_widget(self.client) + + @property + def default_size(self): + return self.client.default_size + + +class TileDecorationVanilla(TileDecoration): + pass + + +class TileDecorationFilledRectangle(TileDecoration): + @property + def default_size(self): + width, height = self.client.default_size + width = None if width is None else width + 10 + height = None if height is None else height + 30 + return width, height + + +class TileDecorationBorder(TileDecoration): + @property + def default_size(self): + width, height = self.client.default_size + width = None if width is None else width + 30 + height = None if height is None else height + 30 + return width, height + +## EOF ## |