mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 20:57:01 +08:00
chore(gdb): add LVGroup wrapper with focus tracking and dump group command
This commit is contained in:
@@ -40,6 +40,7 @@ from .lvgl import (
|
|||||||
LVFsDrv,
|
LVFsDrv,
|
||||||
LVIndev,
|
LVIndev,
|
||||||
INDEV_TYPE_NAMES,
|
INDEV_TYPE_NAMES,
|
||||||
|
LVGroup,
|
||||||
)
|
)
|
||||||
from . import cmds as cmds
|
from . import cmds as cmds
|
||||||
|
|
||||||
@@ -83,4 +84,5 @@ __all__ = [
|
|||||||
"LVFsDrv",
|
"LVFsDrv",
|
||||||
"LVIndev",
|
"LVIndev",
|
||||||
"INDEV_TYPE_NAMES",
|
"INDEV_TYPE_NAMES",
|
||||||
|
"LVGroup",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import gdb
|
import gdb
|
||||||
|
|
||||||
from .core import DumpObj, DumpIndev
|
from .core import DumpObj, DumpIndev, DumpGroup
|
||||||
from .display import DumpDisplayBuf
|
from .display import DumpDisplayBuf
|
||||||
from .draw import InfoDrawUnit, DumpDrawTask
|
from .draw import InfoDrawUnit, DumpDrawTask
|
||||||
from .misc import (
|
from .misc import (
|
||||||
@@ -39,6 +39,7 @@ DumpTimer()
|
|||||||
DumpImageDecoder()
|
DumpImageDecoder()
|
||||||
DumpFsDrv()
|
DumpFsDrv()
|
||||||
DumpIndev()
|
DumpIndev()
|
||||||
|
DumpGroup()
|
||||||
DumpDrawTask()
|
DumpDrawTask()
|
||||||
|
|
||||||
# Infos
|
# Infos
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from .lv_obj import DumpObj
|
from .lv_obj import DumpObj
|
||||||
from .lv_indev import DumpIndev
|
from .lv_indev import DumpIndev
|
||||||
|
from .lv_group import DumpGroup
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"DumpObj",
|
"DumpObj",
|
||||||
"DumpIndev",
|
"DumpIndev",
|
||||||
|
"DumpGroup",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import gdb
|
||||||
|
|
||||||
|
from lvglgdb.lvgl import curr_inst
|
||||||
|
from lvglgdb.lvgl.core.lv_group import LVGroup
|
||||||
|
|
||||||
|
|
||||||
|
class DumpGroup(gdb.Command):
|
||||||
|
"""dump all focus groups"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(DumpGroup, self).__init__(
|
||||||
|
"dump group", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION
|
||||||
|
)
|
||||||
|
|
||||||
|
def invoke(self, args, from_tty):
|
||||||
|
LVGroup.print_entries(curr_inst().groups())
|
||||||
@@ -6,6 +6,7 @@ from .core import (
|
|||||||
dump_obj_styles,
|
dump_obj_styles,
|
||||||
LVIndev,
|
LVIndev,
|
||||||
INDEV_TYPE_NAMES,
|
INDEV_TYPE_NAMES,
|
||||||
|
LVGroup,
|
||||||
)
|
)
|
||||||
from .display import LVDisplay
|
from .display import LVDisplay
|
||||||
from .draw import (
|
from .draw import (
|
||||||
@@ -94,4 +95,5 @@ __all__ = [
|
|||||||
"LVFsDrv",
|
"LVFsDrv",
|
||||||
"LVIndev",
|
"LVIndev",
|
||||||
"INDEV_TYPE_NAMES",
|
"INDEV_TYPE_NAMES",
|
||||||
|
"LVGroup",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from .lv_obj import LVObject, ObjStyle, dump_obj_info, dump_obj_styles
|
from .lv_obj import LVObject, ObjStyle, dump_obj_info, dump_obj_styles
|
||||||
from .lv_global import curr_inst
|
from .lv_global import curr_inst
|
||||||
from .lv_indev import LVIndev, INDEV_TYPE_NAMES
|
from .lv_indev import LVIndev, INDEV_TYPE_NAMES
|
||||||
|
from .lv_group import LVGroup
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"LVObject",
|
"LVObject",
|
||||||
@@ -10,4 +11,5 @@ __all__ = [
|
|||||||
"dump_obj_styles",
|
"dump_obj_styles",
|
||||||
"LVIndev",
|
"LVIndev",
|
||||||
"INDEV_TYPE_NAMES",
|
"INDEV_TYPE_NAMES",
|
||||||
|
"LVGroup",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ class LVGL:
|
|||||||
for timer in LVList(self.lv_global.timer_state.timer_ll, "lv_timer_t"):
|
for timer in LVList(self.lv_global.timer_state.timer_ll, "lv_timer_t"):
|
||||||
yield LVTimer(timer)
|
yield LVTimer(timer)
|
||||||
|
|
||||||
|
def groups(self):
|
||||||
|
from .lv_group import LVGroup
|
||||||
|
|
||||||
|
for group in LVList(self.lv_global.group_ll, "lv_group_t"):
|
||||||
|
yield LVGroup(group)
|
||||||
|
|
||||||
def indevs(self):
|
def indevs(self):
|
||||||
from .lv_indev import LVIndev
|
from .lv_indev import LVIndev
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
|
from lvglgdb.value import Value, ValueInput
|
||||||
|
from ..misc.lv_ll import LVList
|
||||||
|
|
||||||
|
|
||||||
|
class LVGroup(Value):
|
||||||
|
"""LVGL focus group wrapper"""
|
||||||
|
|
||||||
|
def __init__(self, group: ValueInput):
|
||||||
|
super().__init__(Value.normalize(group, "lv_group_t"))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def frozen(self) -> bool:
|
||||||
|
return bool(int(self.super_value("frozen")))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def editing(self) -> bool:
|
||||||
|
return bool(int(self.super_value("editing")))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wrap(self) -> bool:
|
||||||
|
return bool(int(self.super_value("wrap")))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obj_focus(self) -> Value:
|
||||||
|
focus_pp = self.super_value("obj_focus")
|
||||||
|
if not int(focus_pp):
|
||||||
|
return None
|
||||||
|
return focus_pp.dereference()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def focus_cb(self) -> Value:
|
||||||
|
return self.super_value("focus_cb")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def edge_cb(self) -> Value:
|
||||||
|
return self.super_value("edge_cb")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_data(self) -> Value:
|
||||||
|
return self.super_value("user_data")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def refocus_policy(self) -> bool:
|
||||||
|
return bool(int(self.super_value("refocus_policy")))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def obj_count(self) -> int:
|
||||||
|
return LVList(self.obj_ll, "lv_obj_t").len
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
from .lv_obj import LVObject
|
||||||
|
|
||||||
|
for obj_ptr in LVList(self.obj_ll, "lv_obj_t"):
|
||||||
|
yield LVObject(obj_ptr)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def print_entries(groups):
|
||||||
|
"""Print focus groups as a PrettyTable."""
|
||||||
|
table = PrettyTable()
|
||||||
|
table.field_names = ["#", "objects", "frozen", "editing", "wrap", "focused"]
|
||||||
|
table.align = "l"
|
||||||
|
|
||||||
|
for i, group in enumerate(groups):
|
||||||
|
focus = group.obj_focus
|
||||||
|
if focus:
|
||||||
|
from .lv_obj import LVObject
|
||||||
|
|
||||||
|
focus_obj = LVObject(focus)
|
||||||
|
focus_str = f"{focus_obj.class_name}@{int(focus):x}"
|
||||||
|
else:
|
||||||
|
focus_str = "(none)"
|
||||||
|
table.add_row(
|
||||||
|
[
|
||||||
|
i,
|
||||||
|
group.obj_count,
|
||||||
|
group.frozen,
|
||||||
|
group.editing,
|
||||||
|
group.wrap,
|
||||||
|
focus_str,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
if not table.rows:
|
||||||
|
print("No focus groups.")
|
||||||
|
else:
|
||||||
|
print(table)
|
||||||
Reference in New Issue
Block a user