Reduce use of display.h (dp_xres, dp_yres) now that uicontext has bounds

This commit is contained in:
Henrik Rydgard
2014-02-10 12:44:36 +01:00
parent 8b6b491820
commit 4d00a9b4bc
10 changed files with 95 additions and 69 deletions
+17 -15
View File
@@ -17,16 +17,18 @@
#include <vector>
#include "base/display.h"
#include "base/colorutil.h"
#include "gfx_es2/draw_buffer.h"
#include "i18n/i18n.h"
#include "ui/ui_context.h"
#include "ui_atlas.h"
#include "TouchControlLayoutScreen.h"
#include "TouchControlVisibilityScreen.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "base/colorutil.h"
#include "ui/ui_context.h"
#include "ui_atlas.h"
#include "gfx_es2/draw_buffer.h"
#include "GamepadEmu.h"
#include "i18n/i18n.h"
static const int leftColumnWidth = 140;
@@ -34,16 +36,6 @@ static u32 GetButtonColor() {
return g_Config.iTouchButtonStyle == 1 ? 0xFFFFFF : 0xc0b080;
}
// convert from screen coordinates (leftColumnWidth to dp_xres) to actual fullscreen coordinates (0 to 1.0)
static inline float toFullscreenCoord(int screenx) {
return (float)(screenx - leftColumnWidth) / (dp_xres - leftColumnWidth);
}
// convert from external fullscreen coordinates(0 to 1.0) to the current partial coordinates (leftColumnWidth to dp_xres)
static inline int fromFullscreenCoord(float controllerX) {
return leftColumnWidth + (dp_xres - leftColumnWidth) * controllerX;
};
class DragDropButton : public MultiTouchButton {
public:
DragDropButton(float &x, float &y, int bgImg, int img, float &scale)
@@ -71,6 +63,16 @@ public:
virtual void SetSpacing(float s) { }
private:
// convert from screen coordinates (leftColumnWidth to dp_xres) to actual fullscreen coordinates (0 to 1.0)
inline float toFullscreenCoord(int screenx) {
return (float)(screenx - leftColumnWidth) / (dp_xres - leftColumnWidth);
}
// convert from external fullscreen coordinates(0 to 1.0) to the current partial coordinates (leftColumnWidth to dp_xres)
inline int fromFullscreenCoord(float controllerX) {
return leftColumnWidth + (dp_xres - leftColumnWidth) * controllerX;
};
float &x_, &y_;
float &theScale_;
};