mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Changed color_cell to a circle
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "color_cell.h"
|
||||
#include <escher/metric.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
@@ -42,11 +43,12 @@ MessageTableCellWithColor::ColorView::ColorView() :
|
||||
{}
|
||||
|
||||
void MessageTableCellWithColor::ColorView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::DataColor[m_index]);
|
||||
KDPoint center(bounds().x() + k_radius, bounds().y() + (Metric::ParameterCellHeight)/2 - k_radius + 5);
|
||||
ctx->fillCircle(center, k_radius, Palette::DataColor[m_index]);
|
||||
}
|
||||
|
||||
KDSize MessageTableCellWithColor::ColorView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(10, 10);
|
||||
return KDSize(k_radius*2, k_radius*2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ private:
|
||||
constexpr static KDCoordinate k_chevronWidth = 8;
|
||||
private:
|
||||
int m_index;
|
||||
constexpr static int k_radius = 9;
|
||||
};
|
||||
ColorView m_accessoryView;
|
||||
constexpr static I18n::Message k_textForIndex[] = {
|
||||
|
||||
@@ -2,6 +2,7 @@ SFLAGS += -Ikandinsky/include
|
||||
|
||||
kandinsky_src += $(addprefix kandinsky/src/,\
|
||||
color.cpp \
|
||||
context_circle.cpp \
|
||||
context_line.cpp \
|
||||
context_pixel.cpp \
|
||||
context_rect.cpp \
|
||||
|
||||
@@ -28,6 +28,10 @@ public:
|
||||
void fillRectWithPixels(KDRect rect, const KDColor * pixels, KDColor * workingBuffer);
|
||||
void blendRectWithMask(KDRect rect, KDColor color, const uint8_t * mask, KDColor * workingBuffer);
|
||||
void strokeRect(KDRect rect, KDColor color);
|
||||
|
||||
// Circle
|
||||
void fillCircle(KDPoint center, KDCoordinate radius, KDColor c);
|
||||
|
||||
protected:
|
||||
KDContext(KDPoint origin, KDRect clippingRect) :
|
||||
m_origin(origin),
|
||||
@@ -39,6 +43,8 @@ protected:
|
||||
private:
|
||||
KDRect absoluteFillRect(KDRect rect);
|
||||
KDPoint pushOrPullString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxByteLength, bool push, int * result = nullptr);
|
||||
void horizontalLine(KDPoint begin, KDCoordinate length, KDColor c);
|
||||
void verticalLine(KDPoint begin, KDCoordinate length, KDColor c);
|
||||
KDPoint m_origin;
|
||||
KDRect m_clippingRect;
|
||||
};
|
||||
|
||||
31
kandinsky/src/context_circle.cpp
Normal file
31
kandinsky/src/context_circle.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <kandinsky/context.h>
|
||||
#include <assert.h>
|
||||
|
||||
void KDContext::fillCircle(KDPoint center, KDCoordinate radius, KDColor c) { // FIXME The circle doesn't look like a circle
|
||||
KDPoint p(0, radius);
|
||||
KDCoordinate m(5 - 4*radius);
|
||||
while(p.x()<=p.y()) {
|
||||
horizontalLine(KDPoint(center.x()-p.x(), p.y()+center.y()), 2*p.x(),c);
|
||||
horizontalLine(KDPoint(center.x()-p.x(), center.y()-p.y()),2*p.x(),c);
|
||||
verticalLine(KDPoint(center.x()-p.x(),center.y()-p.y()),2*p.y(),c);
|
||||
verticalLine(KDPoint(center.x()+p.x(),center.y()-p.y()),2*p.y(),c);
|
||||
if (m>0) {
|
||||
p = KDPoint(p.x(), p.y()-1);
|
||||
m-=8*p.x()+4;
|
||||
}
|
||||
p = KDPoint(p.x()+1,p.y());
|
||||
m+=8*p.x()+4;
|
||||
}
|
||||
}
|
||||
|
||||
void KDContext::horizontalLine(KDPoint begin, KDCoordinate length, KDColor c) {
|
||||
for(KDCoordinate i = 0; i < length; i++){
|
||||
setPixel(KDPoint(begin.x() + i, begin.y()), c);
|
||||
}
|
||||
}
|
||||
|
||||
void KDContext::verticalLine(KDPoint begin, KDCoordinate length, KDColor c) {
|
||||
for(KDCoordinate i = 0; i < length; i++){
|
||||
setPixel(KDPoint(begin.x(), begin.y() + i), c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user