Mercurial > libervia-desktop-kivy
changeset 185:ab3f5173ef5c
chat, simple XHTML: font size adjustement
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 May 2018 20:07:17 +0200 |
parents | c63922860f80 |
children | a826c70beda2 |
files | cagou/core/simple_xhtml.py cagou/plugins/plugin_wid_chat.kv cagou/plugins/plugin_wid_chat.py |
diffstat | 3 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/core/simple_xhtml.py Thu May 10 08:32:46 2018 +0200 +++ b/cagou/core/simple_xhtml.py Fri May 11 20:07:17 2018 +0200 @@ -23,6 +23,7 @@ from kivy.uix.stacklayout import StackLayout from kivy.uix.label import Label from kivy.utils import escape_markup +from kivy.metrics import sp from kivy import properties from xml.etree import ElementTree as ET from sat_frontends.tools import css_color, strings as sat_strings @@ -39,6 +40,9 @@ class SimpleXHTMLWidgetEscapedText(Label): + def on_parent(self, instance, parent): + self.font_size = parent.font_size + def _addUrlMarkup(self, text): text_elts = [] idx = 0 @@ -79,7 +83,9 @@ class SimpleXHTMLWidgetText(Label): - pass + + def on_parent(self, instance, parent): + self.font_size = parent.font_size class SimpleXHTMLWidgetImage(AsyncImage): @@ -139,6 +145,7 @@ # XXX: bold is only used for escaped text bold = properties.BooleanProperty(False) content_width = properties.NumericProperty(0) + font_size = properties.NumericProperty(sp(14)) # text/XHTML input
--- a/cagou/plugins/plugin_wid_chat.kv Thu May 10 08:32:46 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.kv Fri May 11 20:07:17 2018 +0200 @@ -72,6 +72,7 @@ Label: id: time_label color: (0, 0, 0, 1) if root.mess_data.own_mess else (0.55,0.55,0.55,1) + font_size: root.font_size text_size: None, None size_hint: None, None size: self.texture_size @@ -81,6 +82,8 @@ text: u"[b]{}[/b], {}".format(escape(root.mess_data.nick), root.mess_data.time_text) Label: id: delivery + color: 0.4, 0.4, 0.4, 1 + font_size: root.font_size text_size: None, None size_hint: None, None size: self.texture_size @@ -90,7 +93,6 @@ # which will allow us to use fonts with more unicode characters font_name: "DejaVuSans" text: u'' - color: 0.4, 0.4, 0.4, 1 SimpleXHTMLWidget: id: mess_xhtml size_hint: 1, None
--- a/cagou/plugins/plugin_wid_chat.py Thu May 10 08:32:46 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.py Fri May 11 20:07:17 2018 +0200 @@ -25,7 +25,7 @@ from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout from kivy.uix.textinput import TextInput -from kivy.metrics import dp +from kivy.metrics import sp, dp from kivy import properties from sat_frontends.quick_frontend import quick_widgets from sat_frontends.quick_frontend import quick_chat @@ -65,6 +65,7 @@ mess_padding = (dp(5), dp(5)) avatar = properties.ObjectProperty() delivery = properties.ObjectProperty() + font_size = properties.NumericProperty(sp(12)) def __init__(self, **kwargs): # self must be registered in widgets before kv is parsed