Skip to content

Commit

Permalink
Fix some Colorf stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Nov 9, 2023
1 parent fc61351 commit d5f1d0c
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/zwidget/core/span_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SpanObject> objects;
Expand Down
2 changes: 1 addition & 1 deletion include/zwidget/core/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/checkboxlabel/checkboxlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
14 changes: 7 additions & 7 deletions src/widgets/lineedit/lineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/listview/listview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/menubar/menubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion src/widgets/pushbutton/pushbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/widgets/statusbar/statusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
}
2 changes: 1 addition & 1 deletion src/widgets/textedit/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/textlabel/textlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit d5f1d0c

Please sign in to comment.