mirror of
https://github.com/topydo/topydo.git
synced 2024-05-20 13:58:33 +00:00
Highlight title widget of currently focused column
Previously there wasn't any indicator of focus for empty columns. Now title widget is highlighted then. Color is the same as for TodoWidget focus and already configured by 'focus_background_color'.
This commit is contained in:
parent
00d2496e5c
commit
3d34497576
|
@ -140,7 +140,8 @@ class UIApplication(CLIApplicationBase):
|
|||
self.marked_todos = set()
|
||||
|
||||
self.columns = urwid.Columns([], dividechars=0,
|
||||
min_width=config().column_width())
|
||||
min_width=config().column_width())
|
||||
self.columns.contents.set_focus_changed_callback(self._move_highlight)
|
||||
completer = ColumnCompleter(self.todolist)
|
||||
self.commandline = CommandLineWidget(completer, 'topydo> ')
|
||||
self.keystate_widget = KeystateWidget()
|
||||
|
@ -268,6 +269,15 @@ class UIApplication(CLIApplicationBase):
|
|||
self.column_mode = _APPEND_COLUMN
|
||||
self._set_alarm_for_next_midnight_update()
|
||||
|
||||
def _move_highlight(self, p_new_focus):
|
||||
"""
|
||||
Removes highlight from currently focused column and applies it on
|
||||
column with index equal to p_new_focus.
|
||||
"""
|
||||
self.columns.focus.highlight(False)
|
||||
self.columns.contents[p_new_focus][0].highlight(True)
|
||||
self.columns._invalidate()
|
||||
|
||||
def _set_alarm_for_next_midnight_update(self):
|
||||
def callback(p_loop, p_data):
|
||||
TodoWidget.wipe_cache()
|
||||
|
|
|
@ -19,6 +19,7 @@ import urwid
|
|||
from topydo.lib.HashListValues import max_id_length
|
||||
from topydo.lib.Utils import translate_key_to_config
|
||||
from topydo.ui.columns.TodoWidget import TodoWidget
|
||||
from topydo.ui.columns.Utils import PaletteItem
|
||||
|
||||
|
||||
def get_execute_signal(p_prefix):
|
||||
|
@ -40,7 +41,8 @@ class TodoListWidget(urwid.LineBox):
|
|||
# store offset length for postpone command (e.g. '3' for 'p3w')
|
||||
self._pp_offset = None
|
||||
|
||||
self._title_widget = urwid.Text(p_title, align='center')
|
||||
self._title = urwid.Text(p_title, align='center')
|
||||
self._title_widget = urwid.AttrMap(self._title, PaletteItem.DEFAULT)
|
||||
|
||||
self.todolist = urwid.SimpleFocusListWalker([])
|
||||
self.listbox = urwid.ListBox(self.todolist)
|
||||
|
@ -78,11 +80,11 @@ class TodoListWidget(urwid.LineBox):
|
|||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title_widget.text
|
||||
return self._title.text
|
||||
|
||||
@title.setter
|
||||
def title(self, p_title):
|
||||
self._title_widget.set_text(p_title)
|
||||
self._title.set_text(p_title)
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
|
@ -384,3 +386,9 @@ class TodoListWidget(urwid.LineBox):
|
|||
todo_id = None
|
||||
|
||||
urwid.emit_signal(self, 'repeat_cmd', todo_id)
|
||||
|
||||
def highlight(self, p_highlight):
|
||||
if p_highlight:
|
||||
self._title_widget.set_attr_map({None: PaletteItem.DEFAULT_FOCUS})
|
||||
else:
|
||||
self._title_widget.set_attr_map({None: PaletteItem.DEFAULT})
|
||||
|
|
Loading…
Reference in a new issue