mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 13:03:27 +02:00
rework map rendering
This commit is contained in:
@@ -26,6 +26,15 @@
|
||||
|
||||
uint FrameBuffer::boundFbo = 0;
|
||||
|
||||
FrameBuffer::FrameBuffer()
|
||||
{
|
||||
m_clearColor = Fw::alpha;
|
||||
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
if(!m_fbo)
|
||||
logFatal("Unable to create framebuffer object");
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer(const Size& size)
|
||||
{
|
||||
m_clearColor = Fw::alpha;
|
||||
@@ -44,6 +53,9 @@ FrameBuffer::~FrameBuffer()
|
||||
|
||||
void FrameBuffer::resize(const Size& size)
|
||||
{
|
||||
if(!size.isValid())
|
||||
return;
|
||||
|
||||
if(m_texture && m_texture->getSize() == size)
|
||||
return;
|
||||
|
||||
@@ -88,6 +100,11 @@ void FrameBuffer::generateMipmaps()
|
||||
m_texture->generateMipmaps();
|
||||
}
|
||||
|
||||
void FrameBuffer::draw(const Rect& dest, const Rect& src)
|
||||
{
|
||||
g_painter.drawTexturedRect(dest, m_texture, src);
|
||||
}
|
||||
|
||||
void FrameBuffer::draw(const Rect& dest)
|
||||
{
|
||||
g_painter.drawTexturedRect(dest, m_texture);
|
||||
|
@@ -24,10 +24,12 @@
|
||||
#define FRAMEBUFFER_H
|
||||
|
||||
#include "declarations.h"
|
||||
#include "texture.h"
|
||||
|
||||
class FrameBuffer
|
||||
{
|
||||
public:
|
||||
FrameBuffer();
|
||||
FrameBuffer(const Size& size);
|
||||
virtual ~FrameBuffer();
|
||||
|
||||
@@ -36,10 +38,12 @@ public:
|
||||
void release();
|
||||
void generateMipmaps();
|
||||
void draw(const Rect& dest);
|
||||
void draw(const Rect& dest, const Rect& src);
|
||||
|
||||
void setClearColor(const Color& color) { m_clearColor = color; }
|
||||
|
||||
TexturePtr getTexture() { return m_texture; }
|
||||
const Size& getSize() { return m_texture->getSize(); }
|
||||
|
||||
private:
|
||||
void internalBind();
|
||||
|
@@ -106,3 +106,10 @@ void Graphics::setViewportSize(const Size& size)
|
||||
m_viewportSize = size;
|
||||
}
|
||||
|
||||
int Graphics::getMaxTextureSize()
|
||||
{
|
||||
static GLint maxTexSize = -1;
|
||||
if(maxTexSize == -1)
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
|
||||
return maxTexSize;
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ public:
|
||||
|
||||
void setViewportSize(const Size& size);
|
||||
|
||||
int getMaxTextureSize();
|
||||
const Size& getViewportSize() { return m_viewportSize; }
|
||||
TexturePtr getEmptyTexture() { return m_emptyTexture; }
|
||||
|
||||
|
@@ -29,7 +29,7 @@ Particle::Particle(const Point& pos, const Size& startSize, const Size& finalSiz
|
||||
m_colors = colors;
|
||||
m_colorsStops = colorsStops;
|
||||
|
||||
m_pos = PointF(pos.x, pos.y);
|
||||
m_position = PointF(pos.x, pos.y);
|
||||
m_startSize = startSize;
|
||||
m_finalSize = finalSize;
|
||||
m_velocity = velocity;
|
||||
@@ -80,18 +80,18 @@ void Particle::updatePosition(double elapsedTime)
|
||||
PointF delta = m_velocity * elapsedTime;
|
||||
delta.y *= -1; // painter orientate Y axis in the inverse direction
|
||||
|
||||
PointF position = m_pos + delta;
|
||||
PointF position = m_position + delta;
|
||||
|
||||
if(m_pos != position) {
|
||||
if(m_position != position) {
|
||||
mustRedraw = true;
|
||||
m_pos += delta;
|
||||
m_position += delta;
|
||||
}
|
||||
|
||||
// update acceleration
|
||||
m_velocity += m_acceleration * elapsedTime;
|
||||
}
|
||||
|
||||
m_rect.move((int)m_pos.x - m_size.width() / 2, (int)m_pos.y - m_size.height() / 2);
|
||||
m_rect.move((int)m_position.x - m_size.width() / 2, (int)m_position.y - m_size.height() / 2);
|
||||
}
|
||||
|
||||
void Particle::updateSize()
|
||||
|
@@ -36,10 +36,10 @@ public:
|
||||
|
||||
bool hasFinished() { return m_finished; }
|
||||
|
||||
PointF getPos() { return m_pos; }
|
||||
PointF getPosition() { return m_position; }
|
||||
PointF getVelocity() { return m_velocity; }
|
||||
|
||||
void setPos(const PointF& position) { m_pos = position; }
|
||||
void setPosition(const PointF& position) { m_position = position; }
|
||||
void setVelocity(const PointF& velocity) { m_velocity = velocity; }
|
||||
|
||||
private:
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
std::vector<Color> m_colors;
|
||||
std::vector<float> m_colorsStops;
|
||||
TexturePtr m_texture;
|
||||
PointF m_pos;
|
||||
PointF m_position;
|
||||
PointF m_velocity;
|
||||
PointF m_acceleration;
|
||||
Size m_size, m_startSize, m_finalSize;
|
||||
|
@@ -115,7 +115,7 @@ bool AttractionAffector::load(const OTMLNodePtr& node)
|
||||
|
||||
for(const OTMLNodePtr& childNode : node->children()) {
|
||||
if(childNode->tag() == "position")
|
||||
m_pos = childNode->value<Point>();
|
||||
m_position = childNode->value<Point>();
|
||||
else if(childNode->tag() == "acceleration")
|
||||
m_acceleration = childNode->value<float>();
|
||||
else if(childNode->tag() == "velocity-reduction-percent")
|
||||
@@ -131,8 +131,8 @@ void AttractionAffector::updateParticle(const ParticlePtr& particle, double elap
|
||||
if(!m_active)
|
||||
return;
|
||||
|
||||
PointF pPosition = particle->getPos();
|
||||
PointF d = PointF(m_pos.x - pPosition.x, pPosition.y - m_pos.y);
|
||||
PointF pPosition = particle->getPosition();
|
||||
PointF d = PointF(m_position.x - pPosition.x, pPosition.y - m_position.y);
|
||||
if(d.length() == 0)
|
||||
return;
|
||||
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
void updateParticle(const ParticlePtr& particle, double elapsedTime);
|
||||
|
||||
private:
|
||||
Point m_pos;
|
||||
Point m_position;
|
||||
float m_acceleration, m_reduction;
|
||||
bool m_repelish;
|
||||
};
|
||||
|
@@ -31,7 +31,7 @@ ParticleEmitter::ParticleEmitter(const ParticleSystemPtr& parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
|
||||
m_pos = Point(0, 0);
|
||||
m_position = Point(0, 0);
|
||||
m_duration = -1;
|
||||
m_delay = 0;
|
||||
m_burstRate = 1; m_burstCount = 32;
|
||||
@@ -65,7 +65,7 @@ bool ParticleEmitter::load(const OTMLNodePtr& node)
|
||||
for(const OTMLNodePtr& childNode : node->children()) {
|
||||
// self related
|
||||
if(childNode->tag() == "position")
|
||||
m_pos = childNode->value<Point>();
|
||||
m_position = childNode->value<Point>();
|
||||
else if(childNode->tag() == "duration")
|
||||
m_duration = childNode->value<float>();
|
||||
else if(childNode->tag() == "delay")
|
||||
@@ -199,7 +199,7 @@ void ParticleEmitter::update(double elapsedTime)
|
||||
float pRadius = Fw::randomRange(m_pMinPositionRadius, m_pMaxPositionRadius);
|
||||
float pAngle = Fw::randomRange(m_pMinPositionAngle, m_pMaxPositionAngle);
|
||||
|
||||
Point pPosition = m_pos + Point(pRadius * cos(pAngle), pRadius * sin(pAngle));
|
||||
Point pPosition = m_position + Point(pRadius * cos(pAngle), pRadius * sin(pAngle));
|
||||
|
||||
for(int p = 0; p < m_burstCount; ++p) {
|
||||
|
||||
|
@@ -44,7 +44,7 @@ private:
|
||||
ParticleSystemWeakPtr m_parent;
|
||||
|
||||
// self related
|
||||
Point m_pos;
|
||||
Point m_position;
|
||||
float m_duration, m_delay;
|
||||
double m_elapsedTime;
|
||||
bool m_finished, m_active;
|
||||
|
@@ -128,6 +128,70 @@ std::vector<uint8> Texture::getPixels()
|
||||
return pixels;
|
||||
}
|
||||
|
||||
void Texture::generateBilinearMipmaps()
|
||||
{
|
||||
std::vector<uint8> inPixels = getPixels();
|
||||
|
||||
bind();
|
||||
|
||||
if(!m_useMipmaps) {
|
||||
m_useMipmaps = true;
|
||||
setupFilters();
|
||||
}
|
||||
|
||||
Size inSize = getSize();
|
||||
Size outSize = inSize / 2;
|
||||
std::vector<uint8> outPixels(outSize.area()*4);
|
||||
|
||||
int mipmap = 1;
|
||||
while(true) {
|
||||
for(int x=0;x<outSize.width();++x) {
|
||||
for(int y=0;y<outSize.height();++y) {
|
||||
uint8 *inPixel[4];
|
||||
inPixel[0] = &inPixels[((y*2)*inSize.width() + (x*2))*4];
|
||||
inPixel[1] = &inPixels[((y*2)*inSize.width() + (x*2)+1)*4];
|
||||
inPixel[2] = &inPixels[((y*2+1)*inSize.width() + (x*2))*4];
|
||||
inPixel[3] = &inPixels[((y*2+1)*inSize.width() + (x*2)+1)*4];
|
||||
uint8 *outPixel = &outPixels[(y*outSize.width() + x)*4];
|
||||
|
||||
int pixelsSum[4];
|
||||
for(int i=0;i<4;++i)
|
||||
pixelsSum[i] = 0;
|
||||
|
||||
int usedPixels = 0;
|
||||
for(int j=0;j<4;++j) {
|
||||
// ignore colors of complete alpha pixels
|
||||
if(inPixel[j][3] < 16)
|
||||
continue;
|
||||
|
||||
for(int i=0;i<4;++i)
|
||||
pixelsSum[i] += inPixel[j][i];
|
||||
|
||||
usedPixels++;
|
||||
}
|
||||
|
||||
for(int i=0;i<4;++i) {
|
||||
if(usedPixels > 0)
|
||||
outPixel[i] = pixelsSum[i] / usedPixels;
|
||||
else
|
||||
outPixel[i] = 0;
|
||||
}
|
||||
|
||||
outPixel[3] = pixelsSum[3]/4;
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, mipmap++, GL_RGBA, outSize.width(), outSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, &outPixels[0]);
|
||||
|
||||
if(inSize.width() == 1 || inSize.height() == 1)
|
||||
break;
|
||||
|
||||
inPixels = outPixels;
|
||||
inSize /= 2;
|
||||
outSize /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::setupFilters()
|
||||
{
|
||||
GLint minFilter;
|
||||
|
@@ -35,6 +35,7 @@ public:
|
||||
void bind() { glBindTexture(GL_TEXTURE_2D, m_textureId); }
|
||||
|
||||
void generateMipmaps();
|
||||
void generateBilinearMipmaps();
|
||||
void setSmooth(bool smooth);
|
||||
GLuint getId() { return m_textureId; }
|
||||
|
||||
|
@@ -154,7 +154,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setWidth", &UIWidget::setWidth);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setHeight", &UIWidget::setHeight);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setSize", &UIWidget::setSize);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setPos", &UIWidget::setPos);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setPosition", &UIWidget::setPosition);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setColor", &UIWidget::setColor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setBackgroundColor", &UIWidget::setBackgroundColor);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setBackgroundOffsetX", &UIWidget::setBackgroundOffsetX);
|
||||
@@ -192,7 +192,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getX", &UIWidget::getX);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getY", &UIWidget::getY);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getPos", &UIWidget::getPos);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getPosition", &UIWidget::getPosition);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getWidth", &UIWidget::getWidth);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getHeight", &UIWidget::getHeight);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getSize", &UIWidget::getSize);
|
||||
@@ -409,7 +409,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassStaticFunction("g_window", "getWidth", std::bind(&PlatformWindow::getWidth, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getHeight", std::bind(&PlatformWindow::getHeight, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getUnmaximizedPos", std::bind(&PlatformWindow::getUnmaximizedPos, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getPos", std::bind(&PlatformWindow::getPos, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getPosition", std::bind(&PlatformWindow::getPosition, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getX", std::bind(&PlatformWindow::getX, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getY", std::bind(&PlatformWindow::getY, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window));
|
||||
|
@@ -56,10 +56,10 @@ public:
|
||||
TPoint<T>& operator+=(T other) { x+=other; y+=other; return *this; }
|
||||
TPoint<T> operator-(T other) const { return TPoint<T>(x - other, y - other); }
|
||||
TPoint<T>& operator-=(T other) { x-=other; y-=other; return *this; }
|
||||
TPoint<T> operator*(const T v) const { return TPoint<T>(x*v, y*v); }
|
||||
TPoint<T>& operator*=(const T v) { x*=v; y*=v; return *this; }
|
||||
TPoint<T> operator/(const T v) const { return TPoint<T>(x/v, y/v); }
|
||||
TPoint<T>& operator/=(const T v) { x/=v; y/=v; return *this; }
|
||||
TPoint<T> operator*(float v) const { return TPoint<T>(x*v, y*v); }
|
||||
TPoint<T>& operator*=(float v) { x*=v; y*=v; return *this; }
|
||||
TPoint<T> operator/(float v) const { return TPoint<T>(x/v, y/v); }
|
||||
TPoint<T>& operator/=(float v) { x/=v; y/=v; return *this; }
|
||||
|
||||
bool operator<=(const TPoint<T>&other) const { return x<=other.x && y<=other.y; }
|
||||
bool operator>=(const TPoint<T>&other) const { return x>=other.x && y>=other.y; }
|
||||
|
@@ -52,10 +52,14 @@ public:
|
||||
TSize<T>& operator+=(const TSize<T>& other) { wd+=other.wd; ht+=other.ht; return *this; }
|
||||
TSize<T> operator-(const TSize<T>& other) const { return TSize<T>(wd - other.wd, ht - other.ht); }
|
||||
TSize<T>& operator-=(const TSize<T>& other) { wd-=other.wd; ht-=other.ht; return *this; }
|
||||
TSize<T> operator*(const TSize<T>& other) const { return TSize<T>((T)other.wd*wd, (T)ht*other.ht); }
|
||||
TSize<T>& operator*=(const TSize<T>& other) { wd=(T)other.wd*wd; ht=(T)ht*other.ht; return *this; }
|
||||
TSize<T> operator/(const TSize<T>& other) const { return TSize<T>((T)wd/other.wd, (T)ht/other.ht); }
|
||||
TSize<T>& operator/=(const TSize<T>& other) { (T)wd/=other.wd; (T)ht/=other.ht; return *this; }
|
||||
TSize<T> operator*(const float v) const { return TSize<T>((T)v*wd, (T)ht*v); }
|
||||
TSize<T>& operator*=(const float v) { wd=(T)v*wd; ht=(T)ht*v; return *this; }
|
||||
TSize<T> operator/(const float v) const { return TSize<T>((T)wd/v, (T)ht/v); }
|
||||
TSize<T>& operator/=(const float v) { (T)wd/=v; (T)ht/=v; return *this; }
|
||||
TSize<T>& operator/=(const float v) { wd/=v; ht/=v; return *this; }
|
||||
|
||||
bool operator<=(const TSize<T>&other) const { return wd<=other.wd || ht<=other.ht; }
|
||||
bool operator>=(const TSize<T>&other) const { return wd>=other.wd || ht>=other.ht; }
|
||||
|
@@ -33,7 +33,7 @@ public:
|
||||
BUFFER_MAXSIZE = 16384,
|
||||
HEADER_POS = 0,
|
||||
HEADER_LENGTH = 2,
|
||||
CHECKSUM_POS = 2,
|
||||
CHECKSUm_position = 2,
|
||||
CHECKSUM_LENGTH = 4,
|
||||
DATA_POS = 6,
|
||||
UNENCRYPTED_DATA_POS = 8
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
BUFFER_MAXSIZE = 1024,
|
||||
HEADER_POS = 0,
|
||||
HEADER_LENGTH = 2,
|
||||
CHECKSUM_POS = 2,
|
||||
CHECKSUm_position = 2,
|
||||
CHECKSUM_LENGTH = 4,
|
||||
DATA_POS = 6
|
||||
};
|
||||
|
@@ -71,7 +71,7 @@ void Protocol::send(OutputMessage& outputMessage)
|
||||
|
||||
// set checksum
|
||||
uint32 checksum = getAdlerChecksum(outputMessage.getBuffer() + OutputMessage::DATA_POS, outputMessage.getMessageSize());
|
||||
outputMessage.setWritePos(OutputMessage::CHECKSUM_POS);
|
||||
outputMessage.setWritePos(OutputMessage::CHECKSUm_position);
|
||||
outputMessage.addU32(checksum);
|
||||
|
||||
// set size
|
||||
@@ -107,7 +107,7 @@ void Protocol::internalRecvHeader(uint8* buffer, uint16 size)
|
||||
|
||||
void Protocol::internalRecvData(uint8* buffer, uint16 size)
|
||||
{
|
||||
memcpy(m_inputMessage.getBuffer() + InputMessage::CHECKSUM_POS, buffer, size);
|
||||
memcpy(m_inputMessage.getBuffer() + InputMessage::CHECKSUm_position, buffer, size);
|
||||
|
||||
if(m_checksumEnabled) {
|
||||
uint32 checksum = getAdlerChecksum(m_inputMessage.getBuffer() + InputMessage::DATA_POS, m_inputMessage.getMessageSize() - InputMessage::CHECKSUM_LENGTH);
|
||||
|
@@ -38,7 +38,7 @@ PlatformWindow& g_window = window;
|
||||
void PlatformWindow::updateUnmaximizedCoords()
|
||||
{
|
||||
if(!isMaximized() && !isFullscreen()) {
|
||||
m_unmaximizedPos = m_pos;
|
||||
m_unmaximizedPos = m_position;
|
||||
m_unmaximizedSize = m_size;
|
||||
}
|
||||
}
|
||||
|
@@ -73,9 +73,9 @@ public:
|
||||
int getWidth() { return m_size.width(); }
|
||||
int getHeight() { return m_size.height(); }
|
||||
Point getUnmaximizedPos() { return m_unmaximizedPos; }
|
||||
Point getPos() { return m_pos; }
|
||||
int getX() { return m_pos.x; }
|
||||
int getY() { return m_pos.y; }
|
||||
Point getPosition() { return m_position; }
|
||||
int getX() { return m_position.x; }
|
||||
int getY() { return m_position.y; }
|
||||
Point getMousePos() { return m_inputEvent.mousePos; }
|
||||
int getKeyboardModifiers() { return m_inputEvent.keyboardModifiers; }
|
||||
bool isKeyPressed(Fw::Key keyCode) { return m_keysState[keyCode]; }
|
||||
@@ -104,7 +104,7 @@ protected:
|
||||
Timer m_keyPressTimer;
|
||||
|
||||
Size m_size;
|
||||
Point m_pos;
|
||||
Point m_position;
|
||||
Size m_unmaximizedSize;
|
||||
Point m_unmaximizedPos;
|
||||
InputEvent m_inputEvent;
|
||||
|
@@ -278,7 +278,7 @@ void WIN32Window::internalCreateWindow()
|
||||
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
|
||||
|
||||
RECT windowRect = {m_pos.x, m_pos.y, m_pos.x + m_size.width(), m_pos.y + m_size.height()};
|
||||
RECT windowRect = {m_position.x, m_position.y, m_position.x + m_size.width(), m_position.y + m_size.height()};
|
||||
AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
|
||||
|
||||
updateUnmaximizedCoords();
|
||||
@@ -361,14 +361,14 @@ void *WIN32Window::getExtensionProcAddress(const char *ext)
|
||||
|
||||
void WIN32Window::move(const Point& pos)
|
||||
{
|
||||
RECT windowRect = {pos.x, pos.y, m_pos.x + m_size.width(), m_pos.y + m_size.height()};
|
||||
RECT windowRect = {pos.x, pos.y, m_position.x + m_size.width(), m_position.y + m_size.height()};
|
||||
AdjustWindowRectEx(&windowRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
|
||||
MoveWindow(m_window, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, TRUE);
|
||||
}
|
||||
|
||||
void WIN32Window::resize(const Size& size)
|
||||
{
|
||||
RECT windowRect = {m_pos.x, m_pos.y, m_pos.x + size.width(), m_pos.y + size.height()};
|
||||
RECT windowRect = {m_position.x, m_position.y, m_position.x + size.width(), m_position.y + size.height()};
|
||||
AdjustWindowRectEx(&windowRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
|
||||
MoveWindow(m_window, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, TRUE);
|
||||
}
|
||||
@@ -503,8 +503,8 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||
break;
|
||||
}
|
||||
case WM_MOVE: {
|
||||
m_pos.x = LOWORD(lParam);
|
||||
m_pos.y = HIWORD(lParam);
|
||||
m_position.x = LOWORD(lParam);
|
||||
m_position.y = HIWORD(lParam);
|
||||
break;
|
||||
}
|
||||
case WM_SIZE: {
|
||||
|
@@ -284,7 +284,7 @@ void X11Window::internalCreateWindow()
|
||||
|
||||
updateUnmaximizedCoords();
|
||||
m_window = XCreateWindow(m_display, m_rootWindow,
|
||||
m_pos.x, m_pos.y, m_size.width(), m_size.height(),
|
||||
m_position.x, m_position.y, m_size.width(), m_size.height(),
|
||||
0,
|
||||
depth,
|
||||
InputOutput,
|
||||
@@ -300,7 +300,7 @@ void X11Window::internalCreateWindow()
|
||||
XSetWMHints(m_display, m_window, &hints);
|
||||
|
||||
// ensure window position
|
||||
XMoveWindow(m_display, m_window, m_pos.x, m_pos.y);
|
||||
XMoveWindow(m_display, m_window, m_position.x, m_position.y);
|
||||
|
||||
// handle wm_delete events
|
||||
m_wmDelete = XInternAtom(m_display, "WM_DELETE_WINDOW", True);
|
||||
@@ -580,7 +580,7 @@ void X11Window::poll()
|
||||
}
|
||||
|
||||
// updates window pos
|
||||
m_pos = newPos;
|
||||
m_position = newPos;
|
||||
updateUnmaximizedCoords();
|
||||
break;
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ void UIWidget::drawChildren()
|
||||
g_painter.setColor(Fw::green);
|
||||
g_painter.drawBoundingRect(child->getRect());
|
||||
}
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPos() + Point(2, 0), Fw::red);
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Fw::red);
|
||||
|
||||
g_painter.setOpacity(oldOpacity);
|
||||
}
|
||||
|
@@ -189,7 +189,7 @@ protected:
|
||||
|
||||
// function shortcuts
|
||||
public:
|
||||
void resize(int width, int height) { setRect(Rect(getPos(), Size(width, height))); }
|
||||
void resize(int width, int height) { setRect(Rect(getPosition(), Size(width, height))); }
|
||||
void move(int x, int y) { setRect(Rect(x, y, getSize())); }
|
||||
void hide() { setVisible(false); }
|
||||
void show() { setVisible(true); }
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
void setWidth(int width) { resize(width, getHeight()); }
|
||||
void setHeight(int height) { resize(getWidth(), height); }
|
||||
void setSize(const Size& size) { resize(size.width(), size.height()); }
|
||||
void setPos(const Point& pos) { move(pos.x, pos.y); }
|
||||
void setPosition(const Point& pos) { move(pos.x, pos.y); }
|
||||
void setColor(const Color& color) { m_color = color; }
|
||||
void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
|
||||
void setBackgroundOffsetX(int x) { m_backgroundRect.setX(x); }
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
|
||||
int getX() { return m_rect.x(); }
|
||||
int getY() { return m_rect.y(); }
|
||||
Point getPos() { return m_rect.topLeft(); }
|
||||
Point getPosition() { return m_rect.topLeft(); }
|
||||
int getWidth() { return m_rect.width(); }
|
||||
int getHeight() { return m_rect.height(); }
|
||||
Size getSize() { return m_rect.size(); }
|
||||
|
@@ -55,7 +55,7 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
else if(node->tag() == "y")
|
||||
setY(node->value<int>());
|
||||
else if(node->tag() == "pos")
|
||||
setPos(node->value<Point>());
|
||||
setPosition(node->value<Point>());
|
||||
else if(node->tag() == "width")
|
||||
setWidth(node->value<int>());
|
||||
else if(node->tag() == "height")
|
||||
|
Reference in New Issue
Block a user