tweaks
This commit is contained in:
parent
822c60d839
commit
44bc283f4f
5 changed files with 61 additions and 8 deletions
|
|
@ -82,6 +82,19 @@ void Canvas::frame(RectF rec, const RGBA& col, halnf round) {
|
|||
// nvgFill(mContext->vg);
|
||||
}
|
||||
|
||||
void Canvas::line(Vec2F start, Vec2F end, const RGBA& col, halnf thickness) {
|
||||
start += mOrigin;
|
||||
end += mOrigin;
|
||||
|
||||
nvgBeginPath(mContext->vg);
|
||||
nvgFillColor(mContext->vg, { col.r, col.g, col.b, col.a});
|
||||
nvgMoveTo(mContext->vg, start.x, start.y);
|
||||
nvgLineTo(mContext->vg, end.x, end.y);
|
||||
nvgStrokeWidth(mContext->vg, thickness);
|
||||
nvgStrokeColor(mContext->vg, { col.r, col.g, col.b, col.a });
|
||||
nvgStroke(mContext->vg);
|
||||
}
|
||||
|
||||
void Canvas::circle(Vec2F pos, halnf size, const RGBA& col) {
|
||||
pos += mOrigin;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ namespace tp {
|
|||
void circle(Vec2F pos, halnf size, const RGBA& col);
|
||||
void text(const char*, const RectF&, halnf size, Align, halnf padding, const RGBA&);
|
||||
void colorWheel(const RectF& rec, const ColorWheel& colorWheel);
|
||||
void line(Vec2F start, Vec2F end, const RGBA& col, halnf thickness);
|
||||
|
||||
ImageHandle createImageFromTextId(ualni id, Vec2F size);
|
||||
void updateTextureID(ImageHandle handle, ualni id);
|
||||
|
|
|
|||
|
|
@ -465,8 +465,15 @@ namespace tp {
|
|||
}
|
||||
|
||||
// Matrix Properties
|
||||
MVec toGlobal(const MVec &in) const { return i * in.x + j * in.y; }
|
||||
|
||||
Mat toGlobal(const Mat &in) const { return {toGlobal(in.i), toGlobal(in.j)}; }
|
||||
|
||||
MVec toLocal(const MVec &in) const { return transform(in); }
|
||||
|
||||
MVec transform(const MVec& in) const { return MVec(i.x * in.x + i.y * in.y, j.x * in.x + j.y * in.y); }
|
||||
|
||||
// ???
|
||||
Mat transform(const Mat& in) const {
|
||||
Mat out;
|
||||
out.i.x = i.x * in.i.x + j.x * in.i.y;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,29 @@ namespace tp {
|
|||
return *this;
|
||||
}
|
||||
|
||||
Rect<Type>& adjust(tp::halnf left, tp::halnf bottom, tp::halnf right, tp::halnf top) {
|
||||
x += left;
|
||||
y += bottom;
|
||||
size.x += -left + right;
|
||||
size.y += -bottom + top;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rect<Type> adjusted(tp::halnf left, tp::halnf bottom, tp::halnf right, tp::halnf top) const {
|
||||
return Rect<Type>(*this).adjust(left, bottom, right, top);
|
||||
}
|
||||
|
||||
[[nodiscard]] halnf left() const { return x; }
|
||||
[[nodiscard]] halnf bottom() { return y; }
|
||||
[[nodiscard]] halnf top() { return y + size.y; }
|
||||
[[nodiscard]] halnf right() { return x + size.x; }
|
||||
|
||||
static Rect fromPoints(const Vec2<Type>& p1, const Vec2<Type>& p2) {
|
||||
tp::Vec2F min = {tp::min(p1.x, p2.x), tp::min(p1.y, p2.y)};
|
||||
tp::Vec2F max = {tp::max(p1.x, p2.x), tp::max(p1.y, p2.y)};
|
||||
return { min, max - min };
|
||||
}
|
||||
|
||||
bool operator==(const Rect<Type>& rect) const { return (pos == rect.pos && size == rect.size); }
|
||||
|
||||
bool isEnclosedIn(const Rect<Type>& rect, bool aParent = false) const {
|
||||
|
|
@ -184,13 +207,23 @@ namespace tp {
|
|||
}
|
||||
|
||||
void expand(const Vec2<Type>& point) {
|
||||
pos.x = min(point.x, pos.x);
|
||||
pos.y = min(point.y, pos.y);
|
||||
if (point.x < x) {
|
||||
size.x += x - point.x;
|
||||
x = point.x;
|
||||
}
|
||||
|
||||
auto p = pos + size;
|
||||
p.x = max(point.x, p.x);
|
||||
p.y = max(point.y, p.y);
|
||||
size = p - pos;
|
||||
if (point.y < y) {
|
||||
size.y += y - point.y;
|
||||
y = point.y;
|
||||
}
|
||||
|
||||
if (point.x > x + size.x) {
|
||||
size.x = point.x - x;
|
||||
}
|
||||
|
||||
if (point.y > y + size.y) {
|
||||
size.y = point.y - y;
|
||||
}
|
||||
}
|
||||
|
||||
void expand(const Rect<Type>& rect) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace tp {
|
|||
WidgetApplication() = default;
|
||||
|
||||
void setRoot(Widget* widget);
|
||||
virtual void debugUI();
|
||||
|
||||
private:
|
||||
void processFrame(EventHandler* eventHandler, halnf deltaTime) override;
|
||||
|
|
@ -17,8 +18,6 @@ namespace tp {
|
|||
void drawFrame(Canvas* canvas) override;
|
||||
bool forceNewFrame() override ;
|
||||
|
||||
private:
|
||||
void debugUI();
|
||||
|
||||
private:
|
||||
halnf mDebugSplitFactor = 0.7;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue