annotate src/cagou/kv/root_widget.kv @ 38:9f45098289cc

widgets handler, core: hidden widgets can now be shown with swipes: - a couple of methods have been added to handle visible and hidden widgets - a new getOrClone method allow to recreate a widget if it already has a parent (can happen even if the widget is not shown, e.g. in a carousel) - handler now display hidden widgets of the same class as the displayed one when swiping. For instance, if a chat widget is displayed, and header input is used to show an other one, it's now possible to go back to the former by swiping. QuickWidget.onDelete method can be used to handle if a widget must be really deleted (return True) or just hidden (any other value). - handler use a subclass of Carousel for this new feature, with some adjustement so event can be passed to children without too much delay (and frustration). This may need to be adjusted again in the future. - handler.cagou_widget now give the main displayed widget in the handler - handler.changeWidget must be used when widget need to be changed (it's better to use host.switchWidget which will call it itself)
author Goffi <goffi@goffi.org>
date Sun, 28 Aug 2016 15:27:48 +0200
parents bd3ecac18870
children 1922506846be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org)
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # it under the terms of the GNU Affero General Public License as published by
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # (at your option) any later version.
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # GNU Affero General Public License for more details.
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # You should have received a copy of the GNU Affero General Public License
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 #:import IconButton cagou.core.common.IconButton
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 # <NotifIcon>:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 # source: app.expand("{media}/icons/muchoslava/png/cagou_profil_bleu_32.png")
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 # size_hint: None, None
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 # size: self.texture_size
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 <Note>:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 text: self.message
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 <NoteDrop>:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 canvas.before:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 Color:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 rgba: 1, 1, 1, 1
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 BorderImage:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 pos: self.pos
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 size: self.size
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 source: 'atlas://data/images/defaulttheme/button'
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 size_hint: 1, None
36
bd3ecac18870 cagou widget, root widget: used of dp to specify distances
Goffi <goffi@goffi.org>
parents: 33
diff changeset
36 height: dp(50)
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 <NotesDrop>:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 clear_btn: clear_btn.__self__
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 auto_width: False
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 size_hint: 0.8, None
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 Button:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 id: clear_btn
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 text: "clear"
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 bold: True
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 size_hint: 1, None
36
bd3ecac18870 cagou widget, root widget: used of dp to specify distances
Goffi <goffi@goffi.org>
parents: 33
diff changeset
47 height: dp(50)
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 on_release: del root.notes[:]; root.dismiss()
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 <RootHeadWidget>:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 manager: manager
33
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
52 notifs_icon: notifs_icon
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 size_hint: 1, None
36
bd3ecac18870 cagou widget, root widget: used of dp to specify distances
Goffi <goffi@goffi.org>
parents: 33
diff changeset
54 height: dp(35)
29
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 IconButton:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 source: app.expand("{media}/icons/muchoslava/png/cagou_profil_bleu_32.png") if root.notes else app.expand("{media}/misc/black.png")
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 size_hint: None, 1
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 width: self.texture_size[0]
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 on_release: root.notes_drop.open(self) if root.notes else None
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 ScreenManager:
8b5827c43155 notes first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 id: manager
33
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
62 NotifsIcon:
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
63 id: notifs_icon
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
64 source: app.expand("{media}/icons/muchoslava/png/cagou_profil_bleu_32.png") if self.notifs else app.expand("{media}/misc/black.png")
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
65 size_hint: None, 1
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
66 width: self.texture_size[0]
c21d1be2e54c core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents: 29
diff changeset
67