Refactor out forecolor

This commit is contained in:
elasota
2020-05-21 03:30:11 -04:00
parent a1c45d4fc8
commit 438e7b2138
44 changed files with 924 additions and 967 deletions

View File

@@ -20,6 +20,7 @@
#include "QDManager.h"
#include "QDPixMap.h"
#include "RGBAColor.h"
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include <stdint.h>
@@ -812,42 +813,44 @@ namespace PortabilityLayer
PortabilityLayer::QDState *qdState = qdManager->GetState();
graf->SetForeColor(gs_barMidColor);
graf->FillRect(menuRect);
graf->SetForeColor(gs_barBrightColor);
ResolveCachingColor barMidColor = gs_barMidColor;
graf->FillRect(menuRect, barMidColor);
ResolveCachingColor barBrightColor = gs_barBrightColor;
// Top stripe
{
const Rect rect = Rect::Create(0, 0, 1, static_cast<int16_t>(width) - 1);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barBrightColor);
}
// Left stripe
{
const Rect rect = Rect::Create(0, 0, kMenuBarHeight - 1, 1);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barBrightColor);
}
qdState->SetForeColor(gs_barDarkColor);
ResolveCachingColor barDarkColor = gs_barDarkColor;
// Bottom stripe
{
const Rect rect = Rect::Create(kMenuBarHeight - 2, 1, kMenuBarHeight - 1, width);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barDarkColor);
}
// Right stripe
{
const Rect rect = Rect::Create(0, width - 1, kMenuBarHeight - 1, width);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barDarkColor);
}
qdState->SetForeColor(gs_barBottomEdgeColor);
ResolveCachingColor barBottomEdgeColor = gs_barBottomEdgeColor;
// Bottom edge
{
const Rect rect = Rect::Create(kMenuBarHeight - 1, 0, kMenuBarHeight, width);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barBottomEdgeColor);
}
PixMapHandle pixMap = m_menuBarGraf->m_port.GetPixMap();
@@ -869,28 +872,28 @@ namespace PortabilityLayer
const int16_t right = static_cast<int16_t>(xCoordinate + width);
// Top edge
qdState->SetForeColor(gs_barHighlightBrightColor);
{
ResolveCachingColor barHighlightBrightColor = gs_barHighlightBrightColor;
const Rect rect = Rect::Create(0, left, 1, right);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barHighlightBrightColor);
}
// Middle
qdState->SetForeColor(gs_barHighlightMidColor);
{
ResolveCachingColor barHighlightMidColor = gs_barHighlightMidColor;
const Rect rect = Rect::Create(1, left, kMenuBarHeight - 2, right);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barHighlightMidColor);
}
qdState->SetForeColor(gs_barHighlightDarkColor);
{
ResolveCachingColor barHighlightDarkColor = gs_barHighlightDarkColor;
const Rect rect = Rect::Create(kMenuBarHeight - 2, left, kMenuBarHeight - 1, right);
m_menuBarGraf->FillRect(rect);
m_menuBarGraf->FillRect(rect, barHighlightDarkColor);
}
}
// Text items
qdState->SetForeColor(gs_barNormalTextColor);
ResolveCachingColor barNormalTextColor = gs_barNormalTextColor;
m_menuBarGraf->SetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold);
{
@@ -913,7 +916,7 @@ namespace PortabilityLayer
if (menuHdl != selectedMenuHdl)
{
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true, barNormalTextColor);
}
}
}
@@ -928,11 +931,12 @@ namespace PortabilityLayer
if (menu->stringBlobHandle && !menu->isIcon)
{
qdState->SetForeColor(gs_barHighlightTextColor);
ResolveCachingColor barHighlightTextColor = gs_barHighlightTextColor;
size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding;
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true, barHighlightTextColor);
}
}
@@ -1373,19 +1377,21 @@ namespace PortabilityLayer
QDState *qdState = qdManager->GetState();
qdState->SetForeColor(gs_barMidColor);
ResolveCachingColor barMidColor = gs_barMidColor;
{
const Rect rect = Rect::Create(0, 0, menu->layoutFinalHeight, menu->layoutWidth);
surface->FillRect(rect);
surface->FillRect(rect, barMidColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(0, 0, 1, menu->layoutWidth - 1));
surface->FillRect(Rect::Create(1, 0, menu->layoutFinalHeight - 1, 1));
ResolveCachingColor whiteColor = StdColors::White();
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(1, menu->layoutWidth - 1, menu->layoutFinalHeight, menu->layoutWidth));
surface->FillRect(Rect::Create(menu->layoutFinalHeight - 1, 1, menu->layoutFinalHeight, menu->layoutWidth - 1));
surface->FillRect(Rect::Create(0, 0, 1, menu->layoutWidth - 1), whiteColor);
surface->FillRect(Rect::Create(1, 0, menu->layoutFinalHeight - 1, 1), whiteColor);
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
surface->FillRect(Rect::Create(1, menu->layoutWidth - 1, menu->layoutFinalHeight, menu->layoutWidth), darkGrayColor);
surface->FillRect(Rect::Create(menu->layoutFinalHeight - 1, 1, menu->layoutFinalHeight, menu->layoutWidth - 1), darkGrayColor);
}
m_menuGraf->SetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold);
@@ -1403,21 +1409,23 @@ namespace PortabilityLayer
if (ItemIsSeparator(*menu, item))
{
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(item.layoutYOffset + 2, 0, item.layoutYOffset + 3, menu->layoutWidth));
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(item.layoutYOffset + 3, 0, item.layoutYOffset + 4, menu->layoutWidth));
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
surface->FillRect(Rect::Create(item.layoutYOffset + 2, 0, item.layoutYOffset + 3, menu->layoutWidth), darkGrayColor);
ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(Rect::Create(item.layoutYOffset + 3, 0, item.layoutYOffset + 4, menu->layoutWidth), whiteColor);
}
else
{
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
if (item.enabled)
qdState->SetForeColor(gs_barNormalTextColor);
else
qdState->SetForeColor(gs_barDisabledTextColor);
ResolveCachingColor itemTextAndCheckColor;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true);
if (item.enabled)
itemTextAndCheckColor = gs_barNormalTextColor;
else
itemTextAndCheckColor = gs_barDisabledTextColor;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true, itemTextAndCheckColor);
if (item.key)
{
@@ -1425,38 +1433,39 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true, itemTextAndCheckColor);
}
if (item.checked)
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset));
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), itemTextAndCheckColor);
}
}
if (m_haveItem)
{
const MenuItem &selectedItem = menu->menuItems[m_itemIndex];
qdState->SetForeColor(gs_barHighlightMidColor);
const Rect itemRect = Rect::Create(selectedItem.layoutYOffset, 0, selectedItem.layoutYOffset + selectedItem.layoutHeight, menu->layoutWidth);
surface->FillRect(itemRect);
qdState->SetForeColor(gs_barHighlightBrightColor);
surface->FillRect(Rect::Create(itemRect.top, 0, itemRect.bottom, 1));
PortabilityLayer::ResolveCachingColor barHighlightMidColor = gs_barHighlightMidColor;
surface->FillRect(itemRect, barHighlightMidColor);
ResolveCachingColor barHighlightBrightColor = gs_barHighlightBrightColor;
surface->FillRect(Rect::Create(itemRect.top, 0, itemRect.bottom, 1), barHighlightBrightColor);
if (m_itemIndex == 0)
surface->FillRect(Rect::Create(0, 1, 1, itemRect.right - 1));
surface->FillRect(Rect::Create(0, 1, 1, itemRect.right - 1), barHighlightBrightColor);
qdState->SetForeColor(gs_barHighlightDarkColor);
surface->FillRect(Rect::Create(itemRect.top, itemRect.right - 1, itemRect.bottom, itemRect.right));
ResolveCachingColor barHighlightDarkColor = gs_barHighlightDarkColor;
surface->FillRect(Rect::Create(itemRect.top, itemRect.right - 1, itemRect.bottom, itemRect.right), barHighlightDarkColor);
if (m_itemIndex == menu->numMenuItems - 1)
surface->FillRect(Rect::Create(itemRect.bottom - 1, 1, itemRect.bottom, itemRect.right - 1));
surface->FillRect(Rect::Create(itemRect.bottom - 1, 1, itemRect.bottom, itemRect.right - 1), barHighlightDarkColor);
qdState->SetForeColor(gs_barHighlightTextColor);
ResolveCachingColor barHighlightTextColor = gs_barHighlightTextColor;
const MenuItem &item = menu->menuItems[m_itemIndex];
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true);
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true, barHighlightTextColor);
if (item.key)
{
@@ -1464,10 +1473,10 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true, barHighlightTextColor);
if (item.checked)
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset));
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), barHighlightTextColor);
}
}

