MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / onShow

Method onShow

Tactility/Source/app/display/Display.cpp:140–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138public:
139
140 void onShow(AppContext& app, lv_obj_t* parent) override {
141 displaySettings = settings::display::loadOrGetDefault();
142 auto ui_density = lvgl_get_ui_density();
143
144 lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
145 lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
146
147 auto hal_display = getHalDisplay();
148 assert(hal_display != nullptr);
149
150 lvgl::toolbar_create(parent, app);
151
152 auto* main_wrapper = lv_obj_create(parent);
153 lv_obj_set_flex_flow(main_wrapper, LV_FLEX_FLOW_COLUMN);
154 lv_obj_set_width(main_wrapper, LV_PCT(100));
155 lv_obj_set_flex_grow(main_wrapper, 1);
156
157 // Backlight slider
158
159 if (hal_display->supportsBacklightDuty()) {
160 auto* brightness_wrapper = lv_obj_create(main_wrapper);
161 lv_obj_set_size(brightness_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
162 lv_obj_set_style_pad_hor(brightness_wrapper, 0, LV_STATE_DEFAULT);
163 lv_obj_set_style_border_width(brightness_wrapper, 0, LV_STATE_DEFAULT);
164 if (ui_density != LVGL_UI_DENSITY_COMPACT) {
165 lv_obj_set_style_pad_ver(brightness_wrapper, 4, LV_STATE_DEFAULT);
166 }
167
168 auto* brightness_label = lv_label_create(brightness_wrapper);
169 lv_label_set_text(brightness_label, "Brightness");
170 lv_obj_align(brightness_label, LV_ALIGN_LEFT_MID, 0, 0);
171
172 auto* brightness_slider = lv_slider_create(brightness_wrapper);
173 lv_obj_set_width(brightness_slider, LV_PCT(50));
174 lv_obj_align(brightness_slider, LV_ALIGN_RIGHT_MID, 0, 0);
175 lv_slider_set_range(brightness_slider, 0, 255);
176 lv_obj_add_event_cb(brightness_slider, onBacklightSliderEvent, LV_EVENT_VALUE_CHANGED, this);
177
178 lv_slider_set_value(brightness_slider, displaySettings.backlightDuty, LV_ANIM_OFF);
179 }
180
181 // Gamma slider
182
183 if (hal_display->getGammaCurveCount() > 0) {
184 auto* gamma_wrapper = lv_obj_create(main_wrapper);
185 lv_obj_set_size(gamma_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
186 lv_obj_set_style_pad_hor(gamma_wrapper, 0, LV_STATE_DEFAULT);
187 lv_obj_set_style_border_width(gamma_wrapper, 0, LV_STATE_DEFAULT);
188 if (ui_density != LVGL_UI_DENSITY_COMPACT) {
189 lv_obj_set_style_pad_ver(gamma_wrapper, 4, LV_STATE_DEFAULT);
190 }
191
192 auto* gamma_label = lv_label_create(gamma_wrapper);
193 lv_label_set_text(gamma_label, "Gamma");
194 lv_obj_align(gamma_label, LV_ALIGN_LEFT_MID, 0, 0);
195 lv_obj_set_y(gamma_label, 0);
196
197 auto* gamma_slider = lv_slider_create(gamma_wrapper);

Callers

nothing calls this directly

Calls 7

lvgl_get_ui_densityFunction · 0.85
toolbar_createFunction · 0.85
getHalDisplayFunction · 0.70
loadOrGetDefaultFunction · 0.50
supportsBacklightDutyMethod · 0.45
getGammaCurveCountMethod · 0.45

Tested by

no test coverage detected