Compare commits

...

16 Commits

Author SHA1 Message Date
elasota
f5ff8eb013 Add color fade 2020-05-22 21:14:43 -04:00
elasota
482487d81c Change window title 2020-05-22 20:42:18 -04:00
elasota
2d8b6a29aa Add scroll bar highlights 2020-05-22 20:22:51 -04:00
elasota
8f433c11e8 Revert "Add menu selection flicker"
This reverts commit bd9676be40.
2020-05-22 20:22:40 -04:00
elasota
9c32a6fdd4 Add stripes to window chrome 2020-05-22 05:41:07 -04:00
elasota
bd9676be40 Add menu selection flicker 2020-05-22 05:09:59 -04:00
elasota
392c5d0583 Lighten window chrome 2020-05-22 05:09:48 -04:00
elasota
14cc4b43df Fix a bug where getting a high score in a read-only house and then opening an editable house would cause the editable house to be overwritten 2020-05-21 08:23:09 -04:00
elasota
de342cb368 Fix bad string compare function (caused houses to not appear if they started with the same name as another house) 2020-05-21 08:22:29 -04:00
elasota
b68cfab6d8 Fix wrong prompt font size 2020-05-21 05:04:41 -04:00
elasota
5869571747 Finish removing QDState 2020-05-21 05:01:16 -04:00
elasota
432cdbcc3a Refactor out clip rect 2020-05-21 03:39:33 -04:00
elasota
438e7b2138 Refactor out forecolor 2020-05-21 03:30:11 -04:00
elasota
a1c45d4fc8 Factor out back color 2020-05-20 23:51:25 -04:00
elasota
66fc278ce9 Refactor QD ports so they no longer need to be the first member of draw surfaces 2020-05-20 23:33:17 -04:00
elasota
f53dc21475 Window API refactor 2020-05-20 17:20:50 -04:00
78 changed files with 1675 additions and 1846 deletions

View File

@@ -14,6 +14,9 @@
#include "FontManager.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "Room.h"
#include "Utilities.h"
#include "WindowDef.h"
@@ -119,13 +122,15 @@ void DrawBannerMessage (Point topLeft)
PasStringCopy((*thisHouse)->banner, bannerStr);
workSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
workSrcMap->SetForeColor(StdColors::Black());
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
count = 0;
do
{
GetLineOfText(bannerStr, count, subStr);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr, true);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr, blackColor, appFont);
count++;
}
while (subStr[0] > 0);
@@ -146,13 +151,12 @@ void DrawBannerMessage (Point topLeft)
GetLocalizedString(4, subStr);
PasStringConcat(bannerStr, subStr);
workSrcMap->SetForeColor(StdColors::Red());
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr, true);
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr, redColor, appFont);
GetLocalizedString(5, subStr);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr, true);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr, redColor, appFont);
}
workSrcMap->SetForeColor(StdColors::Black());
SetGraphicsPort(wasGWorld);
}
@@ -223,7 +227,7 @@ void DisplayStarsRemaining(void)
DrawSurface *surface = starsWindow->GetDrawSurface();
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
NumToString((long)numStarsRemaining, theStr);
@@ -232,8 +236,8 @@ void DisplayStarsRemaining(void)
else
{
LoadScaledGraphic(surface, kStarsRemainingPICT, &bounds);
const Point textPoint = Point::Create(bounds.left + 102 - (surface->MeasureString(theStr) / 2), bounds.top + 23);
ColorText(surface, textPoint, theStr, 4L);
const Point textPoint = Point::Create(bounds.left + 102 - (appFont->MeasurePStr(theStr) / 2), bounds.top + 23);
ColorText(surface, textPoint, theStr, 4L, appFont);
}
if (doZooms)

View File

@@ -10,6 +10,7 @@
#include "PLPalettes.h"
#include "PLPasStr.h"
#include "QDStandardPalette.h"
#include "ResolveCachingColor.h"
//============================================================== Functions
@@ -19,14 +20,11 @@
// this function draws text in that color. It assumes the current port,É
// the current font, the current pen location, etc.
void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long color)
void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long color, PortabilityLayer::RenderedFont *font)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->DrawString(point, theStr, true);
surface->SetForeColor(wasColor);
surface->DrawString(point, theStr, rColor, font);
}
//-------------------------------------------------------------- ColorRect
@@ -36,12 +34,9 @@ void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long
void ColorRect (DrawSurface *surface, const Rect &theRect, long color)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FillRect(theRect);
surface->SetForeColor(wasColor);
surface->FillRect(theRect, rColor);
}
//-------------------------------------------------------------- ColorOval
@@ -51,22 +46,16 @@ void ColorRect (DrawSurface *surface, const Rect &theRect, long color)
void ColorOval (DrawSurface *surface, const Rect &theRect, long color)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FillEllipse(theRect);
surface->SetForeColor(wasColor);
surface->FillEllipse(theRect, rColor);
}
void ColorOvalMaskPattern(DrawSurface *surface, const Rect &theRect, long color, bool isMask, const uint8_t *pattern)
void ColorOvalMaskPattern(DrawSurface *surface, const Rect &theRect, long color, const uint8_t *pattern)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FillEllipseWithPattern(theRect, isMask, pattern);
surface->SetForeColor(wasColor);
surface->FillEllipseWithMaskPattern(theRect, pattern, rColor);
}
//-------------------------------------------------------------- ColorRegionMaskPattern
@@ -74,14 +63,10 @@ void ColorOvalMaskPattern(DrawSurface *surface, const Rect &theRect, long color,
// Given a region and color index, this function draws a solidÉ
// region in that color. Current port, pen mode, etc. assumed.
void ColorRegionMaskPattern (DrawSurface *surface, PortabilityLayer::ScanlineMask *scanlineMask, long colorIndex, bool isMask, const uint8_t *pattern)
void ColorRegionMaskPattern (DrawSurface *surface, PortabilityLayer::ScanlineMask *scanlineMask, long colorIndex, const uint8_t *pattern)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[colorIndex];
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FillScanlineMaskWithPattern(scanlineMask, isMask, pattern);
surface->SetForeColor(wasColor);
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(colorIndex);
surface->FillScanlineMaskWithMaskPattern(scanlineMask, pattern, rColor);
}
//-------------------------------------------------------------- ColorLine
@@ -91,12 +76,9 @@ void ColorRegionMaskPattern (DrawSurface *surface, PortabilityLayer::ScanlineMas
void ColorLine (DrawSurface *surface, short h0, short v0, short h1, short v1, long color)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor cacheColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->DrawLine(Point::Create(h0, v0), Point::Create(h1, v1));
surface->SetForeColor(wasColor);
surface->DrawLine(Point::Create(h0, v0), Point::Create(h1, v1), cacheColor);
}
//-------------------------------------------------------------- HiliteRect
@@ -125,12 +107,9 @@ void HiliteRect (DrawSurface *surface, const Rect &theRect, short color1, short
void ColorFrameRect (DrawSurface *surface, const Rect &theRect, long color)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FrameRect(theRect);
surface->SetForeColor(wasColor);
surface->FrameRect(theRect, rColor);
}
//-------------------------------------------------------------- ColorFrameWHRect
@@ -157,12 +136,9 @@ void ColorFrameWHRect (DrawSurface *surface, short left, short top, short wide,
void ColorFrameOval (DrawSurface *surface, const Rect &theRect, long color)
{
const PortabilityLayer::RGBAColor &rgbaColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color];
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(rgbaColor);
surface->FrameEllipse(theRect);
surface->SetForeColor(wasColor);
surface->FrameEllipse(theRect, rColor);
}
//-------------------------------------------------------------- LtGrayForeColor
@@ -170,9 +146,9 @@ void ColorFrameOval (DrawSurface *surface, const Rect &theRect, long color)
// This function finds the closest match to a "light gray" in theÉ
// current palette and sets the pen color to that.
void LtGrayForeColor (DrawSurface *surface)
PortabilityLayer::ResolveCachingColor LtGrayForeColor ()
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(191, 191, 191, 255));
return PortabilityLayer::RGBAColor::Create(191, 191, 191, 255);
}
//-------------------------------------------------------------- GrayForeColor
@@ -180,9 +156,9 @@ void LtGrayForeColor (DrawSurface *surface)
// This function finds the closest match to a "medium gray" in theÉ
// current palette and sets the pen color to that.
void GrayForeColor (DrawSurface *surface)
PortabilityLayer::ResolveCachingColor GrayForeColor ()
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(127, 127, 127, 255));
return PortabilityLayer::RGBAColor::Create(127, 127, 127, 255);
}
//-------------------------------------------------------------- DkGrayForeColor
@@ -190,7 +166,7 @@ void GrayForeColor (DrawSurface *surface)
// This function finds the closest match to a "dark gray" in theÉ
// current palette and sets the pen color to that.
void DkGrayForeColor (DrawSurface *surface)
PortabilityLayer::ResolveCachingColor DkGrayForeColor ()
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(63, 63, 63, 255));
return PortabilityLayer::RGBAColor::Create(63, 63, 63, 255);
}

View File

@@ -13,6 +13,7 @@
#include "Marquee.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "WindowDef.h"
#include "WindowManager.h"
@@ -66,17 +67,19 @@ void UpdateCoordWindow (void)
{
#ifndef COMPILEDEMO
Str255 tempStr, numStr;
GrafPtr wasPort;
if (coordWindow == nil)
return;
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor blueColor = StdColors::Blue();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, 0, true);
DrawSurface *surface = coordWindow->GetDrawSurface();
surface->SetForeColor(StdColors::White());
surface->FillRect(coordWindowRect);
surface->SetForeColor(StdColors::Black());
surface->FillRect(coordWindowRect, whiteColor);
PasStringCopy(PSTR("h: "), tempStr);
if (coordH != -1)
@@ -87,7 +90,7 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(5, 12), tempStr, true);
surface->DrawString(Point::Create(5, 12), tempStr, blackColor, appFont);
PasStringCopy(PSTR("v: "), tempStr);
if (coordV != -1)
@@ -98,9 +101,8 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(4, 22), tempStr, true);
surface->DrawString(Point::Create(4, 22), tempStr, blackColor, appFont);
surface->SetForeColor(StdColors::Blue());
PasStringCopy(PSTR("d: "), tempStr);
if (coordD != -1)
{
@@ -110,8 +112,7 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(5, 32), tempStr, true);
surface->SetForeColor(StdColors::Black());
surface->DrawString(Point::Create(5, 32), tempStr, blueColor, appFont);
#endif
}
@@ -157,8 +158,6 @@ void OpenCoordWindow (void)
coordV = -1;
coordD = -1;
coordWindow->GetDrawSurface()->SetApplicationFont(9, 0);
if (objActive != kNoObjectSelected)
{
if (ObjectHasHandle(&direction, &dist))

View File

@@ -17,6 +17,9 @@
#include "Externs.h"
#include "FontFamily.h"
#include "ResourceManager.h"
#include "ResolveCachingColor.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include <algorithm>
@@ -36,7 +39,7 @@ void BringUpDialog (Dialog **theDialog, short dialogID, const DialogTextSubstitu
// CenterDialog(dialogID);
if (*theDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetGraphicsPort(&(*theDialog)->GetWindow()->m_surface);
SetGraphicsPort((*theDialog)->GetWindow()->GetDrawSurface());
ShowWindow((*theDialog)->GetWindow());
DrawDefaultButton(*theDialog);
}
@@ -572,45 +575,45 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
PasStringCopy(text, stringCopy);
Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
if ((appFont->MeasurePStr(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(appFont, stringCopy, iRect.right - iRect.left - 2);
surface->SetForeColor(StdColors::White());
surface->FillRect(iRect);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(iRect, whiteColor);
short strWidth = surface->MeasureString(stringCopy);
short strWidth = appFont->MeasurePStr(stringCopy);
inset = ((iRect.right - iRect.left) - (strWidth + 2)) / 2;
iRect.left += inset;
iRect.right -= inset;
// Draw centered
const int32_t ascender = surface->MeasureFontAscender();
const int32_t ascender = appFont->GetMetrics().m_ascent;
PortabilityLayer::ResolveCachingColor backgroundColor;
PortabilityLayer::ResolveCachingColor textColor;
if (invert)
{
surface->SetForeColor(StdColors::Black());
surface->FillRect(iRect);
surface->SetForeColor(StdColors::White());
backgroundColor = StdColors::Black();
textColor = StdColors::White();
}
else
{
surface->SetForeColor(StdColors::White());
surface->FillRect(iRect);
surface->SetForeColor(StdColors::Black());
backgroundColor = StdColors::White();
textColor = StdColors::Black();
}
const Point centeredDrawPoint = Point::Create((iRect.left + iRect.right - strWidth) / 2, (iRect.top + iRect.bottom + ascender) / 2);
surface->DrawString(centeredDrawPoint, stringCopy, true);
surface->FillRect(iRect, backgroundColor);
if (invert)
surface->SetForeColor(StdColors::Black());
const Point centeredDrawPoint = Point::Create((iRect.left + iRect.right - strWidth) / 2, (iRect.top + iRect.bottom + ascender) / 2);
surface->DrawString(centeredDrawPoint, stringCopy, textColor, appFont);
}
//-------------------------------------------------------------- DrawDialogUserText
@@ -625,16 +628,16 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
short iType;
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
PasStringCopy(text, stringCopy);
const Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
if ((appFont->MeasurePStr(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(appFont, stringCopy, iRect.right - iRect.left - 2);
surface->SetForeColor(StdColors::Black());
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy, true);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy, blackColor, appFont);
}
//-------------------------------------------------------------- LoadDialogPICT
@@ -655,14 +658,14 @@ void LoadDialogPICT (Dialog *theDialog, short item, short theID)
//-------------------------------------------------------------- FrameDialogItem
// Given a dialog item, this function draws a box around it.
void FrameDialogItem (Dialog *theDialog, short item)
void FrameDialogItem (Dialog *theDialog, short item, PortabilityLayer::ResolveCachingColor &color)
{
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
PortabilityLayer::Widget *widget = itemRef.GetWidget();
const Rect itemRect = widget->GetRect();
theDialog->GetWindow()->GetDrawSurface()->FrameRect(itemRect);
theDialog->GetWindow()->GetDrawSurface()->FrameRect(itemRect, color);
}
//-------------------------------------------------------------- FrameDialogItemC
@@ -673,23 +676,22 @@ void FrameDialogItemC (Dialog *theDialog, short item, long color)
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
const Rect itemRect = theDialog->GetItems()[item - 1].GetWidget()->GetRect();
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
surface->SetForeColor(PortabilityLayer::StandardPalette::GetInstance()->GetColors()[color]);
surface->FrameRect(itemRect);
surface->SetForeColor(wasColor);
PortabilityLayer::ResolveCachingColor frameColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
surface->FrameRect(itemRect, frameColor);
}
//-------------------------------------------------------------- FrameOvalDialogItem
// Given a dialog item, this function draws an oval around it.
void FrameOvalDialogItem (Dialog *theDialog, short item)
void FrameOvalDialogItem (Dialog *theDialog, short item, PortabilityLayer::ResolveCachingColor &color)
{
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
PortabilityLayer::Widget *widget = itemRef.GetWidget();
const Rect itemRect = widget->GetRect();
theDialog->GetWindow()->GetDrawSurface()->FrameEllipse(itemRect);
theDialog->GetWindow()->GetDrawSurface()->FrameEllipse(itemRect, color);
}
//-------------------------------------------------------------- BorderDialogItem
@@ -703,6 +705,9 @@ void BorderDialogItem(Dialog *theDialog, short item, short sides, short thicknes
// 4 = bottom
// 8 = right ... so 6 = top & bottom, 15 = all 4 sides
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
PortabilityLayer::Widget *widget = itemRef.GetWidget();
const Rect itemRect = widget->GetRect();
@@ -716,13 +721,11 @@ void BorderDialogItem(Dialog *theDialog, short item, short sides, short thicknes
const Rect rect = Rect::Create(pointA.v, pointA.h, pointB.v, pointB.h);
if (pattern)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(rect);
surface->SetForeColor(StdColors::Black());
surface->FillRectWithPattern8x8(rect, true, pattern);
surface->FillRect(rect, whiteColor);
surface->FillRectWithMaskPattern8x8(rect, pattern,blackColor);
}
else
surface->FillRect(rect);
surface->FillRect(rect, blackColor);
sides -= 8;
}
if (sides >= 4) // 4 = bottom
@@ -732,13 +735,11 @@ void BorderDialogItem(Dialog *theDialog, short item, short sides, short thicknes
const Rect rect = Rect::Create(pointA.v, pointA.h, pointB.v, pointB.h);
if (pattern)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(rect);
surface->SetForeColor(StdColors::Black());
surface->FillRectWithPattern8x8(rect, true, pattern);
surface->FillRect(rect, whiteColor);
surface->FillRectWithMaskPattern8x8(rect, pattern, blackColor);
}
else
surface->FillRect(rect);
surface->FillRect(rect, blackColor);
sides -= 4;
}
if (sides >= 2) // 2 = top
@@ -748,13 +749,11 @@ void BorderDialogItem(Dialog *theDialog, short item, short sides, short thicknes
const Rect rect = Rect::Create(pointA.v, pointA.h, pointB.v, pointB.h);
if (pattern)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(rect);
surface->SetForeColor(StdColors::Black());
surface->FillRectWithPattern8x8(rect, true, pattern);
surface->FillRect(rect, whiteColor);
surface->FillRectWithMaskPattern8x8(rect, pattern, blackColor);
}
else
surface->FillRect(rect);
surface->FillRect(rect, blackColor);
sides -= 2;
}
if (sides >= 1) // 1 = left
@@ -764,13 +763,11 @@ void BorderDialogItem(Dialog *theDialog, short item, short sides, short thicknes
const Rect rect = Rect::Create(pointA.v, pointA.h, pointB.v, pointB.h);
if (pattern)
{
surface->SetForeColor(StdColors::White());
surface->FillRect(rect);
surface->SetForeColor(StdColors::Black());
surface->FillRectWithPattern8x8(rect, true, pattern);
surface->FillRect(rect, whiteColor);
surface->FillRectWithMaskPattern8x8(rect, pattern, blackColor);
}
else
surface->FillRect(rect);
surface->FillRect(rect, blackColor);
}
}
@@ -784,13 +781,14 @@ void ShadowDialogItem (Dialog *theDialog, short item, short thickness)
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
const Rect itemRect = itemRef.GetWidget()->GetRect();
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
const Point bottomLeftCorner = Point::Create(itemRect.left + thickness, itemRect.bottom);
const Point topRightCorner = Point::Create(itemRect.right, itemRect.top + thickness);
const Point bottomRightCorner = Point::Create(itemRect.right + thickness, itemRect.bottom + thickness);
surface->FillRect(Rect::Create(topRightCorner.v, topRightCorner.h, bottomRightCorner.v, bottomRightCorner.h));
surface->FillRect(Rect::Create(bottomLeftCorner.v, bottomLeftCorner.h, bottomRightCorner.v, bottomRightCorner.h));
surface->FillRect(Rect::Create(topRightCorner.v, topRightCorner.h, bottomRightCorner.v, bottomRightCorner.h), blackColor);
surface->FillRect(Rect::Create(bottomLeftCorner.v, bottomLeftCorner.h, bottomRightCorner.v, bottomRightCorner.h), blackColor);
}
//-------------------------------------------------------------- EraseDialogItem
@@ -803,9 +801,9 @@ void EraseDialogItem (Dialog *theDialog, short item)
const Rect itemRect = widget->GetRect();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
surface->SetForeColor(StdColors::White());
surface->FillRect(itemRect);
surface->SetForeColor(StdColors::Black());
surface->FillRect(itemRect, whiteColor);
}

View File

@@ -7,6 +7,11 @@
#include "PLDialogs.h"
namespace PortabilityLayer
{
class ResolveCachingColor;
}
struct DialogTextSubstitutions;
void BringUpDialog (Dialog **theDialog, short dialogID, const DialogTextSubstitutions *);
@@ -40,9 +45,9 @@ void MyDisableControl(Dialog *, short);
void DrawDialogUserText (Dialog *, short, StringPtr, Boolean);
void DrawDialogUserText2 (Dialog *, short, StringPtr);
void LoadDialogPICT (Dialog *, short, short);
void FrameDialogItem (Dialog *, short);
void FrameDialogItem (Dialog *, short, PortabilityLayer::ResolveCachingColor &color);
void FrameDialogItemC (Dialog *, short, long);
void FrameOvalDialogItem (Dialog *, short);
void FrameOvalDialogItem (Dialog *, short, PortabilityLayer::ResolveCachingColor &color);
void BorderDialogItem (Dialog *theDialog, short item, short sides, short thickness, const uint8_t *pattern);
void ShadowDialogItem (Dialog *, short, short);
void EraseDialogItem (Dialog *, short);

View File

@@ -11,8 +11,10 @@
#include "MainWindow.h"
#include "Objects.h"
#include "PLHacks.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "Room.h"
#include "ResolveCachingColor.h"
#define kShoveVelocity 8
@@ -578,7 +580,8 @@ void HandleOutlet (short who)
}
else
{
workSrcMap->FillRect(dinahs[who].dest);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
workSrcMap->FillRect(dinahs[who].dest, blackColor);
}
AddRectToWorkRects(&dinahs[who].dest);
}

View File