View File

@@ -5,6 +5,7 @@
#include "PLTimeTaggedVOSEvent.h"
#include "PLStandardColors.h"
#include "FontFamily.h"
#include "ResolveCachingColor.h"
#include "SimpleGraphic.h"
#include <algorithm>
@@ -410,39 +411,41 @@ namespace PortabilityLayer
for (int i = 0; i < 3; i++)
{
ResolveCachingColor color;
if (i == 0)
surface->SetForeColor(borderColor);
color = borderColor;
if (i != 0)
surface->SetForeColor(leftStripeColors[i - 1]);
color = leftStripeColors[i - 1];
surface->FillRect(Rect::Create(rect.top + 3, rect.left + i, rect.bottom - 3, rect.left + i + 1));
surface->FillRect(Rect::Create(rect.top + 3, rect.left + i, rect.bottom - 3, rect.left + i + 1), color);
if (i != 0)
surface->SetForeColor(rightStripeColors[i - 1]);
color = rightStripeColors[i - 1];
surface->FillRect(Rect::Create(rect.top + 3, rect.right - 1 - i, rect.bottom - 3, rect.right - i));
surface->FillRect(Rect::Create(rect.top + 3, rect.right - 1 - i, rect.bottom - 3, rect.right - i), color);
if (i != 0)
surface->SetForeColor(topStripeColors[i - 1]);
color = topStripeColors[i - 1];
surface->FillRect(Rect::Create(rect.top + i, rect.left + 3, rect.top + i + 1, rect.right - 3));
surface->FillRect(Rect::Create(rect.top + i, rect.left + 3, rect.top + i + 1, rect.right - 3), color);
if (i != 0)
surface->SetForeColor(bottomStripeColors[i - 1]);
color = bottomStripeColors[i - 1];
surface->FillRect(Rect::Create(rect.bottom - 1 - i, rect.left + 3, rect.bottom - i, rect.right - 3));
surface->FillRect(Rect::Create(rect.bottom - 1 - i, rect.left + 3, rect.bottom - i, rect.right - 3), color);
}
surface->SetForeColor(centerColor);
surface->FillRect(rect.Inset(3, 3));
ResolveCachingColor centerCacheColor = centerColor;
surface->FillRect(rect.Inset(3, 3), centerCacheColor);
surface->SetForeColor(textColor);
ResolveCachingColor textCacheColor = textColor;
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(surface->MeasureString(m_text.ToShortStr()))) / 2;
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(surface->MeasureFontAscender())) / 2;
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), true);
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), true, textCacheColor);
}
void ButtonWidget::DrawAsCheck(DrawSurface *surface, bool inverted)
@@ -450,57 +453,55 @@ namespace PortabilityLayer
if (!m_rect.IsValid())
return;
surface->SetForeColor(StdColors::White());
surface->FillRect(m_rect);
ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(m_rect, whiteColor);
uint16_t checkFrameSize = std::min<uint16_t>(12, std::min(m_rect.Width(), m_rect.Height()));
int16_t top = (m_rect.top + m_rect.bottom - static_cast<int16_t>(checkFrameSize)) / 2;
const Rect checkRect = Rect::Create(top, m_rect.left, top + static_cast<int16_t>(checkFrameSize), m_rect.left + static_cast<int16_t>(checkFrameSize));
RGBAColor checkColor;
RGBAColor checkEraseColor;
RGBAColor textColor;
ResolveCachingColor *checkColor = nullptr;
ResolveCachingColor *checkEraseColor = nullptr;
ResolveCachingColor *textColor = nullptr;
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255);
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor blackColor = StdColors::Black();
if (!m_enabled)
{
surface->SetForeColor(RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(checkRect);
surface->SetForeColor(RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255));
surface->FillRect(checkRect.Inset(1, 1));
surface->FillRect(checkRect, midGrayColor);
surface->FillRect(checkRect.Inset(1, 1), lightGrayColor);
checkColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
checkEraseColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255);
textColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
checkColor = &midGrayColor;
checkEraseColor = &lightGrayColor;
textColor = &midGrayColor;
}
else if (inverted)
{
surface->SetForeColor(StdColors::Black());
surface->FillRect(checkRect);
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(checkRect.Inset(1, 1));
surface->FillRect(checkRect, blackColor);
surface->FillRect(checkRect.Inset(1, 1), darkGrayColor);
checkColor = StdColors::White();
checkEraseColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
textColor = StdColors::Black();
checkColor = &whiteColor;
checkEraseColor = &darkGrayColor;
textColor = &blackColor;
}
else
{
surface->SetForeColor(StdColors::Black());
surface->FillRect(checkRect);
surface->SetForeColor(RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(checkRect.Inset(1, 1));
surface->FillRect(checkRect, blackColor);
surface->FillRect(checkRect.Inset(1, 1), midGrayColor);
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(checkRect.top + 2, checkRect.right - 2, checkRect.bottom - 2, checkRect.right - 1));
surface->FillRect(Rect::Create(checkRect.bottom - 2, checkRect.left + 2, checkRect.bottom - 1, checkRect.right - 1));
surface->FillRect(Rect::Create(checkRect.top + 2, checkRect.right - 2, checkRect.bottom - 2, checkRect.right - 1), darkGrayColor);
surface->FillRect(Rect::Create(checkRect.bottom - 2, checkRect.left + 2, checkRect.bottom - 1, checkRect.right - 1), darkGrayColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(checkRect.top + 1, checkRect.left + 1, checkRect.top + 2, checkRect.right - 2));
surface->FillRect(Rect::Create(checkRect.top + 2, checkRect.left + 1, checkRect.bottom - 2, checkRect.left + 2));
surface->FillRect(Rect::Create(checkRect.top + 1, checkRect.left + 1, checkRect.top + 2, checkRect.right - 2), whiteColor);
surface->FillRect(Rect::Create(checkRect.top + 2, checkRect.left + 1, checkRect.bottom - 2, checkRect.left + 2), whiteColor);
checkColor = StdColors::Black();
checkEraseColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
textColor = StdColors::Black();
checkColor = &blackColor;
checkEraseColor = &midGrayColor;
textColor = &blackColor;
}
if (m_state)
@@ -509,22 +510,19 @@ namespace PortabilityLayer
if (checkmarkRect.IsValid())
{
surface->SetForeColor(checkColor);
surface->FillRect(checkmarkRect);
surface->FillRect(checkmarkRect, *checkColor);
if (checkmarkRect.Width() >= 5)
{
int32_t eraseSpan = checkmarkRect.Width() - 4;
int16_t coordinateOffset = 0;
surface->SetForeColor(checkEraseColor);
while (eraseSpan > 0)
{
surface->FillRect(Rect::Create(checkmarkRect.top + coordinateOffset, checkmarkRect.left + 2 + coordinateOffset, checkmarkRect.top + 1 + coordinateOffset, checkmarkRect.right - 2 - coordinateOffset));
surface->FillRect(Rect::Create(checkmarkRect.top + 2 + coordinateOffset, checkmarkRect.left + coordinateOffset, checkmarkRect.bottom - 2 - coordinateOffset, checkmarkRect.left + 1 + coordinateOffset));
surface->FillRect(Rect::Create(checkmarkRect.bottom - 1 - coordinateOffset, checkmarkRect.left + 2 + coordinateOffset, checkmarkRect.bottom - coordinateOffset, checkmarkRect.right - 2 - coordinateOffset));
surface->FillRect(Rect::Create(checkmarkRect.top + 2 + coordinateOffset, checkmarkRect.right - 1 - coordinateOffset, checkmarkRect.bottom - 2 - coordinateOffset, checkmarkRect.right - coordinateOffset));
surface->FillRect(Rect::Create(checkmarkRect.top + coordinateOffset, checkmarkRect.left + 2 + coordinateOffset, checkmarkRect.top + 1 + coordinateOffset, checkmarkRect.right - 2 - coordinateOffset), *checkEraseColor);
surface->FillRect(Rect::Create(checkmarkRect.top + 2 + coordinateOffset, checkmarkRect.left + coordinateOffset, checkmarkRect.bottom - 2 - coordinateOffset, checkmarkRect.left + 1 + coordinateOffset), *checkEraseColor);
surface->FillRect(Rect::Create(checkmarkRect.bottom - 1 - coordinateOffset, checkmarkRect.left + 2 + coordinateOffset, checkmarkRect.bottom - coordinateOffset, checkmarkRect.right - 2 - coordinateOffset), *checkEraseColor);
surface->FillRect(Rect::Create(checkmarkRect.top + 2 + coordinateOffset, checkmarkRect.right - 1 - coordinateOffset, checkmarkRect.bottom - 2 - coordinateOffset, checkmarkRect.right - coordinateOffset), *checkEraseColor);
eraseSpan -= 2;
coordinateOffset++;
@@ -533,11 +531,9 @@ namespace PortabilityLayer
}
}
surface->SetForeColor(textColor);
surface->SetSystemFont(12, FontFamilyFlag_Bold);
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true);
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true, *textColor);
}
@@ -546,42 +542,44 @@ namespace PortabilityLayer
if (!m_rect.IsValid())
return;
surface->SetForeColor(StdColors::White());
surface->FillRect(m_rect);
ResolveCachingColor whiteColor = StdColors::White();
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(m_rect, whiteColor);
uint16_t checkFrameSize = std::min<uint16_t>(12, std::min(m_rect.Width(), m_rect.Height()));
int16_t top = (m_rect.top + m_rect.bottom - static_cast<int16_t>(checkFrameSize)) / 2;
const Rect checkRect = Rect::Create(top, m_rect.left, top + static_cast<int16_t>(checkFrameSize), m_rect.left + static_cast<int16_t>(checkFrameSize));
RGBAColor radioColor;
RGBAColor textColor;
ResolveCachingColor *radioColor = nullptr;
ResolveCachingColor *textColor = nullptr;
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255);
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
if (!m_enabled)
{
surface->SetForeColor(RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillEllipse(checkRect);
surface->SetForeColor(RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255));
surface->FillEllipse(checkRect.Inset(1, 1));
surface->FillEllipse(checkRect, midGrayColor);
surface->FillEllipse(checkRect.Inset(1, 1), lightGrayColor);
radioColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
textColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
radioColor = &midGrayColor;
textColor = &midGrayColor;
}
else if (inverted)
{
surface->SetForeColor(StdColors::Black());
surface->FillEllipse(checkRect);
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillEllipse(checkRect.Inset(1, 1));
surface->FillEllipse(checkRect, blackColor);
surface->FillEllipse(checkRect.Inset(1, 1), darkGrayColor);
radioColor = StdColors::Black();
textColor = StdColors::Black();
radioColor = &blackColor;
textColor = &blackColor;
}
else
{
gs_buttonRadioGraphic.DrawToPixMapWithMask(surface->m_port.GetPixMap(), gs_buttonRadioGraphicMask, checkRect.left, checkRect.top);
radioColor = StdColors::Black();
textColor = StdColors::Black();
radioColor = &blackColor;
textColor = &blackColor;
}
if (m_state)
@@ -590,16 +588,13 @@ namespace PortabilityLayer
if (checkmarkRect.IsValid())
{
surface->SetForeColor(radioColor);
surface->FillEllipse(checkmarkRect);
surface->FillEllipse(checkmarkRect, *radioColor);
}
}
surface->SetForeColor(textColor);
surface->SetSystemFont(12, FontFamilyFlag_Bold);
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true);
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true, *textColor);
}
void ButtonWidget::DrawDefaultButtonChrome(const Rect &rectRef, DrawSurface *surface)
@@ -629,16 +624,16 @@ namespace PortabilityLayer
for (int i = 0; i < 3; i++)
{
surface->SetForeColor(upperLeftStripeColors[i]);
surface->FillRect(Rect::Create(rect.top - 1 - i, rect.left + 2, rect.top - i, rect.right - 2));
surface->FillRect(Rect::Create(rect.top + 2, rect.left - 1 - i, rect.bottom - 2, rect.left - i));
ResolveCachingColor color = upperLeftStripeColors[i];
surface->FillRect(Rect::Create(rect.top - 1 - i, rect.left + 2, rect.top - i, rect.right - 2), color);
surface->FillRect(Rect::Create(rect.top + 2, rect.left - 1 - i, rect.bottom - 2, rect.left - i), color);
}
for (int i = 0; i < 3; i++)
{
surface->SetForeColor(bottomRightStripeColors[i]);
surface->FillRect(Rect::Create(rect.bottom + i, rect.left + 2, rect.bottom + i + 1, rect.right - 2));
surface->FillRect(Rect::Create(rect.top + 2, rect.right + i, rect.bottom - 2, rect.right + i + 1));
ResolveCachingColor color = bottomRightStripeColors[i];
surface->FillRect(Rect::Create(rect.bottom + i, rect.left + 2, rect.bottom + i + 1, rect.right - 2), color);
surface->FillRect(Rect::Create(rect.top + 2, rect.right + i, rect.bottom - 2, rect.right + i + 1), color);
}
}

