diff --git a/src/cpp/include/nodegui/QtWidgets/QPainter/qpainter_wrap.h b/src/cpp/include/nodegui/QtWidgets/QPainter/qpainter_wrap.h index b4910898f..18ebd28af 100644 --- a/src/cpp/include/nodegui/QtWidgets/QPainter/qpainter_wrap.h +++ b/src/cpp/include/nodegui/QtWidgets/QPainter/qpainter_wrap.h @@ -30,6 +30,8 @@ class DLL_EXPORT QPainterWrap : public Napi::ObjectWrap { Napi::Value setRenderHint(const Napi::CallbackInfo& info); Napi::Value setBrush(const Napi::CallbackInfo& info); Napi::Value drawLine(const Napi::CallbackInfo& info); + Napi::Value drawEllipse(const Napi::CallbackInfo& info); + Napi::Value drawPie(const Napi::CallbackInfo& info); Napi::Value scale(const Napi::CallbackInfo& info); Napi::Value translate(const Napi::CallbackInfo& info); Napi::Value drawConvexPolygon(const Napi::CallbackInfo& info); diff --git a/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp b/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp index bba8e076d..a6ade3011 100644 --- a/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QPainter/qpainter_wrap.cpp @@ -17,6 +17,8 @@ Napi::Object QPainterWrap::init(Napi::Env env, Napi::Object exports) { env, CLASSNAME, {InstanceMethod("drawText", &QPainterWrap::drawText), InstanceMethod("drawPath", &QPainterWrap::drawPath), + InstanceMethod("drawPie", &QPainterWrap::drawPie), + InstanceMethod("drawEllipse", &QPainterWrap::drawEllipse), InstanceMethod("strokePath", &QPainterWrap::strokePath), InstanceMethod("begin", &QPainterWrap::begin), InstanceMethod("end", &QPainterWrap::end), @@ -136,6 +138,40 @@ Napi::Value QPainterWrap::setPen(const Napi::CallbackInfo& info) { } return env.Null(); } +Napi::Value QPainterWrap::drawEllipse(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + if (info.Length() < 4) { + Napi::TypeError::New(env, "Invalid number of arguments to drawEllipse") + .ThrowAsJavaScriptException(); + return env.Null(); + } + qreal x = info[0].As().DoubleValue(); + qreal y = info[1].As().DoubleValue(); + qreal width = info[2].As().DoubleValue(); + qreal height = info[3].As().DoubleValue(); + this->instance->drawEllipse(x, y, width, height); + + return env.Null(); +} +Napi::Value QPainterWrap::drawPie(const Napi::CallbackInfo& info) { + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + if (info.Length() < 6) { + Napi::TypeError::New(env, "Invalid number of arguments to drawPie") + .ThrowAsJavaScriptException(); + return env.Null(); + } + qreal x = info[0].As().DoubleValue(); + qreal y = info[1].As().DoubleValue(); + qreal width = info[2].As().DoubleValue(); + qreal height = info[3].As().DoubleValue(); + qreal startAngle = info[4].As().DoubleValue(); + qreal sweepLength = info[5].As().DoubleValue(); + this->instance->drawPie(x, y, width, height, startAngle, sweepLength); + + return env.Null(); +} Napi::Value QPainterWrap::drawLine(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); Napi::HandleScope scope(env); diff --git a/src/cpp/lib/QtWidgets/QPainterPath/qpainterpath_wrap.cpp b/src/cpp/lib/QtWidgets/QPainterPath/qpainterpath_wrap.cpp index ccdd6433d..c2046eb92 100644 --- a/src/cpp/lib/QtWidgets/QPainterPath/qpainterpath_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QPainterPath/qpainterpath_wrap.cpp @@ -247,7 +247,7 @@ Napi::Value QPainterPathWrap::arcTo(const Napi::CallbackInfo& info) { qreal width = info[2].As().DoubleValue(); qreal height = info[3].As().DoubleValue(); qreal startAngle = info[4].As().DoubleValue(); - qreal sweepLength = info[4].As().DoubleValue(); + qreal sweepLength = info[5].As().DoubleValue(); this->instance->arcTo(x, y, width, height, startAngle, sweepLength); return env.Null(); diff --git a/src/lib/QtWidgets/QPainter.ts b/src/lib/QtWidgets/QPainter.ts index 21081c0a7..c46ae1737 100644 --- a/src/lib/QtWidgets/QPainter.ts +++ b/src/lib/QtWidgets/QPainter.ts @@ -93,6 +93,14 @@ export class QPainter extends Component { this.native.setRenderHint(hint, on); } + drawEllipse(x: number, y: number, width: number, height: number): void { + return this.native.drawEllipse(x, y, width, height); + } + + drawPie(x: number, y: number, width: number, height: number, startAngle: number, sweepLength: number): void { + return this.native.drawPie(x, y, width, height, startAngle, sweepLength); + } + drawLine(x1: number, y1: number, x2: number, y2: number): void { this.native.drawLine(x1, y1, x2, y2); }