Description
I am trying to make a window (lv_win) be a child of another window (lv_win), but the child window is being positioned in the content area of the parent window, instead of fully over the top of it (to occupy the entire display area).
What MCU/Processor/Board and compiler are you using?
PIC32MZ
What LVGL version are you using?
v8.3
What do you want to achieve?
I am trying to create a “chain” (tree) of windows that build upon lv_scr_act() like this:
* Run-Time Object Tree:
*
* lv_scr_act() <-------- Note that lv_scr_act() never changes during
* | settings-window session.
* Hub Window
* |
* Child Window
* |
* Child Child Window
* |
* etc.
Each window will have a BACK button and a CLOSE button. The BACK button merely performs a
lv_obj_del(curr_window);
and the CLOSE button will delete the HUB (root) window, thus deleting the whole tree.
lv_obj_del(hub_window);
Reason: lv_obj_del() automatically deletes all its children, and this is exactly what I want to take advantage of in my user interface.
What have you tried so far?
I studied the v8.3 documentation for lv_win
(more than once).
See code below. I am about to try just going with objects (lv_obj) without making the background container a FLEX-FLOW COLUMN container, manually aligning the header (title bar) and making the content area a FLEX-FLOW COLUMN container instead of the the whole container.
Code to reproduce
Hub (root) window:
SHW_sWindowTreeHub.ipRootWindow = win = lv_win_create(lv_scr_act(), 38);
lv_obj_set_style_text_font(win, &lv_font_montserrat_30, LV_PART_MAIN);
btn = lv_win_add_btn(win, HM_SYMBOL_LEFT, 36);
lv_win_add_title(win, "Root Window");
btn = lv_win_add_btn(win, HM_SYMBOL_CLOSE, 36);
content_area = lv_win_get_content(win);
lv_obj_set_flex_flow(content_area, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_flex_main_place(content_area, LV_FLEX_ALIGN_SPACE_EVENLY, LV_PART_MAIN);
itm = &SHW_saItems[SHWItem_basics];
itm->ipContainer = nvc = wdtNVC_Create(content_area, itm, "Basics...");
lv_obj_add_event_cb(nvc, SHW_OnEvent, LV_EVENT_CLICKED, (void *)SHWItem_basics);
itm = &SHW_saItems[SHWItem_display];
itm->ipContainer = nvc = wdtNVC_Create(content_area, itm, "Display...");
lv_obj_add_event_cb(nvc, SHW_OnEvent, LV_EVENT_CLICKED, (void *)SHWItem_display);
where wdtNVC_Create()
merely creates a horizontal lv_obj_t
(FLEX-FLOW ROW) that intercepts CLICKED events to take actions. The above code creates this:
Then passing SHW_sWindowTreeHub.ipRootWindow
as apParent
, the child window:
SBasics_spThisWindow = win = lv_win_create(apParent, 38);
lv_obj_set_style_text_font(win, &lv_font_montserrat_30, LV_PART_MAIN);
btn = lv_win_add_btn(win, HM_SYMBOL_LEFT, 36);
lv_win_add_title(win, "Child Window 1");
btn = lv_win_add_btn(win, HM_SYMBOL_CLOSE, 36);
content_area = lv_win_get_content(win);
lv_obj_set_flex_flow(content_area, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_flex_main_place(content_area, LV_FLEX_ALIGN_SPACE_EVENLY, LV_PART_MAIN);
itm = &SBasics_saItems[SBasicsItem_basics];
itm->ipContainer = nvc = wdtNVC_Create(content_area, itm, "Make/Model...");
lv_obj_add_event_cb(nvc, SBasics_OnEvent, LV_EVENT_CLICKED, (void *)eSBasicsItem_basics);
itm = &SBasics_saItems[SBasicsItem_wireless_telemetry];
itm->ipContainer = nvc = wdtNVC_Create(content_area, itm, "Wireless Telemetry...");
lv_obj_add_event_cb(nvc, SBasics_OnEvent, LV_EVENT_CLICKED, (void *)eSBasicsItem_wireless_telemetry);
creates this:
But I am trying to get the child window (and subsequent child windows) to be positioned at (0,0) instead of (0,38). Is the FLEX layout feature of the parent window protecting the visibility of the root window’s header by shifting the child window down? (Calling lv_obj_set_style_y(child_win, 0)
does not cause any change in layout.) I’d like the child window to look like this:
Screenshot and/or video
See above.
Does anyone know why the child lv_win_t
is being forced to be positioned below the header (title bar)? Is it something I can turn off?
Kind regards,
Vic