1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 22:15:08 +00:00

Some color cleanup.

This commit is contained in:
Andreas Kling 2018-10-12 23:02:23 +02:00
parent aceedaf957
commit e16d145cb4
9 changed files with 27 additions and 22 deletions

View file

@ -21,22 +21,21 @@ void Button::setCaption(String&& caption)
void Button::onPaint(PaintEvent&) void Button::onPaint(PaintEvent&)
{ {
Color buttonColor(192, 192, 192); Color buttonColor = Color::LightGray;
Color highlightColor(255, 255, 255); Color highlightColor = Color::White;
Color shadowColor(96, 96, 96); Color shadowColor = Color(96, 96, 96);
Painter painter(*this); Painter painter(*this);
painter.fillRect(rect(), Color(255, 0, 255));
painter.drawPixel({ 0, 0 }, backgroundColor()); painter.drawPixel({ 0, 0 }, backgroundColor());
painter.drawPixel({ width() - 1, 0 }, backgroundColor()); painter.drawPixel({ width() - 1, 0 }, backgroundColor());
painter.drawPixel({ 0, height() - 1 }, backgroundColor()); painter.drawPixel({ 0, height() - 1 }, backgroundColor());
painter.drawPixel({ width() - 1, height() - 1 }, backgroundColor()); painter.drawPixel({ width() - 1, height() - 1 }, backgroundColor());
painter.drawLine({ 1, 0 }, { width() - 2, 0 }, Color(0, 0, 0)); painter.drawLine({ 1, 0 }, { width() - 2, 0 }, Color::Black);
painter.drawLine({ 1, height() - 1 }, { width() - 2, height() - 1}, Color(0, 0, 0)); painter.drawLine({ 1, height() - 1 }, { width() - 2, height() - 1}, Color::Black);
painter.drawLine({ 0, 1 }, { 0, height() - 2 }, Color(0, 0, 0)); painter.drawLine({ 0, 1 }, { 0, height() - 2 }, Color::Black);
painter.drawLine({ width() - 1, 1 }, { width() - 1, height() - 2 }, Color(0, 0, 0)); painter.drawLine({ width() - 1, 1 }, { width() - 1, height() - 2 }, Color::Black);
if (m_beingPressed) { if (m_beingPressed) {
// Base // Base
@ -66,7 +65,7 @@ void Button::onPaint(PaintEvent&)
auto textRect = rect(); auto textRect = rect();
if (m_beingPressed) if (m_beingPressed)
textRect.moveBy(1, 1); textRect.moveBy(1, 1);
painter.drawText(textRect, caption(), Painter::TextAlignment::Center, Color(0, 0, 0)); painter.drawText(textRect, caption(), Painter::TextAlignment::Center, Color::Black);
} }
} }

View file

@ -88,10 +88,10 @@ void CheckBox::onPaint(PaintEvent&)
bitmapPosition.setY(height() / 2 - bitmap->height() / 2 - 1); bitmapPosition.setY(height() / 2 - bitmap->height() / 2 - 1);
painter.fillRect(rect(), backgroundColor()); painter.fillRect(rect(), backgroundColor());
painter.drawBitmap(bitmapPosition, *bitmap, Color(0, 0, 0)); painter.drawBitmap(bitmapPosition, *bitmap, foregroundColor());
if (!caption().isEmpty()) { if (!caption().isEmpty()) {
painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, Color(0, 0, 0)); painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, foregroundColor());
} }
} }

View file

@ -22,8 +22,8 @@ void ClockWidget::onPaint(PaintEvent&)
sprintf(timeBuf, "%02u:%02u:%02u ", tm.tm_hour, tm.tm_min, tm.tm_sec); sprintf(timeBuf, "%02u:%02u:%02u ", tm.tm_hour, tm.tm_min, tm.tm_sec);
Painter painter(*this); Painter painter(*this);
painter.fillRect(rect(), Color(127, 127, 127)); painter.fillRect(rect(), Color::MidGray);
painter.drawText(rect(), timeBuf, Painter::TextAlignment::Center, Color(0,0,0)); painter.drawText(rect(), timeBuf, Painter::TextAlignment::Center, Color::Black);
} }
void ClockWidget::onTimer(TimerEvent&) void ClockWidget::onTimer(TimerEvent&)

