Skip to content

Commit

Permalink
fix(menu): use application's title as the title of the menu if it's p…
Browse files Browse the repository at this point in the history
…rovided

fix(menu): add the title space to the application if it has no title
  • Loading branch information
sassanh committed Apr 30, 2024
1 parent 3a2b32e commit 0f0ee4d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 0.11.1

- fix(menu): use application's title as the title of the menu if it's provided
- fix(menu): add the title space to the application if it has no title

## Version 0.11.0

- feat(Menu): render faded next and previous menu items to induce there are more
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ubo-gui"
version = "0.11.0"
version = "0.11.1"
description = "GUI sdk for Ubo Pod"
authors = ["Sassan Haradji <sassanh@gmail.com>"]
license = "Apache-2.0"
Expand Down
5 changes: 2 additions & 3 deletions ubo_gui/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from kivy.app import App
from kivy.core.text import DEFAULT_FONT, LabelBase
from kivy.lang.builder import Builder
from kivy.metrics import dp
from kivy.properties import StringProperty
from kivy.uix.label import Label

Expand Down Expand Up @@ -81,10 +80,10 @@ def title_callback(self: UboApp, _: RootWidget, title: str) -> None:
header_layout: BoxLayout = self.root.ids.header_layout
if title is not None:
self.header_label.text = title
header_layout.height = dp(30)
header_layout.opacity = 1
else:
self.header_label.text = ''
header_layout.height = 0
header_layout.opacity = 0

@cached_property
def header(self: UboApp) -> Widget | None:
Expand Down
2 changes: 1 addition & 1 deletion ubo_gui/app/app.kv
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BoxLayout:
id: header_layout
size_hint: 1, None
pos: 0, root.height - dp(30)
pos: 0, root.height - self.height
height: dp(30)

BoxLayout:
Expand Down
30 changes: 17 additions & 13 deletions ubo_gui/menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,10 @@ def render(self: MenuWidget, *_: object) -> None:
if not self.stack:
return

title = None
if isinstance(self.top, StackApplicationItem):
self.current_screen = self.top.application
title = self.top.application.title
if isinstance(self.top, StackMenuItem):
menu = self.top.menu
last_items = None
Expand Down Expand Up @@ -484,21 +486,23 @@ def handle_items_change(items: Sequence[Item]) -> None:
process_subscribable_value(menu.items, handle_items_change),
)

def handle_title_change(title: str) -> None:
logger.debug(
'Handle `title` change...',
extra={
'new_title': title,
'old_title': self.title,
'subscription_level': 'screen',
},
)
if self._title != title:
self.title = title
title = menu.title

self.screen_subscriptions.add(
process_subscribable_value(menu.title, handle_title_change),
def handle_title_change(title: str | None) -> None:
logger.debug(
'Handle `title` change...',
extra={
'new_title': title,
'old_title': self.title,
'subscription_level': 'screen',
},
)
if self._title != title:
self.title = title

self.screen_subscriptions.add(
process_subscribable_value(title, handle_title_change),
)

def get_current_screen(self: MenuWidget) -> Screen | None:
"""Return current screen."""
Expand Down
12 changes: 6 additions & 6 deletions ubo_gui/notification/notification_widget.kv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<NotificationWidget>:
BoxLayout:
orientation: 'horizontal'
padding: 0, root.padding_top, 0, root.padding_bottom
padding: 0, 0 if root.title is None else root.padding_top, 0, root.padding_bottom
spacing: dp(4)

BoxLayout:
Expand All @@ -27,7 +27,7 @@
BoxLayout:
pos: container.pos
orientation: 'vertical'
height: max(container.height, self.minimum_height)
height: max(container.height, self.minimum_height) - dp(10)
width: container.width
id: scrollable_widget

Expand Down Expand Up @@ -59,19 +59,19 @@
text: root.content
text_size: self.size[0], None
height: self.texture_size[1]
size_hint: 1, None
size_hint: 1, None if root.content else 0
halign: 'center'
valign: 'top'
shorten: False
strip: True
markup: True

Widget:
size_hint: 1, 1
height: 0
size_hint: 1, None
height: max(container.height - scrollable_widget.height, 0)

AnchorLayout:
size_hint: (None, 1) if scrollable_widget.height - container.height else (0, None)
size_hint: (None, 1) if scrollable_widget.height - container.height else (None, None)
width: dp(UBO_GUI_SHORT_WIDTH - 2)

AnimatedSlider:
Expand Down

0 comments on commit 0f0ee4d

Please sign in to comment.