mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 13:58:00 -05:00
* EGD-3087 WIP adding SMS Querry * EGD-3087 Added query virtual interface on Service top layer Service shouldn't implement query logic and should be proxying that. additionally: - small fixes in includes - shared service db name same way as apps and event manager * EGD-3087 Query - want to work on interface not on db * EGD-3087 Query gluecode works fine. Our query in SMS search calls getBySMSQuery Changes cut off before any potential orm interface layer * EGD-3087 WIP Interface in use * EGD-3087 Query for SMS search works as designed * EGD-3087 Query results should be on screen * EGD-3087 BUG workaround - need to deep refresh display to show data * EGD-3087 Searching for text from input works fine * EGD-3087 Showing results / or empty results depending on query * EGD-3087 Pre PR fixups * EGD-3087 Empty search - getting back to prewious window ignore current * EGD-3087 PR applied * EGD-3087 PR - style fixed * EGD-3087 Review - DB ListView handling moved to separate function * EGD-3087 Workaround: crash on use after free fix * EGD-3087 PR stylistic changes * EGD-3087 PR cleanup applied * EGD-3087 Added test for Query interface * EGD-3087 renamed getByQuery to getQuery & finished tests * EGD-3087 Post rebase fixup * EGD-3087 PR - moved ListView request part to separate function * EGD-3087 PR Fixups * EGD-3087 Post rebase style fix * EGD-3087 Added variable for DB service stack & const to getter function
119 lines
2.6 KiB
C++
119 lines
2.6 KiB
C++
#include "BoundingBox.hpp"
|
|
#include <limits>
|
|
#include <sstream>
|
|
#include <limits>
|
|
|
|
namespace gui
|
|
{
|
|
const uint16_t BoundingBox::zero_size = 0;
|
|
const uint16_t BoundingBox::max_size = std::numeric_limits<uint16_t>().max();
|
|
const uint16_t BoundingBox::min_size = std::numeric_limits<uint16_t>().min();
|
|
|
|
const int16_t BoundingBox::zero_position = 0;
|
|
const int16_t BoundingBox::max_position = std::numeric_limits<int16_t>().max();
|
|
const int16_t BoundingBox::min_position = std::numeric_limits<int16_t>().min();
|
|
|
|
BoundingBox::BoundingBox(int32_t x, int32_t y, uint32_t w, uint32_t h)
|
|
{
|
|
this->x = x;
|
|
this->y = y;
|
|
this->w = w;
|
|
this->h = h;
|
|
}
|
|
|
|
bool BoundingBox::intersect(const BoundingBox &box1, const BoundingBox &box2, BoundingBox &result)
|
|
{
|
|
const BoundingBox *l;
|
|
const BoundingBox *r;
|
|
|
|
if (box1.x < box2.x) {
|
|
l = &box1;
|
|
r = &box2;
|
|
}
|
|
else {
|
|
l = &box2;
|
|
r = &box1;
|
|
}
|
|
|
|
int w = l->x + l->w - r->x;
|
|
if (w <= 0) {
|
|
result.clear();
|
|
return false;
|
|
}
|
|
// most left bbox overlap right box entirely
|
|
if ((l->x + l->w) >= (r->x + r->w)) {
|
|
w = r->w;
|
|
}
|
|
result.w = w;
|
|
result.x = r->x;
|
|
|
|
// vertical check
|
|
// select bbox that is higher
|
|
const BoundingBox *u;
|
|
if (box1.y < box2.y) {
|
|
l = &box1;
|
|
u = &box2;
|
|
}
|
|
else {
|
|
l = &box2;
|
|
u = &box1;
|
|
}
|
|
|
|
int h = l->y + l->h - u->y;
|
|
|
|
if (h <= 0) {
|
|
result.clear();
|
|
return false;
|
|
}
|
|
|
|
// most lower bbox overlap upper box entirely
|
|
if ((l->y + l->h) >= (u->y + u->h)) {
|
|
h = u->h;
|
|
}
|
|
result.y = u->y;
|
|
result.h = h;
|
|
|
|
return true;
|
|
}
|
|
|
|
void BoundingBox::clear()
|
|
{
|
|
x = 0;
|
|
y = 0;
|
|
w = 0;
|
|
h = 0;
|
|
}
|
|
|
|
uint16_t BoundingBox::size(gui::Axis axis) const
|
|
{
|
|
if (axis == Axis::X)
|
|
return w;
|
|
else
|
|
return h;
|
|
}
|
|
|
|
int16_t BoundingBox::pos(gui::Axis axis) const
|
|
{
|
|
if (axis == Axis::X)
|
|
return x;
|
|
else
|
|
return y;
|
|
}
|
|
|
|
std::string BoundingBox::str() const
|
|
{
|
|
std::stringstream ss;
|
|
ss << "{";
|
|
ss << "x: " << x << ", y: " << y << ", w: " << w << ", h: " << h;
|
|
ss << "}";
|
|
return ss.str();
|
|
}
|
|
|
|
void BoundingBox::sum(const BoundingBox &box)
|
|
{
|
|
w = box.w > w ? box.w : w;
|
|
h = box.h > h ? box.h : h;
|
|
}
|
|
|
|
} /* namespace gui */
|