View File

@@ -5,6 +5,7 @@
#include "PLPasStr.h"
#include "PLEditboxWidget.h"
#include "PLStandardColors.h"
#include "ResolveCachingColor.h"
DialogTextSubstitutions::DialogTextSubstitutions()
@@ -117,7 +118,8 @@ void HideDialogItem(Dialog *dialog, int item)
widget->SetVisible(false);
DrawSurface *surface = dialog->GetWindow()->GetDrawSurface();
surface->SetForeColor(StdColors::White());
surface->FillRect(widget->GetExpandedRect());
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(widget->GetExpandedRect(), whiteColor);
}
}

View File

@@ -10,6 +10,7 @@
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include <algorithm>
@@ -59,14 +60,15 @@ namespace PortabilityLayer
if (!m_visible)
return;
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor whiteColor = StdColors::White();
const Rect textRect = m_rect;
const Rect innerRect = textRect.Inset(-2, -2);
const Rect outerRect = innerRect.Inset(-1, -1);
surface->SetForeColor(StdColors::Black());
surface->FillRect(outerRect);
surface->SetForeColor(StdColors::White());
surface->FillRect(innerRect);
surface->FillRect(outerRect, blackColor);
surface->FillRect(innerRect, whiteColor);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_None);
int32_t ascender = surface->MeasureFontAscender();
@@ -87,14 +89,12 @@ namespace PortabilityLayer
int32_t verticalOffset = (ascender + lineGap + 1) / 2;
surface->SetForeColor(StdColors::Black());
const Point stringBasePoint = Point::Create(basePoint.m_x, basePoint.m_y + verticalOffset);
if (m_isMultiLine)
surface->DrawStringWrap(stringBasePoint, m_rect, this->GetString(), true);
surface->DrawStringWrap(stringBasePoint, m_rect, this->GetString(), true, blackColor);
else
surface->DrawStringConstrained(stringBasePoint, this->GetString(), true, m_rect);
surface->DrawStringConstrained(stringBasePoint, this->GetString(), true, m_rect, blackColor);
if (m_hasFocus && m_selEndChar == m_selStartChar && m_caratTimer < kCaratBlinkRate)
{
@@ -107,7 +107,7 @@ namespace PortabilityLayer
caratRect = caratRect.Intersect(m_rect);
if (caratRect.IsValid())
surface->FillRect(caratRect);
surface->FillRect(caratRect, blackColor);
}
}
@@ -725,8 +725,7 @@ namespace PortabilityLayer
return;
}
PortabilityLayer::RGBAColor focusColor = PortabilityLayer::RGBAColor::Create(153, 153, 255, 255);
surface->SetForeColor(focusColor);
ResolveCachingColor focusColor = RGBAColor::Create(153, 153, 255, 255);
int32_t lineGap = rfont->GetMetrics().m_linegap;
int32_t ascender = rfont->GetMetrics().m_ascent;
@@ -738,21 +737,21 @@ namespace PortabilityLayer
if (endIsLineBreak || (m_isMultiLine == false && m_selEndChar == m_length))
selRect.right = m_rect.right;
surface->FillRect(selRect);
surface->FillRect(selRect, focusColor);
}
else
{
const Rect firstLineRect = Rect::Create(globalSelStart.m_y, globalSelStart.m_x, globalSelStart.m_y + lineGap, m_rect.right).Intersect(m_rect);
surface->FillRect(firstLineRect);
surface->FillRect(firstLineRect, focusColor);
const Rect midLinesRect = Rect::Create(globalSelStart.m_y + lineGap, m_rect.left, globalSelEnd.m_y, m_rect.right).Intersect(m_rect);
surface->FillRect(midLinesRect);
surface->FillRect(midLinesRect, focusColor);
Rect lastLineRect = Rect::Create(globalSelEnd.m_y, m_rect.left, globalSelEnd.m_y + lineGap, globalSelEnd.m_x);
if (endIsLineBreak || (m_isMultiLine == false && m_selEndChar == m_length))
lastLineRect.right = m_rect.right;
surface->FillRect(lastLineRect);
surface->FillRect(lastLineRect, focusColor);
}
}