@@ -315,115 +315,6 @@ void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent
}
}
//-------------------------------------------------------------- HandleUpdateEvent
// Handle an update event.
#if 0
void HandleUpdateEvent (EventRecord *theEvent)
{
if ((WindowPtr)theEvent->message == mainWindow)
{
SetPort((GrafPtr)mainWindow);
UpdateMainWindow();
EndUpdate(mainWindow);
}
else if ((WindowPtr)theEvent->message == mapWindow)
{
SetPort((GrafPtr)mapWindow);
UpdateMapWindow();
EndUpdate(mapWindow);
}
else if ((WindowPtr)theEvent->message == toolsWindow)
{
SetPort((GrafPtr)toolsWindow);
UpdateToolsWindow();
EndUpdate(toolsWindow);
}
else if ((WindowPtr)theEvent->message == linkWindow)
{
SetPort((GrafPtr)linkWindow);
UpdateLinkWindow();
EndUpdate(linkWindow);
}
else if ((WindowPtr)theEvent->message == coordWindow)
{
SetPort((GrafPtr)coordWindow);
UpdateCoordWindow();
EndUpdate(coordWindow);
}
}
//-------------------------------------------------------------- HandleOSEvent
// Handle an OS Event (MultiFinder - user has switched in or out of app).
void HandleOSEvent (EventRecord *theEvent)
{
PLError_t theErr;
short buttonHit;
if (theEvent->message & 0x01000000) // suspend or resume event
{
if (theEvent->message & 0x00000001) // resume event
{
if (WhatsOurDepth() != thisMac.isDepth)
{
buttonHit = BitchAboutColorDepth();
if (buttonHit == 1) // player wants to Quit
{
#ifndef COMPILEDEMO
if (QuerySaveChanges())
quitting = true;
#else
quitting = true;
#endif
}
else
{
SwitchToDepth(thisMac.isDepth, thisMac.wasColorOrGray);
}
}
switchedOut = false;
InitCursor();
if ((isPlayMusicIdle) && (theMode != kEditMode))
{
theErr = StartMusic();
if (theErr != PLErrors::kNone)
{
YellowAlert(kYellowNoMusic, theErr);
failedMusic = true;
}
}
incrementModeTime = TickCount() + kIdleSplashTicks;
#ifndef COMPILEDEMO
// if (theMode == kEditMode)
// SeeIfValidScrapAvailable(true);
#endif
}
else // suspend event
{
switchedOut = true;
InitCursor();
if ((isMusicOn) && (theMode != kEditMode))
StopTheMusic();
}
}
}
//-------------------------------------------------------------- HandleHighLevelEvent
// Handle an AppleEvent (Open Document, Quit Application, etc.).
void HandleHighLevelEvent (EventRecord *theEvent)
{
PLError_t theErr;
theErr = AEProcessAppleEvent(theEvent);
if ((theErr != PLErrors::kNone) && (theErr != errAEEventNotHandled))
YellowAlert(kYellowAppleEventErr, theErr);
}
#endif
//-------------------------------------------------------------- HandleSplashResolutionChange
void HandleSplashResolutionChange(void)
{
@@ -454,8 +345,7 @@ void KeepWindowInBounds(Window *window)
int32_t leftNudge = std::max<int32_t>(-windowRect.Left(), 0);
int32_t rightNudge = std::min<int32_t>(thisMac.fullScreen.right - windowRect.Right(), 0);
window->m_wmX += leftNudge + rightNudge;
window->m_wmY += topNudge + bottomNudge;
window->SetPosition(window->GetPosition() + PortabilityLayer::Vec2i(leftNudge + rightNudge, topNudge + bottomNudge));
}
void HandleEditorResolutionChange(void)
@@ -497,7 +387,7 @@ void HandleIdleTask (void)
HandleEditorResolutionChange();
}
SetPort(&mainWindow->GetDrawSurface()->m_port);
SetPort(mainWindow->GetDrawSurface());
DoMarquee();
if ((autoRoomEdit) && (newRoomNow))

View File

@@ -13,10 +13,12 @@
namespace PortabilityLayer
{
class ResolveCachingColor;
class ResourceArchive;
class ScanlineMask;
class ResTypeID;
struct RGBAColor;
class RenderedFont;
}
#define kPreferredDepth 8
@@ -133,20 +135,19 @@ void DecrementCursor (void);
void SpinCursor (short);
void BackSpinCursor (short);
void ColorText (DrawSurface *surface, const Point &, StringPtr, long); // --- ColorUtils.c
void ColorText (DrawSurface *surface, const Point &, StringPtr, long, PortabilityLayer::RenderedFont *font); // --- ColorUtils.c
void ColorRect (DrawSurface *surface, const Rect &, long);
void ColorOval (DrawSurface *surface, const Rect &, long);
void ColorOvalMaskPattern (DrawSurface *surface, const Rect &, long, bool, const uint8_t *);
void ColorRegionMaskPattern (DrawSurface *surface, PortabilityLayer::ScanlineMask *scanlineMask, long colorIndex, bool isMask, const uint8_t *pattern);
void ColorOvalMaskPattern (DrawSurface *surface, const Rect &, long, const uint8_t *);
void ColorRegionMaskPattern (DrawSurface *surface, PortabilityLayer::ScanlineMask *scanlineMask, long colorIndex, const uint8_t *pattern);
void ColorLine (DrawSurface *surface, short, short, short, short, long);
void HiliteRect (DrawSurface *surface, const Rect &rect, short, short);
void ColorFrameRect (DrawSurface *surface, const Rect &theRect, long colorIndex);
void ColorFrameWHRect (DrawSurface *surface, short, short, short, short, long);
void ColorFrameOval (DrawSurface *surface, const Rect &, long);
void LtGrayForeColor (DrawSurface *surface);
void GrayForeColor (DrawSurface *surface);
void DkGrayForeColor (DrawSurface *surface);
void RestoreColorsSlam (DrawSurface *surface);
PortabilityLayer::ResolveCachingColor LtGrayForeColor ();
PortabilityLayer::ResolveCachingColor GrayForeColor ();
PortabilityLayer::ResolveCachingColor DkGrayForeColor ();
void MonitorWait (void); // --- DebugUtils.c
void DisplayRect (Rect *);
@@ -189,7 +190,7 @@ void PasStringConcat (StringPtr, const PLPasStr &);
void GetLineOfText (StringPtr, short, StringPtr);
void WrapText (StringPtr, short);
void GetFirstWordOfString (StringPtr, StringPtr);
void CollapseStringToWidth (DrawSurface *, StringPtr, short);
void CollapseStringToWidth (PortabilityLayer::RenderedFont *, StringPtr, short);
void GetChooserName (StringPtr);
StringPtr GetLocalizedString (short, StringPtr);

View File

@@ -17,7 +17,10 @@
#include "InputManager.h"
#include "MainWindow.h"
#include "Objects.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
@@ -68,7 +71,7 @@ void DoGameOver (void)
DrawSurface *surface = mainWindow->GetDrawSurface();
playing = false;
SetUpFinalScreen();
SetPort((GrafPtr)mainWindow);
SetPort(mainWindow->GetDrawSurface());
ColorRect(surface, mainWindowRect, 244);
DoGameOverStarAnimation();
if (!TestHighScore())
@@ -87,6 +90,9 @@ void SetUpFinalScreen (void)
short count, offset, i, textDown;
char wasState;
DrawSurface *surface = workSrcMap;
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
ColorRect(surface, workSrcRect, 244);
QSetRect(&tempRect, 0, 0, 640, 460);
@@ -103,18 +109,16 @@ void SetUpFinalScreen (void)
{
GetLineOfText(tempStr, count, subStr);
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
offset = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) -
surface->MeasureString(subStr)) / 2;
appFont->MeasurePStr(subStr)) / 2;
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
const Point textShadowPos = Point::Create(offset + 1, textDown + 33 + (count * 20));
surface->DrawString(textShadowPos, subStr, true);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textShadowPos, subStr, blackColor, appFont);
const Point textPos = Point::Create(offset, textDown + 32 + (count * 20));
surface->DrawString(textPos, subStr, true);
surface->DrawString(textPos, subStr, whiteColor, appFont);
count++;
}
while (subStr[0] > 0);

View File

@@ -156,10 +156,9 @@ void RedrawSplashScreen (void); // --- MainWindow.c
void UpdateMainWindow (void);
void OpenMainWindow (void);
void CloseMainWindow (void);
void ZoomBetweenWindows (void);
void UpdateEditWindowTitle (void);
void HandleMainClick (Point, Boolean);
//void WashColorIn (void);
void WashColorIn (void);
void CenterMapOnRoom (SInt16, SInt16); // --- Map.c
Boolean ThisRoomVisibleOnMap (void);

View File

@@ -10,7 +10,9 @@
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "Room.h"
@@ -102,9 +104,11 @@ void HandleGrease (void)
}
{
backSrcMap->FillRect(src);
workSrcMap->FillRect(src);
PortabilityLayer::ResolveCachingColor blackColorBack = StdColors::Black();
backSrcMap->FillRect(src, blackColorBack);
PortabilityLayer::ResolveCachingColor blackColorWork = StdColors::Black();
workSrcMap->FillRect(src, blackColorWork);
AddRectToWorkRects(&src);
}
@@ -282,13 +286,16 @@ void RedrawAllGrease (void)
if ((grease[i].where == thisRoomNumber) &&
((src.bottom - src.top) == 2))
{
PortabilityLayer::ResolveCachingColor blackColorBack = StdColors::Black();
PortabilityLayer::ResolveCachingColor blackColorWork = StdColors::Black();
QOffsetRect(&src, playOriginH, playOriginV);
wasCPort = GetGraphicsPort();
backSrcMap->FillRect(src);
backSrcMap->FillRect(src, blackColorBack);
workSrcMap->FillRect(src);
workSrcMap->FillRect(src, blackColorWork);
AddRectToWorkRects(&src);
SetGraphicsPort(wasCPort);

View File

@@ -22,9 +22,11 @@
#include "House.h"
#include "IOStream.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
#include "WindowManager.h"
@@ -69,11 +71,11 @@ extern Boolean quickerTransitions, resumedSavedGame;
void DoHighScores (void)
{
Rect tempRect;
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
SpinCursor(3);
SetPort(&workSrcMap->m_port);
workSrcMap->SetForeColor(StdColors::Black());
workSrcMap->FillRect(workSrcRect);
SetPort(workSrcMap);
workSrcMap->FillRect(workSrcRect, blackColor);
QSetRect(&tempRect, 0, 0, 640, 480);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(workSrcMap, kStarPictID, &tempRect);
@@ -120,11 +122,11 @@ void DrawHighScores (DrawSurface *surface)
Str255 tempStr;
short scoreLeft, bannerWidth, i, dropIt;
char wasState;
PortabilityLayer::RGBAColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
PortabilityLayer::RGBAColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255);
PortabilityLayer::RGBAColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255);
PortabilityLayer::RGBAColor whiteColor = PortabilityLayer::RGBAColor::Create(255, 255, 255, 255);
PortabilityLayer::RGBAColor blueColor = PortabilityLayer::RGBAColor::Create(0, 0, 255, 255);
PortabilityLayer::ResolveCachingColor blackColor = PortabilityLayer::RGBAColor::Create(0, 0, 0, 255);
PortabilityLayer::ResolveCachingColor yellowColor = PortabilityLayer::RGBAColor::Create(255, 255, 0, 255);
PortabilityLayer::ResolveCachingColor cyanColor = PortabilityLayer::RGBAColor::Create(0, 255, 255, 255);
PortabilityLayer::ResolveCachingColor whiteColor = PortabilityLayer::RGBAColor::Create(255, 255, 255, 255);
PortabilityLayer::ResolveCachingColor blueColor = PortabilityLayer::RGBAColor::Create(0, 0, 255, 255);
scoreLeft = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) - kScoreWide) / 2;
dropIt = 129 + splashOriginV;
@@ -147,43 +149,37 @@ void DrawHighScores (DrawSurface *surface)
DisposeGWorld(tempMap);
DisposeGWorld(tempMask);
surface->SetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont14 = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold, true);
PasStringCopy(PSTR("¥ "), tempStr);
PasStringConcat(tempStr, thisHouseName);
PasStringConcat(tempStr, PSTR(" ¥"));
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2) - 1, dropIt - 66);
surface->SetForeColor(blackColor);
surface->DrawString(scoreShadowPoint, tempStr, true);
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2) - 1, dropIt - 66);
surface->DrawString(scoreShadowPoint, tempStr, blackColor, appFont14);
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2), dropIt - 65);
surface->SetForeColor(cyanColor);
surface->DrawString(scoreTextPoint, tempStr, true);
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2), dropIt - 65);
surface->DrawString(scoreTextPoint, tempStr, cyanColor, appFont14);
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont12 = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
thisHousePtr = *thisHouse;
// message for score #1
PasStringCopy(thisHousePtr->highScores.banner, tempStr);
bannerWidth = surface->MeasureString(tempStr);
surface->SetForeColor(blackColor);
bannerWidth = appFont12->MeasurePStr(tempStr);
const Point topScoreShadowPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted);
surface->DrawString(topScoreShadowPoint, tempStr, true);
surface->DrawString(topScoreShadowPoint, tempStr, blackColor, appFont12);
surface->SetForeColor(yellowColor);
const Point topScoreTextPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted - 1);
surface->DrawString(topScoreTextPoint, tempStr, true);
surface->DrawString(topScoreTextPoint, tempStr, yellowColor, appFont12);
QSetRect(&tempRect, 0, 0, bannerWidth + 8, kScoreSpacing);
QOffsetRect(&tempRect, scoreLeft - 3 + (kScoreWide - bannerWidth) / 2,
dropIt + 5 - kScoreSpacing - kKimsLifted);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
surface->FrameRect(tempRect);
surface->FrameRect(tempRect, blackColor);
QOffsetRect(&tempRect, -1, -1);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 0, 255));
surface->FrameRect(tempRect);
surface->FrameRect(tempRect, yellowColor);
for (i = 0; i < kMaxScores; i++)
{
@@ -193,101 +189,90 @@ void DrawHighScores (DrawSurface *surface)
SpinCursor(1);
NumToString((long)i + 1L, tempStr); // draw placing number
surface->SetForeColor(blackColor);
if (i == 0)
strPos = Point::Create(scoreLeft + 1, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 1, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
if (i == lastHighScore)
surface->SetForeColor(whiteColor);
else
surface->SetForeColor(cyanColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *scoreColor = (i == lastHighScore) ? &whiteColor : &cyanColor;
if (i == 0)
strPos = Point::Create(scoreLeft + 0, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 0, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->DrawString(strPos, tempStr, *scoreColor, appFont12);
// draw high score name
PasStringCopy(thisHousePtr->highScores.names[i], tempStr);
surface->SetForeColor(blackColor);
if (i == 0)
strPos = Point::Create(scoreLeft + 31, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 31, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
if (i == lastHighScore)
surface->SetForeColor(whiteColor);
else
surface->SetForeColor(yellowColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *nameColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
if (i == 0)
strPos = Point::Create(scoreLeft + 30, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 30, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->DrawString(strPos, tempStr, *nameColor, appFont12);
// draw level number
NumToString(thisHousePtr->highScores.levels[i], tempStr);
surface->SetForeColor(blackColor);
if (i == 0)
strPos = Point::Create(scoreLeft + 161, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 161, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
if (i == lastHighScore)
surface->SetForeColor(whiteColor);
else
surface->SetForeColor(yellowColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *levelColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
if (i == 0)
strPos = Point::Create(scoreLeft + 160, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 160, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->DrawString(strPos, tempStr, *levelColor, appFont12);
// draw word "rooms"
if (thisHousePtr->highScores.levels[i] == 1)
GetLocalizedString(6, tempStr);
else
GetLocalizedString(7, tempStr);
surface->SetForeColor(blackColor);
if (i == 0)
strPos = Point::Create(scoreLeft + 193, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 193, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->SetForeColor(cyanColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
if (i == 0)
strPos = Point::Create(scoreLeft + 192, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 192, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->DrawString(strPos, tempStr, cyanColor, appFont12);
// draw high score points
NumToString(thisHousePtr->highScores.scores[i], tempStr);
surface->SetForeColor(blackColor);
if (i == 0)
strPos = Point::Create(scoreLeft + 291, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 291, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
if (i == lastHighScore)
surface->SetForeColor(whiteColor);
else
surface->SetForeColor(yellowColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *pointsColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
if (i == 0)
strPos = Point::Create(scoreLeft + 290, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 290, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true);
surface->DrawString(strPos, tempStr, *pointsColor, appFont12);
}
}
surface->SetForeColor(blueColor);
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont9 = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point textPos = Point::Create(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
GetLocalizedString(8, tempStr);
surface->DrawString(textPos, tempStr, true);
surface->SetForeColor(blackColor);
surface->DrawString(textPos, tempStr, blueColor, appFont9);
}
//-------------------------------------------------------------- SortHighScores
@@ -730,6 +715,8 @@ Boolean WriteScoresToDisk (void)
scoresStream->Close();
gameDirty = false;
return (true);
}

View File

@@ -614,20 +614,6 @@ Boolean ReadHouse (void)
YellowAlert(kYellowUnaccounted, 2);
return (false);
}
if (gameDirty || fileDirty)
{
if (houseIsReadOnly)
{
if (!WriteScoresToDisk())
{
YellowAlert(kYellowFailedWrite, 0);
return(false);
}
}
else if (!WriteHouse(false))
return(false);
}
byteCount = houseStream->Size();

View File

@@ -173,7 +173,7 @@ int16_t HouseFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
if (mouseEvt.m_eventType == GpMouseEventTypes::kMove)
{
mouseIs = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if ((houseEditText1.Contains(mouseIs)) ||
(houseEditText2.Contains(mouseIs)))
{
@@ -231,7 +231,7 @@ void DoHouseInfo (void)
houseInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kHouseInfoDialogID, kPutInFront, &substitutions);
if (houseInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&houseInfoDialog->GetWindow()->GetDrawSurface()->m_port);
SetPort(houseInfoDialog->GetWindow()->GetDrawSurface());
ShowWindow(houseInfoDialog->GetWindow());
static_cast<PortabilityLayer::EditboxWidget*>(houseInfoDialog->GetItems()[kBannerTextItem - 1].GetWidget())->SetMultiLine(true);

View File

@@ -119,7 +119,7 @@ void DoPause (void)
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&bounds, &bounds, srcCopy);
do

View File

@@ -379,7 +379,7 @@ void HandleLinkClick (Point wherePt)
return;
SetPortWindowPort(linkWindow);
wherePt -= linkWindow->TopLeftCoord();
wherePt -= linkWindow->GetTopLeftCoord();
part = FindControl(wherePt, linkWindow, &theControl);
if ((theControl != nil) && (part != 0))

View File

@@ -12,6 +12,7 @@
#include "Environ.h"
#include "IOStream.h"
#include "House.h"
#include "WindowManager.h"
#define kPrefsVersion 0x0035
@@ -352,6 +353,10 @@ int gpAppMain()
InitSrcRects();
CreateOffscreens(); SpinCursor(2);
OpenMainWindow();
if (isDoColorFade)
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 1.0);
InitSound(); SpinCursor(2);
InitMusic(); SpinCursor(2);
BuildHouseList();
@@ -366,17 +371,8 @@ int gpAppMain()
// HideMenuBarOld();
#endif
// if ((isDoColorFade) && (thisMac.isDepth == 8))
// {
// wasSeed = ExtractCTSeed((CGrafPtr)mainWindow);
// WashColorIn();
// ForceCTSeed((CGrafPtr)mainWindow, wasSeed);
// }
// if ((!thisMac.hasSM3) && (numSMWarnings < 3))
// {
// numSMWarnings++;
// BitchAboutSM3();
// }
if (isDoColorFade)
WashColorIn();
UpdateMainWindow();

View File

@@ -20,6 +20,7 @@
#include "RectUtils.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "ResolveCachingColor.h"
#include "WindowDef.h"
#include "WindowManager.h"
@@ -69,20 +70,20 @@ void DrawOnSplash(DrawSurface *surface)
if ((thisMac.hasQT) && (hasMovie))
PasStringConcat(houseLoadedStr, PSTR(" (TV)"));
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point textPoint = Point::Create(splashOriginH + 436, splashOriginV + 314);
if (thisMac.isDepth == 4)
{
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textPoint, houseLoadedStr, true);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->DrawString(textPoint, houseLoadedStr, whiteColor, appFont);
}
else
{
if (houseIsReadOnly)
ColorText(surface, textPoint, houseLoadedStr, 5L);
ColorText(surface, textPoint, houseLoadedStr, 5L, appFont);
else
ColorText(surface, textPoint, houseLoadedStr, 28L);
ColorText(surface, textPoint, houseLoadedStr, 28L, appFont);
}
#if defined(powerc) || defined(__powerc)
@@ -106,8 +107,8 @@ void RedrawSplashScreen (void)
Rect tempRect;
DrawSurface *surface = workSrcMap;
surface->SetForeColor(StdColors::Black());
surface->FillRect(workSrcRect);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(workSrcRect, blackColor);
QSetRect(&tempRect, 0, 0, 640, 460);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
@@ -117,7 +118,7 @@ void RedrawSplashScreen (void)
SetPortWindowPort(mainWindow);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&workSrcRect, &workSrcRect, srcCopy);
// if (quickerTransitions)
@@ -126,7 +127,7 @@ void RedrawSplashScreen (void)
// DissBits(&workSrcRect);
CopyRectMainToWork(&workSrcRect);
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(true);
}
@@ -144,25 +145,27 @@ void UpdateMainWindow (void)
{
PauseMarquee();
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&mainWindowRect, &mainWindowRect, srcCopy);
ResumeMarquee();
}
else if ((theMode == kSplashMode) || (theMode == kPlayMode))
{
workSrcMap->FillRect(workSrcRect);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
workSrcMap->FillRect(workSrcRect, blackColor);
QSetRect(&tempRect, 0, 0, 640, 460);
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(workSrcMap, kSplash8BitPICT, &tempRect);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&workSrcRect, &mainWindowRect, srcCopy);
SetPortWindowPort(mainWindow);
DrawOnSplash(mainWindow->GetDrawSurface());
}
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
splashDrawn = true;
}
@@ -174,7 +177,9 @@ void OpenMainWindow (void)
{
// long wasSeed;
short whichRoom;
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
if (mainWindow != nil)
{
YellowAlert(kYellowUnaccounted, 6);
@@ -199,10 +204,6 @@ void OpenMainWindow (void)
ShowWindow(mainWindow);
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();
mainWindowSurface->SetClipRect(mainWindowRect);
mainWindowSurface->SetForeColor(StdColors::Black());
mainWindowSurface->SetBackColor(StdColors::White());
whichRoom = GetFirstRoomNumber();
CopyRoomToThisRoom(whichRoom);
@@ -249,11 +250,9 @@ void OpenMainWindow (void)
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();
mainWindowSurface->SetClipRect(mainWindowRect);
// CopyRgn(mainWindow->clipRgn, mainWindow->visRgn);
mainWindowSurface->SetForeColor(StdColors::Black());
mainWindowSurface->SetBackColor(StdColors::White());
mainWindowSurface->FillRect(mainWindowRect);
mainWindowSurface->FillRect(mainWindowRect, blackColor);
splashOriginH = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) - 640) / 2;
if (splashOriginH < 0)
@@ -262,7 +261,7 @@ void OpenMainWindow (void)
if (splashOriginV < 0)
splashOriginV = 0;
workSrcMap->FillRect(workSrcRect);
workSrcMap->FillRect(workSrcRect, blackColor);
// if ((fadeGraysOut) && (isDoColorFade))
// {
@@ -279,10 +278,10 @@ void OpenMainWindow (void)
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&mainWindowRect, &mainWindowRect, srcCopy);
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- CloseMainWindow
@@ -373,7 +372,7 @@ void HandleMainClick (Point wherePt, Boolean isDoubleClick)
return;
SetPortWindowPort(mainWindow);
wherePt -= mainWindow->TopLeftCoord();
wherePt -= mainWindow->GetTopLeftCoord();
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();
@@ -580,54 +579,20 @@ void HardDrawMainWindow (void)
//-------------------------------------------------------------- WashColorIn
// Slowly walks the palette from its gray luminance state to the full colorÉ
// palette. In this way, color appears to slowly wash in.
/*
void WashColorIn (void)
{
#define kGray2ColorSteps 180
GDHandle theDevice;
long longDelta;
short i, c;
theDevice = GetGDevice();
SetGDevice(thisGDevice);
for (i = 0; i < kGray2ColorSteps; i++)
{
for (c = 0; c < 256; c++)
{
if (c != 5)
{
longDelta = (((long)wasColors[c].rgb.red -
(long)newColors[c].rgb.red) /
(long)(kGray2ColorSteps - i)) + (long)newColors[c].rgb.red;
newColors[c].rgb.red = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.green -
(long)newColors[c].rgb.green) /
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.green;
newColors[c].rgb.green = (unsigned short)longDelta;
longDelta = (((long)wasColors[c].rgb.blue -
(long)newColors[c].rgb.blue) /
(long)(kGray2ColorSteps - i)) +
(long)newColors[c].rgb.blue;
newColors[c].rgb.blue = (unsigned short)longDelta;
}
}
SetEntries(0, 255, newColors);
if (Button())
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, static_cast<float>(kGray2ColorSteps - i) / static_cast<float>(kGray2ColorSteps));
Delay(1, nullptr);
if (PortabilityLayer::InputManager::GetInstance()->GetKeys()->m_mouse.Get(GpMouseButtons::kLeft))
break;
}
SetEntries(0, 255, wasColors);
SetGDevice(theDevice);
RestoreColorsSlam();
if (wasColors != nil)
DisposePtr((Ptr)wasColors);
if (newColors != nil)
DisposePtr((Ptr)newColors);
PortabilityLayer::WindowManager::GetInstance()->SetWindowDesaturation(mainWindow, 0.0f);
}
*/

View File

@@ -19,6 +19,7 @@
#include "WindowManager.h"
#include "QDPixMap.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
@@ -205,9 +206,6 @@ void RedrawMapContents (void)
newClip.bottom = mapWindowRect.bottom + 2 - kMapScrollBarWidth;
DrawSurface *surface = mapWindow->GetDrawSurface();
const Rect wasClip = surface->GetClipRect();
surface->SetClipRect(newClip);
for (i = 0; i < mapRoomsHigh; i++)
{
@@ -227,7 +225,6 @@ void RedrawMapContents (void)
type = kNumBackgrounds; // Draw "?" thumbnail.
}
surface->SetForeColor(StdColors::Black());
if (type > kNumBackgrounds) // Do a "pretty" thumbnail.
{
LoadGraphicPlus(surface, type + kBaseBackgroundID, aRoom);
@@ -237,7 +234,7 @@ void RedrawMapContents (void)
QSetRect(&src, 0, 0, kMapRoomWidth, kMapRoomHeight);
QOffsetRect(&src, 0, type * kMapRoomHeight);
CopyBits((BitMap *)*GetGWorldPixMap(nailSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mapWindow)),
GetPortBitMapForCopyBits(mapWindow->GetDrawSurface()),
&src, &aRoom, srcCopy);
}
@@ -249,49 +246,48 @@ void RedrawMapContents (void)
}
else
{
surface->SetForeColor(StdColors::White());
surface->FillRect(aRoom);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(aRoom, whiteColor);
PortabilityLayer::ResolveCachingColor overlayColor;
if (i >= groundLevel)
surface->SetForeColor(StdColors::Green());
overlayColor = StdColors::Green();
else
surface->SetForeColor(StdColors::Blue());
overlayColor = StdColors::Blue();
Pattern dummyPat;
surface->FillRectWithPattern8x8(aRoom, true, *GetQDGlobalsGray(&dummyPat));
surface->FillRectWithMaskPattern8x8(aRoom, *GetQDGlobalsGray(&dummyPat), overlayColor);
}
}
}
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
for (i = 1; i < mapRoomsWide; i++)
{
const Point upperPoint = Point::Create(i * kMapRoomWidth, 0);
const Point lowerPoint = Point::Create(upperPoint.h, upperPoint.v + mapRoomsHigh * kMapRoomHeight);
surface->DrawLine(upperPoint, lowerPoint);
surface->DrawLine(upperPoint, lowerPoint, blackColor);
}
for (i = 1; i < mapRoomsHigh; i++)
{
const Point leftPoint = Point::Create(0, i * kMapRoomHeight);
const Point rightPoint = leftPoint + Point::Create(mapRoomsWide * kMapRoomWidth, 0);
surface->DrawLine(leftPoint, rightPoint);
surface->DrawLine(leftPoint, rightPoint, blackColor);
}
if (activeRoomVisible)
{
surface->SetForeColor(StdColors::Red());
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
activeRoomRect.right++;
activeRoomRect.bottom++;
surface->FrameRect(activeRoomRect);
surface->FrameRect(activeRoomRect, redColor);
InsetRect(&activeRoomRect, 1, 1);
surface->FrameRect(activeRoomRect);
surface->SetForeColor(StdColors::Black());
surface->FrameRect(activeRoomRect, redColor);
InsetRect(&activeRoomRect, -1, -1);
}
surface->SetClipRect(wasClip);
}
#endif
@@ -299,23 +295,23 @@ void RedrawMapContents (void)
//-------------------------------------------------------------- UpdateMapWindow
void DrawMapResizeBox(void)
{
DrawSurface *surface = &mapWindow->m_surface;
DrawSurface *surface = mapWindow->GetDrawSurface();
const Rect windowRect = surface->m_port.GetRect();
Rect growBoxRect = Rect::Create(windowRect.bottom - 14, windowRect.right - 14, windowRect.bottom, windowRect.right);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(204, 204, 204, 255));
surface->FillRect(growBoxRect);
PortabilityLayer::ResolveCachingColor backgroundColor = PortabilityLayer::RGBAColor::Create(204, 204, 204, 255);
surface->FillRect(growBoxRect, backgroundColor);
surface->SetForeColor(StdColors::Black());
surface->FillRect(Rect::Create(growBoxRect.top + 2, growBoxRect.left + 2, growBoxRect.top + 3, growBoxRect.left + 6));
surface->FillRect(Rect::Create(growBoxRect.top + 3, growBoxRect.left + 2, growBoxRect.top + 6, growBoxRect.left + 3));
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(Rect::Create(growBoxRect.top + 2, growBoxRect.left + 2, growBoxRect.top + 3, growBoxRect.left + 6), blackColor);
surface->FillRect(Rect::Create(growBoxRect.top + 3, growBoxRect.left + 2, growBoxRect.top + 6, growBoxRect.left + 3), blackColor);
surface->FillRect(Rect::Create(growBoxRect.top + 8, growBoxRect.left + 11, growBoxRect.top + 12, growBoxRect.left + 12));
surface->FillRect(Rect::Create(growBoxRect.top + 11, growBoxRect.left + 8, growBoxRect.top + 12, growBoxRect.left + 11));
surface->FillRect(Rect::Create(growBoxRect.top + 8, growBoxRect.left + 11, growBoxRect.top + 12, growBoxRect.left + 12), blackColor);
surface->FillRect(Rect::Create(growBoxRect.top + 11, growBoxRect.left + 8, growBoxRect.top + 12, growBoxRect.left + 11), blackColor);
for (int i = 0; i < 7; i++)
surface->FillRect(Rect::Create(growBoxRect.top + 3 + i, growBoxRect.left + 3 + i, growBoxRect.top + 5 + i, growBoxRect.left + 5 + i));
surface->FillRect(Rect::Create(growBoxRect.top + 3 + i, growBoxRect.left + 3 + i, growBoxRect.top + 5 + i, growBoxRect.left + 5 + i), blackColor);
}
//-------------------------------------------------------------- UpdateMapWindow
@@ -359,8 +355,8 @@ void ResizeMapWindow (short newH, short newV)
mapRoomsWide * kMapRoomWidth + kMapScrollBarWidth - 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth - 1);
surface->SetForeColor(StdColors::White());
surface->FillRect(mapWindowRect);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(mapWindowRect, whiteColor);
SizeWindow(mapWindow, mapWindowRect.right, mapWindowRect.bottom, true);
mapHScroll->SetMax(kMaxNumRoomsH - mapRoomsWide);
@@ -415,7 +411,7 @@ void OpenMapWindow (void)
PortabilityLayer::WindowManager::GetInstance()->ShowWindow(mapWindow);
// FlagWindowFloating(mapWindow); TEMP - use flaoting windows
SetPort(&mapWindow->GetDrawSurface()->m_port);
SetPort(mapWindow->GetDrawSurface());
QSetRect(&mapHScrollRect, -1, mapRoomsHigh * kMapRoomHeight,
mapRoomsWide * kMapRoomWidth + 1,
mapRoomsHigh * kMapRoomHeight + kMapScrollBarWidth);
@@ -625,7 +621,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
SetPortWindowPort(mapWindow);
globalWhere = wherePt;
wherePt -= mapWindow->TopLeftCoord();
wherePt -= mapWindow->GetTopLeftCoord();
wherePt.h -= 1;
wherePt.v -= 1;

View File

@@ -432,7 +432,7 @@ Boolean PtInMarqueeHandle (Point where)
void DrawGliderMarquee (void)
{
DrawSurface *surface = GetWindowPort(mainWindow);
DrawSurface *surface = mainWindow->GetDrawSurface();
ImageInvert(*GetGWorldPixMap(blowerMaskMap), GetPortBitMapForCopyBits(surface), leftStartGliderSrc, marqueeGliderRect);
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}

View File

@@ -14,6 +14,7 @@
#include "Room.h"
#include "Vec2i.h"
#include "PLStandardColors.h"
#include "ResolveCachingColor.h"
#include "ScanlineMask.h"
#include "ScanlineMaskConverter.h"
@@ -164,9 +165,9 @@ void DrawTable (Rect *tableTop, short down)
GetQDGlobalsGray(&dummyPattern);
if (thisMac.isDepth == 4)
ColorOvalMaskPattern(backSrcMap, tempRect, 15, true, dummyPattern);
ColorOvalMaskPattern(backSrcMap, tempRect, 15, dummyPattern);
else
ColorOvalMaskPattern(backSrcMap, tempRect, k8DkstGrayColor, true, dummyPattern);
ColorOvalMaskPattern(backSrcMap, tempRect, k8DkstGrayColor, dummyPattern);
InsetRect(tableTop, 0, 1);
ColorRect(backSrcMap, *tableTop, brownC);
@@ -279,9 +280,9 @@ void DrawShelf (Rect *shelfTop)
{
GetQDGlobalsGray(&dummyPattern);
if (thisMac.isDepth == 4)
ColorRegionMaskPattern(backSrcMap, mask, 15, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, 15, dummyPattern);
else
ColorRegionMaskPattern(backSrcMap, mask, k8DkstGrayColor, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, k8DkstGrayColor, dummyPattern);
mask->Destroy();
}
@@ -367,9 +368,9 @@ void DrawCabinet (Rect *cabinet)
{
GetQDGlobalsGray(&dummyPattern);
if (thisMac.isDepth == 4)
ColorRegionMaskPattern(backSrcMap, mask, 15, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, 15, dummyPattern);
else
ColorRegionMaskPattern(backSrcMap, mask, dkGrayC, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, dkGrayC, dummyPattern);
mask->Destroy();
}
@@ -445,7 +446,8 @@ void DrawCabinet (Rect *cabinet)
(BitMap *)*GetGWorldPixMap(backSrcMap),
&handleSrc, &handleSrc, &tempRect);
backSrcMap->FrameRect(*cabinet);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FrameRect(*cabinet, blackColor);
}
//-------------------------------------------------------------- DrawSimpleFurniture
@@ -504,9 +506,9 @@ void DrawCounter(Rect *counter)
{
GetQDGlobalsGray(&dummyPattern);
if (thisMac.isDepth == 4)
ColorRegionMaskPattern(backSrcMap, mask, 15, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, 15, dummyPattern);
else
ColorRegionMaskPattern(backSrcMap, mask, dkGrayC, true, dummyPattern);
ColorRegionMaskPattern(backSrcMap, mask, dkGrayC, dummyPattern);
mask->Destroy();
}
@@ -747,7 +749,7 @@ void DrawDeckTable (Rect *tableTop, short down)
-HalfRectTall(&tempRect) + kTableShadowTop + down);
QOffsetRect(&tempRect, kTableShadowOffset, -kTableShadowOffset);
GetQDGlobalsGray(&dummyPattern);
ColorOvalMaskPattern(backSrcMap, tempRect, dkGrayC, true, dummyPattern);
ColorOvalMaskPattern(backSrcMap, tempRect, dkGrayC, dummyPattern);
InsetRect(tableTop, 0, 1);
ColorRect(backSrcMap, *tableTop, kGoldColor);
@@ -982,7 +984,7 @@ void DrawClockHands (Point where, short bigHand, short littleHand)
{
DrawSurface *surface = backSrcMap;
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
const Point midPoint = Point::Create(where.h, where.v);
Point otherPoint = midPoint;
@@ -1037,7 +1039,7 @@ void DrawClockHands (Point where, short bigHand, short littleHand)
break;
}
surface->DrawLine(midPoint, otherPoint);
surface->DrawLine(midPoint, otherPoint, blackColor);
switch (littleHand)
{
@@ -1090,7 +1092,7 @@ void DrawClockHands (Point where, short bigHand, short littleHand)
break;
}
surface->DrawLine(midPoint, otherPoint);
surface->DrawLine(midPoint, otherPoint, blackColor);
}
//-------------------------------------------------------------- DrawClockHands
@@ -1099,7 +1101,7 @@ void DrawLargeClockHands (Point where, short bigHand, short littleHand)
{
DrawSurface *surface = backSrcMap;
surface->SetForeColor(StdColors::White());
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
const Point midPoint = Point::Create(where.h, where.v);
Point otherPoint = midPoint;
@@ -1155,7 +1157,7 @@ void DrawLargeClockHands (Point where, short bigHand, short littleHand)
break;
}
surface->DrawLine(midPoint, otherPoint);
surface->DrawLine(midPoint, otherPoint, whiteColor);
switch (littleHand)
{
@@ -1208,8 +1210,7 @@ void DrawLargeClockHands (Point where, short bigHand, short littleHand)
break;
}
surface->DrawLine(midPoint, otherPoint);
surface->SetForeColor(StdColors::Black());
surface->DrawLine(midPoint, otherPoint, whiteColor);
}
//-------------------------------------------------------------- DrawSimplePrizes
@@ -1249,8 +1250,8 @@ void DrawGreaseRt (Rect *theRect, short distance, Boolean state, Boolean drawSpi
QSetRect(&spill, 0, -2, distance - 5, 0);
QOffsetRect(&spill, dest.right - 1, dest.bottom);
backSrcMap->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
backSrcMap->FillRect(spill);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FillRect(spill, blackColor);
}
}
}
@@ -1280,11 +1281,11 @@ void DrawGreaseLf (Rect *theRect, short distance, Boolean state, Boolean drawSpi
if (drawSpill)
{
backSrcMap->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
QSetRect(&spill, -distance + 5, -2, 0, 0);
QOffsetRect(&spill, dest.left + 1, dest.bottom);
backSrcMap->FillRect(spill);
backSrcMap->FillRect(spill, blackColor);
}
}
}
@@ -1312,6 +1313,7 @@ void DrawInvisBonus (Rect *theRect)
void DrawSlider (Rect *theRect)
{
backSrcMap->FrameRect(*theRect);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FrameRect(*theRect, blackColor);
}

View File

@@ -15,6 +15,8 @@
#include "Environ.h"
#include "Objects.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "ResourceManager.h"
#include "Room.h"
#include "Utilities.h"
@@ -578,8 +580,7 @@ void DrawMacPlus (Rect *theRect, Boolean isOn, Boolean isLit)
if (IsMacPlusGraphicBanned())
{
const PortabilityLayer::RGBAColor beigeColor = PortabilityLayer::RGBAColor::Create(255, 255, 204, 255);
const PortabilityLayer::RGBAColor wasColor = backSrcMap->GetForeColor();
PortabilityLayer::ResolveCachingColor beigeColor = PortabilityLayer::RGBAColor::Create(255, 255, 204, 255);
Rect paintOverRect = *theRect;
paintOverRect.left += 8;
@@ -587,9 +588,7 @@ void DrawMacPlus (Rect *theRect, Boolean isOn, Boolean isLit)
paintOverRect.right = paintOverRect.left + 17;
paintOverRect.bottom = paintOverRect.top + 6;
backSrcMap->SetForeColor(beigeColor);
backSrcMap->FillRect(paintOverRect);
backSrcMap->SetForeColor(wasColor);
backSrcMap->FillRect(paintOverRect, beigeColor);
}
}
@@ -1063,13 +1062,13 @@ void DrawCalendar (Rect *theRect)
backSrcMap->DrawPicture(thePicture, bounds);
thePicture.Dispose();
backSrcMap->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
GetTime(&timeRec);
GetIndString(monthStr, kMonthStringID, timeRec.month);
const Point textPos = Point::Create(theRect->left + ((64 - backSrcMap->MeasureString(monthStr)) / 2), theRect->top + 55);
ColorText(backSrcMap, textPos, monthStr, kDarkFleshColor);
const Point textPos = Point::Create(theRect->left + ((64 - appFont->MeasurePStr(monthStr)) / 2), theRect->top + 55);
ColorText(backSrcMap, textPos, monthStr, kDarkFleshColor, appFont);
}
//-------------------------------------------------------------- DrawBulletin

View File

