Commit 902c65d0 authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

Adjustments for disabled hovering (Good for touch devices)

parent 8ed11d26
......@@ -9,6 +9,8 @@ set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
option(USE_VIRTUALPAD "Enable Onscreen Virtual Gamepad support " yes)
if(USE_VIRTUALPAD)
ADD_DEFINITIONS(-DVIRTUALPAD)
endif(USE_VIRTUALPAD)
......
......@@ -8,7 +8,6 @@ Project(GsKit)
OPTION(USE_SDL2 "SDL2 support" Yes)
option(USE_PYTHON3 "Use Python3 scripts" yes)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......
......@@ -777,7 +777,8 @@ void CInput::pollEvents()
else
#endif
{
const Vector2D<int> rotPt(Event.tfinger.x, Event.tfinger.y);
const Vector2D<int> rotPt(Event.tfinger.x,
Event.tfinger.y);
transMouseRelCoord(Pos, rotPt, activeArea, tiltedScreen);
m_EventList.add( new PointingDevEvent( Pos, PDE_BUTTONDOWN ) );
gPointDevice.mPointingState.mActionButton = 1;
......
......@@ -11,6 +11,7 @@
#include <base/video/CVideoDriver.h>
#include <base/GsTimer.h>
#include <base/PointDevice.h>
#include <base/GsLogging.h>
#include "GsControl.h"
......@@ -75,6 +76,7 @@ void GsControl::processPointingState(const GsRect<float> &rect)
const bool hasPoint = rect.HasPoint(pointingState.mPos);
const bool bDown = (pointingState.mActionButton>0);
mReleased = false;
if(!bDown && mPressed)
......@@ -83,6 +85,9 @@ void GsControl::processPointingState(const GsRect<float> &rect)
if(hasPoint)
{
gLogging.ftextOut("rect = %f,%f,%f,%f\n", rect.x, rect.y, rect.w, rect.h);
gLogging.ftextOut("pointingState.mPos = %f,%f\n", pointingState.mPos.x, pointingState.mPos.y);
mReleased = true;
}
}
......@@ -100,7 +105,10 @@ void GsControl::processPointingState(const GsRect<float> &rect)
#else
if(bDown)
{
mPressed = true;
if(hasPoint)
{
mPressed = true;
}
}
#endif
}
......
......@@ -94,7 +94,9 @@ protected:
int mFontID = 0;
// For mouse/touch we have those
#ifndef DISABLE_HOVER
bool mHovered = false;
#endif
bool mPressed = false;
bool mReleased = false;
......@@ -110,11 +112,13 @@ protected:
/**
* @brief mHoverTriggers This is for touch friendly devices were there is no device
*/
#ifndef DISABLE_HOVER
#ifdef ANDROID
static const bool mHoverTriggers = true;
#else
static const bool mHoverTriggers = false;
#endif
#endif
};
......
......@@ -165,7 +165,7 @@ void CGUINumberControl::processLogic()
}
}
#else
if(bDown)
if(bDown && hasPoint)
{
mPressed = true;
......
......@@ -129,10 +129,12 @@ void CGUITextSelectionList::processLogic()
it->mBgColor.converge( GsColor(0xB5, 0xB5, 0xF1, 0xFF) );
}
}
#ifndef DISABLE_HOVER
else if( mHoverSelection == curLinePos )
{
it->mBgColor.converge( GsColor(0xC5, 0xC5, 0xC5, 0xFF) );
}
#endif
}
......@@ -179,6 +181,7 @@ void CGUITextSelectionList::processLogic()
if( mousePos.x > x_innerbound_min && mousePos.y > y_innerbound_min)
{
/*
if(mHoverTriggers)
{
if(mHovered)
......@@ -188,12 +191,14 @@ void CGUITextSelectionList::processLogic()
mReleasedSelection = newselection;
}
}
else
else*/
{
#ifndef DISABLE_HOVER
if(mHovered)
{
mHoverSelection = newselection;
}
#endif
if(mPressed)
{
mPressedSelection = newselection;
......@@ -208,7 +213,9 @@ void CGUITextSelectionList::processLogic()
}
else
{
#ifndef DISABLE_HOVER
mHoverSelection = -1;
#endif
mPressedSelection = -1;
}
}
......@@ -277,11 +284,13 @@ void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloa
rect.y = ypos + (line*rect.h);
blitsfc.fillRGBA(rect, theColor);
}
#ifndef DISABLE_HOVER
else if( mHoverSelection == curLinePos )
{
rect.y = ypos+(line*sepHeight);
blitsfc.fillRGBA(rect, theColor);
}
#endif
std::string trimmedText = theText;
......
......@@ -82,7 +82,9 @@ private:
std::vector<item> mItemList;
#ifndef DISABLE_HOVER
int mHoverSelection = 0;
#endif
int mPressedSelection = -1;
int mReleasedSelection = -1;
......
......@@ -27,8 +27,13 @@ void BorderedButton::processRender(const GsRect<float> &RectDispCoordFloat)
if(!mEnabled)
newcolor = blitsfc.mapRGB(123, 150, 123);
#ifndef DISABLE_HOVER
else if(mHovered || mPressed)
newcolor = blitsfc.mapRGB(84, 234, 84);
#else
else if(mPressed)
newcolor = blitsfc.mapRGB(84, 234, 84);
#endif
else
newcolor = blitsfc.mapRGB(38, 134, 38);
......@@ -43,11 +48,13 @@ void BorderedButton::processRender(const GsRect<float> &RectDispCoordFloat)
}
else
{
#ifndef DISABLE_HOVER
if(mHovered)
{
drawEnabledButton(blitsfc, lRect, true);
}
else
#endif
{
drawEnabledButton(blitsfc, lRect, false);
}
......
......@@ -60,7 +60,11 @@ void GameButton::processRender(const GsRect<float> &RectDispCoordFloat)
}
else
{
#ifndef DISABLE_HOVER
drawEnabledButton(blitsfc, lRect, mHovered);
#else
drawEnabledButton(blitsfc, lRect, false);
#endif
}
drawBlinker(lRect);
......
......@@ -72,7 +72,11 @@ void ComboSelection::processRender(const GsRect<float> &RectDispCoordFloat)
}
else
{
#ifndef DISABLE_HOVER
drawEnabledButton(blitsfc, lRect, mHovered);
#else
drawEnabledButton(blitsfc, lRect, false);
#endif
}
drawBlinker(lRect);
......
......@@ -28,8 +28,13 @@ void InputText::processRender(const GsRect<float> &RectDispCoordFloat)
Uint32 newcolor;
#ifndef DISABLE_HOVER
if(mHovered || mPressed || mSelected)
newcolor = blit.mapRGB(84, 234, 84);
#else
if(mPressed || mSelected)
newcolor = blit.mapRGB(84, 234, 84);
#endif
else
newcolor = blit.mapRGB(38, 134, 38);
......
......@@ -106,9 +106,9 @@ void NumberControl::processRender(const GsRect<float> &RectDispCoordFloat)
mTextDisabledSfc.blitTo(blitsfc, lRect);
}
else
{
{
#ifndef DISABLE_HOVER
drawEnabledButton(blitsfc, lRect, mHovered);
if(mHovered)
{
if(mDecSel)
......@@ -118,6 +118,9 @@ void NumberControl::processRender(const GsRect<float> &RectDispCoordFloat)
else
mTextLightSfc.blitTo(blitsfc, lRect);
}
#else
drawEnabledButton(blitsfc, lRect, false);
#endif
}
drawBlinker(lRect);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment