mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Fix up some level editor dialog behavior
This commit is contained in:
@@ -435,18 +435,17 @@ void SetDialogItemValue (Dialog *theDialog, short item, short theState)
|
||||
|
||||
void ToggleDialogItemValue (Dialog *theDialog, short item)
|
||||
{
|
||||
Rect itemRect;
|
||||
ControlHandle itemHandle;
|
||||
int16_t itemType, theState;
|
||||
|
||||
const PortabilityLayer::DialogItem &itemRef = theDialog->GetItems()[item - 1];
|
||||
int16_t theState;
|
||||
|
||||
theState = itemRef.GetWidget()->GetState();
|
||||
PortabilityLayer::Widget *widget = theDialog->GetItems()[item - 1].GetWidget();
|
||||
|
||||
theState = widget->GetState();
|
||||
if (theState == 0)
|
||||
theState = 1;
|
||||
else
|
||||
theState = 0;
|
||||
SetControlValue(itemHandle, theState);
|
||||
widget->SetState(theState);
|
||||
widget->DrawControl(theDialog->GetWindow()->GetDrawSurface());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SetDialogNumToStr
|
||||
|
||||
@@ -173,10 +173,10 @@ void StartMarqueeHandled (Rect *, SInt16, SInt16);
|
||||
void StopMarquee (void);
|
||||
void PauseMarquee (void);
|
||||
void ResumeMarquee (void);
|
||||
void DragOutMarqueeRect (Point, Rect *);
|
||||
void DragMarqueeRect (DrawSurface *, Point, Rect *, Boolean, Boolean);
|
||||
void DragMarqueeHandle (DrawSurface *, Point, SInt16 *);
|
||||
void DragMarqueeCorner (DrawSurface *, Point, SInt16 *, SInt16 *, Boolean);
|
||||
void DragOutMarqueeRect (Window *, Point, Rect *);
|
||||
void DragMarqueeRect (Window *, DrawSurface *, Point, Rect *, Boolean, Boolean);
|
||||
void DragMarqueeHandle (Window *, DrawSurface *, Point, SInt16 *);
|
||||
void DragMarqueeCorner (Window *, DrawSurface *, Point, SInt16 *, SInt16 *, Boolean);
|
||||
Boolean MarqueeHasHandles (SInt16 *, SInt16 *);
|
||||
Boolean PtInMarqueeHandle (Point);
|
||||
void SetMarqueeGliderRect (SInt16, SInt16);
|
||||
@@ -306,7 +306,7 @@ void DrawCustPictSansWhite (SInt16, Rect *);
|
||||
|
||||
void DrawARoomsObjects (SInt16, Boolean); // --- ObjectDrawAll.c
|
||||
|
||||
void DoSelectionClick (DrawSurface *, Point, Boolean); // --- ObjectEdit.c
|
||||
void DoSelectionClick (Window *, DrawSurface *, Point, Boolean); // --- ObjectEdit.c
|
||||
void DoNewObjectClick (Point);
|
||||
void DeleteObject (void);
|
||||
void DuplicateObject (void);
|
||||
|
||||
@@ -389,7 +389,7 @@ void HandleMainClick (Point wherePt, Boolean isDoubleClick)
|
||||
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();
|
||||
|
||||
if (toolSelected == kSelectTool)
|
||||
DoSelectionClick(mainWindowSurface, wherePt, isDoubleClick);
|
||||
DoSelectionClick(mainWindow, mainWindowSurface, wherePt, isDoubleClick);
|
||||
else
|
||||
DoNewObjectClick(wherePt);
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
#include "Externs.h"
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "InputManager.h"
|
||||
#include "Marquee.h"
|
||||
#include "Objects.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#define kMarqueePatListID 128
|
||||
@@ -186,7 +188,7 @@ void ResumeMarquee (void)
|
||||
|
||||
//-------------------------------------------------------------- DragOutMarqueeRect
|
||||
|
||||
void DragOutMarqueeRect (Point start, Rect *theRect)
|
||||
void DragOutMarqueeRect (Window *window, Point start, Rect *theRect)
|
||||
{
|
||||
Point wasPt, newPt;
|
||||
DrawSurface *surface = mainWindow->GetDrawSurface();
|
||||
@@ -200,8 +202,8 @@ void DragOutMarqueeRect (Point start, Rect *theRect)
|
||||
|
||||
while (WaitMouseUp())
|
||||
{
|
||||
GetMouse(&newPt);
|
||||
if (DeltaPoint(wasPt, newPt))
|
||||
GetMouse(window, &newPt);
|
||||
if (wasPt != newPt)
|
||||
{
|
||||
surface->InvertFrameRect(*theRect, pattern);
|
||||
QSetRect(theRect, start.h, start.v, newPt.h, newPt.v);
|
||||
@@ -215,7 +217,7 @@ void DragOutMarqueeRect (Point start, Rect *theRect)
|
||||
|
||||
//-------------------------------------------------------------- DragMarqueeRect
|
||||
|
||||
void DragMarqueeRect (DrawSurface *surface, Point start, Rect *theRect, Boolean lockH, Boolean lockV)
|
||||
void DragMarqueeRect (Window *window, DrawSurface *surface, Point start, Rect *theRect, Boolean lockH, Boolean lockV)
|
||||
{
|
||||
Point wasPt, newPt;
|
||||
short deltaH, deltaV;
|
||||
@@ -230,8 +232,8 @@ void DragMarqueeRect (DrawSurface *surface, Point start, Rect *theRect, Boolean
|
||||
wasPt = start;
|
||||
while (WaitMouseUp())
|
||||
{
|
||||
GetMouse(&newPt);
|
||||
if (DeltaPoint(wasPt, newPt))
|
||||
GetMouse(window, &newPt);
|
||||
if (wasPt != newPt)
|
||||
{
|
||||
if (lockV)
|
||||
deltaH = 0;
|
||||
@@ -257,7 +259,7 @@ void DragMarqueeRect (DrawSurface *surface, Point start, Rect *theRect, Boolean
|
||||
|
||||
//-------------------------------------------------------------- DragMarqueeHandle
|
||||
|
||||
void DragMarqueeHandle (DrawSurface *surface, Point start, short *dragged)
|
||||
void DragMarqueeHandle (Window *window, DrawSurface *surface, Point start, short *dragged)
|
||||
{
|
||||
Point wasPt, newPt;
|
||||
short deltaH, deltaV;
|
||||
@@ -275,8 +277,8 @@ void DragMarqueeHandle (DrawSurface *surface, Point start, short *dragged)
|
||||
wasPt = start;
|
||||
while (WaitMouseUp())
|
||||
{
|
||||
GetMouse(&newPt);
|
||||
if (DeltaPoint(wasPt, newPt))
|
||||
GetMouse(window, &newPt);
|
||||
if (wasPt != newPt)
|
||||
{
|
||||
switch (theMarquee.direction)
|
||||
{
|
||||
@@ -343,7 +345,7 @@ void DragMarqueeHandle (DrawSurface *surface, Point start, short *dragged)
|
||||
|
||||
//-------------------------------------------------------------- DragMarqueeCorner
|
||||
|
||||
void DragMarqueeCorner (DrawSurface *surface, Point start, short *hDragged, short *vDragged, Boolean isTop)
|
||||
void DragMarqueeCorner (Window *window, DrawSurface *surface, Point start, short *hDragged, short *vDragged, Boolean isTop)
|
||||
{
|
||||
Point wasPt, newPt;
|
||||
short deltaH, deltaV;
|
||||
@@ -358,8 +360,8 @@ void DragMarqueeCorner (DrawSurface *surface, Point start, short *hDragged, shor
|
||||
wasPt = start;
|
||||
while (WaitMouseUp())
|
||||
{
|
||||
GetMouse(&newPt);
|
||||
if (DeltaPoint(wasPt, newPt))
|
||||
GetMouse(window, &newPt);
|
||||
if (wasPt != newPt)
|
||||
{
|
||||
deltaH = newPt.h - wasPt.h;
|
||||
if (isTop)
|
||||
@@ -490,7 +492,12 @@ void DrawMarquee (DrawSurface *surface, const uint8_t *pattern)
|
||||
break;
|
||||
}
|
||||
|
||||
surface->InvertFillRect(Rect::Create(points[0].v, points[0].h, points[1].v, points[1].h), pattern);
|
||||
if (points[1].h < points[0].h)
|
||||
std::swap(points[0].h, points[1].h);
|
||||
if (points[1].v < points[0].v)
|
||||
std::swap(points[0].v, points[1].v);
|
||||
|
||||
surface->InvertFillRect(Rect::Create(points[0].v, points[0].h, points[1].v + 1, points[1].h + 1), pattern);
|
||||
}
|
||||
|
||||
if (gliderMarqueeUp)
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
|
||||
short FindObjectSelected (Point);
|
||||
void DragHandle (DrawSurface *, Point);
|
||||
void DragObject (DrawSurface *, Point);
|
||||
void DragHandle (Window *, DrawSurface *, Point);
|
||||
void DragObject (Window *, DrawSurface *, Point);
|
||||
void AddObjectPairing (void);
|
||||
Boolean ObjectIsUpBlower (objectType *);
|
||||
|
||||
@@ -74,7 +74,7 @@ short FindObjectSelected (Point where)
|
||||
|
||||
//-------------------------------------------------------------- DoSelectionClick
|
||||
|
||||
void DoSelectionClick (DrawSurface *surface, Point where, Boolean isDoubleClick)
|
||||
void DoSelectionClick (Window *window, DrawSurface *surface, Point where, Boolean isDoubleClick)
|
||||
{
|
||||
#ifndef COMPILEDEMO
|
||||
short direction, dist;
|
||||
@@ -84,7 +84,7 @@ void DoSelectionClick (DrawSurface *surface, Point where, Boolean isDoubleClick)
|
||||
if ((PtInMarqueeHandle(where)) && (objActive != kNoObjectSelected))
|
||||
{
|
||||
if (StillDown())
|
||||
DragHandle(surface, where);
|
||||
DragHandle(window, surface, where);
|
||||
if (ObjectHasHandle(&direction, &dist))
|
||||
{
|
||||
StartMarqueeHandled(&roomObjectRects[objActive], direction, dist);
|
||||
@@ -117,7 +117,7 @@ void DoSelectionClick (DrawSurface *surface, Point where, Boolean isDoubleClick)
|
||||
else
|
||||
{
|
||||
if (StillDown())
|
||||
DragObject(surface, where);
|
||||
DragObject(window, surface, where);
|
||||
if (ObjectHasHandle(&direction, &dist))
|
||||
{
|
||||
StartMarqueeHandled(&roomObjectRects[objActive], direction, dist);
|
||||
@@ -144,7 +144,7 @@ void DoSelectionClick (DrawSurface *surface, Point where, Boolean isDoubleClick)
|
||||
//-------------------------------------------------------------- DragHandle
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
void DragHandle (DrawSurface *surface, Point where)
|
||||
void DragHandle (Window *window, DrawSurface *surface, Point where)
|
||||
{
|
||||
short hDelta, vDelta;
|
||||
Boolean whoCares;
|
||||
@@ -164,7 +164,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kGrecoVent:
|
||||
case kSewerBlower:
|
||||
vDelta = thisRoom->objects[objActive].data.a.distance;
|
||||
DragMarqueeHandle(surface, where, &vDelta);
|
||||
DragMarqueeHandle(window, surface, where, &vDelta);
|
||||
thisRoom->objects[objActive].data.a.distance = vDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
break;
|
||||
@@ -172,7 +172,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kLiftArea:
|
||||
hDelta = thisRoom->objects[objActive].data.a.distance;
|
||||
vDelta = thisRoom->objects[objActive].data.a.tall * 2;
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, false);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, false);
|
||||
thisRoom->objects[objActive].data.a.distance = hDelta;
|
||||
thisRoom->objects[objActive].data.a.tall = vDelta / 2;
|
||||
whoCares = KeepObjectLegal();
|
||||
@@ -185,7 +185,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kLeftFan:
|
||||
case kRightFan:
|
||||
hDelta = thisRoom->objects[objActive].data.a.distance;
|
||||
DragMarqueeHandle(surface, where, &hDelta);
|
||||
DragMarqueeHandle(window, surface, where, &hDelta);
|
||||
thisRoom->objects[objActive].data.a.distance = hDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
break;
|
||||
@@ -195,13 +195,13 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
((thisRoom->objects[objActive].data.a.vector & 0x0F) == 4))
|
||||
{
|
||||
vDelta = thisRoom->objects[objActive].data.a.distance;
|
||||
DragMarqueeHandle(surface, where, &vDelta);
|
||||
DragMarqueeHandle(window, surface, where, &vDelta);
|
||||
thisRoom->objects[objActive].data.a.distance = vDelta;
|
||||
}
|
||||
else
|
||||
{
|
||||
hDelta = thisRoom->objects[objActive].data.a.distance;
|
||||
DragMarqueeHandle(surface, where, &hDelta);
|
||||
DragMarqueeHandle(window, surface, where, &hDelta);
|
||||
thisRoom->objects[objActive].data.a.distance = hDelta;
|
||||
}
|
||||
whoCares = KeepObjectLegal();
|
||||
@@ -211,7 +211,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kShelf:
|
||||
case kDeckTable:
|
||||
hDelta = RectWide(&thisRoom->objects[objActive].data.b.bounds);
|
||||
DragMarqueeHandle(surface, where, &hDelta);
|
||||
DragMarqueeHandle(window, surface, where, &hDelta);
|
||||
thisRoom->objects[objActive].data.b.bounds.right =
|
||||
thisRoom->objects[objActive].data.b.bounds.left + hDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
@@ -226,7 +226,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kInvisBounce:
|
||||
hDelta = RectWide(&thisRoom->objects[objActive].data.b.bounds);
|
||||
vDelta = RectTall(&thisRoom->objects[objActive].data.b.bounds);
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, false);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, false);
|
||||
thisRoom->objects[objActive].data.b.bounds.right =
|
||||
thisRoom->objects[objActive].data.b.bounds.left + hDelta;
|
||||
thisRoom->objects[objActive].data.b.bounds.bottom =
|
||||
@@ -242,7 +242,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kDresser:
|
||||
hDelta = RectWide(&thisRoom->objects[objActive].data.b.bounds);
|
||||
vDelta = RectTall(&thisRoom->objects[objActive].data.b.bounds);
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, true);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, true);
|
||||
thisRoom->objects[objActive].data.b.bounds.right =
|
||||
thisRoom->objects[objActive].data.b.bounds.left + hDelta;
|
||||
thisRoom->objects[objActive].data.b.bounds.top =
|
||||
@@ -258,7 +258,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kGreaseLf:
|
||||
case kSlider:
|
||||
hDelta = thisRoom->objects[objActive].data.c.length;
|
||||
DragMarqueeHandle(surface, where, &hDelta);
|
||||
DragMarqueeHandle(window, surface, where, &hDelta);
|
||||
thisRoom->objects[objActive].data.c.length = hDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
@@ -270,7 +270,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kInvisTrans:
|
||||
hDelta = thisRoom->objects[objActive].data.d.wide;
|
||||
vDelta = thisRoom->objects[objActive].data.d.tall;
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, false);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, false);
|
||||
if (hDelta > 127)
|
||||
hDelta = 127;
|
||||
thisRoom->objects[objActive].data.d.wide = (Byte)hDelta;
|
||||
@@ -285,7 +285,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kDeluxeTrans:
|
||||
hDelta = ((thisRoom->objects[objActive].data.d.tall & 0xFF00) >> 8) * 4;
|
||||
vDelta = (thisRoom->objects[objActive].data.d.tall & 0x00FF) * 4;
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, false);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, false);
|
||||
if (hDelta < 64)
|
||||
hDelta = 64;
|
||||
if (vDelta < 32)
|
||||
@@ -301,7 +301,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kFlourescent:
|
||||
case kTrackLight:
|
||||
hDelta = thisRoom->objects[objActive].data.f.length;
|
||||
DragMarqueeHandle(surface, where, &hDelta);
|
||||
DragMarqueeHandle(window, surface, where, &hDelta);
|
||||
thisRoom->objects[objActive].data.f.length = hDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
@@ -312,7 +312,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
|
||||
case kToaster:
|
||||
vDelta = thisRoom->objects[objActive].data.g.height;
|
||||
DragMarqueeHandle(surface, where, &vDelta);
|
||||
DragMarqueeHandle(window, surface, where, &vDelta);
|
||||
thisRoom->objects[objActive].data.g.height = vDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
break;
|
||||
@@ -321,7 +321,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kDrip:
|
||||
case kFish:
|
||||
vDelta = thisRoom->objects[objActive].data.h.length;
|
||||
DragMarqueeHandle(surface, where, &vDelta);
|
||||
DragMarqueeHandle(window, surface, where, &vDelta);
|
||||
thisRoom->objects[objActive].data.h.length = vDelta;
|
||||
whoCares = KeepObjectLegal();
|
||||
break;
|
||||
@@ -330,7 +330,7 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
case kWallWindow:
|
||||
hDelta = RectWide(&thisRoom->objects[objActive].data.i.bounds);
|
||||
vDelta = RectTall(&thisRoom->objects[objActive].data.i.bounds);
|
||||
DragMarqueeCorner(surface, where, &hDelta, &vDelta, false);
|
||||
DragMarqueeCorner(window, surface, where, &hDelta, &vDelta, false);
|
||||
thisRoom->objects[objActive].data.i.bounds.right =
|
||||
thisRoom->objects[objActive].data.i.bounds.left + hDelta;
|
||||
thisRoom->objects[objActive].data.i.bounds.bottom =
|
||||
@@ -352,30 +352,30 @@ void DragHandle (DrawSurface *surface, Point where)
|
||||
//-------------------------------------------------------------- DragObject
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
void DragObject (DrawSurface *surface, Point where)
|
||||
void DragObject (Window *window, DrawSurface *surface, Point where)
|
||||
{
|
||||
Rect newRect, wasRect;
|
||||
short deltaH, deltaV, increment;
|
||||
char wasState;
|
||||
Boolean invalAll;
|
||||
Boolean invalAll = false;
|
||||
|
||||
if (objActive == kInitialGliderSelected)
|
||||
{
|
||||
wasRect = initialGliderRect;
|
||||
newRect = initialGliderRect;
|
||||
DragMarqueeRect(surface, where, &newRect, false, false);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, false);
|
||||
}
|
||||
else if (objActive == kLeftGliderSelected)
|
||||
{
|
||||
wasRect = leftStartGliderDest;
|
||||
newRect = leftStartGliderDest;
|
||||
DragMarqueeRect(surface, where, &newRect, false, true);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, true);
|
||||
}
|
||||
else if (objActive == kRightGliderSelected)
|
||||
{
|
||||
wasRect = rightStartGliderDest;
|
||||
newRect = rightStartGliderDest;
|
||||
DragMarqueeRect(surface, where, &newRect, false, true);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -412,13 +412,13 @@ void DragObject (DrawSurface *surface, Point where)
|
||||
case kCopterRt:
|
||||
case kMousehole:
|
||||
case kFireplace:
|
||||
DragMarqueeRect(surface, where, &newRect, true, false);
|
||||
DragMarqueeRect(window, surface, where, &newRect, true, false);
|
||||
invalAll = false;
|
||||
break;
|
||||
|
||||
case kDartLf:
|
||||
case kDartRt:
|
||||
DragMarqueeRect(surface, where, &newRect, false, true);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, true);
|
||||
invalAll = false;
|
||||
break;
|
||||
|
||||
@@ -439,14 +439,14 @@ void DragObject (DrawSurface *surface, Point where)
|
||||
case kDeluxeTrans:
|
||||
case kMirror:
|
||||
case kWallWindow:
|
||||
DragMarqueeRect(surface, where, &newRect, false, false);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, false);
|
||||
invalAll = true;
|
||||
break;
|
||||
|
||||
case kCounter:
|
||||
case kDresser:
|
||||
case kTrackLight:
|
||||
DragMarqueeRect(surface, where, &newRect, true, false);
|
||||
DragMarqueeRect(window, surface, where, &newRect, true, false);
|
||||
invalAll = true;
|
||||
break;
|
||||
|
||||
@@ -516,7 +516,7 @@ void DragObject (DrawSurface *surface, Point where)
|
||||
case kFaucet:
|
||||
case kRug:
|
||||
case kChimes:
|
||||
DragMarqueeRect(surface, where, &newRect, false, false);
|
||||
DragMarqueeRect(window, surface, where, &newRect, false, false);
|
||||
invalAll = false;
|
||||
break;
|
||||
}
|
||||
@@ -749,23 +749,11 @@ void DragObject (DrawSurface *surface, Point where)
|
||||
{
|
||||
}
|
||||
GetThisRoomsObjRects();
|
||||
if (invalAll)
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
else
|
||||
{
|
||||
InvalWindowRect(mainWindow, &wasRect);
|
||||
if (objActive == kInitialGliderSelected)
|
||||
InvalWindowRect(mainWindow, &initialGliderRect);
|
||||
else if (objActive == kLeftGliderSelected)
|
||||
InvalWindowRect(mainWindow, &leftStartGliderDest);
|
||||
else if (objActive == kRightGliderSelected)
|
||||
InvalWindowRect(mainWindow, &rightStartGliderDest);
|
||||
else
|
||||
InvalWindowRect(mainWindow, &roomObjectRects[objActive]);
|
||||
}
|
||||
|
||||
ReadyBackground(thisRoom->background, thisRoom->tiles);
|
||||
DrawThisRoomsObjects();
|
||||
|
||||
UpdateMainWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1140,11 +1128,12 @@ void DeleteObject (void)
|
||||
thisRoom->numObjects--;
|
||||
fileDirty = true;
|
||||
UpdateMenus(false);
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
QSetRect(&roomObjectRects[objActive], -1, -1, 0, 0);
|
||||
DeselectObject();
|
||||
ReadyBackground(thisRoom->background, thisRoom->tiles);
|
||||
DrawThisRoomsObjects();
|
||||
|
||||
UpdateMainWindow();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "Externs.h"
|
||||
#include "ObjectEdit.h"
|
||||
#include "PLStandardColors.h"
|
||||
#include "PLTimeTaggedVOSEvent.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
|
||||
@@ -78,7 +80,7 @@ void UpdateInvisBonusInfo (Dialog *);
|
||||
void UpdateTransInfo (Dialog *);
|
||||
void UpdateEnemyInfo (Dialog *);
|
||||
void UpdateFlowerInfo (Dialog *);
|
||||
Boolean BlowerFilter (Dialog *, EventRecord *, short *);
|
||||
int16_t BlowerFilter (Dialog *, const TimeTaggedVOSEvent *evt);
|
||||
Boolean FurnitureFilter (Dialog *, EventRecord *, short *);
|
||||
Boolean CustPictFilter (Dialog *, EventRecord *, short *);
|
||||
Boolean SwitchFilter (Dialog *, EventRecord *, short *);
|
||||
@@ -124,12 +126,16 @@ void UpdateBlowerInfo (Dialog *theDialog)
|
||||
{
|
||||
#define kArrowheadLength 4
|
||||
Rect bounds;
|
||||
|
||||
Window *window = theDialog->GetWindow();
|
||||
DrawSurface *surface = window->GetDrawSurface();
|
||||
surface->SetForeColor(StdColors::White());
|
||||
surface->FillRect((*surface->m_port.GetPixMap())->m_rect);
|
||||
|
||||
window->DrawControls();
|
||||
|
||||
DrawDialog(theDialog);
|
||||
DrawDefaultButton(theDialog);
|
||||
FrameDialogItemC(theDialog, 5, kRedOrangeColor8);
|
||||
|
||||
DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface();
|
||||
|
||||
if ((thisRoom->objects[objActive].what != kLeftFan) &&
|
||||
(thisRoom->objects[objActive].what != kRightFan))
|
||||
@@ -143,6 +149,8 @@ void UpdateBlowerInfo (Dialog *theDialog)
|
||||
bounds.right -= 2;
|
||||
bounds.bottom -= 2;
|
||||
|
||||
surface->SetForeColor(StdColors::Black());
|
||||
|
||||
for (int16_t offsetChunk = 0; offsetChunk < 4; offsetChunk++)
|
||||
{
|
||||
const int16_t xOffset = offsetChunk & 1;
|
||||
@@ -153,39 +161,39 @@ void UpdateBlowerInfo (Dialog *theDialog)
|
||||
switch (newDirection)
|
||||
{
|
||||
case 1: // up
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.top),
|
||||
offset + Point::Create(0, RectTall(&bounds)));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.top),
|
||||
offset + Point::Create(kArrowheadLength, kArrowheadLength));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.top),
|
||||
offset + Point::Create(-kArrowheadLength, kArrowheadLength));
|
||||
{
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // right
|
||||
surface->DrawLine(offset + Point::Create(bounds.right, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(-RectWide(&bounds), 0));
|
||||
surface->DrawLine(offset + Point::Create(bounds.right, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(-kArrowheadLength, kArrowheadLength));
|
||||
surface->DrawLine(offset + Point::Create(bounds.right, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(-kArrowheadLength, -kArrowheadLength));
|
||||
{
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: // down
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.top),
|
||||
offset + Point::Create(0, RectTall(&bounds)));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.bottom),
|
||||
offset + Point::Create(kArrowheadLength, -kArrowheadLength));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left + HalfRectWide(&bounds), bounds.bottom),
|
||||
offset + Point::Create(-kArrowheadLength, -kArrowheadLength));
|
||||
{
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
case 8: // left
|
||||
surface->DrawLine(offset + Point::Create(bounds.left, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(RectWide(&bounds), 0));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(kArrowheadLength, -kArrowheadLength));
|
||||
surface->DrawLine(offset + Point::Create(bounds.left, bounds.top + HalfRectTall(&bounds)),
|
||||
offset + Point::Create(kArrowheadLength, kArrowheadLength));
|
||||
{
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -347,56 +355,36 @@ void UpdateFlowerInfo (Dialog *theDialog)
|
||||
|
||||
//-------------------------------------------------------------- BlowerFilter
|
||||
|
||||
Boolean BlowerFilter (Dialog *dial, EventRecord *event, short *item)
|
||||
int16_t BlowerFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
{
|
||||
switch (event->what)
|
||||
if (!evt)
|
||||
return -1;
|
||||
|
||||
if (evt->IsKeyDownEvent())
|
||||
{
|
||||
case keyDown:
|
||||
switch (event->message)
|
||||
const GpKeyboardInputEvent &keyboardEvent = evt->m_vosEvent.m_event.m_keyboardInputEvent;
|
||||
|
||||
switch (PackVOSKeyCode(keyboardEvent))
|
||||
{
|
||||
case PL_KEY_SPECIAL(kEnter):
|
||||
case PL_KEY_NUMPAD_SPECIAL(kEnter):
|
||||
case PL_KEY_SPECIAL(kEnter):
|
||||
case PL_KEY_NUMPAD_SPECIAL(kEnter):
|
||||
FlashDialogButton(dial, kOkayButton);
|
||||
*item = kOkayButton;
|
||||
return(true);
|
||||
break;
|
||||
|
||||
case PL_KEY_SPECIAL(kEscape):
|
||||
return kOkayButton;
|
||||
|
||||
case PL_KEY_SPECIAL(kEscape):
|
||||
FlashDialogButton(dial, kCancelButton);
|
||||
*item = kCancelButton;
|
||||
return(true);
|
||||
break;
|
||||
|
||||
case PL_KEY_SPECIAL(kTab):
|
||||
// SelectDialogItemText(dial, kRoomNameItem, 0, 1024);
|
||||
return(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case mouseDown:
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case mouseUp:
|
||||
return(false);
|
||||
break;
|
||||
|
||||
case updateEvt:
|
||||
SetPortDialogPort(dial);
|
||||
UpdateBlowerInfo(dial);
|
||||
EndUpdate(dial->GetWindow());
|
||||
event->what = nullEvent;
|
||||
return(false);
|
||||
break;
|
||||
|
||||
return kCancelButton;
|
||||
|
||||
case PL_KEY_SPECIAL(kTab):
|
||||
// SelectDialogItemText(dial, kRoomNameItem, 0, 1024);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return(false);
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- FurnitureFilter
|
||||
@@ -985,7 +973,9 @@ void DoBlowerObjectInfo (short what)
|
||||
|
||||
if (retroLinkList[objActive].room == -1)
|
||||
HideDialogItem(infoDial, 15);
|
||||
|
||||
|
||||
UpdateBlowerInfo(infoDial);
|
||||
|
||||
ShowWindow(infoDial->GetWindow());
|
||||
|
||||
leaving = false;
|
||||
@@ -993,7 +983,7 @@ void DoBlowerObjectInfo (short what)
|
||||
|
||||
while (!leaving)
|
||||
{
|
||||
ModalDialog(BlowerFilter, &item);
|
||||
item = infoDial->ExecuteModal(BlowerFilter);
|
||||
|
||||
if (item == kOkayButton)
|
||||
{
|
||||
@@ -1012,10 +1002,10 @@ void DoBlowerObjectInfo (short what)
|
||||
if (KeepObjectLegal())
|
||||
{
|
||||
}
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
GetThisRoomsObjRects();
|
||||
ReadyBackground(thisRoom->background, thisRoom->tiles);
|
||||
DrawThisRoomsObjects();
|
||||
UpdateMainWindow();
|
||||
}
|
||||
fileDirty = true;
|
||||
UpdateMenus(false);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
|
||||
void UpdateRoomInfoDialog (Dialog *);
|
||||
void DragMiniTile (DrawSurface *, Point, short *);
|
||||
void DragMiniTile (Window *, DrawSurface *, Point, short *);
|
||||
void HiliteTileOver (DrawSurface *, Point);
|
||||
int16_t RoomFilter (Dialog *dialog, const TimeTaggedVOSEvent *evt);
|
||||
|
||||
@@ -125,7 +125,7 @@ void UpdateRoomInfoDialog (Dialog *theDialog)
|
||||
//-------------------------------------------------------------- DragMiniTile
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
void DragMiniTile (DrawSurface *surface, Point mouseIs, short *newTileOver)
|
||||
void DragMiniTile (Window *window, DrawSurface *surface, Point mouseIs, short *newTileOver)
|
||||
{
|
||||
Rect dragRect;
|
||||
Point mouseWas;
|
||||
@@ -146,8 +146,8 @@ void DragMiniTile (DrawSurface *surface, Point mouseIs, short *newTileOver)
|
||||
mouseWas = mouseIs;
|
||||
while (WaitMouseUp()) // loop until mouse button let up
|
||||
{
|
||||
GetMouse(&mouseIs); // get mouse coords
|
||||
if (DeltaPoint(mouseWas, mouseIs) != 0L) // the mouse has moved
|
||||
GetMouse(window, &mouseIs); // get mouse coords
|
||||
if (mouseWas != mouseIs) // the mouse has moved
|
||||
{
|
||||
surface->InvertFrameRect(dragRect, pattern);
|
||||
QOffsetRect(&dragRect, mouseIs.h - mouseWas.h, 0);
|
||||
@@ -358,6 +358,7 @@ int16_t RoomFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
if (!evt)
|
||||
return -1;
|
||||
|
||||
Window *window = dial->GetWindow();
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
|
||||
if (evt->IsKeyDownEvent())
|
||||
@@ -393,7 +394,7 @@ int16_t RoomFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
|
||||
{
|
||||
if (StillDown())
|
||||
{
|
||||
DragMiniTile(surface, mouseIs, &newTileOver);
|
||||
DragMiniTile(window, surface, mouseIs, &newTileOver);
|
||||
if ((newTileOver >= 0) && (newTileOver < kNumTiles))
|
||||
{
|
||||
tempTiles[newTileOver] = tileOver;
|
||||
|
||||
@@ -108,9 +108,14 @@ void OpenMessageWindow (const PLPasStr &title)
|
||||
|
||||
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
|
||||
|
||||
const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(mssgWindowRect, windowStyle, false, 0, 0, title);
|
||||
Rect placementRect = mssgWindowRect;
|
||||
CenterRectInRect(&placementRect, &thisMac.screen);
|
||||
|
||||
mssgWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(wdef);
|
||||
const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(placementRect, windowStyle, false, 0, 0, title);
|
||||
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
mssgWindow = wm->CreateWindow(wdef);
|
||||
wm->PutWindowBehind(mssgWindow, wm->GetPutInFrontSentinel());
|
||||
|
||||
if (mssgWindow != nil)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "InputManager.h"
|
||||
#include "MacRomanConversion.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "Vec2i.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
@@ -17,6 +18,7 @@ namespace PortabilityLayer
|
||||
void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) override;
|
||||
void ApplyMouseEvent(const GpMouseInputEvent &vosEvent) override;
|
||||
int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) override;
|
||||
Vec2i GetMousePosition() const override;
|
||||
void ClearState() override;
|
||||
|
||||
static InputManagerImpl *GetInstance();
|
||||
@@ -28,6 +30,7 @@ namespace PortabilityLayer
|
||||
|
||||
KeyDownStates m_keyMap;
|
||||
int16_t m_axisStates[PL_INPUT_MAX_PLAYERS][GpGamepadAxes::kCount];
|
||||
Vec2i m_mousePos;
|
||||
|
||||
static InputManagerImpl ms_instance;
|
||||
};
|
||||
@@ -53,6 +56,9 @@ namespace PortabilityLayer
|
||||
|
||||
void InputManagerImpl::ApplyMouseEvent(const GpMouseInputEvent &vosEvent)
|
||||
{
|
||||
m_mousePos.m_x = vosEvent.m_x;
|
||||
m_mousePos.m_y = vosEvent.m_y;
|
||||
|
||||
if (vosEvent.m_eventType == GpMouseEventTypes::kUp || vosEvent.m_eventType == GpMouseEventTypes::kLeave)
|
||||
this->ApplyEventAsMouseButton(vosEvent, false);
|
||||
else if (vosEvent.m_eventType == GpMouseEventTypes::kDown)
|
||||
@@ -66,6 +72,11 @@ namespace PortabilityLayer
|
||||
return m_axisStates[playerNum][gamepadAxis];
|
||||
}
|
||||
|
||||
Vec2i InputManagerImpl::GetMousePosition() const
|
||||
{
|
||||
return m_mousePos;
|
||||
}
|
||||
|
||||
void InputManagerImpl::ClearState()
|
||||
{
|
||||
memset(&m_axisStates, 0, sizeof(m_axisStates));
|
||||
@@ -132,6 +143,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
|
||||
InputManagerImpl::InputManagerImpl()
|
||||
: m_mousePos(0, 0)
|
||||
{
|
||||
memset(m_axisStates, 0, sizeof(m_axisStates));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ struct KeyDownStates;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct Vec2i;
|
||||
|
||||
class InputManager
|
||||
{
|
||||
public:
|
||||
@@ -17,6 +19,7 @@ namespace PortabilityLayer
|
||||
virtual void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) = 0;
|
||||
virtual void ApplyMouseEvent(const GpMouseInputEvent &vosEvent) = 0;
|
||||
virtual int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) = 0;
|
||||
virtual Vec2i GetMousePosition() const = 0;
|
||||
virtual void ClearState() = 0;
|
||||
|
||||
static InputManager *GetInstance();
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t ButtonWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (m_haveMouseDown)
|
||||
{
|
||||
if (evt.IsLMouseUpEvent())
|
||||
|
||||
@@ -74,6 +74,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t CheckboxWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (m_haveMouseDown)
|
||||
{
|
||||
if (evt.IsLMouseUpEvent())
|
||||
|
||||
@@ -496,9 +496,11 @@ void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL)
|
||||
}
|
||||
}
|
||||
|
||||
void GetMouse(Point *point)
|
||||
void GetMouse(Window *window, Point *point)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
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()
|
||||
@@ -514,7 +516,11 @@ Boolean StillDown()
|
||||
|
||||
Boolean WaitMouseUp()
|
||||
{
|
||||
return StillDown();
|
||||
const Boolean isDown = StillDown();
|
||||
if (isDown)
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
return isDown;
|
||||
}
|
||||
|
||||
short Random()
|
||||
|
||||
@@ -285,7 +285,7 @@ PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfoOut);
|
||||
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID);
|
||||
void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL);
|
||||
|
||||
void GetMouse(Point *point);
|
||||
void GetMouse(Window *window, Point *point);
|
||||
Boolean Button(); // Returns true if there's a mouse down event in the queue
|
||||
Boolean StillDown();
|
||||
Boolean WaitMouseUp();
|
||||
|
||||
@@ -109,5 +109,5 @@ void ShowDialogItem(Dialog *dialog, int item)
|
||||
|
||||
void HideDialogItem(Dialog *dialog, int item)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
dialog->GetItems()[item - 1].GetWidget()->SetVisible(false);
|
||||
}
|
||||
|
||||
@@ -164,6 +164,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t EditboxWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (evt.m_vosEvent.m_eventType == GpVOSEventTypes::kKeyboardInput)
|
||||
{
|
||||
if (!m_hasFocus)
|
||||
|
||||
@@ -50,6 +50,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t IconWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (evt.IsLMouseDownEvent() && m_rect.Contains(m_window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent)))
|
||||
return WidgetHandleStates::kActivated;
|
||||
else
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t InvisibleWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (m_clickable && evt.IsLMouseDownEvent() && m_rect.Contains(m_window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent)))
|
||||
return WidgetHandleStates::kActivated;
|
||||
else
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
static inline void InvertPixel8(uint8_t &pixel)
|
||||
{
|
||||
pixel = 255 ^ pixel;
|
||||
}
|
||||
|
||||
|
||||
void GetPort(GrafPtr *graf)
|
||||
{
|
||||
@@ -1362,7 +1367,7 @@ void DrawSurface::InvertFrameRect(const Rect &rect, const uint8_t *pattern)
|
||||
{
|
||||
InvertFillRect(Rect::Create(rect.top, rect.left, rect.top + 1, rect.right), pattern);
|
||||
InvertFillRect(Rect::Create(rect.top + 1, rect.left, rect.bottom - 1, rect.left + 1), pattern);
|
||||
InvertFillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom + 1, rect.right), pattern);
|
||||
InvertFillRect(Rect::Create(rect.bottom - 1, rect.left, rect.bottom, rect.right), pattern);
|
||||
InvertFillRect(Rect::Create(rect.top + 1, rect.right - 1, rect.bottom - 1, rect.right), pattern);
|
||||
}
|
||||
}
|
||||
@@ -1414,7 +1419,7 @@ void DrawSurface::InvertFillRect(const Rect &rect, const uint8_t *pattern)
|
||||
{
|
||||
const int patternCol = static_cast<int>((patternFirstCol + col) & 7);
|
||||
if ((pattern[patternRow] >> patternCol) & 1)
|
||||
pixData[firstLineIndex + col] = 255 - pixData[firstLineIndex + col];
|
||||
InvertPixel8(pixData[firstLineIndex + col]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1477,11 +1482,6 @@ void PenNormal()
|
||||
qdState->m_penMask = false;
|
||||
}
|
||||
|
||||
void InvertRect(const Rect *rect)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
void InsetRect(Rect *rect, int x, int y)
|
||||
{
|
||||
rect->left += x;
|
||||
@@ -1783,7 +1783,7 @@ void ImageInvert(const PixMap *invertMask, PixMap *targetBitmap, const Rect &src
|
||||
const int32_t srcCol = c + firstSrcCol;
|
||||
const int32_t destCol = c + firstDestCol;
|
||||
if (invertRowStart[srcCol] != 0)
|
||||
targetRowStart[destCol] = 255 - targetRowStart[destCol];
|
||||
InvertPixel8(targetRowStart[destCol]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1814,14 +1814,6 @@ DrawSurface *GetWindowPort(WindowPtr window)
|
||||
return &window->m_surface;
|
||||
}
|
||||
|
||||
|
||||
Int32 DeltaPoint(Point pointA, Point pointB)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SubPt(Point srcPoint, Point *destPoint)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
|
||||
@@ -117,7 +117,6 @@ void PenMask(bool maskMode);
|
||||
void PenPat(const Pattern *pattern);
|
||||
void PenSize(int w, int h);
|
||||
void PenNormal();
|
||||
void InvertRect(const Rect *rect);
|
||||
void InsetRect(Rect *rect, int x, int y);
|
||||
Pattern *GetQDGlobalsGray(Pattern *pattern);
|
||||
Pattern *GetQDGlobalsBlack(Pattern *pattern);
|
||||
@@ -140,9 +139,6 @@ bool PointInScanlineMask(Point point, PortabilityLayer::ScanlineMask *scanlineMa
|
||||
PixMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr);
|
||||
DrawSurface *GetWindowPort(WindowPtr window);
|
||||
|
||||
// Computes A - B and returns it packed?
|
||||
Int32 DeltaPoint(Point pointA, Point pointB);
|
||||
|
||||
// Subtracts srcPoint from destPoint (reverse of DeltaPoint)
|
||||
void SubPt(Point srcPoint, Point *destPoint);
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ namespace PortabilityLayer
|
||||
|
||||
WidgetHandleState_t RadioButtonWidget::ProcessEvent(const TimeTaggedVOSEvent &evt)
|
||||
{
|
||||
if (!m_visible || !m_enabled)
|
||||
return WidgetHandleStates::kIgnored;
|
||||
|
||||
if (m_haveMouseDown)
|
||||
{
|
||||
if (evt.IsLMouseUpEvent())
|
||||
|
||||
@@ -18,6 +18,9 @@ struct Point
|
||||
Point &operator-=(const Point &other);
|
||||
Point &operator+=(const Point &other);
|
||||
|
||||
bool operator==(const Point &other) const;
|
||||
bool operator!=(const Point &other) const;
|
||||
|
||||
static Point Create(int16_t h, int16_t v);
|
||||
};
|
||||
|
||||
@@ -139,6 +142,17 @@ inline Point &Point::operator+=(const Point &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Point::operator==(const Point &other) const
|
||||
{
|
||||
return this->h == other.h && this->v == other.v;
|
||||
}
|
||||
|
||||
inline bool Point::operator!=(const Point &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
|
||||
inline Point Point::Create(int16_t h, int16_t v)
|
||||
{
|
||||
Point p;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
virtual void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const = 0;
|
||||
virtual void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const = 0;
|
||||
virtual bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID &outRegion) const = 0;
|
||||
virtual bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const = 0;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -46,7 +46,7 @@ namespace PortabilityLayer
|
||||
public:
|
||||
void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const override;
|
||||
void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const override;
|
||||
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID &outRegion) const override;
|
||||
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const override;
|
||||
};
|
||||
|
||||
class GenericWindowChromeTheme final : public WindowChromeThemeSingleton<GenericWindowChromeTheme>
|
||||
@@ -54,7 +54,7 @@ namespace PortabilityLayer
|
||||
public:
|
||||
void GetChromePadding(const WindowImpl *window, uint16_t padding[WindowChromeSides::kCount]) const override;
|
||||
void RenderChrome(WindowImpl *window, DrawSurface *surface, WindowChromeSide_t chromeSide) const override;
|
||||
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID &outRegion) const override;
|
||||
bool GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const override;
|
||||
|
||||
private:
|
||||
void RenderChromeTop(WindowImpl *window, DrawSurface *surface) const;
|
||||
@@ -93,7 +93,7 @@ namespace PortabilityLayer
|
||||
|
||||
void GetChromePadding(uint16_t padding[WindowChromeSides::kCount]) const;
|
||||
void GetChromeDimensions(int width, int height, Rect dimensions[WindowChromeSides::kCount]) const;
|
||||
bool GetChromeInteractionZone(const Vec2i &point, RegionID &outRegion) const;
|
||||
bool GetChromeInteractionZone(const Vec2i &point, RegionID_t &outRegion) const;
|
||||
|
||||
bool IsBorderless() const;
|
||||
uint16_t GetStyleFlags() const;
|
||||
@@ -163,7 +163,7 @@ namespace PortabilityLayer
|
||||
padding[WindowChromeSides::kRight] = 1;
|
||||
}
|
||||
|
||||
bool SimpleBoxChromeTheme::GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID &outRegion) const
|
||||
bool SimpleBoxChromeTheme::GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
bool GenericWindowChromeTheme::GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID &outRegion) const
|
||||
bool GenericWindowChromeTheme::GetChromeInteractionZone(const WindowImpl *window, const Vec2i &point, RegionID_t &outRegion) const
|
||||
{
|
||||
const DrawSurface *surface = window->GetDrawSurface();
|
||||
const Rect rect = (*surface->m_port.GetPixMap())->m_rect;
|
||||
@@ -214,7 +214,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
if (point.m_x >= 0 && point.m_x < rect.Width() && point.m_y < 0 && point.m_y >= -13)
|
||||
{
|
||||
outRegion = RegionID::inDrag;
|
||||
outRegion = RegionIDs::kTitleBar;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
if (point.m_x >= 0 && point.m_x < rect.Width() && point.m_y < 0 && point.m_y >= -17)
|
||||
{
|
||||
outRegion = RegionID::inDrag;
|
||||
outRegion = RegionIDs::kTitleBar;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -457,6 +457,8 @@ namespace PortabilityLayer
|
||||
m_styleFlags = windowDef.m_styleFlags;
|
||||
|
||||
const Rect adjustedBounds = Rect::Create(0, 0, bounds.Height(), bounds.Width());
|
||||
m_wmX = bounds.left;
|
||||
m_wmY = bounds.top;
|
||||
|
||||
GpPixelFormat_t pixelFormat = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetPixelFormat();
|
||||
|
||||
@@ -565,7 +567,7 @@ namespace PortabilityLayer
|
||||
dimensions[WindowChromeSides::kRight] = Rect::Create(0, 0, leftAndRightHeight, padding[WindowChromeSides::kRight]);
|
||||
}
|
||||
|
||||
bool WindowImpl::GetChromeInteractionZone(const Vec2i &point, RegionID &outRegion) const
|
||||
bool WindowImpl::GetChromeInteractionZone(const Vec2i &point, RegionID_t &outRegion) const
|
||||
{
|
||||
return m_chromeTheme->GetChromeInteractionZone(this, point, outRegion);
|
||||
}
|
||||
@@ -669,24 +671,13 @@ namespace PortabilityLayer
|
||||
|
||||
void WindowManagerImpl::FindWindow(const Point &point, Window **outWindow, short *outRegion) const
|
||||
{
|
||||
// outRegion = One of:
|
||||
/*
|
||||
inMenuBar,
|
||||
inContent,
|
||||
inDrag,
|
||||
inGrow,
|
||||
inGoAway,
|
||||
inZoomIn,
|
||||
inZoomOut,
|
||||
*/
|
||||
|
||||
if (PortabilityLayer::MenuManager::GetInstance()->IsPointInMenuBar(PortabilityLayer::Vec2i(point.h, point.v)))
|
||||
{
|
||||
if (outWindow)
|
||||
*outWindow = nullptr;
|
||||
|
||||
if (outRegion)
|
||||
*outRegion = inMenuBar;
|
||||
*outRegion = RegionIDs::kMenuBar;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -699,7 +690,7 @@ namespace PortabilityLayer
|
||||
const int32_t localX = point.h - window->m_wmX;
|
||||
const int32_t localY = point.v - window->m_wmY;
|
||||
|
||||
RegionID chromeInteractionZone = inContent;
|
||||
RegionID_t chromeInteractionZone = RegionIDs::kContent;
|
||||
if (window->GetChromeInteractionZone(Vec2i(localX, localY), chromeInteractionZone))
|
||||
{
|
||||
*outRegion = chromeInteractionZone;
|
||||
@@ -713,7 +704,7 @@ namespace PortabilityLayer
|
||||
*outWindow = window;
|
||||
|
||||
if (outRegion)
|
||||
*outRegion = inContent;
|
||||
*outRegion = RegionIDs::kContent;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user