您好,我正在
STM32F7 上使用 TouchGFX。
在 Screen1View 文件中添加 Screen1View::handleClickEvent 函数后,我无法调用 Screen1ViewBase 文件中的 ButtonCallbackHandle 函数。在我的 ViewBase 文件中,它有 2 个回调函数,1 个用于 Toggle Button,1 个用于 Slider。
下面是我的功能,谁能告诉我如何使用它们?
非常感谢。
我的 Screen1View.cpp 文件
- void Screen1View::handleClickEvent(const ClickEvent& evt)
- {
- if (color_wheel.getRect().intersect(Rect(evt.getX(), evt.getY(), 1, 1)))
- {
- touchgfx_printf("ncolor_wheel_x = %d",color_wheel.getX());
- touchgfx_printf(", color_wheel_y = %d",color_wheel.getY());
- touchgfx_printf("nevt_x = %d", evt.getX());
- touchgfx_printf(", evt_y = %d", evt.getY());
- int offsetX = evt.getX() - color_center_x;
- int offsetY = evt.getY() - color_center_y;
- touchgfx_printf("n offsetX: %d",offsetX);
- touchgfx_printf(" - offsetY: %d",offsetY);
- if (evt.getType() == ClickEvent::PRESSED)
- {
- const uint32_t dist = colorDistancesq(offsetX, offsetY);
- touchgfx_printf("ndist = %d",dist);
- if (dist < MAX_DIST)
- {
- selectColor(offsetX, offsetY);
- // selectColor(evt.getX(), evt.getY());
- isDown = true;
- }
- }
- }
- if (evt.getType() == ClickEvent::RELEASED)
- {
- isDown = false;
- }
- if (OnOff.getRect().intersect(Rect(evt.getX(), evt.getY(), 1, 1)))
- {
- Screen1View::OnOffBtn_Function();
- }
- // Screen1View::handleClickEvent(evt);
- }
- void Screen1View::handleDragEvent(const DragEvent& evt)
- {
- if (isDown)
- {
- int offsetX = evt.getNewX() - color_center_x;
- int offsetY = evt.getNewY() - color_center_y;
- const uint32_t dist = colorDistancesq(offsetX, offsetY);
- if (dist < MAX_DIST)
- {
- selectColor(offsetX, offsetY);
- }
- else
- {
- //calculate rim
- float angle = float(atan2(float(offsetY - color_center_y), float(offsetX - color_center_x)));
- selectColor(uint32_t(MAX_RADIUS * cosf(angle) + color_center_x), uint32_t(MAX_RADIUS * sinf(angle) + color_center_y));
- }
- }
- // Screen1View::handleDragEvent(evt);
- }
我的 Screen1ViewBase.cpp 文件
- void Screen1ViewBase::setupScreen()
- {
- }
- void Screen1ViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
- {
- if (&src == &OnOff)
- {
- //Interaction_OnOffBtn
- //When OnOff clicked call virtual function
- //Call OnOffBtn_Function
- OnOffBtn_Function();
- }
- }
- void Screen1ViewBase::sliderValueChangedCallbackHandler(const touchgfx::Slider& src, int value)
- {
- if (&src == &slider1)
- {
- //Interaction_Slider
- //When slider1 value changed call virtual function
- //Call Slider_Function
- Slider_Function(value);
- }
- }