From 394dafc8a1be31b68df40e553c2ed40918dda35b Mon Sep 17 00:00:00 2001 From: Nanako <469449812@qq.com> Date: Mon, 27 May 2024 12:59:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96volume=20bar=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Arona/src/widget/misc/w_volume_bar.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Arona/src/widget/misc/w_volume_bar.cpp b/Arona/src/widget/misc/w_volume_bar.cpp index bef3ddd..e29ef5b 100644 --- a/Arona/src/widget/misc/w_volume_bar.cpp +++ b/Arona/src/widget/misc/w_volume_bar.cpp @@ -1,7 +1,6 @@ #include "w_volume_bar.h" #include "arona_application.h" -#include "tool/math/lerp.h" w_volume_bar::w_volume_bar(bool vertical) : is_vertical(vertical) { @@ -11,8 +10,9 @@ w_volume_bar::w_volume_bar(bool vertical) : is_vertical(vertical) } void w_volume_bar::on_draw(const Cairo::RefPtr& cr, int width, int height) { - // Draw a black rectangle. + // Draw background color cr->set_source_rgba(0.0, 0.0, 0.0, 1.0); + cr->rectangle(0, 0, width, height); cr->fill(); Cairo::RefPtr line_color; @@ -21,9 +21,10 @@ void w_volume_bar::on_draw(const Cairo::RefPtr& cr, int width, i } else { line_color = Cairo::LinearGradient::create(0, 0, width, 0); } - line_color->add_color_stop_rgb(0, 0.0, 1.0, 0.0); - line_color->add_color_stop_rgb(0.7, 0.5, 0.5, 0.0); // (0.5, 0.5, 0.5) - line_color->add_color_stop_rgb(1, 1.0, 0.0, 0.0); + line_color->add_color_stop_rgb(0, 1.0, 0.0, 0.0); + line_color->add_color_stop_rgb(0.2, 1.0, 0.0, 0.0); + line_color->add_color_stop_rgb(0.4, 0.5, 0.5, 0.0); // (0.5, 0.5, 0.5) + line_color->add_color_stop_rgb(1, 0.0, 1.0, 0.0); cr->set_source(line_color); // draw value bar @@ -34,5 +35,13 @@ void w_volume_bar::on_draw(const Cairo::RefPtr& cr, int width, i } cr->fill(); + // draw border + cr->set_source_rgba(1.0, 1.0, 1.0, 1.0); + cr->set_line_width(1.0); + cr->line_to(0, 0); + cr->line_to(width, 0); + cr->line_to(width, height); + cr->line_to(0, height); + cr->line_to(0, 0); cr->stroke(); }