View File

@@ -2,6 +2,7 @@
#include "PLQDraw.h"
#include "FontFamily.h"
#include "PLStandardColors.h"
#include "ResolveCachingColor.h"
#include <algorithm>
@@ -31,15 +32,16 @@ namespace PortabilityLayer
void LabelWidget::DrawControl(DrawSurface *surface)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(m_rect);
ResolveCachingColor whiteColor = StdColors::White();
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(m_rect, whiteColor);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
surface->SetForeColor(StdColors::Black());
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true);
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true, blackColor);
}
}

View File

@@ -5,6 +5,7 @@
#include "PLPasStr.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
#include "FontFamily.h"
#include "Vec2i.h"
@@ -75,23 +76,25 @@ namespace PortabilityLayer
void PopupMenuWidget::DrawControl(DrawSurface *surface)
{
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
PortabilityLayer::ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
const Rect rect = m_rect;
const Rect innerRect = rect.Inset(2, 2);
surface->SetForeColor(StdColors::Black());
surface->FillRect(rect);
surface->FillRect(rect, blackColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(rect.Inset(1, 1));
surface->FillRect(rect.Inset(1, 1), whiteColor);
surface->SetForeColor(RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(rect.Inset(2, 2));
surface->FillRect(rect.Inset(2, 2), midGrayColor);
const Rect inset2Rect = rect.Inset(2, 2);
surface->SetForeColor(RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(inset2Rect.bottom, inset2Rect.left, inset2Rect.bottom + 1, inset2Rect.right + 1));
surface->FillRect(Rect::Create(inset2Rect.top, inset2Rect.right, inset2Rect.bottom + 1, inset2Rect.right + 1));
surface->FillRect(Rect::Create(inset2Rect.bottom, inset2Rect.left, inset2Rect.bottom + 1, inset2Rect.right + 1), darkGrayColor);
surface->FillRect(Rect::Create(inset2Rect.top, inset2Rect.right, inset2Rect.bottom + 1, inset2Rect.right + 1), darkGrayColor);
Rect textRect = innerRect;
@@ -100,8 +103,7 @@ namespace PortabilityLayer
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + surface->MeasureFontAscender() + 1) / 2 - 1);
surface->SetForeColor(StdColors::Black());
surface->DrawStringConstrained(basePoint, GetString(), true, textRect);
surface->DrawStringConstrained(basePoint, GetString(), true, textRect, blackColor);
Point arrowMidPoint = Point::Create(textRect.right + 5, (textRect.top + textRect.bottom + 1) / 2);
@@ -116,7 +118,7 @@ namespace PortabilityLayer
for (int i = 0; i < 4; i++)
{
const Rect constrainedRect = innerRect.Intersect(arrowRects[i]);
surface->FillRect(constrainedRect);
surface->FillRect(constrainedRect, blackColor);
}
}

View File