@@ -19,6 +19,7 @@
#include "Play.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "ResourceManager.h"
#include "Room.h"
@@ -2251,7 +2252,8 @@ void DrawThisRoomsObjects (void)
{
if (GetNumberOfLights(thisRoomNumber) <= 0)
{
surface->FillRectWithPattern8x8(backSrcRect, true, *GetQDGlobalsGray(&dummyPattern));
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->FillRectWithMaskPattern8x8(backSrcRect, *GetQDGlobalsGray(&dummyPattern), blackColor);
}
for (i = 0; i < kMaxRoomObs; i++)

View File

@@ -18,6 +18,7 @@
#include "PLTimeTaggedVOSEvent.h"
#include "QDPixMap.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#define kBlowerInfoDialogID 1007
@@ -126,11 +127,12 @@ void UpdateBlowerInfo (Dialog *theDialog)
{
#define kArrowheadLength 4
Rect bounds;
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
Window *window = theDialog->GetWindow();
DrawSurface *surface = window->GetDrawSurface();
surface->SetForeColor(StdColors::White());
surface->FillRect((*surface->m_port.GetPixMap())->m_rect);
surface->FillRect((*surface->m_port.GetPixMap())->m_rect, whiteColor);
window->DrawControls();
@@ -140,19 +142,20 @@ void UpdateBlowerInfo (Dialog *theDialog)
if ((thisRoom->objects[objActive].what != kLeftFan) &&
(thisRoom->objects[objActive].what != kRightFan))
{
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
GetDialogItemRect(theDialog, 8, &bounds);
bounds.right += 2;
bounds.bottom += 2;
surface->SetForeColor(StdColors::White());
surface->FillRect(bounds);
surface->FillRect(bounds, whiteColor);
bounds.right -= 2;
bounds.bottom -= 2;
surface->SetForeColor(StdColors::Black());
for (int16_t offsetChunk = 0; offsetChunk < 4; offsetChunk++)
{
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
const int16_t xOffset = offsetChunk & 1;
const int16_t yOffset = (offsetChunk >> 1) & 1;
@@ -163,36 +166,36 @@ void UpdateBlowerInfo (Dialog *theDialog)
case 1: // up
{
const Point basePoint = offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.top);
surface->DrawLine(basePoint, basePoint + Point::Create(0, RectTall(&bounds)));
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(0, RectTall(&bounds)), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, kArrowheadLength), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, kArrowheadLength), blackColor);
}
break;
case 2: // right
{
const Point basePoint = offset + Point::Create(bounds.right, bounds.top + HalfRectTall(&bounds));
surface->DrawLine(basePoint, basePoint + Point::Create(-RectWide(&bounds), 0));
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, -kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(-RectWide(&bounds), 0), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, kArrowheadLength), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, -kArrowheadLength), blackColor);
}
break;
case 4: // down
{
const Point basePoint = offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.bottom);
surface->DrawLine(basePoint, basePoint + Point::Create(0, -RectTall(&bounds)));
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, -kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, -kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(0, -RectTall(&bounds)), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, -kArrowheadLength), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(-kArrowheadLength, -kArrowheadLength), blackColor);
}
break;
case 8: // left
{
const Point basePoint = offset + Point::Create(bounds.left, bounds.top + HalfRectTall(&bounds));
surface->DrawLine(basePoint, basePoint + Point::Create(RectWide(&bounds), 0));
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, -kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, kArrowheadLength));
surface->DrawLine(basePoint, basePoint + Point::Create(RectWide(&bounds), 0), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, -kArrowheadLength), blackColor);
surface->DrawLine(basePoint, basePoint + Point::Create(kArrowheadLength, kArrowheadLength), blackColor);
}
break;
@@ -204,33 +207,35 @@ void UpdateBlowerInfo (Dialog *theDialog)
if ((thisRoom->objects[objActive].what == kInvisBlower) ||
(thisRoom->objects[objActive].what == kLiftArea))
{
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
switch (newDirection)
{
case 1: // up
EraseDialogItem(theDialog, 11);
FrameOvalDialogItem(theDialog, 12);
FrameOvalDialogItem(theDialog, 13);
FrameOvalDialogItem(theDialog, 14);
FrameOvalDialogItem(theDialog, 12, blackColor);
FrameOvalDialogItem(theDialog, 13, blackColor);
FrameOvalDialogItem(theDialog, 14, blackColor);
break;
case 2: // right
FrameOvalDialogItem(theDialog, 11);
FrameOvalDialogItem(theDialog, 11, blackColor);
EraseDialogItem(theDialog, 12);
FrameOvalDialogItem(theDialog, 13);
FrameOvalDialogItem(theDialog, 14);
FrameOvalDialogItem(theDialog, 13, blackColor);
FrameOvalDialogItem(theDialog, 14, blackColor);
break;
case 4: // down
FrameOvalDialogItem(theDialog, 11);
FrameOvalDialogItem(theDialog, 12);
FrameOvalDialogItem(theDialog, 11, blackColor);
FrameOvalDialogItem(theDialog, 12, blackColor);
EraseDialogItem(theDialog, 13);
FrameOvalDialogItem(theDialog, 14);
FrameOvalDialogItem(theDialog, 14, blackColor);
break;
case 8: // left
FrameOvalDialogItem(theDialog, 11);
FrameOvalDialogItem(theDialog, 12);
FrameOvalDialogItem(theDialog, 13);
FrameOvalDialogItem(theDialog, 11, blackColor);
FrameOvalDialogItem(theDialog, 12, blackColor);
FrameOvalDialogItem(theDialog, 13, blackColor);
EraseDialogItem(theDialog, 14);
break;
}
@@ -732,7 +737,7 @@ void DoBlowerObjectInfo (short what)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kBlowerInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
SetPort(infoDial->GetWindow()->GetDrawSurface());
newDirection = thisRoom->objects[objActive].data.a.vector & 0x0F;
if (thisRoom->objects[objActive].data.a.initial)
@@ -1349,7 +1354,7 @@ void DoLightObjectInfo (void)
infoDial = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kLightInfoDialogID, kPutInFront, &substitutions);
if (infoDial == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&infoDial->GetWindow()->GetDrawSurface()->m_port);
SetPort(infoDial->GetWindow()->GetDrawSurface());
if (thisRoom->objects[objActive].data.f.initial)
SetDialogItemValue(infoDial, kInitialStateCheckbox, 1);

View File

@@ -14,6 +14,7 @@
#include "House.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "Scoreboard.h"
@@ -136,19 +137,21 @@ void NewGame (short mode)
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();
PortabilityLayer::ResolveCachingColor blackColorMain = StdColors::Black();
tempRect = thisMac.constrainedScreen;
tempRect.top = tempRect.bottom - 20; // thisMac.menuHigh
mainWindowSurface->FillRect(tempRect);
mainWindowSurface->FillRect(tempRect, blackColorMain);
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie))
{
theMovie.m_surface = &mainWindow->m_surface;
theMovie.m_surface = mainWindow->GetDrawSurface();
}
#endif
workSrcMap->SetForeColor(StdColors::Black());
workSrcMap->FillRect(workSrcRect);
PortabilityLayer::ResolveCachingColor blackColorWork = StdColors::Black();
workSrcMap->FillRect(workSrcRect, blackColorWork);
// if (quickerTransitions)
// DissBitsChunky(&workSrcRect);
// else
@@ -374,7 +377,7 @@ void HandleGameResolutionChange(void)
OpenMainWindow();
if (hasMovie)
theMovie.m_surface = &mainWindow->m_surface;
theMovie.m_surface = mainWindow->GetDrawSurface();
ResetLocale(true);
InitScoreboardMap();
@@ -752,8 +755,8 @@ void RestoreEntireGameScreen (void)
DrawSurface *surface = mainWindow->GetDrawSurface();
tempRect = thisMac.constrainedScreen;
surface->SetForeColor(StdColors::Black());
surface->FillRect(tempRect);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->FillRect(tempRect, blackColor);
ResetLocale(false);
RefreshScoreboard(kNormalTitleMode);

View File

@@ -16,7 +16,7 @@
// Given the top left corner and a width and height, this functionÉ
// simply creates the necessary rectangle and frames it.
void FrameWHRect (DrawSurface *surface, short left, short top, short wide, short high)
void FrameWHRect (DrawSurface *surface, short left, short top, short wide, short high, PortabilityLayer::ResolveCachingColor &color)
{
Rect theRect;
@@ -24,7 +24,7 @@ void FrameWHRect (DrawSurface *surface, short left, short top, short wide, short
theRect.top = top;
theRect.right = left + wide;
theRect.bottom = top + high;
surface->FrameRect(theRect);
surface->FrameRect(theRect, color);
}
//-------------------------------------------------------------- NormalizeRect

View File

@@ -10,8 +10,13 @@
#include "PLQDraw.h"
namespace PortabilityLayer
{
class ResolveCachingColor;
}
void FrameWHRect (short, short, short, short);
void FrameWHRect (short, short, short, short, PortabilityLayer::ResolveCachingColor &color);
void NormalizeRect (Rect *);
void ZeroRectCorner (Rect *);
void CenterRectOnPoint (Rect *, Point);

View File

@@ -147,7 +147,7 @@ void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
dest = thisGlider->dest;
QOffsetRect(&dest, playOriginH - 20, playOriginV - 16);
SetPort(&workSrcMap->m_port);
SetPort(workSrcMap);
long numMirrorRects = GetHandleSize(mirrorRects.StaticCast<void>()) / sizeof(Rect);
@@ -612,7 +612,7 @@ void CopyRectsQD (void)
{
short i;
DrawSurface *mainWindowGraf = GetWindowPort(mainWindow);
DrawSurface *mainWindowGraf = mainWindow->GetDrawSurface();
for (i = 0; i < numWork2Main; i++)
{
@@ -713,7 +713,7 @@ void CopyRectWorkToBack (Rect *theRect)
void CopyRectWorkToMain (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
theRect, theRect, srcCopy);
}
@@ -721,7 +721,7 @@ void CopyRectWorkToMain (Rect *theRect)
void CopyRectMainToWork (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
CopyBits(GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
(BitMap *)*GetGWorldPixMap(workSrcMap),
theRect, theRect, srcCopy);
}
@@ -730,7 +730,7 @@ void CopyRectMainToWork (Rect *theRect)
void CopyRectMainToBack (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
CopyBits(GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
(BitMap *)*GetGWorldPixMap(backSrcMap),
theRect, theRect, srcCopy);
}

View File

@@ -18,6 +18,7 @@
#include "MainWindow.h"
#include "MemoryManager.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#define kDeleteRoomAlert 1005
@@ -246,16 +247,18 @@ void ReadyBackground (short theID, short *theTiles)
if ((noRoomAtAll) || (!houseUnlocked))
{
LtGrayForeColor(workSrcMap);
workSrcMap->FillRect(workSrcRect);
workSrcMap->SetForeColor(StdColors::Black());
workSrcMap->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::ResolveCachingColor ltGrayColor = LtGrayForeColor();
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
workSrcMap->FillRect(workSrcRect, ltGrayColor);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
const Point textPoint = Point::Create(10, 20);
if (houseUnlocked)
workSrcMap->DrawString(textPoint, PSTR("No rooms"), true);
workSrcMap->DrawString(textPoint, PSTR("No rooms"), blackColor, appFont);
else
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"), true);
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"), blackColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),

View File

@@ -11,6 +11,7 @@
#include "Environ.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "Room.h"
#include "BitmapImage.h"
@@ -82,8 +83,8 @@ void ResetLocale (Boolean soft)
DrawSurface *wasCPort = GetGraphicsPort();
const short roomV = (*thisHouse)->rooms[thisRoomNumber].floor;
backSrcMap->SetForeColor(StdColors::Black());
backSrcMap->FillRect(backSrcRect);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FillRect(backSrcRect, blackColor);
if (numNeighbors > 3)
{
@@ -185,8 +186,8 @@ void DrawRoomBackground (short who, short where, short elevation)
if ((numLights == 0) && (who != kRoomIsEmpty))
{
backSrcMap->SetForeColor(StdColors::Black());
backSrcMap->FillRect(localRoomsDest[where]);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FillRect(localRoomsDest[where], blackColor);
return;
}
@@ -195,8 +196,8 @@ void DrawRoomBackground (short who, short where, short elevation)
{
if (wardBitSet)
{
backSrcMap->SetForeColor(StdColors::Black());
backSrcMap->FillRect(localRoomsDest[where]);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
backSrcMap->FillRect(localRoomsDest[where], blackColor);
return;
}

View File

@@ -20,6 +20,7 @@
#include "PLPopupMenuWidget.h"
#include "PLTimeTaggedVOSEvent.h"
#include "QDPixMap.h"
#include "ResolveCachingColor.h"
#include "ResourceCompiledRef.h"
#include "ResourceManager.h"
#include "Utilities.h"
@@ -117,11 +118,13 @@ void UpdateRoomInfoDialog (Dialog *theDialog)
SetDialogString(theDialog, kLitUnlitText, PSTR("(Room Is Dark)"));
else
SetDialogString(theDialog, kLitUnlitText, PSTR("(Room Is Lit)"));
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
FrameDialogItemC(theDialog, kRoomLocationBox, kRedOrangeColor8);
FrameDialogItem(theDialog, kRoomTilesBox);
FrameDialogItem(theDialog, kRoomTilesBox, blackColor);
FrameDialogItemC(theDialog, kRoomDividerLine, kRedOrangeColor8);
FrameDialogItem(theDialog, kRoomTilesBox2);
FrameDialogItem(theDialog, kRoomTilesBox2, blackColor);
}
#endif
@@ -134,6 +137,9 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
Point mouseWas;
short wasTileOver;
Pattern dummyPattern;
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor blueColor = StdColors::Blue();
tileOver = (mouseIs.h - tileSrc.left) / kMiniTileWide;
wasTileOver = -1;
@@ -161,14 +167,13 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
*newTileOver = (mouseIs.h - tileDest.left) / kMiniTileWide;
if (*newTileOver != wasTileOver)
{
surface->SetForeColor(StdColors::Blue());
for (int offset = 0; offset < 2; offset++)
{
Point pointA = Point::Create(tileDest.left + (*newTileOver * kMiniTileWide), tileDest.top - 3 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, blueColor);
}
for (int offset = 0; offset < 2; offset++)
@@ -176,19 +181,17 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
Point pointA = Point::Create(tileDest.left + (*newTileOver * kMiniTileWide), tileDest.bottom + 1 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, blueColor);
}
if (wasTileOver != -1)
{
surface->SetForeColor(StdColors::White());
for (int offset = 0; offset < 2; offset++)
{
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.top - 3 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
for (int offset = 0; offset < 2; offset++)
@@ -196,7 +199,7 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.bottom + 1 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
}
@@ -208,14 +211,12 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
*newTileOver = -1; // we're not in the drop zone
if (wasTileOver != -1)
{
surface->SetForeColor(StdColors::White());
for (int offset = 0; offset < 2; offset++)
{
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.top - 3 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
for (int offset = 0; offset < 2; offset++)
@@ -223,7 +224,7 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.bottom + 1 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
wasTileOver = -1;
@@ -235,14 +236,12 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
}
if (wasTileOver != -1)
{
surface->SetForeColor(StdColors::White());
for (int offset = 0; offset < 2; offset++)
{
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.top - 3 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
for (int offset = 0; offset < 2; offset++)
@@ -250,7 +249,7 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
Point pointA = Point::Create(tileDest.left + (wasTileOver * kMiniTileWide), tileDest.bottom + 1 + offset);
Point pointB = Point::Create(pointA.h + kMiniTileWide, pointA.v);
surface->DrawLine(pointA, pointB);
surface->DrawLine(pointA, pointB, whiteColor);
}
wasTileOver = -1;
@@ -265,6 +264,8 @@ void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *n
void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
short newTileOver;
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
if (tileSrc.Contains(mouseIs))
{
@@ -277,33 +278,27 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
newTileOver = (mouseIs.h - tileSrc.left) / kMiniTileWide;
if (newTileOver != tileOver)
{
surface->SetForeColor(StdColors::Red());
{
const Point tileLineTopLeft = Point::Create(tileSrc.left + (newTileOver * kMiniTileWide), tileSrc.top - 3);
const Point tileLineBottomRight = Point::Create(tileLineTopLeft.h + kMiniTileWide + 1, tileLineTopLeft.v + 2);
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h));
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h), redColor);
}
if (tileOver != -1)
{
surface->SetForeColor(StdColors::White());
{
const Point tileLineTopLeft = Point::Create(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.top - 3);
const Point tileLineBottomRight = Point::Create(tileLineTopLeft.h + kMiniTileWide + 1, tileLineTopLeft.v + 2);
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h));
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h), whiteColor);
}
{
const Point tileLineTopLeft = Point::Create(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.bottom + 1);
const Point tileLineBottomRight = Point::Create(tileLineTopLeft.h + kMiniTileWide + 1, tileLineTopLeft.v + 2);
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h));
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h), whiteColor);
}
}
surface->SetForeColor(StdColors::Black());
tileOver = newTileOver;
}
}
@@ -311,21 +306,18 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
if (tileOver != -1)
{
surface->SetForeColor(StdColors::White());
{
const Point tileLineTopLeft = Point::Create(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.top - 3);
const Point tileLineBottomRight = Point::Create(tileLineTopLeft.h + kMiniTileWide + 1, tileLineTopLeft.v + 2);
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h));
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h), whiteColor);
}
{
const Point tileLineTopLeft = Point::Create(tileSrc.left + (tileOver * kMiniTileWide), tileSrc.bottom + 1);
const Point tileLineBottomRight = Point::Create(tileLineTopLeft.h + kMiniTileWide + 1, tileLineTopLeft.v + 2);
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h));
surface->FillRect(Rect::Create(tileLineTopLeft.v, tileLineTopLeft.h, tileLineBottomRight.v, tileLineBottomRight.h), whiteColor);
}
surface->SetForeColor(StdColors::Black());
tileOver = -1;
}
@@ -391,7 +383,7 @@ int16_t RoomFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
if (evt->IsLMouseDownEvent())
{
mouseIs = Point::Create(mouseEvent.m_x, mouseEvent.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if (tileSrc.Contains(mouseIs))
{
if (StillDown())
@@ -465,7 +457,7 @@ void DoRoomInfo(void)
roomInfoDialog = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kRoomInfoDialogID, kPutInFront, &substitutions);
if (roomInfoDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetPort(&roomInfoDialog->GetWindow()->GetDrawSurface()->m_port);
SetPort(roomInfoDialog->GetWindow()->GetDrawSurface());
{
PortabilityLayer::WidgetBasicState state;
@@ -681,7 +673,7 @@ int16_t OriginalArtFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
const GpMouseInputEvent &mouseEvt = evt->m_vosEvent.m_event.m_mouseInputEvent;
mouseIs = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if (leftBound.Contains(mouseIs))
return 7;
else if (topBound.Contains(mouseIs))

View File

@@ -10,10 +10,14 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "MenuManager.h"
#include "PLStandardColors.h"
#include "QDPixMap.h"
#include "QDStandardPalette.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#define kGrayBackgroundColor 251
@@ -56,7 +60,7 @@ extern Boolean evenFrame, onePlayerLeft;
void MarkScoreboardPortDirty(void)
{
GetWindowPort(boardWindow)->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
boardWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- RefreshScoreboard
@@ -71,7 +75,7 @@ void RefreshScoreboard (SInt16 mode)
RefreshPoints();
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardSrcRect, &boardDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -153,48 +157,44 @@ void RefreshRoomTitle (short mode)
{
DrawSurface *surface = boardTSrcMap;
PortabilityLayer::RGBAColor theRGBColor, wasColor;
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
wasColor = surface->GetForeColor();
theRGBColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[kGrayBackgroundColor];
surface->SetForeColor(theRGBColor);
surface->FillRect(boardTSrcRect);
surface->SetForeColor(wasColor);
surface->FillRect(boardTSrcRect, theRGBColor);
const Point strShadowPoint = Point::Create(1, 10);
const Point strPoint = Point::Create(0, 9);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
switch (mode)
{
case kEscapedTitleMode:
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"), true);
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"), blackColor, appFont);
break;
case kSavingTitleMode:
surface->DrawString(strShadowPoint, PSTR("Saving GameÉ"), true);
surface->DrawString(strShadowPoint, PSTR("Saving GameÉ"), blackColor, appFont);
break;
default:
surface->DrawString(strShadowPoint, thisRoom->name, true);
surface->DrawString(strShadowPoint, thisRoom->name, blackColor, appFont);
break;
}
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
switch (mode)
{
case kEscapedTitleMode:
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"), true);
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"), whiteColor, appFont);
break;
case kSavingTitleMode:
surface->DrawString(strPoint, PSTR("Saving GameÉ"), true);
surface->DrawString(strPoint, PSTR("Saving GameÉ"), whiteColor, appFont);
break;
default:
surface->DrawString(strPoint, thisRoom->name, true);
surface->DrawString(strPoint, thisRoom->name, whiteColor, appFont);
break;
}
@@ -207,16 +207,17 @@ void RefreshRoomTitle (short mode)
void RefreshNumGliders (void)
{
PortabilityLayer::RGBAColor theRGBColor, wasColor;
Str255 nGlidersStr;
long displayMortals;
DrawSurface *surface = boardGSrcMap;
theRGBColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[kGrayBackgroundColor];
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
wasColor = surface->GetForeColor();
surface->SetForeColor(theRGBColor);
surface->FillRect(boardGSrcRect);
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(boardGSrcRect, theRGBColor);
displayMortals = mortals;
if (displayMortals < 0)
@@ -226,11 +227,8 @@ void RefreshNumGliders (void)
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
surface->DrawString(shadowPoint, nGlidersStr, true);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textPoint, nGlidersStr, true);
surface->DrawString(shadowPoint, nGlidersStr, blackColor, appFont);
surface->DrawString(textPoint, nGlidersStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
@@ -241,25 +239,24 @@ void RefreshNumGliders (void)
void RefreshPoints (void)
{
PortabilityLayer::RGBAColor theRGBColor, wasColor;
Str255 scoreStr;
DrawSurface *surface = boardPSrcMap;
theRGBColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[kGrayBackgroundColor];
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->SetForeColor(theRGBColor);
surface->FillRect(boardPSrcRect);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardPSrcRect, theRGBColor);
NumToString(theScore, scoreStr);
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
surface->DrawString(shadowPoint, scoreStr, true);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textPoint, scoreStr, true);
surface->DrawString(shadowPoint, scoreStr, blackColor, appFont);
surface->DrawString(textPoint, scoreStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
@@ -272,28 +269,27 @@ void RefreshPoints (void)
void QuickGlidersRefresh (void)
{
PortabilityLayer::RGBAColor theRGBColor, wasColor;
Str255 nGlidersStr;
DrawSurface *surface = boardGSrcMap;
theRGBColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[kGrayBackgroundColor];
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->SetForeColor(theRGBColor);
surface->FillRect(boardGSrcRect);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardGSrcRect, theRGBColor);
NumToString((long)mortals, nGlidersStr);
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
surface->DrawString(shadowPoint, nGlidersStr, true);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textPoint, nGlidersStr, true);
surface->DrawString(shadowPoint, nGlidersStr, blackColor, appFont);
surface->DrawString(textPoint, nGlidersStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardGSrcRect, &boardGQDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -303,27 +299,27 @@ void QuickGlidersRefresh (void)
void QuickScoreRefresh (void)
{
PortabilityLayer::RGBAColor theRGBColor, wasColor;
Str255 scoreStr;
DrawSurface *surface = boardPSrcMap;
theRGBColor = PortabilityLayer::StandardPalette::GetInstance()->GetColors()[kGrayBackgroundColor];
surface->SetForeColor(theRGBColor);
surface->FillRect(boardPSrcRect);
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardPSrcRect, theRGBColor);
NumToString(displayedScore, scoreStr);
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
surface->DrawString(shadowPoint, scoreStr, true);
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
surface->DrawString(textPoint, scoreStr, true);
surface->DrawString(shadowPoint, scoreStr, blackColor, appFont);
surface->DrawString(textPoint, scoreStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardPSrcRect, &boardPQDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -336,7 +332,7 @@ void QuickBatteryRefresh (Boolean flash)
if ((batteryTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy);
@@ -344,7 +340,7 @@ void QuickBatteryRefresh (Boolean flash)
else if ((batteryTotal < 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kHeliumBadge],
&badgesDestRects[kHeliumBadge],
srcCopy);
@@ -352,7 +348,7 @@ void QuickBatteryRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy);
@@ -368,7 +364,7 @@ void QuickBandsRefresh (Boolean flash)
if ((bandsTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy);
@@ -376,7 +372,7 @@ void QuickBandsRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy);
@@ -392,7 +388,7 @@ void QuickFoilRefresh (Boolean flash)
if ((foilTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy);
@@ -400,7 +396,7 @@ void QuickFoilRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy);

View File

@@ -17,6 +17,7 @@
#include "FileManager.h"
#include "House.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "ResourceFile.h"
#include "ResourceManager.h"
#include "PLTimeTaggedVOSEvent.h"
@@ -157,9 +158,8 @@ void PageUpHouses (Dialog *theDial)
QSetRect(&tempRect, 8, 39, 421, 223);
surface->SetForeColor(StdColors::White());
surface->FillRect(tempRect);
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(tempRect, whiteColor);
UpdateLoadDialog(theDial);
}
@@ -191,9 +191,8 @@ void PageDownHouses (Dialog *theDial)
}
QSetRect(&tempRect, 8, 39, 421, 223);
surface->SetForeColor(StdColors::White());
surface->FillRect(tempRect);
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(tempRect, whiteColor);
UpdateLoadDialog(theDial);
}

View File

@@ -12,6 +12,7 @@
#include "PLTextUtils.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#include "ResolveCachingColor.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Externs.h"
@@ -348,27 +349,26 @@ void UpdateSettingsControl (Dialog *theDialog)
{
short i;
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
for (i = 0; i < 4; i++)
{
Rect rect = controlRects[i];
surface->FrameRect(rect);
surface->FrameRect(rect, whiteColor);
InsetRect(&rect, 1, 1);
surface->FrameRect(rect);
surface->FrameRect(rect, whiteColor);
}
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 0, 0, 255));
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
{
Rect rect = controlRects[whichCtrl];
surface->FrameRect(rect);
surface->FrameRect(rect, redColor);
InsetRect(&rect, 1, 1);
surface->FrameRect(rect);
surface->FrameRect(rect, redColor);
}
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
UpdateControlKeyName(theDialog);
FrameDialogItemC(theDialog, 3, kRedOrangeColor8);
}
@@ -494,7 +494,7 @@ void DoControlPrefs (void)
prefDlg = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kControlPrefsDialID, kPutInFront, nullptr);
if (prefDlg == nil)
RedAlert(kErrDialogDidntLoad);
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
for (i = 0; i < 4; i++)
{
GetDialogItemRect(prefDlg, i + kRightControl, &controlRects[i]);
@@ -555,18 +555,20 @@ void DoControlPrefs (void)
{
Rect ctrlRect = controlRects[whichCtrl];
surface->SetForeColor(StdColors::White());
surface->FrameRect(ctrlRect);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FrameRect(ctrlRect, whiteColor);
InsetRect(&ctrlRect, 1, 1);
surface->FrameRect(ctrlRect);
surface->FrameRect(ctrlRect, whiteColor);
whichCtrl = itemHit - kRightControl;
ctrlRect = controlRects[whichCtrl];
surface->SetForeColor(StdColors::Red());
surface->FrameRect(ctrlRect);
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
surface->FrameRect(ctrlRect, redColor);
InsetRect(&ctrlRect, 1, 1);
surface->FrameRect(ctrlRect);
surface->FrameRect(ctrlRect, redColor);
}
UpdateControlKeyName(prefDlg);
@@ -887,17 +889,15 @@ void FrameDisplayIcon (Dialog *theDialog, const PortabilityLayer::RGBAColor &col
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
surface->SetForeColor(color);
PortabilityLayer::ResolveCachingColor cacheColor = color;
theRect.left -= 3;
theRect.top += 0;
theRect.right += 3;
theRect.bottom -= 1;
surface->FrameRect(theRect);
surface->FrameRect(theRect, cacheColor);
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
surface->SetForeColor(StdColors::Black());
surface->FrameRect(theRect, cacheColor);
}
//-------------------------------------------------------------- DisplayUpdate
@@ -1204,7 +1204,7 @@ int16_t PrefsFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
const Window *window = dial->GetWindow();
const GpMouseInputEvent &mouseEvent = evt->m_vosEvent.m_event.m_mouseInputEvent;
const Point testPt = Point::Create(mouseEvent.m_x - window->m_wmX, mouseEvent.m_y - window->m_wmY);
const Point testPt = window->MouseToLocal(evt->m_vosEvent.m_event.m_mouseInputEvent);
int16_t hitCode = -1;
@@ -1263,20 +1263,20 @@ void DoSettingsMain (void)
case kDisplayButton:
FlashSettingsButton(surface, 0);
DoDisplayPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kSoundButton:
FlashSettingsButton(surface, 1);
DoSoundPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
FlushEvents(everyEvent, 0);
break;
case kControlsButton:
FlashSettingsButton(surface, 2);
DoControlPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kBrainsButton:
@@ -1288,7 +1288,7 @@ void DoSettingsMain (void)
}
FlashSettingsButton(surface, 3);
DoBrainsPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kAllDefaultsButton:

View File

@@ -7,6 +7,7 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "RenderedFont.h"
#include <string.h>
@@ -275,17 +276,17 @@ void GetFirstWordOfString (StringPtr stringIn, StringPtr stringOut)
// font. If the text would exceed our width limit, charactersÉ
// are dropped off the end of the string and "É" appended.
void CollapseStringToWidth (DrawSurface *surface, StringPtr theStr, short wide)
void CollapseStringToWidth (PortabilityLayer::RenderedFont *font, StringPtr theStr, short wide)
{
short dotsWide;
Boolean tooWide;
dotsWide = surface->MeasureString(PSTR("É"));
tooWide = surface->MeasureString(theStr) > wide;
while (tooWide)
dotsWide = font->MeasurePStr(PSTR("É"));
tooWide = font->MeasurePStr(theStr) > wide;
while (tooWide && theStr[0] > 0)
{
theStr[0]--;
tooWide = ((surface->MeasureString(theStr) + dotsWide) > wide);
tooWide = ((font->MeasurePStr(theStr) + dotsWide) > wide);
if (!tooWide)
PasStringConcat(theStr, PSTR("É"));
}

View File

@@ -105,7 +105,6 @@ void InitScoreboardMap(void)
if (!boardTSrcMap)
{
theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredPixelFormat);
boardTSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardTDestRect = boardTSrcRect;
QOffsetRect(&boardTDestRect, 137 + hOffset, 5);
@@ -114,7 +113,6 @@ void InitScoreboardMap(void)
if (!boardGSrcMap)
{
theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredPixelFormat);
boardGSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardGDestRect = boardGSrcRect;
QOffsetRect(&boardGDestRect, 526 + hOffset, 5);
@@ -124,7 +122,6 @@ void InitScoreboardMap(void)
if (!boardPSrcMap)
{
theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredPixelFormat);
boardPSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardPDestRect = boardPSrcRect;
QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels

View File

@@ -16,6 +16,7 @@
#include "PLPopupMenuWidget.h"
#include "QDPixMap.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
#include "WindowDef.h"
#include "WindowManager.h"
@@ -129,13 +130,12 @@ void FrameSelectedTool (DrawSurface *surface)
}
theRect = toolRects[toolIcon];
surface->SetForeColor(StdColors::Red());
surface->FrameRect(theRect);
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
surface->FrameRect(theRect, redColor);
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
surface->SetForeColor(StdColors::Black());
surface->FrameRect(theRect, redColor);
}
#endif
@@ -152,14 +152,13 @@ void DrawToolName (DrawSurface *surface)
GetIndString(theString, kObjectNameStrings,
toolSelected + ((toolMode - 1) * 0x0010));
surface->SetForeColor(StdColors::White());
surface->FillRect(toolTextRect);
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(toolTextRect, whiteColor);
const Point textPoint = Point::Create(toolTextRect.left + 3, toolTextRect.bottom - 6);
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
ColorText(surface, textPoint, theString, 171L);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
ColorText(surface, textPoint, theString, 171L, appFont);
}
#endif
@@ -182,7 +181,7 @@ void DrawToolTiles (DrawSurface *surface)
QOffsetRect(&destRect, toolRects[i + 1].left + 2, toolRects[i + 1].top + 2);
CopyBits((BitMap *)*GetGWorldPixMap(toolSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(toolsWindow)),
GetPortBitMapForCopyBits(toolsWindow->GetDrawSurface()),
&srcRect, &destRect, srcCopy);
}
}
@@ -200,7 +199,7 @@ void EraseSelectedTool (void)
if (toolsWindow == nil)
return;
SetPort(&toolsWindow->GetDrawSurface()->m_port);
SetPort(toolsWindow->GetDrawSurface());
toolIcon = toolSelected;
if ((toolMode == kBlowerMode) && (toolIcon >= 7))
@@ -216,10 +215,11 @@ void EraseSelectedTool (void)
}
theRect = toolRects[toolIcon];
surface->SetForeColor(StdColors::White());
surface->FrameRect(theRect);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FrameRect(theRect, whiteColor);
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
surface->FrameRect(theRect, whiteColor);
#endif
}
@@ -250,11 +250,12 @@ void SelectTool (short which)
}
theRect = toolRects[toolIcon];
surface->SetForeColor(StdColors::Red());
surface->FrameRect(theRect);
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
surface->FrameRect(theRect, redColor);
InsetRect(&theRect, 1, 1);
surface->FrameRect(theRect);
surface->FrameRect(theRect, redColor);
toolSelected = which;
DrawToolName(surface);
@@ -271,9 +272,8 @@ void UpdateToolsWindow (void)
DrawSurface *surface = toolsWindow->GetDrawSurface();
DkGrayForeColor(surface);
surface->DrawLine(Point::Create(4, 25), Point::Create(112, 25));
surface->SetForeColor(StdColors::Black());
PortabilityLayer::ResolveCachingColor lineColor = DkGrayForeColor();
surface->DrawLine(Point::Create(4, 25), Point::Create(112, 25), lineColor);
DrawToolTiles(surface);
FrameSelectedTool(surface);
@@ -472,7 +472,7 @@ void HandleToolsClick (Point wherePt)
return;
SetPortWindowPort(toolsWindow);
wherePt -= toolsWindow->TopLeftCoord();
wherePt -= toolsWindow->GetTopLeftCoord();
part = FindControl(wherePt, toolsWindow, &theControl);
if ((theControl != nil) && (part != 0))

