From d9b10f103ab2d86072ee1dd66bcb79ae140576f0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 1 May 2020 17:10:30 +0200 Subject: Draw axis texts with painter. --- plugingui/powerwidget.cc | 27 ++++++++++----------------- plugingui/powerwidget.h | 4 ++-- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/plugingui/powerwidget.cc b/plugingui/powerwidget.cc index 2843d85..e618d16 100644 --- a/plugingui/powerwidget.cc +++ b/plugingui/powerwidget.cc @@ -52,15 +52,6 @@ PowerWidget::PowerWidget(GUI::Widget* parent, shelf_label.resize(59, 16); shelf_checkbox.resize(59, 40); - input_label.setText("in"); - input_label.resize(20, 16); - input_label.setAlignment(GUI::TextAlignment::center); - input_label.setColour(GUI::Colour(1.0f, 1.0f, 1.0f, 0.2f)); - output_label.setText("out"); - output_label.resize(20, 16); - output_label.setAlignment(GUI::TextAlignment::left); - output_label.setColour(GUI::Colour(1.0f, 1.0f, 1.0f, 0.2f)); - CONNECT(&settings_notifier, powermap_shelf, &shelf_checkbox, &GUI::CheckBox::setChecked); } @@ -89,8 +80,6 @@ void PowerWidget::resize(std::size_t width, std::size_t height) shelf_label.move(width - 59 + 5 - 32 , 0); shelf_checkbox.move(width - 59 + 5 - 32, 16); - input_label.move((width-64-59)/2, height-30); - output_label.move(20, height/2); } PowerWidget::Canvas::Canvas(GUI::Widget* parent, @@ -198,22 +187,26 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent) // draw the fixed nodes of the spline float rad = radius * width(); p.setColour(GUI::Colour{0.0f, 1.0f, 0.0f, 0.7f}); - p.drawFilledCircle(x0 + std::round(settings.powermap_fixed0_x.load() * width0), - y0 + height0 - std::round(settings.powermap_fixed0_y.load() * height0), rad); + p.drawFilledCircle(x0 + settings.powermap_fixed0_x.load() * width0, + y0 + height0 - settings.powermap_fixed0_y.load() * height0, rad); p.drawCircle(x0 + std::round(power_map.getFixed0().in * width0), y0 + height0 - std::round(power_map.getFixed0().out * height0), rad + 1); p.setColour(GUI::Colour{1.0f, 1.0f, 0.0f, 0.7f}); - p.drawFilledCircle(x0 + std::round(settings.powermap_fixed1_x.load() * width0), - y0 + height0 - std::round(settings.powermap_fixed1_y.load() * height0), rad); + p.drawFilledCircle(x0 + settings.powermap_fixed1_x.load() * width0, + y0 + height0 - settings.powermap_fixed1_y.load() * height0, rad); p.drawCircle(x0 + std::round(power_map.getFixed1().in * width0), y0 + height0 - std::round(power_map.getFixed1().out * height0), rad + 1); p.setColour(GUI::Colour{1.0f, 0.0f, 0.0f, 0.7f}); - p.drawFilledCircle(x0 + std::round(settings.powermap_fixed2_x.load() * width0), - y0 + height0 - std::round(settings.powermap_fixed2_y.load() * height0), rad); + p.drawFilledCircle(x0 + settings.powermap_fixed2_x.load() * width0, + y0 + height0 - settings.powermap_fixed2_y.load() * height0, rad); p.drawCircle(x0 + std::round(power_map.getFixed2().in * width0), y0 + height0 - std::round(power_map.getFixed2().out * height0), rad + 1); + + p.setColour(GUI::Colour(1.0f, 1.0f, 1.0f, 0.2f)); + p.drawText(width() / 2, height() - 8, font, "in"); + p.drawText(16, height() / 2 + 8, font, "out"); } void PowerWidget::Canvas::buttonEvent(GUI::ButtonEvent* buttonEvent) diff --git a/plugingui/powerwidget.h b/plugingui/powerwidget.h index 562383b..c5c6665 100644 --- a/plugingui/powerwidget.h +++ b/plugingui/powerwidget.h @@ -32,6 +32,7 @@ #include #include #include +#include #include struct Settings; @@ -83,6 +84,7 @@ private: int in_point{-1}; const float radius = 0.02f; const float brd = 6.0f; + GUI::Font font{":resources/fontemboss.png"}; }; void chk_shelf(bool v); @@ -90,8 +92,6 @@ private: Canvas canvas; GUI::Label shelf_label{this}; GUI::CheckBox shelf_checkbox{this}; - GUI::Label input_label{this}; - GUI::Label output_label{this}; Settings& settings; }; -- cgit v1.2.3