diff --git a/include/zwidget/core/span_layout.h b/include/zwidget/core/span_layout.h index 4a1ddd1..974feca 100644 --- a/include/zwidget/core/span_layout.h +++ b/include/zwidget/core/span_layout.h @@ -212,7 +212,7 @@ class SpanLayout Colorf cursor_color; std::string::size_type sel_start = 0, sel_end = 0; - Colorf sel_foreground, sel_background = Colorf(153 / 255.0f, 201 / 255.0f, 239 / 255.0f); + Colorf sel_foreground, sel_background = Colorf::fromRgba8(153, 201, 239); std::string text; std::vector objects; diff --git a/include/zwidget/core/widget.h b/include/zwidget/core/widget.h index 787d0ce..4eb434a 100644 --- a/include/zwidget/core/widget.h +++ b/include/zwidget/core/widget.h @@ -158,7 +158,7 @@ class Widget : DisplayWindowHost Rect FrameGeometry = Rect::xywh(0.0, 0.0, 0.0, 0.0); Rect ContentGeometry = Rect::xywh(0.0, 0.0, 0.0, 0.0); - Colorf WindowBackground = Colorf(240 / 255.0f, 240 / 255.0f, 240 / 255.0f); + Colorf WindowBackground = Colorf::fromRgba8(240, 240, 240); struct { diff --git a/src/widgets/checkboxlabel/checkboxlabel.cpp b/src/widgets/checkboxlabel/checkboxlabel.cpp index cb9e6a3..6c17d77 100644 --- a/src/widgets/checkboxlabel/checkboxlabel.cpp +++ b/src/widgets/checkboxlabel/checkboxlabel.cpp @@ -26,5 +26,5 @@ double CheckboxLabel::GetPreferredHeight() const void CheckboxLabel::OnPaint(Canvas* canvas) { - canvas->drawText(Point(0.0, GetHeight() - 5.0), Colorf(1.0f, 1.0f, 1.0f), "[x] " + text); + canvas->drawText(Point(0.0, GetHeight() - 5.0), Colorf::fromRgba8(255, 255, 255), "[x] " + text); } diff --git a/src/widgets/lineedit/lineedit.cpp b/src/widgets/lineedit/lineedit.cpp index e8e55c0..0d4c373 100644 --- a/src/widgets/lineedit/lineedit.cpp +++ b/src/widgets/lineedit/lineedit.cpp @@ -1066,8 +1066,8 @@ void LineEdit::OnPaintFrame(Canvas* canvas) { double w = GetFrameGeometry().width; double h = GetFrameGeometry().height; - Colorf bordercolor(200 / 255.0f, 200 / 255.0f, 200 / 255.0f); - canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + Colorf bordercolor = Colorf::fromRgba8(200, 200, 200); + canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf::fromRgba8(255, 255, 255)); canvas->fillRect(Rect::xywh(0.0, 0.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, h - 1.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, 0.0, 1.0, h - 0.0), bordercolor); @@ -1096,21 +1096,21 @@ void LineEdit::OnPaint(Canvas* canvas) { // Draw selection box. Rect selection_rect = GetSelectionRect(); - canvas->fillRect(selection_rect, HasFocus() ? Colorf(153 / 255.0f, 201 / 255.0f, 239 / 255.0f) : Colorf(229 / 255.0f, 235 / 255.0f, 241 / 255.0f)); + canvas->fillRect(selection_rect, HasFocus() ? Colorf::fromRgba8(153, 201, 239) : Colorf::fromRgba8(229, 235, 241)); } // Draw text before selection if (!txt_before.empty()) { - canvas->drawText(Point(0.0, canvas->verticalTextAlign().baseline), Colorf(0.0f, 0.0f, 0.0f), txt_before); + canvas->drawText(Point(0.0, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_before); } if (!txt_selected.empty()) { - canvas->drawText(Point(size_before.width, canvas->verticalTextAlign().baseline), Colorf(0.0f, 0.0f, 0.0f), txt_selected); + canvas->drawText(Point(size_before.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_selected); } if (!txt_after.empty()) { - canvas->drawText(Point(size_before.width + size_selected.width, canvas->verticalTextAlign().baseline), Colorf(0.0f, 0.0f, 0.0f), txt_after); + canvas->drawText(Point(size_before.width + size_selected.width, canvas->verticalTextAlign().baseline), Colorf::fromRgba8(0, 0, 0), txt_after); } // draw cursor @@ -1119,7 +1119,7 @@ void LineEdit::OnPaint(Canvas* canvas) if (cursor_blink_visible) { Rect cursor_rect = GetCursorRect(); - canvas->fillRect(cursor_rect, Colorf(0.0f, 0.0f, 0.0f)); + canvas->fillRect(cursor_rect, Colorf::fromRgba8(0, 0, 0)); } } } diff --git a/src/widgets/listview/listview.cpp b/src/widgets/listview/listview.cpp index c8255f5..8a8cdb0 100644 --- a/src/widgets/listview/listview.cpp +++ b/src/widgets/listview/listview.cpp @@ -11,7 +11,7 @@ void ListView::OnPaintFrame(Canvas* canvas) double w = GetFrameGeometry().width; double h = GetFrameGeometry().height; Colorf bordercolor = Colorf::fromRgba8(100, 100, 100); - canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf(38 / 255.0f, 38 / 255.0f, 38 / 255.0f)); + canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf::fromRgba8(38, 38, 38)); canvas->fillRect(Rect::xywh(0.0, 0.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, h - 1.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, 0.0, 1.0, h - 0.0), bordercolor); diff --git a/src/widgets/menubar/menubar.cpp b/src/widgets/menubar/menubar.cpp index feb9092..8a66ce8 100644 --- a/src/widgets/menubar/menubar.cpp +++ b/src/widgets/menubar/menubar.cpp @@ -12,5 +12,5 @@ Menubar::~Menubar() void Menubar::OnPaint(Canvas* canvas) { - canvas->drawText(Point(16.0, 21.0), Colorf(0.0f, 0.0f, 0.0f), "File Edit View Tools Window Help"); + canvas->drawText(Point(16.0, 21.0), Colorf::fromRgba8(0, 0, 0), "File Edit View Tools Window Help"); } diff --git a/src/widgets/pushbutton/pushbutton.cpp b/src/widgets/pushbutton/pushbutton.cpp index d998348..deb7bc9 100644 --- a/src/widgets/pushbutton/pushbutton.cpp +++ b/src/widgets/pushbutton/pushbutton.cpp @@ -40,5 +40,5 @@ void PushButton::OnPaintFrame(Canvas* canvas) void PushButton::OnPaint(Canvas* canvas) { Rect box = canvas->measureText(text); - canvas->drawText(Point((GetWidth() - box.width) * 0.5, GetHeight() - 5.0), Colorf(1.0f, 1.0f, 1.0f), text); + canvas->drawText(Point((GetWidth() - box.width) * 0.5, GetHeight() - 5.0), Colorf::fromRgba8(255, 255, 255), text); } diff --git a/src/widgets/statusbar/statusbar.cpp b/src/widgets/statusbar/statusbar.cpp index 41593af..fd91429 100644 --- a/src/widgets/statusbar/statusbar.cpp +++ b/src/widgets/statusbar/statusbar.cpp @@ -15,5 +15,5 @@ Statusbar::~Statusbar() void Statusbar::OnPaint(Canvas* canvas) { - canvas->drawText(Point(16.0, 21.0), Colorf(0.0f, 0.0f, 0.0f), "Command:"); + canvas->drawText(Point(16.0, 21.0), Colorf::fromRgba8(0, 0, 0), "Command:"); } diff --git a/src/widgets/textedit/textedit.cpp b/src/widgets/textedit/textedit.cpp index ec26adf..7314b0e 100644 --- a/src/widgets/textedit/textedit.cpp +++ b/src/widgets/textedit/textedit.cpp @@ -1007,7 +1007,7 @@ void TextEdit::OnPaintFrame(Canvas* canvas) double w = GetFrameGeometry().width; double h = GetFrameGeometry().height; Colorf bordercolor(200 / 255.0f, 200 / 255.0f, 200 / 255.0f); - canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + canvas->fillRect(Rect::xywh(0.0, 0.0, w, h), Colorf::fromRgba8(255, 255, 255)); canvas->fillRect(Rect::xywh(0.0, 0.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, h - 1.0, w, 1.0), bordercolor); canvas->fillRect(Rect::xywh(0.0, 0.0, 1.0, h - 0.0), bordercolor); diff --git a/src/widgets/textlabel/textlabel.cpp b/src/widgets/textlabel/textlabel.cpp index 67c939e..5f738db 100644 --- a/src/widgets/textlabel/textlabel.cpp +++ b/src/widgets/textlabel/textlabel.cpp @@ -26,5 +26,5 @@ double TextLabel::GetPreferredHeight() const void TextLabel::OnPaint(Canvas* canvas) { - canvas->drawText(Point(0.0, GetHeight() - 5.0), Colorf(1.0f, 1.0f, 1.0f), text); + canvas->drawText(Point(0.0, GetHeight() - 5.0), Colorf::fromRgba8(255, 255, 255), text); }