View File

@@ -57,7 +57,7 @@ void PourScreenOn (Rect *theRect)
columnRects[i].bottom = theRect->bottom;
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&columnRects[i], &columnRects[i], srcCopy);
QOffsetRect(&columnRects[i], 0, kChipHigh);
@@ -115,7 +115,7 @@ void WipeScreenOn (short direction, Rect *theRect)
for (i = 0; i < count; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&wipeRect, &wipeRect, srcCopy);
QOffsetRect(&wipeRect, hOffset, vOffset);
@@ -135,7 +135,7 @@ void WipeScreenOn (short direction, Rect *theRect)
void DumpScreenOn (Rect *theRect)
{
DrawSurface *graf = GetWindowPort(mainWindow);
DrawSurface *graf = mainWindow->GetDrawSurface();
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(graf),

View File

@@ -8,8 +8,10 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
#include "WindowDef.h"
#include "WindowManager.h"
@@ -36,8 +38,9 @@ void GetWindowLeftTop (WindowPtr theWindow, short *left, short *top)
}
else
{
*left = static_cast<short>(theWindow->m_wmX);
*top = static_cast<short>(theWindow->m_wmY);
const Point windowPos = theWindow->GetTopLeftCoord();
*left = windowPos.h;
*top = windowPos.v;
}
}
@@ -51,7 +54,7 @@ void GetWindowRect (WindowPtr theWindow, Rect *bounds)
{
Point upperLeft;
GetWindowLeftTop(theWindow, &upperLeft.h, &upperLeft.v);
*bounds = theWindow->m_surface.m_port.GetRect() + upperLeft;
*bounds = theWindow->GetSurfaceRect() + upperLeft;
}
}
@@ -123,12 +126,6 @@ void OpenMessageWindow (const PLPasStr &title)
ShowWindow(mssgWindow);
DrawSurface *surface = mssgWindow->GetDrawSurface();
surface->SetClipRect(mssgWindowRect);
surface->SetForeColor(StdColors::Black());
surface->SetBackColor(StdColors::White());
surface->SetSystemFont(12, 0);
}
mssgWindowExclusiveStack = mssgWindow;
@@ -152,14 +149,18 @@ void SetMessageWindowMessage (StringPtr message, const PortabilityLayer::RGBACol
{
DrawSurface *surface = mssgWindow->GetDrawSurface();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
InsetRect(&mssgWindowRect, 16, 16);
surface->SetForeColor(StdColors::White());
surface->FillRect(mssgWindowRect);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(mssgWindowRect, whiteColor);
const Point textPoint = Point::Create(mssgWindowRect.left, mssgWindowRect.bottom - 6);
surface->SetForeColor(color);
surface->DrawString(textPoint, message, true);
PortabilityLayer::ResolveCachingColor specifiedColor = color;
surface->DrawString(textPoint, message, specifiedColor, sysFont);
}
}

View File

@@ -16,6 +16,7 @@ struct GpDisplayDriverSurfaceEffects
int32_t m_flickerAxisY;
int32_t m_flickerStartThreshold;
int32_t m_flickerEndThreshold;
float m_desaturation;
};
// Display drivers are responsible for timing and calling the game tick function.
@@ -48,5 +49,6 @@ inline GpDisplayDriverSurfaceEffects::GpDisplayDriverSurfaceEffects()
, m_flickerAxisY(0)
, m_flickerStartThreshold(0)
, m_flickerEndThreshold(0)
, m_desaturation(0)
{
}

View File

@@ -1,10 +1,10 @@
static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 16, 112, 155, 167, 152, 216, 111, 160, 194, 37, 151,
206, 26, 38, 150, 132, 1, 0, 0, 0, 140, 5, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 48, 2, 0, 0, 136, 2, 0, 0, 188,
2, 0, 0, 16, 5, 0, 0, 82, 68, 69, 70, 244, 1, 0, 0,
68, 88, 66, 67, 123, 171, 231, 206, 83, 178, 250, 149, 189, 168, 129,
29, 12, 186, 195, 194, 1, 0, 0, 0, 24, 9, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 172, 2, 0, 0, 4, 3, 0, 0, 56,
3, 0, 0, 156, 8, 0, 0, 82, 68, 69, 70, 112, 2, 0, 0,
1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 202, 1, 0, 0, 124, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 72, 2, 0, 0, 124, 0,
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
139, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0,
@@ -15,85 +15,146 @@ static unsigned char gs_shaderData[] = {
117, 114, 101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116,
117, 114, 101, 0, 83, 68, 114, 97, 119, 81, 117, 97, 100, 80, 105,
120, 101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171,
154, 0, 0, 0, 4, 0, 0, 0, 204, 0, 0, 0, 32, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0,
0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 68, 1, 0, 0, 0,
0, 0, 0, 84, 1, 0, 0, 16, 0, 0, 0, 8, 0, 0, 0,
2, 0, 0, 0, 108, 1, 0, 0, 0, 0, 0, 0, 124, 1, 0,
0, 24, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 156, 1,
0, 0, 0, 0, 0, 0, 172, 1, 0, 0, 28, 0, 0, 0, 4,
0, 0, 0, 2, 0, 0, 0, 156, 1, 0, 0, 0, 0, 0, 0,
99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111, 100, 117, 108,
97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3, 0, 1, 0,
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116,
97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 65, 120, 105,
115, 0, 171, 171, 1, 0, 2, 0, 1, 0, 2, 0, 0, 0, 0,
0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95,
70, 108, 105, 99, 107, 101, 114, 83, 116, 97, 114, 116, 84, 104, 114,
101, 115, 104, 111, 108, 100, 0, 0, 0, 2, 0, 1, 0, 1, 0,
154, 0, 0, 0, 6, 0, 0, 0, 204, 0, 0, 0, 48, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 1, 0, 0, 0, 0,
0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 116, 1, 0, 0, 0,
0, 0, 0, 132, 1, 0, 0, 16, 0, 0, 0, 8, 0, 0, 0,
2, 0, 0, 0, 156, 1, 0, 0, 0, 0, 0, 0, 172, 1, 0,
0, 24, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 204, 1,
0, 0, 0, 0, 0, 0, 220, 1, 0, 0, 28, 0, 0, 0, 4,
0, 0, 0, 2, 0, 0, 0, 204, 1, 0, 0, 0, 0, 0, 0,
250, 1, 0, 0, 32, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0,
0, 20, 2, 0, 0, 0, 0, 0, 0, 36, 2, 0, 0, 36, 0,
0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 56, 2, 0, 0, 0,
0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111,
100, 117, 108, 97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3,
0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111,
110, 115, 116, 97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114,
65, 120, 105, 115, 0, 171, 171, 1, 0, 2, 0, 1, 0, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110,
116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 69, 110, 100, 84, 104,
114, 101, 115, 104, 111, 108, 100, 0, 77, 105, 99, 114, 111, 115, 111,
102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32, 83, 104, 97,
100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, 49, 48,
46, 49, 0, 171, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0,
171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0,
8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 83, 86,
95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72, 68, 82, 76,
2, 0, 0, 64, 0, 0, 0, 147, 0, 0, 0, 89, 0, 0, 4,
70, 142, 32, 0, 0, 0, 0, 0, 2, 0, 0, 0, 88, 24, 0,
4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68, 0, 0, 88, 16,
0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85, 85, 0, 0, 98,
16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2, 2, 0, 0,
0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 70, 16,
16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 0,
0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8,
194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0,
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 0,
0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8,
226, 0, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0,
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 1,
0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 54, 0, 0, 5,
130, 0, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128,
63, 56, 0, 0, 8, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14,
16, 0, 1, 0, 0, 0, 70, 142, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 38, 0, 0, 9, 0, 208, 0, 0, 50, 0, 16, 0,
0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 70, 128, 32,
0, 0, 0, 0, 0, 1, 0, 0, 0, 30, 0, 0, 7, 18, 0,
16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0, 0, 0, 0, 10,
0, 16, 0, 0, 0, 0, 0, 34, 0, 0, 8, 34, 0, 16, 0,
0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 42, 128, 32,
0, 0, 0, 0, 0, 1, 0, 0, 0, 33, 0, 0, 8, 18, 0,
16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 58,
128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0, 55, 0, 0, 12,
242, 0, 16, 0, 1, 0, 0, 0, 6, 0, 16, 0, 0, 0, 0,
0, 70, 14, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 0, 0,
128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 55,
0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0, 86, 5, 16, 0,
0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0,
0, 0, 29, 0, 0, 7, 18, 0, 16, 0, 1, 0, 0, 0, 1,
64, 0, 0, 0, 0, 0, 0, 58, 0, 16, 0, 0, 0, 0, 0,
13, 0, 4, 3, 10, 0, 16, 0, 1, 0, 0, 0, 54, 0, 0,
5, 242, 32, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 0, 0,
0, 0, 62, 0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 18,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 83, 116, 97, 114, 116,
84, 104, 114, 101, 115, 104, 111, 108, 100, 0, 0, 0, 2, 0, 1,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115,
116, 97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 69, 110,
100, 84, 104, 114, 101, 115, 104, 111, 108, 100, 0, 99, 111, 110, 115,
116, 97, 110, 116, 115, 95, 68, 101, 115, 97, 116, 117, 114, 97, 116,
105, 111, 110, 0, 171, 171, 171, 0, 0, 3, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110,
116, 115, 95, 85, 110, 117, 115, 101, 100, 0, 171, 171, 171, 1, 0,
3, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 76,
83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105,
108, 101, 114, 32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 80, 0,
0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86,
95, 80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79,
79, 82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0,
1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0,
0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83,
72, 68, 82, 92, 5, 0, 0, 64, 0, 0, 0, 87, 1, 0, 0,
89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 3, 0, 0,
0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68,
0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1, 0, 0, 0, 85,
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
2, 4, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50,
0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0,
54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70,
14, 16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0,
54, 0, 0, 8, 226, 0, 16, 0, 1, 0, 0, 0, 2, 64, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70,
14, 16, 0, 1, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0,
56, 0, 0, 9, 242, 0, 16, 0, 2, 0, 0, 0, 70, 142, 32,
0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 142, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130, 0, 16, 0, 1,
0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 56, 0, 0, 7,
242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
0, 70, 14, 16, 0, 2, 0, 0, 0, 38, 0, 0, 9, 0, 208,
0, 0, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0,
0, 0, 0, 70, 128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0,
30, 0, 0, 7, 18, 0, 16, 0, 0, 0, 0, 0, 26, 0, 16,
0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 34, 0,
0, 8, 34, 0, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0,
0, 0, 0, 42, 128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0,
33, 0, 0, 8, 18, 0, 16, 0, 0, 0, 0, 0, 10, 0, 16,
0, 0, 0, 0, 0, 58, 128, 32, 0, 0, 0, 0, 0, 1, 0,
0, 0, 55, 0, 0, 12, 242, 0, 16, 0, 1, 0, 0, 0, 86,
5, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 14, 16,
0, 1, 0, 0, 0, 60, 0, 0, 7, 18, 0, 16, 0, 0, 0,
0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0,
0, 0, 0, 55, 0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0,
6, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
0, 2, 64, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
128, 63, 0, 0, 128, 63, 57, 0, 0, 8, 18, 0, 16, 0, 1,
0, 0, 0, 10, 128, 32, 0, 0, 0, 0, 0, 2, 0, 0, 0,
1, 64, 0, 0, 0, 0, 0, 0, 31, 0, 4, 3, 10, 0, 16,
0, 1, 0, 0, 0, 29, 0, 0, 10, 114, 0, 16, 0, 1, 0,
0, 0, 2, 64, 0, 0, 28, 46, 77, 59, 28, 46, 77, 59, 28,
46, 77, 59, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 70, 2, 16,
0, 0, 0, 0, 0, 2, 64, 0, 0, 82, 184, 78, 65, 82, 184,
78, 65, 82, 184, 78, 65, 0, 0, 0, 0, 47, 0, 0, 5, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
0, 3, 0, 0, 0, 2, 64, 0, 0, 85, 85, 213, 62, 85, 85,
213, 62, 85, 85, 213, 62, 0, 0, 0, 0, 25, 0, 0, 5, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0, 0,
50, 0, 0, 15, 114, 0, 16, 0, 3, 0, 0, 0, 70, 2, 16,
0, 3, 0, 0, 0, 2, 64, 0, 0, 61, 10, 135, 63, 61, 10,
135, 63, 61, 10, 135, 63, 0, 0, 0, 0, 2, 64, 0, 0, 174,
71, 97, 189, 174, 71, 97, 189, 174, 71, 97, 189, 0, 0, 0, 0,
55, 0, 0, 9, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 2,
16, 0, 3, 0, 0, 0, 16, 0, 0, 10, 130, 0, 16, 0, 1,
0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0,
154, 153, 153, 62, 154, 153, 25, 63, 205, 204, 204, 61, 0, 0, 0,
0, 0, 0, 0, 9, 18, 0, 16, 0, 2, 0, 0, 0, 10, 128,
32, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1,
64, 0, 0, 0, 0, 128, 63, 56, 0, 0, 8, 130, 0, 16, 0,
1, 0, 0, 0, 58, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32,
0, 0, 0, 0, 0, 2, 0, 0, 0, 50, 0, 0, 9, 114, 0,
16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 6,
0, 16, 0, 2, 0, 0, 0, 246, 15, 16, 0, 1, 0, 0, 0,
29, 0, 0, 10, 114, 0, 16, 0, 2, 0, 0, 0, 2, 64, 0,
0, 230, 174, 37, 61, 230, 174, 37, 61, 230, 174, 37, 61, 0, 0,
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 56, 0, 0, 10, 114,
0, 16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
2, 64, 0, 0, 145, 131, 158, 61, 145, 131, 158, 61, 145, 131, 158,
61, 0, 0, 0, 0, 0, 0, 0, 10, 114, 0, 16, 0, 1, 0,
0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 174,
71, 97, 61, 174, 71, 97, 61, 174, 71, 97, 61, 0, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0, 2, 64, 0, 0, 110, 167, 114, 63, 110, 167,
114, 63, 110, 167, 114, 63, 0, 0, 0, 0, 47, 0, 0, 5, 114,
0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0, 2, 64, 0, 0, 154, 153, 25, 64, 154, 153,
25, 64, 154, 153, 25, 64, 0, 0, 0, 0, 25, 0, 0, 5, 114,
0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0,
55, 0, 0, 9, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16,
0, 2, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0, 0, 70, 2,
16, 0, 1, 0, 0, 0, 21, 0, 0, 1, 29, 0, 0, 7, 18,
0, 16, 0, 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0,
58, 0, 16, 0, 0, 0, 0, 0, 13, 0, 4, 3, 10, 0, 16,
0, 1, 0, 0, 0, 54, 0, 0, 5, 242, 32, 16, 0, 0, 0,
0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 62, 0, 0, 1, 83,
84, 65, 84, 116, 0, 0, 0, 42, 0, 0, 0, 4, 0, 0, 0,
0, 0, 0, 0, 2, 0, 0, 0, 22, 0, 0, 0, 4, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0,
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
};
namespace GpBinarizedShaders