@@ -24,6 +24,7 @@
#include "ScanlineMaskIterator.h"
#include "QDGraf.h"
#include "QDStandardPalette.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include "WindowManager.h"
#include "QDGraf.h"
@@ -62,26 +63,7 @@ void SetPortWindowPort(WindowPtr window)
PortabilityLayer::QDManager::GetInstance()->SetPort(window->GetDrawSurface());
}
void SetPortDialogPort(Dialog *dialog)
{
PL_NotYetImplemented();
}
int TextWidth(const PLPasStr &str, int firstChar1Based, int length)
{
PL_NotYetImplemented();
return 0;
}
void MoveTo(int x, int y)
{
Point &penPos = PortabilityLayer::QDManager::GetInstance()->GetState()->m_penPos;
penPos.h = x;
penPos.v = y;
}
static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB)
static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB, PortabilityLayer::ResolveCachingColor &foreColor)
{
const Rect lineRect = Rect::Create(
std::min(pointA.m_y, pointB.m_y),
@@ -92,7 +74,7 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
// If the points are a straight line, paint as a rect
if (pointA.m_y == pointB.m_y || pointA.m_x == pointB.m_x)
{
surface->FillRect(lineRect);
surface->FillRect(lineRect, foreColor);
return;
}
@@ -141,7 +123,7 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
case GpPixelFormats::k8BitStandard:
{
const size_t pixelSize = 1;
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = foreColor.Resolve8(nullptr, 0);
while (currentPoint.m_x >= constrainedRect.left && currentPoint.m_x < constrainedRect.right && currentPoint.m_y < constrainedRect.bottom)
{
@@ -200,14 +182,8 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void GetForeColor(RGBColor *color)
{
const PortabilityLayer::RGBAColor foreColor = PortabilityLayer::QDManager::GetInstance()->GetState()->GetForeColor();
*color = RGBColor(foreColor.r, foreColor.g, foreColor.b);
}
static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor)
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
{
assert(rect.IsValid());
@@ -254,12 +230,11 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
if (isAA)
{
const PortabilityLayer::RGBAColor foreColor = qdState->GetForeColor();
if (foreColor == PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
if (cacheColor.GetRGBAColor() == PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetBlackAATable();
else if (foreColor == PortabilityLayer::RGBAColor::Create(255, 255, 255, 255))
else if (cacheColor.GetRGBAColor() == PortabilityLayer::RGBAColor::Create(255, 255, 255, 255))
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetWhiteAATable();
else if (cachedAATable != nullptr && foreColor == cachedAATableColor)
else if (cachedAATable != nullptr && cacheColor.GetRGBAColor() == cachedAATableColor)
aaTable = cachedAATable;
else
{
@@ -270,14 +245,14 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
return;
}
cachedAATableColor = foreColor;
cachedAATable->GenerateForPalette(foreColor, PortabilityLayer::StandardPalette::GetInstance()->GetColors(), 256);
cachedAATableColor = cacheColor.GetRGBAColor();
cachedAATable->GenerateForPalette(cacheColor.GetRGBAColor(), PortabilityLayer::StandardPalette::GetInstance()->GetColors(), 256);
aaTable = cachedAATable;
}
}
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
for (uint32_t row = 0; row < numRows; row++)
{
const uint8_t *inputRowData = firstInputRowData + row * inputPitch;
@@ -314,22 +289,22 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
}
static void DrawText(PortabilityLayer::TextPlacer &placer, PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont,
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor)
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PortabilityLayer::GlyphPlacementCharacteristics characteristics;
while (placer.PlaceGlyph(characteristics))
{
if (characteristics.m_haveGlyph)
DrawGlyph(qdState, pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cachedAATable, cachedAATableColor);
DrawGlyph(qdState, pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cachedAATable, cachedAATableColor, cacheColor);
}
}
void DrawSurface::DrawString(const Point &point, const PLPasStr &str, bool aa)
void DrawSurface::DrawString(const Point &point, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor)
{
DrawStringConstrained(point, str, aa, Rect::CreateLargest());
DrawStringConstrained(point, str, aa, Rect::CreateLargest(), cacheColor);
}
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect)
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PortabilityLayer::QDPort *port = &m_port;
@@ -351,12 +326,12 @@ void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str,
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), -1, rfont, str);
DrawText(placer, qdState, pixMap, rect, rfont, m_cachedAATable, m_cachedAAColor);
DrawText(placer, qdState, pixMap, rect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa)
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PortabilityLayer::QDPort *port = &m_port;
@@ -384,7 +359,7 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), areaRect.Width(), rfont, str);
DrawText(placer, qdState, pixMap, limitRect, rfont, m_cachedAATable, m_cachedAAColor);
DrawText(placer, qdState, pixMap, limitRect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
@@ -780,7 +755,7 @@ PortabilityLayer::RenderedFont *DrawSurface::ResolveFont(bool aa) const
return fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
}
void DrawSurface::FillRect(const Rect &rect)
void DrawSurface::FillRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
@@ -809,7 +784,7 @@ void DrawSurface::FillRect(const Rect &rect)
{
case GpPixelFormats::k8BitStandard:
{
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
size_t scanlineIndex = 0;
for (size_t ln = 0; ln < numLines; ln++)
@@ -828,7 +803,7 @@ void DrawSurface::FillRect(const Rect &rect)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern)
void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
@@ -863,7 +838,7 @@ void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pa
{
case GpPixelFormats::k8BitStandard:
{
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
uint8_t backColor = 0;
size_t scanlineIndex = 0;
@@ -915,52 +890,52 @@ void DrawSurface::SetSystemFont(int size, int variationFlags)
qdState->m_fontVariationFlags = variationFlags;
}
void DrawSurface::FillEllipse(const Rect &rect)
void DrawSurface::FillEllipse(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid() || rect.Width() < 1 || rect.Height() < 1)
return;
if (rect.Width() <= 2 || rect.Height() <= 2)
{
FillRect(rect);
FillRect(rect, cacheColor);
return;
}
PortabilityLayer::ScanlineMask *mask = PortabilityLayer::ScanlineMaskConverter::CompileEllipse(PortabilityLayer::Rect2i(rect.top, rect.left, rect.bottom, rect.right));
if (mask)
{
FillScanlineMask(mask);
FillScanlineMask(mask, cacheColor);
mask->Destroy();
}
}
void DrawSurface::FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern)
void DrawSurface::FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid() || rect.Width() < 1 || rect.Height() < 1)
return;
if (rect.Width() <= 2 || rect.Height() <= 2)
{
FillRectWithMaskPattern8x8(rect, pattern);
FillRectWithMaskPattern8x8(rect, pattern, cacheColor);
return;
}
PortabilityLayer::ScanlineMask *mask = PortabilityLayer::ScanlineMaskConverter::CompileEllipse(PortabilityLayer::Rect2i(rect.top, rect.left, rect.bottom, rect.right));
if (mask)
{
FillScanlineMaskWithMaskPattern(mask, pattern);
FillScanlineMaskWithMaskPattern(mask, pattern, cacheColor);
mask->Destroy();
}
}
void DrawSurface::FrameEllipse(const Rect &rect)
void DrawSurface::FrameEllipse(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
if (rect.Width() <= 2 || rect.Height() <= 2)
{
FillRect(rect);
FillRect(rect, cacheColor);
return;
}
@@ -995,7 +970,7 @@ void DrawSurface::FrameEllipse(const Rect &rect)
{
case GpPixelFormats::k8BitStandard:
{
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
for (;;)
{
@@ -1037,12 +1012,12 @@ static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol,
}
}
void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask)
void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask, PortabilityLayer::ResolveCachingColor &cacheColor)
{
FillScanlineMaskWithMaskPattern(scanlineMask, nullptr);
FillScanlineMaskWithMaskPattern(scanlineMask, nullptr, cacheColor);
}
void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern)
void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!scanlineMask)
return;
@@ -1082,7 +1057,7 @@ void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::Scanli
switch (pixMap->m_pixelFormat)
{
case GpPixelFormats::k8BitStandard:
foreColor8 = qdState->ResolveForeColor8(nullptr, 256);
foreColor8 = cacheColor.Resolve8(nullptr, 256);
break;
default:
PL_NotYetImplemented();
@@ -1190,9 +1165,9 @@ void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::Scanli
}
void DrawSurface::DrawLine(const Point &a, const Point &b)
void DrawSurface::DrawLine(const Point &a, const Point &b, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PlotLine(m_port.GetState(), this, PortabilityLayer::Vec2i(a.h, a.v), PortabilityLayer::Vec2i(b.h, b.v));
PlotLine(m_port.GetState(), this, PortabilityLayer::Vec2i(a.h, a.v), PortabilityLayer::Vec2i(b.h, b.v), cacheColor);
}
void GetClip(Rect *rect)
@@ -1210,7 +1185,7 @@ void ClipRect(const Rect *rect)
qdState->m_clipRect = *rect;
}
void DrawSurface::FrameRect(const Rect &rect)
void DrawSurface::FrameRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
@@ -1219,7 +1194,7 @@ void DrawSurface::FrameRect(const Rect &rect)
uint16_t height = rect.bottom - rect.top;
if (width <= 2 || height <= 2)
FillRect(rect);
FillRect(rect, cacheColor);
else
{
// This is stupid, especially in the vertical case, but oh well
@@ -1227,28 +1202,28 @@ void DrawSurface::FrameRect(const Rect &rect)
edgeRect = rect;
edgeRect.right = edgeRect.left + 1;
FillRect(edgeRect);
FillRect(edgeRect, cacheColor);
edgeRect = rect;
edgeRect.left = edgeRect.right - 1;
FillRect(edgeRect);
FillRect(edgeRect, cacheColor);
edgeRect = rect;
edgeRect.bottom = edgeRect.top + 1;
FillRect(edgeRect);
FillRect(edgeRect, cacheColor);
edgeRect = rect;
edgeRect.top = edgeRect.bottom - 1;
FillRect(edgeRect);
FillRect(edgeRect, cacheColor);
}
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight)
void DrawSurface::FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PL_NotYetImplemented_TODO("RoundRect");
this->FrameRect(rect);
this->FrameRect(rect, cacheColor);
}
void DrawSurface::InvertFrameRect(const Rect &rect, const uint8_t *pattern)
@@ -1305,8 +1280,6 @@ void DrawSurface::InvertFillRect(const Rect &rect, const uint8_t *pattern)
{
case GpPixelFormats::k8BitStandard:
{
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
size_t scanlineIndex = 0;
for (size_t ln = 0; ln < numLines; ln++)
{
@@ -1330,21 +1303,6 @@ void DrawSurface::InvertFillRect(const Rect &rect, const uint8_t *pattern)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::SetForeColor(const PortabilityLayer::RGBAColor &color)
{
m_port.GetState()->SetForeColor(color);
}
const PortabilityLayer::RGBAColor &DrawSurface::GetForeColor() const
{
return m_port.GetState()->GetForeColor();
}
void PenSize(int w, int h)
{
PL_NotYetImplemented();
}
void InsetRect(Rect *rect, int x, int y)
{
rect->left += x;

View File

@@ -61,7 +61,6 @@ typedef CIconPtr *CIconHandle;
typedef Byte Pattern[8];
void SetPortWindowPort(WindowPtr window);
void SetPortDialogPort(Dialog *dialog);
void SetPort(DrawSurface *graf);
@@ -69,13 +68,9 @@ void EndUpdate(WindowPtr graf);
void SetRect(Rect *rect, short left, short top, short right, short bottom);
int TextWidth(const PLPasStr &str, int firstChar1Based, int length);
void GetForeColor(RGBColor *color);
void ClipRect(const Rect *rect);
void GetClip(Rect *rect);
void PenSize(int w, int h);
void InsetRect(Rect *rect, int x, int y);
Pattern *GetQDGlobalsGray(Pattern *pattern);
Pattern *GetQDGlobalsBlack(Pattern *pattern);

View File

@@ -2,6 +2,7 @@
#include "PLControlDefinitions.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
namespace PortabilityLayer
{
@@ -40,8 +41,8 @@ namespace PortabilityLayer
void ScrollBarWidget::DrawControl(DrawSurface *surface)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(this->m_rect.Inset(1, 1));
ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(this->m_rect.Inset(1, 1), whiteColor);
if (m_rect.Width() < 16 || m_rect.Height() < 16)
return;
@@ -54,43 +55,41 @@ namespace PortabilityLayer
void ScrollBarWidget::DrawControlHorizontal(DrawSurface *surface)
{
surface->SetForeColor(StdColors::Black());
surface->FrameRect(m_rect);
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor whiteColor = StdColors::White();
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 255);
surface->FrameRect(m_rect, blackColor);
const Rect leftArrowRect = Rect::Create(m_rect.top, m_rect.left, m_rect.bottom, m_rect.left + 16);
DrawBeveledBox(surface, leftArrowRect);
surface->SetForeColor(StdColors::Black());
for (int i = 0; i < 4; i++)
{
const Rect arrowSegRect = Rect::Create(7 - i + leftArrowRect.top, 6 + i + leftArrowRect.left, 9 + i + leftArrowRect.top, 7 + i + leftArrowRect.left);
surface->FillRect(arrowSegRect);
surface->FillRect(arrowSegRect, blackColor);
}
const Rect rightArrowRect = Rect::Create(m_rect.top, m_rect.right - 16, m_rect.bottom, m_rect.right);
DrawBeveledBox(surface, rightArrowRect);
surface->SetForeColor(StdColors::Black());
for (int i = 0; i < 4; i++)
{
const Rect arrowSegRect = Rect::Create(4 + i + rightArrowRect.top, 6 + i + rightArrowRect.left, 12 - i + rightArrowRect.top, 7 + i + rightArrowRect.left);
surface->FillRect(arrowSegRect);
surface->FillRect(arrowSegRect, blackColor);
}
const Rect laneRect = Rect::Create(m_rect.top, leftArrowRect.right, m_rect.bottom, rightArrowRect.left);
surface->SetForeColor(RGBAColor::Create(136, 136, 136, 255));
surface->FillRect(Rect::Create(laneRect.top + 1, laneRect.left, laneRect.top + 2, laneRect.right));
surface->FillRect(Rect::Create(laneRect.top + 1, laneRect.left, laneRect.top + 2, laneRect.right), midGrayColor);
surface->SetForeColor(RGBAColor::Create(187, 187, 187, 255));
surface->FillRect(Rect::Create(laneRect.top + 2, laneRect.left, laneRect.bottom - 2, laneRect.right));
surface->FillRect(Rect::Create(laneRect.top + 2, laneRect.left, laneRect.bottom - 2, laneRect.right), lightGrayColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(laneRect.bottom - 2, laneRect.left, laneRect.bottom - 1, laneRect.right));
surface->FillRect(Rect::Create(laneRect.bottom - 2, laneRect.left, laneRect.bottom - 1, laneRect.right), whiteColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.top + 1, laneRect.right));
surface->FillRect(Rect::Create(laneRect.bottom - 1, laneRect.left, laneRect.bottom, laneRect.right));
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.top + 1, laneRect.right), blackColor);
surface->FillRect(Rect::Create(laneRect.bottom - 1, laneRect.left, laneRect.bottom, laneRect.right), blackColor);
if (m_laneCapacity > 0)
@@ -99,43 +98,38 @@ namespace PortabilityLayer
void ScrollBarWidget::DrawControlVertical(DrawSurface *surface)
{
surface->SetForeColor(StdColors::Black());
surface->FrameRect(m_rect);
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor whiteColor = StdColors::White();
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 255);
surface->FrameRect(m_rect, blackColor);
const Rect topArrowRect = Rect::Create(m_rect.top, m_rect.left, m_rect.top + 16, m_rect.right);
DrawBeveledBox(surface, topArrowRect);
surface->SetForeColor(StdColors::Black());
for (int i = 0; i < 4; i++)
{
const Rect arrowSegRect = Rect::Create(6 + i + topArrowRect.top, 7 - i + topArrowRect.left, 7 + i + topArrowRect.top, 9 + i + topArrowRect.left);
surface->FillRect(arrowSegRect);
surface->FillRect(arrowSegRect, blackColor);
}
const Rect bottomArrowRect = Rect::Create(m_rect.bottom - 16, m_rect.left, m_rect.bottom, m_rect.right);
DrawBeveledBox(surface, bottomArrowRect);
surface->SetForeColor(StdColors::Black());
for (int i = 0; i < 4; i++)
{
const Rect arrowSegRect = Rect::Create(6 + i + bottomArrowRect.top, 4 + i + bottomArrowRect.left, 7 + i + bottomArrowRect.top, 12 - i + bottomArrowRect.left);
surface->FillRect(arrowSegRect);
surface->FillRect(arrowSegRect, blackColor);
}
const Rect laneRect = Rect::Create(topArrowRect.bottom, m_rect.left, bottomArrowRect.top, m_rect.right);
surface->SetForeColor(RGBAColor::Create(136, 136, 136, 255));
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 1, laneRect.bottom, laneRect.left + 2));
surface->SetForeColor(RGBAColor::Create(187, 187, 187, 255));
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 2, laneRect.bottom, laneRect.right - 2));
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(laneRect.bottom, laneRect.right - 2, laneRect.bottom, laneRect.right - 1));
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.bottom, laneRect.left + 1));
surface->FillRect(Rect::Create(laneRect.top, laneRect.right - 1, laneRect.bottom, laneRect.right));
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 1, laneRect.bottom, laneRect.left + 2), midGrayColor);
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 2, laneRect.bottom, laneRect.right - 2), lightGrayColor);
surface->FillRect(Rect::Create(laneRect.bottom, laneRect.right - 2, laneRect.bottom, laneRect.right - 1), whiteColor);
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.bottom, laneRect.left + 1), blackColor);
surface->FillRect(Rect::Create(laneRect.top, laneRect.right - 1, laneRect.bottom, laneRect.right), blackColor);
if (m_laneCapacity > 0)
DrawBeveledBox(surface, Rect::Create(laneRect.top + m_gripPos, laneRect.left, laneRect.top + m_gripPos + m_gripSize, laneRect.right));
@@ -143,19 +137,19 @@ namespace PortabilityLayer
void ScrollBarWidget::DrawBeveledBox(DrawSurface *surface, const Rect &rect)
{
surface->SetForeColor(StdColors::Black());
surface->FrameRect(rect);
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor whiteColor = StdColors::White();
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 255);
surface->SetForeColor(RGBAColor::Create(187, 187, 187, 187));
surface->FillRect(rect.Inset(1, 1));
surface->FrameRect(rect, blackColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.top + 2, rect.left + 1, rect.bottom - 2, rect.left + 2));
surface->FillRect(rect.Inset(1, 1), lightGrayColor);
surface->SetForeColor(RGBAColor::Create(136, 136, 136, 136));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 1));
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom - 2, rect.right - 1));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2), whiteColor);
surface->FillRect(Rect::Create(rect.top + 2, rect.left + 1, rect.bottom - 2, rect.left + 2), whiteColor);
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 1), midGrayColor);
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom - 2, rect.right - 1), midGrayColor);
}
bool ScrollBarWidget::IsHorizontal() const

