mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Add scroll bar highlights
This commit is contained in:
@@ -13,6 +13,8 @@ namespace PortabilityLayer
|
|||||||
, m_gripSize(0)
|
, m_gripSize(0)
|
||||||
, m_gripPos(0)
|
, m_gripPos(0)
|
||||||
, m_laneCapacity(0)
|
, m_laneCapacity(0)
|
||||||
|
, m_isActive(false)
|
||||||
|
, m_activePart(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,21 +61,37 @@ namespace PortabilityLayer
|
|||||||
ResolveCachingColor whiteColor = StdColors::White();
|
ResolveCachingColor whiteColor = StdColors::White();
|
||||||
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
|
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
|
||||||
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 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);
|
surface->FrameRect(m_rect, blackColor);
|
||||||
|
|
||||||
const Rect leftArrowRect = Rect::Create(m_rect.top, m_rect.left, m_rect.bottom, m_rect.left + 16);
|
const Rect leftArrowRect = Rect::Create(m_rect.top, m_rect.left, m_rect.bottom, m_rect.left + 16);
|
||||||
DrawBeveledBox(surface, leftArrowRect);
|
DrawBeveledBox(surface, leftArrowRect);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlUpButtonPart)
|
||||||
|
{
|
||||||
|
surface->FillRect(leftArrowRect.Inset(1, 1), darkGrayColor);
|
||||||
|
leftArrowColor = &whiteColor;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
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);
|
const Rect arrowSegRect = Rect::Create(7 - i + leftArrowRect.top, 6 + i + leftArrowRect.left, 9 + i + leftArrowRect.top, 7 + i + leftArrowRect.left);
|
||||||
surface->FillRect(arrowSegRect, blackColor);
|
surface->FillRect(arrowSegRect, *leftArrowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rect rightArrowRect = Rect::Create(m_rect.top, m_rect.right - 16, m_rect.bottom, m_rect.right);
|
const Rect rightArrowRect = Rect::Create(m_rect.top, m_rect.right - 16, m_rect.bottom, m_rect.right);
|
||||||
DrawBeveledBox(surface, rightArrowRect);
|
DrawBeveledBox(surface, rightArrowRect);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlDownButtonPart)
|
||||||
|
{
|
||||||
|
surface->FillRect(rightArrowRect.Inset(1, 1), darkGrayColor);
|
||||||
|
rightArrowColor = &whiteColor;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
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);
|
const Rect arrowSegRect = Rect::Create(4 + i + rightArrowRect.top, 6 + i + rightArrowRect.left, 12 - i + rightArrowRect.top, 7 + i + rightArrowRect.left);
|
||||||
@@ -88,6 +106,12 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
surface->FillRect(Rect::Create(laneRect.bottom - 2, laneRect.left, laneRect.bottom - 1, laneRect.right), whiteColor);
|
surface->FillRect(Rect::Create(laneRect.bottom - 2, laneRect.left, laneRect.bottom - 1, laneRect.right), whiteColor);
|
||||||
|
|
||||||
|
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.top, laneRect.left, laneRect.top + 1, laneRect.right), blackColor);
|
||||||
surface->FillRect(Rect::Create(laneRect.bottom - 1, laneRect.left, laneRect.bottom, laneRect.right), blackColor);
|
surface->FillRect(Rect::Create(laneRect.bottom - 1, laneRect.left, laneRect.bottom, laneRect.right), blackColor);
|
||||||
|
|
||||||
@@ -102,25 +126,42 @@ namespace PortabilityLayer
|
|||||||
ResolveCachingColor whiteColor = StdColors::White();
|
ResolveCachingColor whiteColor = StdColors::White();
|
||||||
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
|
ResolveCachingColor midGrayColor = RGBAColor::Create(136, 136, 136, 255);
|
||||||
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 255);
|
ResolveCachingColor lightGrayColor = RGBAColor::Create(187, 187, 187, 255);
|
||||||
|
ResolveCachingColor darkGrayColor = RGBAColor::Create(85, 85, 85, 255);
|
||||||
|
|
||||||
surface->FrameRect(m_rect, blackColor);
|
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);
|
const Rect topArrowRect = Rect::Create(m_rect.top, m_rect.left, m_rect.top + 16, m_rect.right);
|
||||||
DrawBeveledBox(surface, topArrowRect);
|
DrawBeveledBox(surface, topArrowRect);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlUpButtonPart)
|
||||||
|
{
|
||||||
|
surface->FillRect(topArrowRect.Inset(1, 1), darkGrayColor);
|
||||||
|
topArrowColor = &whiteColor;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
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);
|
const Rect arrowSegRect = Rect::Create(6 + i + topArrowRect.top, 7 - i + topArrowRect.left, 7 + i + topArrowRect.top, 9 + i + topArrowRect.left);
|
||||||
surface->FillRect(arrowSegRect, blackColor);
|
surface->FillRect(arrowSegRect, *topArrowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rect bottomArrowRect = Rect::Create(m_rect.bottom - 16, m_rect.left, m_rect.bottom, m_rect.right);
|
const Rect bottomArrowRect = Rect::Create(m_rect.bottom - 16, m_rect.left, m_rect.bottom, m_rect.right);
|
||||||
DrawBeveledBox(surface, bottomArrowRect);
|
DrawBeveledBox(surface, bottomArrowRect);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlDownButtonPart)
|
||||||
|
{
|
||||||
|
surface->FillRect(bottomArrowRect.Inset(1, 1), darkGrayColor);
|
||||||
|
bottomArrowColor = &whiteColor;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
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);
|
const Rect arrowSegRect = Rect::Create(6 + i + bottomArrowRect.top, 4 + i + bottomArrowRect.left, 7 + i + bottomArrowRect.top, 12 - i + bottomArrowRect.left);
|
||||||
surface->FillRect(arrowSegRect, blackColor);
|
surface->FillRect(arrowSegRect, *bottomArrowColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rect laneRect = Rect::Create(topArrowRect.bottom, m_rect.left, bottomArrowRect.top, m_rect.right);
|
const Rect laneRect = Rect::Create(topArrowRect.bottom, m_rect.left, bottomArrowRect.top, m_rect.right);
|
||||||
@@ -128,6 +169,13 @@ namespace PortabilityLayer
|
|||||||
surface->FillRect(Rect::Create(laneRect.top, laneRect.left + 1, laneRect.bottom, laneRect.left + 2), midGrayColor);
|
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.top, laneRect.left + 2, laneRect.bottom, laneRect.right - 2), lightGrayColor);
|
||||||
surface->FillRect(Rect::Create(laneRect.bottom, laneRect.right - 2, laneRect.bottom, laneRect.right - 1), whiteColor);
|
surface->FillRect(Rect::Create(laneRect.bottom, laneRect.right - 2, laneRect.bottom, laneRect.right - 1), whiteColor);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlPageUpPart)
|
||||||
|
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.top + m_gripPos, laneRect.right), darkGrayColor);
|
||||||
|
|
||||||
|
if (m_isActive && m_activePart == kControlPageDownPart)
|
||||||
|
surface->FillRect(Rect::Create(laneRect.top + m_gripPos, laneRect.left, laneRect.bottom, laneRect.right), darkGrayColor);
|
||||||
|
|
||||||
surface->FillRect(Rect::Create(laneRect.top, laneRect.left, laneRect.bottom, laneRect.left + 1), blackColor);
|
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);
|
surface->FillRect(Rect::Create(laneRect.top, laneRect.right - 1, laneRect.bottom, laneRect.right), blackColor);
|
||||||
|
|
||||||
@@ -248,23 +296,31 @@ namespace PortabilityLayer
|
|||||||
int tickDelay = 15;
|
int tickDelay = 15;
|
||||||
|
|
||||||
Point currentPos = pos;
|
Point currentPos = pos;
|
||||||
bool wasInBounds = false;
|
bool wasActive = false;
|
||||||
bool isInBounds = (ResolvePart(pos) == part);
|
|
||||||
|
m_activePart = part;
|
||||||
|
|
||||||
int ticksUntilIterate = 0;
|
int ticksUntilIterate = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
m_isActive = (ResolvePart(currentPos) == part); // Update in-bounds since the scroll may invalidate it
|
||||||
|
|
||||||
if (ticksUntilIterate == 0)
|
if (ticksUntilIterate == 0)
|
||||||
{
|
{
|
||||||
if (isInBounds)
|
if (m_isActive)
|
||||||
{
|
|
||||||
IterateScrollSegment(part, callback);
|
IterateScrollSegment(part, callback);
|
||||||
isInBounds = (ResolvePart(currentPos) == part); // Update in-bounds since the scroll may invalidate it
|
|
||||||
}
|
|
||||||
|
|
||||||
ticksUntilIterate = tickDelay;
|
ticksUntilIterate = tickDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_isActive != wasActive)
|
||||||
|
{
|
||||||
|
wasActive = m_isActive;
|
||||||
|
ticksUntilIterate = tickDelay;
|
||||||
|
|
||||||
|
DrawControl(m_window->GetDrawSurface());
|
||||||
|
}
|
||||||
|
|
||||||
TimeTaggedVOSEvent evt;
|
TimeTaggedVOSEvent evt;
|
||||||
if (WaitForEvent(&evt, 1))
|
if (WaitForEvent(&evt, 1))
|
||||||
{
|
{
|
||||||
@@ -272,11 +328,19 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
|
const GpMouseInputEvent &mouseEvt = evt.m_vosEvent.m_event.m_mouseInputEvent;
|
||||||
if (mouseEvt.m_button == GpMouseButtons::kLeft && mouseEvt.m_eventType == GpMouseEventTypes::kUp)
|
if (mouseEvt.m_button == GpMouseButtons::kLeft && mouseEvt.m_eventType == GpMouseEventTypes::kUp)
|
||||||
|
{
|
||||||
|
if (m_isActive)
|
||||||
|
{
|
||||||
|
m_isActive = false;
|
||||||
|
DrawControl(m_window->GetDrawSurface());
|
||||||
|
}
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentPos = m_window->MouseToLocal(mouseEvt);
|
currentPos = m_window->MouseToLocal(mouseEvt);
|
||||||
isInBounds = (ResolvePart(currentPos) == part);
|
m_isActive = (ResolvePart(currentPos) == part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,5 +48,8 @@ namespace PortabilityLayer
|
|||||||
int32_t m_gripSize;
|
int32_t m_gripSize;
|
||||||
int32_t m_gripPos;
|
int32_t m_gripPos;
|
||||||
int32_t m_laneCapacity;
|
int32_t m_laneCapacity;
|
||||||
|
|
||||||
|
bool m_isActive;
|
||||||
|
int m_activePart;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user