View File

@@ -919,7 +919,7 @@ void GpDisplayDriverD3D11::Run()
RECT wr = { 0, 0, m_windowWidthPhysical, m_windowHeightPhysical };
AdjustWindowRect(&wr, windowStyle, menus != NULL);
m_osGlobals->m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W L" (Direct3D 11)", WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
m_osGlobals->m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W, WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
ShowWindow(m_osGlobals->m_hwnd, m_osGlobals->m_nCmdShow);
@@ -1094,6 +1094,8 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t
pConstantsData.m_flickerStart = -2;
}
pConstantsData.m_desaturation = effects->m_desaturation;
if (effects->m_darken)
for (int i = 0; i < 3; i++)
pConstantsData.m_modulation[i] = 0.5f;

View File

@@ -74,6 +74,9 @@ private:
int32_t m_flickerAxis[2];
int32_t m_flickerStart;
int32_t m_flickerEnd;
float m_desaturation;
float m_unused[3];
};
struct ScaleQuadPixelConstants

View File

@@ -8,5 +8,5 @@ Rect BitmapImage::GetRect() const
const uint32_t width = infoHeader->m_width;
const uint32_t height = infoHeader->m_height;
return Rect::Create(0, 0, static_cast<int16_t>(height), static_cast<int16_t>(width));
return Rect::Create(0, 0, static_cast<int16_t>(height), static_cast<int16_t>(width));
}

View File

@@ -511,11 +511,7 @@ namespace PortabilityLayer
Point DialogImpl::MouseToDialog(const GpMouseInputEvent &evt)
{
const Window *window = m_window;
const int32_t x = evt.m_x - window->m_wmX;
const int32_t y = evt.m_y - window->m_wmY;
return Point::Create(x, y);
return Point::Create(evt.m_x, evt.m_y) - m_window->GetTopLeftCoord();
}
void DialogImpl::MakeStringSubstitutions(uint8_t *outStr, const uint8_t *inStr, const DialogTextSubstitutions *substitutions)
@@ -843,7 +839,9 @@ namespace PortabilityLayer
const uint16_t dialogWidth = rect.Width();
const uint16_t dialogHeight = rect.Height();
window->m_wmX = (static_cast<int32_t>(displayWidth) - static_cast<int32_t>(dialogWidth)) / 2;
Vec2i newPosition;
newPosition.m_x = (static_cast<int32_t>(displayWidth) - static_cast<int32_t>(dialogWidth)) / 2;
// We center dialogs vertically in one of 3 ways in this priority:
// - Centered at 1/3 until the top edge is at the 1/4 mark
@@ -853,13 +851,15 @@ namespace PortabilityLayer
//if (displayHeight / 3 - dialogHeight / 2 >= displayHeight / 4)
if (static_cast<int32_t>(displayHeight * 4) - static_cast<int32_t>(dialogHeight * 6) >= static_cast<int32_t>(displayHeight * 3))
{
//window->m_wmY = displayHeight / 3 - dialogHeight / 2;
window->m_wmY = (static_cast<int32_t>(displayHeight * 2) - static_cast<int32_t>(dialogHeight * 3)) / 6;
//newPosition.m_y = displayHeight / 3 - dialogHeight / 2;
newPosition.m_y = (static_cast<int32_t>(displayHeight * 2) - static_cast<int32_t>(dialogHeight * 3)) / 6;
}
else if (dialogHeight * 2U <= displayHeight)
window->m_wmY = displayHeight / 4;
newPosition.m_y = displayHeight / 4;
else
window->m_wmY = (static_cast<int32_t>(displayHeight) - static_cast<int32_t>(dialogHeight)) / 2;
newPosition.m_y = (static_cast<int32_t>(displayHeight) - static_cast<int32_t>(dialogHeight)) / 2;
window->SetPosition(newPosition);
}
DialogManagerImpl *DialogManagerImpl::GetInstance()

View File

@@ -20,6 +20,7 @@
#include "QDManager.h"
#include "QDPixMap.h"
#include "RGBAColor.h"
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include <stdint.h>
@@ -810,44 +811,44 @@ namespace PortabilityLayer
SetGraphicsPort(m_menuBarGraf);
PortabilityLayer::QDState *qdState = qdManager->GetState();
ResolveCachingColor barMidColor = gs_barMidColor;
graf->SetForeColor(gs_barMidColor);
graf->FillRect(menuRect);
graf->SetForeColor(gs_barBrightColor);
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,29 +870,29 @@ 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);
m_menuBarGraf->SetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold);
ResolveCachingColor barNormalTextColor = gs_barNormalTextColor;
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
{
Menu **menuHdl = m_firstMenu;
@@ -913,7 +914,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)), barNormalTextColor, sysFont);
}
}
}
@@ -928,11 +929,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)), barHighlightTextColor, sysFont);
}
}
@@ -1371,24 +1373,24 @@ namespace PortabilityLayer
SetGraphicsPort(m_menuGraf);
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);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents);
@@ -1403,21 +1405,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), itemTextAndCheckColor, sysFont);
if (item.key)
{
@@ -1425,38 +1429,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)), itemTextAndCheckColor, sysFont);
}
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), barHighlightTextColor, sysFont);
if (item.key)
{
@@ -1464,10 +1469,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)), barHighlightTextColor, sysFont);
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

@@ -4,7 +4,11 @@
#include "PLRegions.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLStandardColors.h"
#include "PLQDraw.h"
#include "FontFamily.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "SimpleGraphic.h"
#include <algorithm>
@@ -410,39 +414,42 @@ 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);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(sysFont->MeasureString(reinterpret_cast<const uint8_t*>(m_text.UnsafeCharPtr()), m_text.Length()))) / 2;
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(sysFont->GetMetrics().m_ascent)) / 2;
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), textCacheColor, sysFont);
}
void ButtonWidget::DrawAsCheck(DrawSurface *surface, bool inverted)
@@ -450,57 +457,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 +514,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 +535,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);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
}
@@ -546,42 +546,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 +592,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);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
}
void ButtonWidget::DrawDefaultButtonChrome(const Rect &rectRef, DrawSurface *surface)
@@ -629,16 +628,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);
}
}
@@ -649,7 +648,7 @@ namespace PortabilityLayer
if (m_haveHighlightOverride != enabled)
{
m_haveHighlightOverride = enabled;
DrawControl(&m_window->m_surface);
DrawControl(m_window->GetDrawSurface());
}
}
}

View File

@@ -128,7 +128,7 @@ PortabilityLayer::Vec2i TrackResize(WindowPtr window, Point start, uint16_t minW
{
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
const Rect baseRect = window->m_surface.m_port.GetRect();
const Rect baseRect = window->GetSurfaceRect();
const PortabilityLayer::Vec2i baseSize = PortabilityLayer::Vec2i(baseRect.Width(), baseRect.Height());
const PortabilityLayer::Vec2i basePoint = PortabilityLayer::Vec2i(start.h, start.v);
@@ -498,14 +498,9 @@ void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL)
void GetMouse(Window *window, Point *point)
{
const PortabilityLayer::Vec2i mousePos = PortabilityLayer::InputManager::GetInstance()->GetMousePosition();
point->h = mousePos.m_x - window->m_wmX;
point->v = mousePos.m_y - window->m_wmY;
}
Boolean Button()
{
PL_NotYetImplemented();
return false;
const PortabilityLayer::Vec2i relativePos = mousePos - window->GetPosition();
point->h = relativePos.m_x;
point->v = relativePos.m_y;
}
Boolean StillDown()
@@ -691,9 +686,26 @@ Point Window::MouseToLocal(const GpMouseInputEvent &evt) const
return Point::Create(evt.m_x - m_wmX, evt.m_y - m_wmY);
}
Point Window::TopLeftCoord() const
Point Window::GetTopLeftCoord() const
{
return Point::Create(m_wmX, m_wmY);
const PortabilityLayer::Vec2i position = GetPosition();
return Point::Create(position.m_x, position.m_y);
}
Rect Window::GetSurfaceRect() const
{
return m_surface.m_port.GetRect();
}
void Window::SetPosition(const PortabilityLayer::Vec2i &pos)
{
m_wmX = pos.m_x;
m_wmY = pos.m_y;
}
PortabilityLayer::Vec2i Window::GetPosition() const
{
return PortabilityLayer::Vec2i(m_wmX, m_wmY);
}
bool Window::AddWidget(PortabilityLayer::Widget *widget)

View File

@@ -91,13 +91,17 @@ struct Window
{
Window();
DrawSurface *GetDrawSurface() const;
void SetPosition(const PortabilityLayer::Vec2i &pos);
PortabilityLayer::Vec2i GetPosition() const;
// Convenience method to convert a mouse event to local point
Point MouseToLocal(const GpMouseInputEvent &evt) const;
// Convenience method that returns a 16-bit precision X/Y
Point TopLeftCoord() const;
Point GetTopLeftCoord() const;
// Returns the bounds rect of the draw surface (which is always 0,0 based
Rect GetSurfaceRect() const;
bool AddWidget(PortabilityLayer::Widget *widget);
ArrayView<PortabilityLayer::Widget*> GetWidgets() const;
@@ -112,15 +116,9 @@ struct Window
void OnTick();
DrawSurface *GetDrawSurface() const;
DrawSurface *GetChromeSurface(WindowChromeSide_t aChromeSide) const;
DrawSurface m_surface; // Must be the first item until the immediate mode draw API is completely removed
// The port is always at 0,0
// These are the WM coordinates
int32_t m_wmX;
int32_t m_wmY;
protected:
~Window();
@@ -130,6 +128,13 @@ protected:
size_t m_numWidgets;
size_t m_numTickReceivingWidgets;
DrawSurface m_surface;
// The surface is always at 0,0
// These are the WM coordinates
int32_t m_wmX;
int32_t m_wmY;
PortabilityLayer::Widget *m_widgetWithFocus;
};

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

@@ -8,8 +8,10 @@
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "PLKeyEncoding.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include <algorithm>
@@ -59,18 +61,19 @@ 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();
int32_t lineGap = surface->MeasureFontLineGap();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
int32_t ascender = sysFont->GetMetrics().m_ascent;
int32_t lineGap = sysFont->GetMetrics().m_linegap;
const PLPasStr str = this->GetString();
@@ -83,22 +86,20 @@ namespace PortabilityLayer
Vec2i basePoint = ResolveBasePoint();
if (m_hasFocus && m_selStartChar != m_selEndChar)
DrawSelection(surface, basePoint);
DrawSelection(surface, basePoint, sysFont);
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(), blackColor, sysFont);
else
surface->DrawStringConstrained(stringBasePoint, this->GetString(), true, m_rect);
surface->DrawStringConstrained(stringBasePoint, this->GetString(), m_rect, blackColor, sysFont);
if (m_hasFocus && m_selEndChar == m_selStartChar && m_caratTimer < kCaratBlinkRate)
{
PortabilityLayer::Vec2i caratPos = ResolveCaratPos(basePoint, surface->ResolveFont(true));
PortabilityLayer::Vec2i caratPos = ResolveCaratPos(basePoint, sysFont);
int32_t caratTop = caratPos.m_y;
int32_t caratBottom = caratTop + lineGap;
@@ -107,7 +108,7 @@ namespace PortabilityLayer
caratRect = caratRect.Intersect(m_rect);
if (caratRect.IsValid())
surface->FillRect(caratRect);
surface->FillRect(caratRect, blackColor);
}
}
@@ -654,9 +655,8 @@ namespace PortabilityLayer
return WidgetHandleStates::kCaptured;
}
void EditboxWidget::DrawSelection(DrawSurface *surface, const Vec2i &basePoint) const
void EditboxWidget::DrawSelection(DrawSurface *surface, const Vec2i &basePoint, PortabilityLayer::RenderedFont *rfont) const
{
PortabilityLayer::RenderedFont *rfont = surface->ResolveFont(true);
PortabilityLayer::TextPlacer placer(basePoint, m_isMultiLine ? m_rect.Width() : -1, rfont, GetString());
#if 0
@@ -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

@@ -59,7 +59,7 @@ namespace PortabilityLayer
WidgetHandleState_t HandleDragSelection(const TimeTaggedVOSEvent &evt);
void DrawSelection(DrawSurface *surface, const Vec2i &basePoint) const;
void DrawSelection(DrawSurface *surface, const Vec2i &basePoint, PortabilityLayer::RenderedFont *font) const;
Vec2i ResolveCaratPos(const Vec2i &basePoint, PortabilityLayer::RenderedFont *rfont) const;
Vec2i ResolveBasePoint() const;

View File

@@ -2,6 +2,9 @@
#include "PLQDraw.h"
#include "FontFamily.h"
#include "PLStandardColors.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include <algorithm>
@@ -31,15 +34,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->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
surface->SetForeColor(StdColors::Black());
surface->FillRect(m_rect, whiteColor);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
const Point textStartPoint = topLeftCorner + Point::Create(0, sysFont->GetMetrics().m_ascent);
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true);
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), blackColor, sysFont);
}
}

View File

@@ -3,8 +3,12 @@
#include "MenuManager.h"
#include "PLMenus.h"
#include "PLPasStr.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "FontFamily.h"
#include "Vec2i.h"
@@ -41,7 +45,7 @@ namespace PortabilityLayer
{
const GpMouseInputEvent &mouseEvent = evt.m_vosEvent.m_event.m_mouseInputEvent;
const Vec2i globalPoint = Vec2i(mouseEvent.m_x, mouseEvent.m_y);
const Vec2i localPoint = globalPoint - Vec2i(m_window->m_wmX, m_window->m_wmY);
const Vec2i localPoint = globalPoint - m_window->GetPosition();
if (this->m_rect.Contains(Point::Create(localPoint.m_x, localPoint.m_y)))
{
@@ -60,8 +64,8 @@ namespace PortabilityLayer
{
MenuManager *mm = PortabilityLayer::MenuManager::GetInstance();
const Vec2i popupMenuPos = Vec2i(m_window->m_wmX, m_window->m_wmY) + Vec2i(m_rect.left, m_rect.top);
const Vec2i globalPos = Vec2i(pos.h, pos.v) + Vec2i(m_window->m_wmX, m_window->m_wmY);
const Vec2i popupMenuPos = m_window->GetPosition() + Vec2i(m_rect.left, m_rect.top);
const Vec2i globalPos = Vec2i(pos.h, pos.v) + m_window->GetPosition();
uint16_t item = 0;
mm->PopupMenuSelect(m_menu, popupMenuPos, globalPos, m_state - 1, &item);
@@ -75,33 +79,34 @@ 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;
textRect.right -= 11;
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + surface->MeasureFontAscender() + 1) / 2 - 1);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + sysFont->GetMetrics().m_ascent + 1) / 2 - 1);
surface->SetForeColor(StdColors::Black());
surface->DrawStringConstrained(basePoint, GetString(), true, textRect);
surface->DrawStringConstrained(basePoint, GetString(), textRect, blackColor, sysFont);
Point arrowMidPoint = Point::Create(textRect.right + 5, (textRect.top + textRect.bottom + 1) / 2);
@@ -116,7 +121,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

@@ -46,15 +46,10 @@ void OffsetRect(Rect *rect, int right, int down)
DrawSurface *GetGraphicsPort()
{
PortabilityLayer::QDPort *port = PortabilityLayer::QDManager::GetInstance()->GetPort();
DrawSurface *grafPtr = reinterpret_cast<DrawSurface *>(port);
assert(&grafPtr->m_port == port);
return grafPtr;
return PortabilityLayer::QDManager::GetInstance()->GetPort();
}
void SetGraphicsPort(DrawSurface *gw)
{
PortabilityLayer::QDManager::GetInstance()->SetPort(&gw->m_port);
PortabilityLayer::QDManager::GetInstance()->SetPort(gw);
}

View File