View File

@@ -367,6 +367,7 @@
<ClCompile Include="PLSysCalls.cpp" />
<ClCompile Include="PLTimeTaggedVOSEvent.cpp" />
<ClCompile Include="PLWidgets.cpp" />
<ClCompile Include="ResolveCachingColor.cpp" />
<ClCompile Include="ScanlineMask.cpp" />
<ClCompile Include="ScanlineMaskBuilder.cpp" />
<ClCompile Include="ScanlineMaskConverter.cpp" />

View File

@@ -752,14 +752,17 @@
<ClCompile Include="TextPlacer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AppEventHandler.cpp">
<Filter>Header Files</Filter>
</ClCompile>
<ClCompile Include="UTF16.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PLButtonWidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AppEventHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ResolveCachingColor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -13,6 +13,7 @@ namespace PortabilityLayer
class FontFamily;
struct RGBAColor;
class RenderedFont;
class ResolveCachingColor;
class ScanlineMask;
}
@@ -59,30 +60,27 @@ struct DrawSurface
void PushToDDSurface(IGpDisplayDriver *displayDriver);
void FillRect(const Rect &rect);
void FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern);
void FrameRect(const Rect &rect);
void FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight);
void FillRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor);
void FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor);
void FrameRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor);
void FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight, PortabilityLayer::ResolveCachingColor &cacheColor);
void InvertFrameRect(const Rect &rect, const uint8_t *pattern);
void InvertFillRect(const Rect &rect, const uint8_t *pattern);
void FillEllipse(const Rect &rect);
void FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern);
void FrameEllipse(const Rect &rect);
void FillEllipse(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor);
void FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor);
void FrameEllipse(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor);
void FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask);
void FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern);
void FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask, PortabilityLayer::ResolveCachingColor &cacheColor);
void FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor);
void DrawLine(const Point &a, const Point &b);
void SetForeColor(const PortabilityLayer::RGBAColor &color);
const PortabilityLayer::RGBAColor &GetForeColor() const;
void DrawLine(const Point &a, const Point &b, PortabilityLayer::ResolveCachingColor &cacheColor);
void SetApplicationFont(int size, int variationFlags);
void SetSystemFont(int size, int variationFlags);
void DrawString(const Point &point, const PLPasStr &str, bool aa);
void DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect);
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa);
void DrawString(const Point &point, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor);
void DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor);
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor);
size_t MeasureString(const PLPasStr &str);
int32_t MeasureFontAscender();

View File

@@ -9,57 +9,7 @@ namespace PortabilityLayer
: m_fontFamily(nullptr)
, m_fontSize(12)
, m_fontVariationFlags(0)
, m_foreResolvedColor16(0)
, m_backResolvedColor16(0)
, m_foreResolvedColor8(0)
, m_backResolvedColor8(0)
, m_isForeResolved16(false)
, m_isBackResolved16(false)
, m_isForeResolved8(false)
, m_isBackResolved8(false)
, m_clipRect(Rect::Create(INT16_MIN, INT16_MIN, INT16_MAX, INT16_MAX))
{
m_backUnresolvedColor.r = m_backUnresolvedColor.g = m_backUnresolvedColor.b = m_backUnresolvedColor.a = 255;
m_foreUnresolvedColor.r = m_foreUnresolvedColor.g = m_foreUnresolvedColor.b = 0;
m_foreUnresolvedColor.a = 255;
m_penPos.h = m_penPos.v = 0;
}
void QDState::SetForeColor(const RGBAColor &color)
{
m_foreUnresolvedColor = color;
m_isForeResolved16 = false;
m_isForeResolved8 = false;
}
const RGBAColor &QDState::GetForeColor() const
{
return m_foreUnresolvedColor;
}
uint8_t QDState::ResolveForeColor8(const RGBAColor *palette, unsigned int numColors)
{
return ResolveColor8(m_foreUnresolvedColor, m_foreResolvedColor8, m_isForeResolved8, palette, numColors);
}
uint8_t QDState::ResolveColor8(const RGBAColor &color, uint8_t &cached, bool &isCached, const RGBAColor *palette, unsigned int numColors)
{
if (isCached)
return cached;
if (palette)
{
PL_NotYetImplemented();
return 0;
}
else
{
const uint8_t resolvedColor = StandardPalette::GetInstance()->MapColorLUT(color);
isCached = true;
cached = resolvedColor;
return resolvedColor;
}
}
}

