mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-02 10:58:45 -05:00
1. Implement partial refresh. 2. Implement refresh canceling mechanism. 3. Refactor some parts of the gui and display code. ad 1. - Detect parts of the screen changed since last update and merge them into bigger regions. These regions defines parts of the context sent to the display. - Refresh the region covering all of the parts since this is the most time consuming part and the size of the refreshed region doesn't change the time much. - Refresh the whole screen if deep refresh is requested and previously fast refresh was used. This is needed to prevent unwanted artifacts in some cases. ad 2. - Separate display update and refresh logic. - Divide image display message handling into two handlers, one updating and other one refreshing the screen. - Add cancel refresh message and use it to cancel refresh during update. - Store sum of refresh regions gathered during updates to refresh them all at once at the end.
133 lines
3.0 KiB
C++
133 lines
3.0 KiB
C++
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
/*
|
|
* Rect.cpp
|
|
*
|
|
* Created on: 6 mar 2019
|
|
* Author: robert
|
|
*/
|
|
|
|
#include "../core/BoundingBox.hpp"
|
|
#include "../core/DrawCommand.hpp"
|
|
|
|
#include "Rect.hpp"
|
|
#include "Style.hpp"
|
|
#include <log/log.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
|
|
Rect::Rect(Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w, const uint32_t &h)
|
|
{
|
|
setArea({int16_t(x), int16_t(y), uint16_t(w), uint16_t(h)});
|
|
setMinimumHeight(h);
|
|
setMinimumWidth(w);
|
|
|
|
this->parent = parent;
|
|
if (parent != nullptr) {
|
|
parent->addWidget(this);
|
|
}
|
|
}
|
|
|
|
Rect::Rect() : Rect(nullptr, 0, 0, 0, 0)
|
|
{}
|
|
|
|
void Rect::setFillColor(const Color &color)
|
|
{
|
|
fillColor = color;
|
|
setFilled(true);
|
|
}
|
|
|
|
void Rect::setBorderColor(const Color &color)
|
|
{
|
|
borderColor = color;
|
|
}
|
|
void Rect::setPenWidth(uint8_t width)
|
|
{
|
|
penWidth = width;
|
|
}
|
|
void Rect::setPenFocusWidth(uint8_t width)
|
|
{
|
|
penFocusWidth = width;
|
|
}
|
|
|
|
void Rect::setEdges(RectangleEdge edges)
|
|
{
|
|
this->edges = edges;
|
|
}
|
|
void Rect::setCorners(RectangleRoundedCorner corners)
|
|
{
|
|
this->corners = corners;
|
|
}
|
|
|
|
void Rect::setFlat(RectangleFlatEdge flats)
|
|
{
|
|
flatEdges = flats;
|
|
}
|
|
|
|
void Rect::setFilled(bool val)
|
|
{
|
|
filled = val;
|
|
}
|
|
|
|
void Rect::setYaps(RectangleYap yaps)
|
|
{
|
|
this->yaps = yaps;
|
|
if (yaps & (RectangleYap::BottomLeft | RectangleYap::TopLeft)) {
|
|
padding.left = yapSize;
|
|
}
|
|
else {
|
|
padding.left = 0;
|
|
}
|
|
if (yaps & (RectangleYap::BottomRight | RectangleYap::TopRight)) {
|
|
padding.right = yapSize;
|
|
}
|
|
else {
|
|
padding.right = 0;
|
|
}
|
|
}
|
|
|
|
void Rect::setYapSize(unsigned short value)
|
|
{
|
|
yapSize = value;
|
|
}
|
|
|
|
void Rect::buildDrawListImplementation(std::list<Command> &commands)
|
|
{
|
|
auto rect = std::make_unique<DrawRectangle>();
|
|
|
|
rect->origin = {drawArea.x, drawArea.y};
|
|
rect->width = drawArea.w;
|
|
rect->height = drawArea.h;
|
|
rect->areaX = widgetArea.x;
|
|
rect->areaY = widgetArea.y;
|
|
rect->areaW = widgetArea.w;
|
|
rect->areaH = widgetArea.h;
|
|
rect->corners = corners;
|
|
rect->flatEdges = this->flatEdges;
|
|
rect->edges = edges;
|
|
rect->yaps = yaps;
|
|
rect->yapSize = yapSize;
|
|
rect->radius = radius;
|
|
if (focus) {
|
|
rect->penWidth = penFocusWidth;
|
|
}
|
|
else {
|
|
rect->penWidth = penWidth;
|
|
}
|
|
|
|
rect->filled = filled;
|
|
rect->borderColor = borderColor;
|
|
rect->fillColor = fillColor;
|
|
|
|
commands.emplace_back(std::move(rect));
|
|
}
|
|
|
|
void Rect::accept(GuiVisitor &visitor)
|
|
{
|
|
visitor.visit(*this);
|
|
}
|
|
|
|
} /* namespace gui */
|