@@ -1,6 +1,5 @@
#include "PLQDraw.h"
#include "QDManager.h"
#include "QDState.h"
#include "BitmapImage.h"
#include "DisplayDeviceManager.h"
#include "EllipsePlotter.h"
@@ -24,6 +23,7 @@
#include "ScanlineMaskIterator.h"
#include "QDGraf.h"
#include "QDStandardPalette.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include "WindowManager.h"
#include "QDGraf.h"
@@ -38,20 +38,14 @@ static inline void InvertPixel8(uint8_t &pixel)
pixel = 255 ^ pixel;
}
void GetPort(GrafPtr *graf)
{
PL_NotYetImplemented();
}
void SetPort(GrafPtr graf)
void SetPort(DrawSurface *graf)
{
PortabilityLayer::QDManager::GetInstance()->SetPort(graf);
}
void EndUpdate(WindowPtr graf)
{
graf->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
graf->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void SetRect(Rect *rect, short left, short top, short right, short bottom)
@@ -65,29 +59,10 @@ void SetRect(Rect *rect, short left, short top, short right, short bottom)
void SetPortWindowPort(WindowPtr window)
{
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_surface.m_port);
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(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),
@@ -98,7 +73,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;
}
@@ -108,7 +83,6 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
Rect constrainedRect = port->GetRect();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(lineRect);
if (!constrainedRect.IsValid())
@@ -147,7 +121,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)
{
@@ -206,14 +180,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)
static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
{
assert(rect.IsValid());
@@ -260,12 +228,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
{
@@ -276,14 +243,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;
@@ -319,35 +286,28 @@ 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)
static void DrawText(PortabilityLayer::TextPlacer &placer, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont,
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(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, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font)
{
DrawStringConstrained(point, str, aa, Rect::CreateLargest());
DrawStringConstrained(point, str, Rect::CreateLargest(), cacheColor, font);
}
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect)
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *rfont)
{
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
PixMap *pixMap = *port->GetPixMap();
const Rect rect = pixMap->m_rect.Intersect(constraintRect);
@@ -357,25 +317,17 @@ 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, 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, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *rfont)
{
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
Point penPos = point;
const size_t len = str.Length();
const uint8_t *chars = str.UChars();
@@ -390,70 +342,11 @@ 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, pixMap, limitRect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
size_t DrawSurface::MeasureString(const PLPasStr &str)
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->MeasureString(str.UChars(), str.Length());
}
int32_t DrawSurface::MeasureFontAscender()
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->GetMetrics().m_ascent;
}
int32_t DrawSurface::MeasureFontLineGap()
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->GetMetrics().m_linegap;
}
void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
{
@@ -763,30 +656,7 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
Rect DrawSurface::GetClipRect() const
{
return m_port.GetState()->m_clipRect;
}
void DrawSurface::SetClipRect(const Rect &rect)
{
m_port.GetState()->m_clipRect = rect;;
}
PortabilityLayer::RenderedFont *DrawSurface::ResolveFont(bool aa) const
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
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;
@@ -797,8 +667,6 @@ void DrawSurface::FillRect(const Rect &rect)
Rect constrainedRect = rect;
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -815,7 +683,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++)
@@ -834,7 +702,7 @@ void DrawSurface::FillRect(const Rect &rect)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const uint8_t *pattern)
void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
@@ -846,8 +714,6 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
Rect constrainedRect = rect;
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -869,12 +735,9 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
{
case GpPixelFormats::k8BitStandard:
{
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
const uint8_t color = cacheColor.Resolve8(nullptr, 0);
uint8_t backColor = 0;
if (!isMask)
backColor = qdState->ResolveBackColor8(nullptr, 0);
size_t scanlineIndex = 0;
for (size_t ln = 0; ln < numLines; ln++)
{
@@ -886,8 +749,6 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
const int patternCol = static_cast<int>((patternFirstCol + col) & 7);
if ((pattern[patternRow] >> patternCol) & 1)
pixData[firstLineIndex + col] = color;
else if (!isMask)
pixData[firstLineIndex + col] = backColor;
}
}
}
@@ -900,78 +761,52 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::SetApplicationFont(int size, int variationFlags)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(size, variationFlags);
if (!fontFamily)
return;
PortabilityLayer::QDState *qdState = m_port.GetState();
qdState->m_fontFamily = fontFamily;
qdState->m_fontSize = size;
qdState->m_fontVariationFlags = variationFlags;
}
void DrawSurface::SetSystemFont(int size, int variationFlags)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(size, variationFlags);
if (!fontFamily)
return;
PortabilityLayer::QDState *qdState = m_port.GetState();
qdState->m_fontFamily = fontFamily;
qdState->m_fontSize = size;
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::FillEllipseWithPattern(const Rect &rect, bool isMask, 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)
{
FillRectWithPattern8x8(rect, isMask, pattern);
FillRectWithMaskPattern8x8(rect, pattern, cacheColor);
return;
}
PortabilityLayer::ScanlineMask *mask = PortabilityLayer::ScanlineMaskConverter::CompileEllipse(PortabilityLayer::Rect2i(rect.top, rect.left, rect.bottom, rect.right));
if (mask)
{
FillScanlineMaskWithPattern(mask, isMask, 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;
}
@@ -981,8 +816,6 @@ void DrawSurface::FrameEllipse(const Rect &rect)
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(portRect);
if (!constrainedRect.IsValid())
@@ -1006,7 +839,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 (;;)
{
@@ -1031,7 +864,7 @@ void DrawSurface::FrameEllipse(const Rect &rect)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol, uint8_t patternByte, uint8_t foreColor, uint8_t bgColor, bool mask)
static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol, uint8_t patternByte, uint8_t foreColor)
{
if (patternByte == 0xff)
{
@@ -1040,39 +873,25 @@ static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol,
}
else
{
if (mask)
for (size_t col = startCol; col < endCol; col++)
{
for (size_t col = startCol; col < endCol; col++)
{
if (patternByte & (0x80 >> (col & 7)))
rowStart[col] = foreColor;
}
}
else
{
for (size_t col = startCol; col < endCol; col++)
{
if (patternByte & (0x80 >> (col & 7)))
rowStart[col] = foreColor;
else
rowStart[col] = bgColor;
}
if (patternByte & (0x80 >> (col & 7)))
rowStart[col] = foreColor;
}
}
}
void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask)
void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask, PortabilityLayer::ResolveCachingColor &cacheColor)
{
FillScanlineMaskWithPattern(scanlineMask, false, nullptr);
FillScanlineMaskWithMaskPattern(scanlineMask, nullptr, cacheColor);
}
void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMask *scanlineMask, bool isMask, const uint8_t *pattern)
void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!scanlineMask)
return;
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = port->GetState();
PixMap *pixMap = *port->GetPixMap();
const Rect portRect = port->GetRect();
@@ -1099,7 +918,6 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
}
uint8_t foreColor8 = 0;
uint8_t backColor8 = 0;
const GpPixelFormat_t pixelFormat = pixMap->m_pixelFormat;
@@ -1107,8 +925,7 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
switch (pixMap->m_pixelFormat)
{
case GpPixelFormats::k8BitStandard:
foreColor8 = qdState->ResolveForeColor8(nullptr, 256);
backColor8 = qdState->ResolveBackColor8(nullptr, 256);
foreColor8 = cacheColor.Resolve8(nullptr, 256);
break;
default:
PL_NotYetImplemented();
@@ -1178,7 +995,7 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
{
const size_t spanEndCol = spanStartCol + currentSpan;
if (spanState)
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8, backColor8, isMask);
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8);
spanStartCol = spanEndCol;
paintColsRemaining -= currentSpan;
@@ -1191,7 +1008,7 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
if (spanState)
{
const size_t spanEndCol = firstPortCol + constrainedRectWidth;
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8, backColor8, isMask);
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8);
}
if (row != numRows - 1)
@@ -1216,27 +1033,12 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
}
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(this, PortabilityLayer::Vec2i(a.h, a.v), PortabilityLayer::Vec2i(b.h, b.v), cacheColor);
}
void GetClip(Rect *rect)
{
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
*rect = qdState->m_clipRect;
}
void ClipRect(const Rect *rect)
{
if (!rect->IsValid())
return;
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
qdState->m_clipRect = *rect;
}
void DrawSurface::FrameRect(const Rect &rect)
void DrawSurface::FrameRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
return;
@@ -1245,7 +1047,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
@@ -1253,28 +1055,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)
@@ -1308,8 +1110,6 @@ void DrawSurface::InvertFillRect(const Rect &rect, const uint8_t *pattern)
Rect constrainedRect = rect;
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -1331,8 +1131,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++)
{
@@ -1356,31 +1154,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 DrawSurface::SetBackColor(const PortabilityLayer::RGBAColor &color)
{
m_port.GetState()->SetBackColor(color);
}
const PortabilityLayer::RGBAColor &DrawSurface::GetBackColor() const
{
return m_port.GetState()->GetBackColor();
}
void PenSize(int w, int h)
{
PL_NotYetImplemented();
}
void InsetRect(Rect *rect, int x, int y)
{
rect->left += x;
@@ -1708,17 +1481,6 @@ PixMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr)
return *grafPtr->m_port.GetPixMap();
}
DrawSurface *GetWindowPort(WindowPtr window)
{
return &window->m_surface;
}
void SubPt(Point srcPoint, Point *destPoint)
{
PL_NotYetImplemented();
}
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection)
{
*outIntersection = rectA->Intersect(*rectB);
@@ -1727,11 +1489,6 @@ Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection)
}
void RestoreDeviceClut(void *unknown)
{
PL_NotYetImplemented();
}
void BitMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, void *dataPtr)
{
m_rect = rect;
@@ -1740,6 +1497,25 @@ void BitMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, v
m_data = dataPtr;
}
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(size, variationFlags);
if (!fontFamily)
return nullptr;
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
}
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(size, variationFlags);
if (!fontFamily)
return nullptr;
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
}
#include "stb_image_write.h"
void DebugPixMap(PixMap **pixMapH, const char *outName)
@@ -1751,3 +1527,4 @@ void DebugPixMap(PixMap **pixMapH, const char *outName)
stbi_write_png(outPath, pixMap->m_rect.right - pixMap->m_rect.left, pixMap->m_rect.bottom - pixMap->m_rect.top, 1, pixMap->m_data, pixMap->m_pitch);
}

View File

@@ -7,6 +7,7 @@
namespace PortabilityLayer
{
class ScanlineMask;
class RenderedFont;
}
struct Dialog;
@@ -58,27 +59,19 @@ private:
typedef CIcon *CIconPtr;
typedef CIconPtr *CIconHandle;
typedef PortabilityLayer::QDPort GrafPort;
typedef GrafPort *GrafPtr;
typedef Byte Pattern[8];
void GetPort(GrafPtr *graf);
void SetPort(GrafPtr graf);
void SetPortWindowPort(WindowPtr window);
void SetPortDialogPort(Dialog *dialog);
void SetPort(DrawSurface *graf);
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);
@@ -99,14 +92,11 @@ void ImageInvert(const PixMap *invertMask, PixMap *targetBitmap, const Rect &src
bool PointInScanlineMask(Point point, PortabilityLayer::ScanlineMask *scanlineMask);
PixMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr);
DrawSurface *GetWindowPort(WindowPtr window);
// Subtracts srcPoint from destPoint (reverse of DeltaPoint)
void SubPt(Point srcPoint, Point *destPoint);
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection);
void RestoreDeviceClut(void *unknown);
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa);
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa);
inline RGBColor::RGBColor(uint8_t r, uint8_t g, uint8_t b)

View File

@@ -2,6 +2,7 @@
#include "PLControlDefinitions.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
namespace PortabilityLayer
{
@@ -12,6 +13,8 @@ namespace PortabilityLayer
, m_gripSize(0)
, m_gripPos(0)
, m_laneCapacity(0)
, m_isActive(false)
, m_activePart(0)
{
}
@@ -40,8 +43,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 +57,63 @@ 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);
ResolveCachingColor darkGrayColor = RGBAColor::Create(85, 85, 85, 255);
ResolveCachingColor *leftArrowColor = &blackColor;
ResolveCachingColor *rightArrowColor = &blackColor;
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());
if (m_isActive && m_activePart == kControlUpButtonPart)
{
surface->FillRect(leftArrowRect.Inset(1, 1), darkGrayColor);
leftArrowColor = &whiteColor;
}
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, *leftArrowColor);
}
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());
if (m_isActive && m_activePart == kControlDownButtonPart)
{
surface->FillRect(rightArrowRect.Inset(1, 1), darkGrayColor);
rightArrowColor = &whiteColor;
}
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));
if (m_isActive && m_activePart == kControlPageUpPart)
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.bottom, laneRect.left + m_gripPos), darkGrayColor);
if (m_isActive && m_activePart == kControlPageDownPart)
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + m_gripPos, laneRect.bottom, laneRect.right), darkGrayColor);
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 +122,62 @@ 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);
ResolveCachingColor darkGrayColor = RGBAColor::Create(85, 85, 85, 255);
surface->FrameRect(m_rect, blackColor);
ResolveCachingColor *topArrowColor = &blackColor;
ResolveCachingColor *bottomArrowColor = &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());
if (m_isActive && m_activePart == kControlUpButtonPart)
{
surface->FillRect(topArrowRect.Inset(1, 1), darkGrayColor);
topArrowColor = &whiteColor;
}
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, *topArrowColor);
}
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());
if (m_isActive && m_activePart == kControlDownButtonPart)
{
surface->FillRect(bottomArrowRect.Inset(1, 1), darkGrayColor);
bottomArrowColor = &whiteColor;
}
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, *bottomArrowColor);
}
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->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->SetForeColor(RGBAColor::Create(187, 187, 187, 255));
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 2, laneRect.bottom, laneRect.right - 2));
if (m_isActive && m_activePart == kControlPageUpPart)
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.top + m_gripPos, laneRect.right), darkGrayColor);
surface->SetForeColor(StdColors::White());
surface->FillRect(Rect::Create(laneRect.bottom, laneRect.right - 2, laneRect.bottom, laneRect.right - 1));
if (m_isActive && m_activePart == kControlPageDownPart)
surface->FillRect(Rect::Create(laneRect.top + m_gripPos, laneRect.left, laneRect.bottom, laneRect.right), darkGrayColor);
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, 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 +185,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
@@ -254,23 +296,31 @@ namespace PortabilityLayer
int tickDelay = 15;
Point currentPos = pos;
bool wasInBounds = false;
bool isInBounds = (ResolvePart(pos) == part);
bool wasActive = false;
m_activePart = part;
int ticksUntilIterate = 0;
for (;;)
{
m_isActive = (ResolvePart(currentPos) == part); // Update in-bounds since the scroll may invalidate it
if (ticksUntilIterate == 0)
{
if (isInBounds)
{
if (m_isActive)
IterateScrollSegment(part, callback);
isInBounds = (ResolvePart(currentPos) == part); // Update in-bounds since the scroll may invalidate it
}
ticksUntilIterate = tickDelay;
}
if (m_isActive != wasActive)
{
wasActive = m_isActive;
ticksUntilIterate = tickDelay;
DrawControl(m_window->GetDrawSurface());
}
TimeTaggedVOSEvent evt;
if (WaitForEvent(&evt, 1))
{
@@ -278,11 +328,19 @@ namespace PortabilityLayer
{
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
if (mouseEvt.m_button == GpMouseButtons::kLeft && mouseEvt.m_eventType == GpMouseEventTypes::kUp)
{
if (m_isActive)
{
m_isActive = false;
DrawControl(m_window->GetDrawSurface());
}
return part;
}
else
{
currentPos = m_window->MouseToLocal(mouseEvt);
isInBounds = (ResolvePart(currentPos) == part);
m_isActive = (ResolvePart(currentPos) == part);
}
}
}

View File

@@ -48,5 +48,8 @@ namespace PortabilityLayer
int32_t m_gripSize;
int32_t m_gripPos;
int32_t m_laneCapacity;
bool m_isActive;
int m_activePart;
};
}

View File

@@ -24,7 +24,7 @@ namespace StrCmp
const uint8_t *chars2 = string2.UChars();
const size_t len1 = string1.Length();
const size_t len2 = string1.Length();
const size_t len2 = string2.Length();
const size_t shorterLen = std::min(len1, len2);

View File

@@ -1,41 +1,41 @@
#pragma once
#pragma once
#include "UnsafePascalStr.h"
class PLPasStr;
namespace PortabilityLayer
{
template<size_t TSize>
class PascalStr : public UnsafePascalStr<TSize, true>
{
public:
PascalStr();
class PLPasStr;
namespace PortabilityLayer
{
template<size_t TSize>
class PascalStr : public UnsafePascalStr<TSize, true>
{
public:
PascalStr();
PascalStr(size_t size, const char *str);
explicit PascalStr(const PLPasStr &pstr);
};
}
explicit PascalStr(const PLPasStr &pstr);
};
}
#include <string.h>
#include "PLPasStr.h"
namespace PortabilityLayer
{
template<size_t TSize>
inline PascalStr<TSize>::PascalStr()
: UnsafePascalStr<TSize, true>(0, nullptr)
{
}
template<size_t TSize>
PascalStr<TSize>::PascalStr(size_t size, const char *str)
: UnsafePascalStr<TSize, true>(size, str)
{
}
template<size_t TSize>
PascalStr<TSize>::PascalStr(const PLPasStr &pstr)
: UnsafePascalStr<TSize, true>(pstr.Length(), pstr.Chars())
{
}
}
#include "PLPasStr.h"
namespace PortabilityLayer
{
template<size_t TSize>
inline PascalStr<TSize>::PascalStr()
: UnsafePascalStr<TSize, true>(0, nullptr)
{
}
template<size_t TSize>
PascalStr<TSize>::PascalStr(size_t size, const char *str)
: UnsafePascalStr<TSize, true>(size, str)
{
}
template<size_t TSize>
PascalStr<TSize>::PascalStr(const PLPasStr &pstr)
: UnsafePascalStr<TSize, true>(pstr.Length(), pstr.Chars())
{
}
}

View File

@@ -229,6 +229,7 @@
<ClInclude Include="PLScrollBarWidget.h" />
<ClInclude Include="PLUnalignedPtr.h" />
<ClInclude Include="PLWidgets.h" />
<ClInclude Include="ResolveCachingColor.h" />
<ClInclude Include="TextPlacer.h" />
<ClInclude Include="UTF16.h" />
<ClInclude Include="UTF8.h" />
@@ -256,7 +257,6 @@
<ClInclude Include="QDPort.h" />
<ClInclude Include="QDRegion.h" />
<ClInclude Include="QDStandardPalette.h" />
<ClInclude Include="QDState.h" />
<ClInclude Include="RandomNumberGenerator.h" />
<ClInclude Include="Rect2i.h" />
<ClInclude Include="RenderedFont.h" />
@@ -366,6 +366,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" />
@@ -377,7 +378,6 @@
<ClCompile Include="QDPixMap.cpp" />
<ClCompile Include="QDPort.cpp" />
<ClCompile Include="QDStandardPalette.cpp" />
<ClCompile Include="QDState.cpp" />
<ClCompile Include="RandomNumberGenerator.cpp" />
<ClCompile Include="ResourceCompiledRef.cpp" />
<ClCompile Include="ResourceFile.cpp" />

View File

@@ -243,9 +243,6 @@
<ClInclude Include="QDRegion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="QDState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ResourceCompiledTypeList.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -483,6 +480,9 @@
<ClInclude Include="PLRegions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ResolveCachingColor.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CFileStream.cpp">
@@ -602,9 +602,6 @@
<ClCompile Include="QDPictHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="QDState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="QDPictDecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -749,14 +746,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