View File

@@ -15,28 +15,5 @@ namespace PortabilityLayer
int m_fontVariationFlags;
int m_fontSize;
Rect m_clipRect;
Point m_penPos;
void SetForeColor(const RGBAColor &color);
const RGBAColor &GetForeColor() const;
uint8_t ResolveForeColor8(const RGBAColor *palette, unsigned int numColors);
private:
static uint8_t ResolveColor8(const RGBAColor &color, uint8_t &cached, bool &isCached, const RGBAColor *palette, unsigned int numColors);
RGBAColor m_foreUnresolvedColor;
RGBAColor m_backUnresolvedColor;
uint16_t m_foreResolvedColor16;
uint16_t m_backResolvedColor16;
uint8_t m_foreResolvedColor8;
uint8_t m_backResolvedColor8;
bool m_isForeResolved16;
bool m_isForeResolved8;
bool m_isBackResolved16;
bool m_isBackResolved8;
};
}

View File

@@ -0,0 +1,75 @@
#include "ResolveCachingColor.h"
#include "PLCore.h"
#include "QDStandardPalette.h"
namespace PortabilityLayer
{
ResolveCachingColor::ResolveCachingColor()
: m_isResolved16(false)
, m_isResolved8(false)
, m_resolved16(0)
, m_resolved8(0)
, m_rgbaColor(RGBAColor::Create(0, 0, 0, 255))
{
}
ResolveCachingColor::ResolveCachingColor(const RGBAColor &color)
: m_isResolved16(false)
, m_isResolved8(false)
, m_resolved16(0)
, m_resolved8(0)
, m_rgbaColor(color)
{
}
ResolveCachingColor::ResolveCachingColor(const ResolveCachingColor &color)
: m_isResolved16(color.m_isResolved16)
, m_isResolved8(color.m_isResolved8)
, m_resolved16(color.m_resolved16)
, m_resolved8(color.m_resolved8)
, m_rgbaColor(color.m_rgbaColor)
{
}
uint8_t ResolveCachingColor::Resolve8(const RGBAColor *palette, unsigned int numColors)
{
if (m_isResolved8)
return m_resolved8;
if (palette)
{
PL_NotYetImplemented();
return 0;
}
else
{
const uint8_t resolvedColor = StandardPalette::GetInstance()->MapColorLUT(m_rgbaColor);
m_isResolved8 = true;
m_resolved8 = resolvedColor;
return resolvedColor;
}
}
ResolveCachingColor &ResolveCachingColor::operator=(const ResolveCachingColor &other)
{
m_isResolved16 = other.m_isResolved16;
m_isResolved8 = other.m_isResolved8;
m_resolved16 = other.m_resolved16;
m_resolved8 = other.m_resolved8;
m_rgbaColor = other.m_rgbaColor;
return *this;
}
ResolveCachingColor ResolveCachingColor::FromStandardColor(uint8_t standardColor)
{
ResolveCachingColor result(StandardPalette::GetInstance()->GetColors()[standardColor]);
result.m_isResolved8 = true;
result.m_resolved8 = standardColor;
return result;
}
}

View File

@@ -1,17 +1,24 @@
#pragma once
#include "RGBAColor.h"
#include "RGBAColor.h"
namespace PortabilityLayer
{
class ResolveCachingColor
{
public:
ResolveCachingColor();
ResolveCachingColor(const RGBAColor &color);
ResolveCachingColor(const ResolveCachingColor &color);
uint8_t Resolve8(const RGBAColor *palette, unsigned int numColors);
ResolveCachingColor &operator=(const ResolveCachingColor &other);
static ResolveCachingColor FromStandardColor(uint8_t standardColor);
const RGBAColor &GetRGBAColor() const;
private:
RGBAColor m_rgbaColor;
@@ -22,3 +29,8 @@ namespace PortabilityLayer
bool m_isResolved8;
};
}
inline const PortabilityLayer::RGBAColor &PortabilityLayer::ResolveCachingColor::GetRGBAColor() const
{
return m_rgbaColor;
}

View File