View file

@ -10,6 +10,9 @@ public:
Red, Red,
Green, Green,
Blue, Blue,
DarkGray,
MidGray,
LightGray,
}; };
Color() { } Color() { }

View file

@ -20,6 +20,9 @@ Color::Color(NamedColor named)
case Red: rgb = { 255, 0, 0}; break; case Red: rgb = { 255, 0, 0}; break;
case Green: rgb = { 0, 255, 0}; break; case Green: rgb = { 0, 255, 0}; break;
case Blue: rgb = { 0, 0, 255}; break; case Blue: rgb = { 0, 0, 255}; break;
case DarkGray: rgb = { 64, 64, 64 }; break;
case MidGray: rgb = { 127, 127, 127 }; break;
case LightGray: rgb = { 192, 192, 192 }; break;
default: ASSERT_NOT_REACHED(); break; default: ASSERT_NOT_REACHED(); break;
} }

View file

@ -21,7 +21,7 @@ void RootWidget::onPaint(PaintEvent& event)
event.rect().width(), event.rect().width(),
event.rect().height()); event.rect().height());
Painter painter(*this); Painter painter(*this);
painter.fillRect(event.rect(), Color(0x40, 0x40, 0x40)); painter.fillRect(event.rect(), Color(0, 72, 96));
} }
void RootWidget::onMouseMove(MouseEvent& event) void RootWidget::onMouseMove(MouseEvent& event)

View file

@ -63,7 +63,7 @@ CharacterWithAttributes& TerminalWidget::at(unsigned row, unsigned column)
void TerminalWidget::onPaint(PaintEvent&) void TerminalWidget::onPaint(PaintEvent&)
{ {
Painter painter(*this); Painter painter(*this);
painter.fillRect(rect(), Color(0, 0, 0)); painter.fillRect(rect(), Color::Black);
auto& font = Font::defaultFont(); auto& font = Font::defaultFont();

View file

@ -8,8 +8,8 @@
Widget::Widget(Widget* parent) Widget::Widget(Widget* parent)
: Object(parent) : Object(parent)
{ {
m_backgroundColor = Color(255, 255, 255); m_backgroundColor = Color::White;
m_foregroundColor = Color(0, 0, 0); m_foregroundColor = Color::Black;
} }
Widget::~Widget() Widget::~Widget()

View file

@ -46,8 +46,8 @@ WindowManager& WindowManager::the()
WindowManager::WindowManager() WindowManager::WindowManager()
{ {
m_windowBorderColor = Color(0x00, 0x00, 0x80); m_windowBorderColor = Color(0, 64, 192);
m_windowTitleColor = Color(0xff, 0xff, 0xff); m_windowTitleColor = Color::White;
} }
WindowManager::~WindowManager() WindowManager::~WindowManager()
@ -92,17 +92,17 @@ void WindowManager::paintWindowFrame(Window& window)
if (!m_lastDragRect.isEmpty()) { if (!m_lastDragRect.isEmpty()) {
p.xorRect(m_lastDragRect, Color(255, 0, 0)); p.xorRect(m_lastDragRect, Color::Red);
m_lastDragRect = Rect(); m_lastDragRect = Rect();
} }
if (m_dragWindow == &window) { if (m_dragWindow == &window) {
p.xorRect(outerRect, Color(255, 0, 0)); p.xorRect(outerRect, Color::Red);
m_lastDragRect = outerRect; m_lastDragRect = outerRect;
return; return;
} }
p.drawRect(borderRect, Color(255, 255, 255)); p.drawRect(borderRect, Color::White);
p.drawRect(outerRect, m_windowBorderColor); p.drawRect(outerRect, m_windowBorderColor);
p.fillRect(titleBarRect, m_windowBorderColor); p.fillRect(titleBarRect, m_windowBorderColor);