@@ -4,8 +4,8 @@
#include "GpPixelFormat.h"
#include "PLHandle.h"
#include "QDState.h"
#include "QDPort.h"
#include "RGBAColor.h"
namespace PortabilityLayer
{
@@ -13,7 +13,9 @@ namespace PortabilityLayer
class FontFamily;
struct RGBAColor;
class RenderedFont;
class ResolveCachingColor;
class ScanlineMask;
class FontSpec;
}
struct PixMap;
@@ -24,7 +26,7 @@ struct IGpDisplayDriver;
struct IGpDisplayDriverSurface;
class PLPasStr;
struct DrawSurface final
struct DrawSurface
{
DrawSurface()
: m_port(PortabilityLayer::QDPortType_DrawSurface)
@@ -59,50 +61,32 @@ struct DrawSurface final
void PushToDDSurface(IGpDisplayDriver *displayDriver);
void FillRect(const Rect &rect);
void FillRectWithPattern8x8(const Rect &rect, bool isMask, 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 FillEllipseWithPattern(const Rect &rect, bool isMask, 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 FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMask *scanlineMask, bool isMask, 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 DrawLine(const Point &a, const Point &b, PortabilityLayer::ResolveCachingColor &cacheColor);
void SetForeColor(const PortabilityLayer::RGBAColor &color);
const PortabilityLayer::RGBAColor &GetForeColor() const;
void SetBackColor(const PortabilityLayer::RGBAColor &color);
const PortabilityLayer::RGBAColor &GetBackColor() const;
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);
size_t MeasureString(const PLPasStr &str);
int32_t MeasureFontAscender();
int32_t MeasureFontLineGap();
void DrawString(const Point &point, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawStringConstrained(const Point &point, const PLPasStr &str, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawPicture(THandle<BitmapImage> pictHandle, const Rect &rect);
Rect GetClipRect() const;
void SetClipRect(const Rect &rect);
PortabilityLayer::RenderedFont *ResolveFont(bool aa) const;
// Must be the first item
PortabilityLayer::QDPort m_port;
IGpDisplayDriverSurface *m_ddSurface;
PortabilityLayer::AntiAliasTable *m_cachedAATable;
PortabilityLayer::RGBAColor m_cachedAAColor;
PortabilityLayer::QDPort m_port;
};

View File

@@ -4,7 +4,6 @@
#include "PLCore.h"
#include "PLQDOffscreen.h"
#include "QDGraf.h"
#include "QDState.h"
#include <assert.h>
@@ -16,16 +15,15 @@ namespace PortabilityLayer
QDManagerImpl();
void Init() override;
QDPort *GetPort() const override;
void SetPort(QDPort *gw) override;
DrawSurface *GetPort() const override;
void SetPort(DrawSurface *gw) override;
PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
void DisposeGWorld(DrawSurface *gw) override;
QDState *GetState() override;
static QDManagerImpl *GetInstance();
private:
QDPort *m_port;
DrawSurface *m_port;
static QDManagerImpl ms_instance;
};
@@ -39,16 +37,16 @@ namespace PortabilityLayer
{
}
QDPort *QDManagerImpl::GetPort() const
DrawSurface *QDManagerImpl::GetPort() const
{
return m_port;
}
void QDManagerImpl::SetPort(QDPort *gw)
void QDManagerImpl::SetPort(DrawSurface *gw)
{
#if GP_DEBUG_CONFIG
if (gw)
gw->CheckPortSentinel();
gw->m_port.CheckPortSentinel();
#endif
m_port = gw;
@@ -81,11 +79,6 @@ namespace PortabilityLayer
MemoryManager::GetInstance()->Release(gw);
}
QDState *QDManagerImpl::GetState()
{
return m_port->GetState();
}
QDManagerImpl *QDManagerImpl::GetInstance()
{
return &ms_instance;

View File

@@ -10,19 +10,16 @@ struct Rect;
namespace PortabilityLayer
{
class QDPort;
struct QDState;
class QDManager
{
public:
virtual void Init() = 0;
virtual QDPort *GetPort() const = 0;
virtual void SetPort(QDPort *gw) = 0;
virtual DrawSurface *GetPort() const = 0;
virtual void SetPort(DrawSurface *gw) = 0;
virtual PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) = 0;
virtual void DisposeGWorld(DrawSurface *gw) = 0;
virtual QDState *GetState() = 0;
static QDManager *GetInstance();
};
}

View File

@@ -35,7 +35,7 @@ namespace PortabilityLayer
{
#if GP_DEBUG_CONFIG
// Detach the port BEFORE destroying it!!
assert(PortabilityLayer::QDManager::GetInstance()->GetPort() != this);
assert(&PortabilityLayer::QDManager::GetInstance()->GetPort()->m_port != this);
#endif
DisposePixMap();
@@ -102,16 +102,6 @@ namespace PortabilityLayer
return m_pixMap.ImplicitCast<PixMap>();
}
const QDState *QDPort::GetState() const
{
return &m_state;
}
QDState *QDPort::GetState()
{
return &m_state;
}
GpPixelFormat_t QDPort::GetPixelFormat() const
{
return m_pixelFormat;

View File

@@ -4,7 +4,6 @@
#include "GpPixelFormat.h"
#include "PLErrorCodes.h"
#include "PLHandle.h"
#include "QDState.h"
struct PixMap;
struct Rect;
@@ -37,8 +36,6 @@ namespace PortabilityLayer
QDPortType GetPortType() const;
THandle<PixMap> GetPixMap() const;
const QDState *GetState() const;
QDState *GetState();
GpPixelFormat_t GetPixelFormat() const;
Rect GetRect() const;
@@ -61,7 +58,6 @@ namespace PortabilityLayer
QDPortType m_portType;
QDState m_state;
THandle<PixMapImpl> m_pixMap;
int16_t m_left;

View File

@@ -1,82 +0,0 @@
#include "QDState.h"
#include "PLQDraw.h"
#include "QDStandardPalette.h"
namespace PortabilityLayer
{
QDState::QDState()
: 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;
}
void QDState::SetBackColor(const RGBAColor &color)
{
m_backUnresolvedColor = color;
m_isBackResolved16 = false;
m_isBackResolved8 = false;
}
const RGBAColor &QDState::GetForeColor() const
{
return m_foreUnresolvedColor;
}
const RGBAColor &QDState::GetBackColor() const
{
return m_backUnresolvedColor;
}
uint8_t QDState::ResolveForeColor8(const RGBAColor *palette, unsigned int numColors)
{
return ResolveColor8(m_foreUnresolvedColor, m_foreResolvedColor8, m_isForeResolved8, palette, numColors);
}
uint8_t QDState::ResolveBackColor8(const RGBAColor *palette, unsigned int numColors)
{
return ResolveColor8(m_backUnresolvedColor, m_backResolvedColor8, m_isBackResolved8, 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

@@ -1,45 +0,0 @@
#pragma once
#include "RGBAColor.h"
#include "SharedTypes.h"
namespace PortabilityLayer
{
class FontFamily;
struct QDState
{
QDState();
FontFamily *m_fontFamily;
int m_fontVariationFlags;
int m_fontSize;
Rect m_clipRect;
Point m_penPos;
void SetForeColor(const RGBAColor &color);
void SetBackColor(const RGBAColor &color);
const RGBAColor &GetForeColor() const;
const RGBAColor &GetBackColor() const;
uint8_t ResolveForeColor8(const RGBAColor *palette, unsigned int numColors);
uint8_t ResolveBackColor8(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

@@ -2,6 +2,8 @@
#include <stdint.h>
class PLPasStr;
namespace PortabilityLayer
{
struct RenderedFontMetrics;
@@ -17,5 +19,20 @@ namespace PortabilityLayer
virtual bool IsAntiAliased() const = 0;
virtual void Destroy() = 0;
size_t MeasureCharStr(const char *str, size_t len) const;
size_t MeasurePStr(const PLPasStr &pstr) const;
};
}
#include "PLPasStr.h"
inline size_t PortabilityLayer::RenderedFont::MeasurePStr(const PLPasStr &pstr) const
{
return this->MeasureString(pstr.UChars(), pstr.Length());
}
inline size_t PortabilityLayer::RenderedFont::MeasureCharStr(const char *str, size_t len) const
{
return this->MeasureString(reinterpret_cast<const uint8_t*>(str), len);
}

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

@@ -0,0 +1,36 @@
#pragma once
#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;
uint16_t m_resolved16;
uint8_t m_resolved8;
bool m_isResolved16;
bool m_isResolved8;
};
}
inline const PortabilityLayer::RGBAColor &PortabilityLayer::ResolveCachingColor::GetRGBAColor() const
{
return m_rgbaColor;
}

View File

@@ -16,6 +16,9 @@
#include "QDPixMap.h"
#include "PLTimeTaggedVOSEvent.h"
#include "Rect2i.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include "WindowDef.h"
@@ -83,7 +86,7 @@ namespace PortabilityLayer
void RenderChromeCloseBox(DrawSurface *surface, const Rect &windowRect, bool isClicked) const;
static const int kDarkGray = 85;
static const int kMidGray = 187;
static const int kMidGray = 204;
static const int kLightGray = 221;
};
@@ -107,6 +110,13 @@ namespace PortabilityLayer
static const RGBAColor kLightColor;
};
struct WindowEffects
{
WindowEffects();
float m_desaturationLevel;
};
class WindowImpl final : public Window
{
public:
@@ -137,7 +147,12 @@ namespace PortabilityLayer
void SetTitle(const PLPasStr &str);
const PascalStr<255> &GetTitle() const;
WindowEffects &GetEffects();
const WindowEffects &GetEffects() const;
private:
WindowEffects m_effects;
WindowImpl *m_windowAbove;
WindowImpl *m_windowBelow;
@@ -172,6 +187,8 @@ namespace PortabilityLayer
void FlickerWindowIn(Window *window, int32_t velocity) override;
void FlickerWindowOut(Window *window, int32_t velocity) override;
void SetWindowDesaturation(Window *window, float desaturationLevel) override;
void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) override;
void ClearResizeInProgress() override;
@@ -249,8 +266,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,166 +438,185 @@ 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 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(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();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
int32_t ascender = sysFont->GetMetrics().m_ascent;
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
size_t titleWidth = surface->MeasureString(titlePStr);
size_t titleWidth = sysFont->MeasureString(titlePStr.UChars(), titlePStr.Length());
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, blackColor, sysFont);
Rect leftStripesRect = Rect::Create(rect.top + 5, rect.left + 5, rect.bottom - 5, (rect.left + rect.right - static_cast<int16_t>(titleWidth) - 10) / 2);
Rect rightStripesRect = Rect::Create(rect.top + 5, (rect.left + rect.right + static_cast<int16_t>(titleWidth) + 10) / 2, rect.bottom - 5, rect.right - 5);
if (leftStripesRect.IsValid() && rightStripesRect.IsValid())
{
for (int i = leftStripesRect.top; i < leftStripesRect.bottom; i += 3)
{
surface->FillRect(Rect::Create(i, leftStripesRect.left, i + 2, leftStripesRect.right), lightGrayColor);
surface->FillRect(Rect::Create(i, rightStripesRect.left, i + 2, rightStripesRect.right), lightGrayColor);
surface->FillRect(Rect::Create(i + 1, leftStripesRect.left + 1, i + 2, leftStripesRect.right), darkGrayColor);
surface->FillRect(Rect::Create(i + 1, rightStripesRect.left + 1, i + 2, rightStripesRect.right), darkGrayColor);
}
}
}
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();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
int32_t ascender = appFont->GetMetrics().m_ascent;
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
size_t titleWidth = surface->MeasureString(titlePStr);
size_t titleWidth = appFont->MeasureString(titlePStr.UChars(), titlePStr.Length());
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, blackColor, appFont);
}
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 +636,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 +710,100 @@ 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);
}
//---------------------------------------------------------------------------
WindowEffects::WindowEffects()
: m_desaturationLevel(0.0f)
{
}
//---------------------------------------------------------------------------
@@ -948,6 +994,18 @@ namespace PortabilityLayer
return m_title;
}
WindowEffects &WindowImpl::GetEffects()
{
return m_effects;
}
const WindowEffects &WindowImpl::GetEffects() const
{
return m_effects;
}
WindowManagerImpl::WindowManagerImpl()
: m_windowStackTop(nullptr)
, m_windowStackBottom(nullptr)
@@ -1059,10 +1117,11 @@ namespace PortabilityLayer
WindowImpl *window = m_windowStackTop;
while (window)
{
const Rect windowRect = window->m_surface.m_port.GetRect();
const Rect windowRect = window->GetSurfaceRect();
const Vec2i windowPos = window->GetPosition();
const int32_t localX = point.h - window->m_wmX;
const int32_t localY = point.v - window->m_wmY;
const int32_t localX = point.h - windowPos.m_x;
const int32_t localY = point.v - windowPos.m_y;
RegionID_t chromeInteractionZone = RegionIDs::kContent;
if (window->GetChromeInteractionZone(Vec2i(localX, localY), chromeInteractionZone))
@@ -1101,7 +1160,7 @@ namespace PortabilityLayer
DetachWindow(window);
if (PortabilityLayer::QDManager::GetInstance()->GetPort() == &windowImpl->m_surface.m_port)
if (PortabilityLayer::QDManager::GetInstance()->GetPort() == windowImpl->GetDrawSurface())
PortabilityLayer::QDManager::GetInstance()->SetPort(nullptr);
windowImpl->~WindowImpl();
@@ -1133,8 +1192,7 @@ namespace PortabilityLayer
if (y >= constraintRect.bottom)
y = constraintRect.bottom - 1;
window->m_wmX += x - baseX;
window->m_wmY += y - baseY;
window->SetPosition(window->GetPosition() + Vec2i(x - baseX, y - baseY));
baseX = x;
baseY = y;
@@ -1150,7 +1208,7 @@ namespace PortabilityLayer
{
bool isInBounds = false;
const Vec2i windowCoord = Vec2i(window->m_wmX, window->m_wmY);
const Vec2i windowCoord = window->GetPosition();
Rect2i closeBoxRect;
if (!static_cast<WindowImpl*>(window)->GetChromeRegionRect(RegionIDs::kClose, closeBoxRect))
@@ -1216,9 +1274,10 @@ namespace PortabilityLayer
uint16_t padding[WindowChromeSides::kCount];
windowImpl->GetChromePadding(padding);
const Rect portRect = windowImpl->m_surface.m_port.GetRect();
const Rect portRect = windowImpl->GetSurfaceRect();
const Vec2i windowPos = windowImpl->GetPosition();
return Rect2i(window->m_wmY - padding[WindowChromeSides::kTop], window->m_wmX - padding[WindowChromeSides::kLeft], window->m_wmY + portRect.Height() + padding[WindowChromeSides::kBottom], window->m_wmX + portRect.Width() + padding[WindowChromeSides::kRight]);
return Rect2i(windowPos.m_y - padding[WindowChromeSides::kTop], windowPos.m_x - padding[WindowChromeSides::kLeft], windowPos.m_y + portRect.Height() + padding[WindowChromeSides::kBottom], windowPos.m_x + portRect.Width() + padding[WindowChromeSides::kRight]);
}
bool WindowManagerImpl::GetWindowChromeInteractionZone(Window *window, const Vec2i &point, RegionID_t &outRegion) const
@@ -1242,7 +1301,7 @@ namespace PortabilityLayer
const Rect windowRect = window->GetDrawSurface()->m_port.GetRect();
Vec2i topLeft = Vec2i(m_flickerWindow->m_wmX, m_flickerWindow->m_wmY);
Vec2i topLeft = m_flickerWindow->GetPosition();
Vec2i dimensions = Vec2i(windowRect.Width(), windowRect.Height());
m_flickerAxis = Vec2i(1, 1);
@@ -1269,9 +1328,9 @@ namespace PortabilityLayer
int32_t chromeLead = 64;
int32_t flickerZoneSize = 128;
const Rect windowRect = window->GetDrawSurface()->m_port.GetRect();
const Rect windowRect = window->GetSurfaceRect();
Vec2i topLeft = Vec2i(m_flickerWindow->m_wmX, m_flickerWindow->m_wmY);
Vec2i topLeft = m_flickerWindow->GetPosition();
Vec2i dimensions = Vec2i(windowRect.Width(), windowRect.Height());
m_flickerAxis = Vec2i(-1, -1);
@@ -1291,17 +1350,24 @@ namespace PortabilityLayer
m_flickerWindow = nullptr;
}
void WindowManagerImpl::SetWindowDesaturation(Window *window, float desaturationLevel)
{
static_cast<WindowImpl*>(window)->GetEffects().m_desaturationLevel = desaturationLevel;
}
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
{
@@ -1311,11 +1377,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
{
@@ -1323,7 +1387,7 @@ namespace PortabilityLayer
return;
}
const PortabilityLayer::Vec2i topLeft = PortabilityLayer::Vec2i(window->m_wmX, window->m_wmY);
const PortabilityLayer::Vec2i topLeft = window->GetPosition();
m_resizeInProgressRect = PortabilityLayer::Rect2i(topLeft, topLeft + size);
}
@@ -1379,12 +1443,13 @@ namespace PortabilityLayer
{
uint32_t prevClearanceX = prevWidth - paddedWidth;
uint32_t newClearanceX = newWidth - paddedWidth;
newX = static_cast<int64_t>(window->m_wmX) * static_cast<int64_t>(newClearanceX) / static_cast<int64_t>(prevClearanceX);
newX = static_cast<int64_t>(window->GetPosition().m_x) * static_cast<int64_t>(newClearanceX) / static_cast<int64_t>(prevClearanceX);
}
int64_t newY = 0;
if (window->m_wmY < static_cast<int32_t>(menuBarHeight))
newY = window->m_wmY;
int32_t currentY = window->GetPosition().m_y;
if (currentY < static_cast<int32_t>(menuBarHeight))
newY = currentY;
else
{
if (newHeight <= (paddedHeight + menuBarHeight) || prevHeight <= paddedHeight + menuBarHeight)
@@ -1393,15 +1458,14 @@ namespace PortabilityLayer
{
uint32_t prevClearanceY = prevHeight - paddedHeight - menuBarHeight;
uint32_t newClearanceY = newHeight - paddedHeight - menuBarHeight;
newY = (static_cast<int64_t>(window->m_wmY) - static_cast<int64_t>(menuBarHeight) - chromePadding[WindowChromeSides::kTop]) * static_cast<int64_t>(newClearanceY) / static_cast<int64_t>(prevClearanceY) + menuBarHeight + chromePadding[WindowChromeSides::kTop];
newY = (static_cast<int64_t>(currentY) - static_cast<int64_t>(menuBarHeight) - chromePadding[WindowChromeSides::kTop]) * static_cast<int64_t>(newClearanceY) / static_cast<int64_t>(prevClearanceY) + menuBarHeight + chromePadding[WindowChromeSides::kTop];
}
}
newX = std::max<int64_t>(0, std::min<int64_t>(newX, newWidth - 1));
newY = std::max<int64_t>(0, std::min<int64_t>(newY, newHeight - 1));
window->m_wmX = static_cast<int32_t>(newX);
window->m_wmY = static_cast<int32_t>(newY);
window->SetPosition(Vec2i(newX, newY));
}
}
@@ -1412,8 +1476,7 @@ namespace PortabilityLayer
void WindowManagerImpl::MoveWindow(Window *window, int x, int y)
{
window->m_wmX = x;
window->m_wmY = y;
window->SetPosition(Vec2i(x, y));
}
void WindowManagerImpl::DetachWindow(Window *window)
@@ -1475,9 +1538,11 @@ namespace PortabilityLayer
if (m_exclusiveWindow != nullptr && m_exclusiveWindow != window)
effects.m_darken = true;
effects.m_desaturation = window->GetEffects().m_desaturationLevel;
bool hasFlicker = (m_flickerWindow == window);
DrawSurface &graf = window->m_surface;
DrawSurface &graf = *window->GetDrawSurface();
graf.PushToDDSurface(displayDriver);
@@ -1485,10 +1550,12 @@ namespace PortabilityLayer
const uint16_t width = pixMap->m_rect.Width();
const uint16_t height = pixMap->m_rect.Height();
if (hasFlicker)
ComputeFlickerEffects(Vec2i(window->m_wmX, window->m_wmY), 0, effects);
const Vec2i windowPos = window->GetPosition();
displayDriver->DrawSurface(graf.m_ddSurface, window->m_wmX, window->m_wmY, width, height, &effects);
if (hasFlicker)
ComputeFlickerEffects(windowPos, 0, effects);
displayDriver->DrawSurface(graf.m_ddSurface, windowPos.m_x, windowPos.m_y, width, height, &effects);
if (!window->IsBorderless())
{
@@ -1496,10 +1563,10 @@ namespace PortabilityLayer
window->GetChromePadding(chromePadding);
Vec2i chromeOrigins[WindowChromeSides::kCount];
chromeOrigins[WindowChromeSides::kTop] = Vec2i(window->m_wmX - chromePadding[WindowChromeSides::kLeft], window->m_wmY - chromePadding[WindowChromeSides::kTop]);
chromeOrigins[WindowChromeSides::kLeft] = Vec2i(window->m_wmX - chromePadding[WindowChromeSides::kLeft], window->m_wmY);
chromeOrigins[WindowChromeSides::kRight] = Vec2i(window->m_wmX + width, window->m_wmY);
chromeOrigins[WindowChromeSides::kBottom] = Vec2i(window->m_wmX - chromePadding[WindowChromeSides::kLeft], window->m_wmY + height);
chromeOrigins[WindowChromeSides::kTop] = Vec2i(windowPos.m_x - chromePadding[WindowChromeSides::kLeft], windowPos.m_y - chromePadding[WindowChromeSides::kTop]);
chromeOrigins[WindowChromeSides::kLeft] = Vec2i(windowPos.m_x - chromePadding[WindowChromeSides::kLeft], windowPos.m_y);
chromeOrigins[WindowChromeSides::kRight] = Vec2i(windowPos.m_x + width, windowPos.m_y);
chromeOrigins[WindowChromeSides::kBottom] = Vec2i(windowPos.m_x - chromePadding[WindowChromeSides::kLeft], windowPos.m_y + height);
Vec2i chromeDimensions[WindowChromeSides::kCount];
chromeDimensions[WindowChromeSides::kTop] = Vec2i(chromePadding[WindowChromeSides::kLeft] + chromePadding[WindowChromeSides::kRight] + width, chromePadding[WindowChromeSides::kTop]);

View File

@@ -41,6 +41,8 @@ namespace PortabilityLayer
virtual void FlickerWindowIn(Window *window, int32_t velocity) = 0;
virtual void FlickerWindowOut(Window *window, int32_t velocity) = 0;
virtual void SetWindowDesaturation(Window *window, float desaturationLevel) = 0;
virtual void SetResizeInProgress(Window *window, const PortabilityLayer::Vec2i &size) = 0;
virtual void ClearResizeInProgress() = 0;

View File

@@ -1,5 +1,6 @@
#include "DrawQuad.h"
#include "DrawQuadPixelConstants.h"
#include "Functions.h"
SamplerState nearestNeighborSampler : register(s0);
Texture2D<uint> surfaceTexture : register(t0);
@@ -20,7 +21,10 @@ SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{
SDrawQuadPixelOutput result;
int2 pixelCoordinate = int2(floor(input.texCoord.xy));
result.color = ApplyFlicker(pixelCoordinate, float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0) * constants_Modulation);
result.color = float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0);
result.color *= constants_Modulation;
result.color = ApplyFlicker(pixelCoordinate, constants_FlickerStartThreshold, constants_FlickerEndThreshold, result.color * constants_Modulation);
result.color = ApplyDesaturation(constants_Desaturation, result.color);
if (result.color.a <= 0.0)
discard;

View File

@@ -5,15 +5,7 @@ cbuffer SDrawQuadPixelConstants : register(b0)
int2 constants_FlickerAxis;
int constants_FlickerStartThreshold;
int constants_FlickerEndThreshold;
float constants_Desaturation;
float3 constants_Unused;
};
float4 ApplyFlicker(int2 coordinate, float4 color)
{
int flickerTotal = dot(constants_FlickerAxis, coordinate);
if (flickerTotal < constants_FlickerStartThreshold)
return float4(0, 0, 0, 0);
else if (flickerTotal >= constants_FlickerEndThreshold)
return color;
else
return float4(1, 1, 1, 1);
}

59
ShaderSrc/Functions.h Normal file
View File

@@ -0,0 +1,59 @@
float SRGBToLinear(float v)
{
if (v <= 0.04045)
return v * (1.0 / 12.92);
else
return pow(((v + 0.055) * (1.0 / 1.055)), 2.4);
}
float2 SRGBToLinear(float2 v)
{
return float2(SRGBToLinear(v.x), SRGBToLinear(v.y));
}
float3 SRGBToLinear(float3 v)
{
return float3(SRGBToLinear(v.x), SRGBToLinear(v.y), SRGBToLinear(v.z));
}
float LinearToSRGB(float v)
{
if (v <= 0.0031308)
return 12.92 * v;
else
return 1.055 * pow(v, 1.0 / 2.4) - 0.055;
}
float2 LinearToSRGB(float2 v)
{
return float2(LinearToSRGB(v.x), LinearToSRGB(v.y));
}
float3 LinearToSRGB(float3 v)
{
return float3(LinearToSRGB(v.x), LinearToSRGB(v.y), LinearToSRGB(v.z));
}
float4 ApplyFlicker(int2 coordinate, int startThreshold, int endThreshold, float4 color)
{
int flickerTotal = dot(constants_FlickerAxis, coordinate);
if (flickerTotal < startThreshold)
return float4(0, 0, 0, 0);
else if (flickerTotal >= endThreshold)
return color;
return float4(1, 1, 1, 1);
}
float4 ApplyDesaturation(float desaturation, float4 color)
{
if (desaturation == 0.0)
return color;
float3 srgbColor = LinearToSRGB(color.rgb);
float grayLevel = dot(srgbColor, float3(3.0, 6.0, 1.0) / 10.0);
srgbColor = srgbColor * (1.0 - desaturation) + float3(grayLevel, grayLevel, grayLevel) * desaturation;
return float4(SRGBToLinear(srgbColor), color.a);
}