@@ -16,6 +16,7 @@
#include "QDPixMap.h"
#include "PLTimeTaggedVOSEvent.h"
#include "Rect2i.h"
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include "WindowDef.h"
@@ -249,8 +250,8 @@ namespace PortabilityLayer
void SimpleBoxChromeTheme::RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const
{
surface->SetForeColor(StdColors::Black());
surface->FillRect((*surface->m_port.GetPixMap())->m_rect);
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect((*surface->m_port.GetPixMap())->m_rect, blackColor);
}
//---------------------------------------------------------------------------
@@ -421,31 +422,31 @@ namespace PortabilityLayer
void GenericWindowChromeTheme::RenderChromeTop(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor whiteColor = StdColors::White();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(rect);
surface->FillRect(rect, midGrayColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 5, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 5, rect.bottom, rect.right - 5), blackColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom - 1, rect.right - 5));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom, rect.left + 5));
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom - 1, rect.right - 5), darkGrayColor);
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom, rect.left + 5), darkGrayColor);
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom, rect.right - 1), darkGrayColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom, rect.left + 2));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom, rect.left + 2), whiteColor);
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2), whiteColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.right - 5, rect.bottom, rect.right - 4), whiteColor);
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetForeColor(StdColors::Black());
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
@@ -455,98 +456,101 @@ namespace PortabilityLayer
int32_t titleH = (rect.left + rect.right - static_cast<int32_t>(titleWidth) + 1) / 2;
int32_t titleV = (rect.top + rect.bottom + ascender + 1) / 2;
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true);
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true, blackColor);
}
void GenericWindowChromeTheme::RenderChromeLeft(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor whiteColor = StdColors::White();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4), whiteColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1), darkGrayColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midGrayColor);
}
void GenericWindowChromeTheme::RenderChromeBottom(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor whiteColor = StdColors::White();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 1, rect.left + 5));
surface->FillRect(Rect::Create(rect.bottom - 4, rect.left + 5, rect.bottom - 2, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom - 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 1, rect.left + 5), midGrayColor);
surface->FillRect(Rect::Create(rect.bottom - 4, rect.left + 5, rect.bottom - 2, rect.right - 4), midGrayColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom - 2, rect.right - 2), midGrayColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, rect.left + 1));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.left + 5, rect.bottom - 5, rect.left + 6));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom - 5, rect.right - 5));
surface->FillRect(Rect::Create(rect.bottom - 6, rect.left + 6, rect.bottom - 5, rect.right - 6));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, rect.left + 1), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 5, rect.bottom - 5, rect.left + 6), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom - 5, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 6, rect.left + 6, rect.bottom - 5, rect.right - 6), blackColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom - 5, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 2, rect.left + 2));
surface->FillRect(Rect::Create(rect.bottom - 5, rect.left + 5, rect.bottom - 4, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom - 5, rect.right - 4), whiteColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 2, rect.left + 2), whiteColor);
surface->FillRect(Rect::Create(rect.bottom - 5, rect.left + 5, rect.bottom - 4, rect.right - 4), whiteColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.left + 4, rect.bottom - 5, rect.left + 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom - 1, rect.right - 1));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2), darkGrayColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 4, rect.bottom - 5, rect.left + 5), darkGrayColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom - 1, rect.right - 1), darkGrayColor);
}
void GenericWindowChromeTheme::RenderChromeRight(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor whiteColor = StdColors::White();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4), whiteColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1), darkGrayColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midGrayColor);
}
void GenericWindowChromeTheme::RenderChromeTopMini(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255);
ResolveCachingColor whiteColor = StdColors::White();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255));
surface->FillRect(rect);
surface->FillRect(rect, lightGrayColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 1, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 1, rect.bottom, rect.right - 1), blackColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2));
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom - 1, rect.right - 1));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2), darkGrayColor);
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom - 1, rect.right - 1), darkGrayColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom - 2, rect.left + 2));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom - 2, rect.left + 2), whiteColor);
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2), whiteColor);
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetForeColor(StdColors::Black());
surface->SetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
@@ -556,31 +560,31 @@ namespace PortabilityLayer
int32_t titleH = (rect.left + rect.right - static_cast<int32_t>(titleWidth) + 1) / 2;
int32_t titleV = (rect.top + rect.bottom + ascender + 1) / 2;
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true);
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true, blackColor);
}
void GenericWindowChromeTheme::RenderChromeLeftMini(WindowImpl *window, DrawSurface *surface) const
{
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(rect);
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(rect, blackColor);
}
void GenericWindowChromeTheme::RenderChromeBottomMini(WindowImpl *window, DrawSurface *surface) const
{
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(rect);
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(rect, blackColor);
}
void GenericWindowChromeTheme::RenderChromeRightMini(WindowImpl *window, DrawSurface *surface) const
{
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(rect);
ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(rect, blackColor);
}
Rect GenericWindowChromeTheme::GetCloseBoxRectInTopChrome()
@@ -600,25 +604,25 @@ namespace PortabilityLayer
if (isClicked)
{
surface->SetForeColor(StdColors::Black());
surface->FillRect(closeBoxRect);
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom - 1, closeBoxRect.right - 1));
surface->FillRect(closeBoxRect, blackColor);
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom - 1, closeBoxRect.right - 1), darkGrayColor);
}
else
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(closeBoxRect);
ResolveCachingColor darkGrayColor = RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255);
ResolveCachingColor midGrayColor = RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255);
ResolveCachingColor lightGrayColor = RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255);
surface->FillRect(closeBoxRect, darkGrayColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kMidGray, kMidGray, kMidGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom, closeBoxRect.right));
surface->FillRect(Rect::Create(closeBoxRect.top + 1, closeBoxRect.left + 1, closeBoxRect.bottom, closeBoxRect.right), midGrayColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kDarkGray, kDarkGray, kDarkGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 1, closeBoxRect.right - 1));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 1, closeBoxRect.right - 1), darkGrayColor);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(kLightGray, kLightGray, kLightGray, 255));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 2, closeBoxRect.right - 2));
surface->FillRect(Rect::Create(closeBoxRect.top + 2, closeBoxRect.left + 2, closeBoxRect.bottom - 2, closeBoxRect.right - 2), lightGrayColor);
}
}
@@ -674,90 +678,94 @@ namespace PortabilityLayer
void AlertWindowChromeTheme::RenderChromeTop(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor darkColor = kDarkColor;
ResolveCachingColor midColor = kMidColor;
ResolveCachingColor lightColor = kLightColor;
ResolveCachingColor blackColor = StdColors::Black();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(kMidColor);
surface->FillRect(rect);
surface->FillRect(rect, midColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 5, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, 1), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left + 5, rect.bottom, rect.right - 5), blackColor);
surface->SetForeColor(kDarkColor);
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom - 1, rect.right - 5));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom, rect.left + 5));
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom - 1, rect.right - 5), darkColor);
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 4, rect.bottom, rect.left + 5), darkColor);
surface->FillRect(Rect::Create(rect.top + 2, rect.right - 2, rect.bottom, rect.right - 1), darkColor);
surface->SetForeColor(kLightColor);
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom, rect.left + 2));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.bottom, rect.left + 2), lightColor);
surface->FillRect(Rect::Create(rect.top + 1, rect.left + 1, rect.top + 2, rect.right - 2), lightColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.right - 5, rect.bottom, rect.right - 4), lightColor);
}
void AlertWindowChromeTheme::RenderChromeLeft(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor darkColor = kDarkColor;
ResolveCachingColor midColor = kMidColor;
ResolveCachingColor lightColor = kLightColor;
ResolveCachingColor blackColor = StdColors::Black();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->SetForeColor(kLightColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4), lightColor);
surface->SetForeColor(kDarkColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1), darkColor);
surface->SetForeColor(kMidColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midColor);
}
void AlertWindowChromeTheme::RenderChromeBottom(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor darkColor = kDarkColor;
ResolveCachingColor midColor = kMidColor;
ResolveCachingColor lightColor = kLightColor;
ResolveCachingColor blackColor = StdColors::Black();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(kMidColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 1, rect.left + 5));
surface->FillRect(Rect::Create(rect.bottom - 4, rect.left + 5, rect.bottom - 2, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom - 2, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 1, rect.left + 5), midColor);
surface->FillRect(Rect::Create(rect.bottom - 4, rect.left + 5, rect.bottom - 2, rect.right - 4), midColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom - 2, rect.right - 2), midColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, rect.left + 1));
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.left + 5, rect.bottom - 5, rect.left + 6));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom - 5, rect.right - 5));
surface->FillRect(Rect::Create(rect.bottom - 6, rect.left + 6, rect.bottom - 5, rect.right - 6));
surface->FillRect(Rect::Create(rect.top, rect.left, rect.bottom, rect.left + 1), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 5, rect.bottom - 5, rect.left + 6), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom - 5, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.bottom - 6, rect.left + 6, rect.bottom - 5, rect.right - 6), blackColor);
surface->SetForeColor(kLightColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom - 5, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 2, rect.left + 2));
surface->FillRect(Rect::Create(rect.bottom - 5, rect.left + 5, rect.bottom - 4, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom - 5, rect.right - 4), lightColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 1, rect.bottom - 2, rect.left + 2), lightColor);
surface->FillRect(Rect::Create(rect.bottom - 5, rect.left + 5, rect.bottom - 4, rect.right - 4), lightColor);
surface->SetForeColor(kDarkColor);
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.left + 4, rect.bottom - 5, rect.left + 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom - 1, rect.right - 1));
surface->FillRect(Rect::Create(rect.bottom - 2, rect.left + 2, rect.bottom - 1, rect.right - 2), darkColor);
surface->FillRect(Rect::Create(rect.top, rect.left + 4, rect.bottom - 5, rect.left + 5), darkColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom - 1, rect.right - 1), darkColor);
}
void AlertWindowChromeTheme::RenderChromeRight(WindowImpl *window, DrawSurface *surface) const
{
ResolveCachingColor darkColor = kDarkColor;
ResolveCachingColor midColor = kMidColor;
ResolveCachingColor lightColor = kLightColor;
ResolveCachingColor blackColor = StdColors::Black();
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5));
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right));
surface->FillRect(Rect::Create(rect.top, rect.right - 6, rect.bottom, rect.right - 5), blackColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 1, rect.bottom, rect.right), blackColor);
surface->SetForeColor(kLightColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4));
surface->FillRect(Rect::Create(rect.top, rect.right - 5, rect.bottom, rect.right - 4), lightColor);
surface->SetForeColor(kDarkColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1));
surface->FillRect(Rect::Create(rect.top, rect.right - 2, rect.bottom, rect.right - 1), darkColor);
surface->SetForeColor(kMidColor);
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2));
surface->FillRect(Rect::Create(rect.top, rect.right - 4, rect.bottom, rect.right - 2), midColor);
}
//---------------------------------------------------------------------------
@@ -1294,15 +1302,16 @@ namespace PortabilityLayer
void WindowManagerImpl::SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size)
{
ResolveCachingColor blackColor = StdColors::Black();
ResolveCachingColor whiteColor = StdColors::White();
ResetResizeInProgressSurfaces();
m_isResizeInProgress = true;
if (!m_resizeInProgressHorizontalBar.Init(Rect::Create(0, 0, 3, size.m_x + 4), GpPixelFormats::k8BitStandard))
{
m_resizeInProgressHorizontalBar.SetForeColor(StdColors::Black());
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(0, 0, 3, size.m_x + 4));
m_resizeInProgressHorizontalBar.SetForeColor(StdColors::White());
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(1, 1, 2, size.m_x + 3));
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(0, 0, 3, size.m_x + 4), blackColor);
m_resizeInProgressHorizontalBar.FillRect(Rect::Create(1, 1, 2, size.m_x + 3), whiteColor);
}
else
{
@@ -1312,11 +1321,9 @@ namespace PortabilityLayer
if (!m_resizeInProgressVerticalBar.Init(Rect::Create(0, 0, size.m_y, 3), GpPixelFormats::k8BitStandard))
{
m_resizeInProgressVerticalBar.SetForeColor(StdColors::Black());
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 0, size.m_y, 1));
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 2, size.m_y, 3));
m_resizeInProgressVerticalBar.SetForeColor(StdColors::White());
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 1, size.m_y, 2));
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 0, size.m_y, 1), blackColor);
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 2, size.m_y, 3), blackColor);
m_resizeInProgressVerticalBar.FillRect(Rect::Create(0, 1, size.m_y, 2), whiteColor);
}
else
{