mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
fix use with, improve move, change icons, improve topbar
This commit is contained in:
@@ -28,6 +28,8 @@ uint FrameBuffer::boundFbo = 0;
|
||||
|
||||
FrameBuffer::FrameBuffer(const Size& size)
|
||||
{
|
||||
m_clearColor = Fw::alpha;
|
||||
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
if(!m_fbo)
|
||||
logFatal("Unable to create framebuffer object");
|
||||
@@ -68,8 +70,10 @@ void FrameBuffer::bind(bool clear)
|
||||
g_painter.setProjectionMatrix(projectionMatrix);
|
||||
g_graphics.setViewportSize(m_texture->getSize());
|
||||
|
||||
if(clear)
|
||||
if(clear) {
|
||||
glClearColor(m_clearColor.rF(), m_clearColor.gF(), m_clearColor.bF(), m_clearColor.aF());
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void FrameBuffer::release()
|
||||
|
@@ -30,12 +30,14 @@ class FrameBuffer
|
||||
public:
|
||||
FrameBuffer(const Size& size);
|
||||
virtual ~FrameBuffer();
|
||||
|
||||
|
||||
void resize(const Size& size);
|
||||
void bind(bool clear = true);
|
||||
void release();
|
||||
void draw(const Rect& dest);
|
||||
|
||||
void setClearColor(const Color& color) { m_clearColor = color; }
|
||||
|
||||
TexturePtr getTexture() { return m_texture; }
|
||||
|
||||
private:
|
||||
@@ -48,6 +50,7 @@ private:
|
||||
Size m_oldViewportSize;
|
||||
uint m_fbo;
|
||||
uint m_prevBoundFbo;
|
||||
Color m_clearColor;
|
||||
|
||||
static uint boundFbo;
|
||||
};
|
||||
|
@@ -43,7 +43,6 @@ void Graphics::init()
|
||||
#endif
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
logInfo("GPU ", glGetString(GL_RENDERER));
|
||||
logInfo("OpenGL ", glGetString(GL_VERSION));
|
||||
@@ -93,6 +92,7 @@ void Graphics::resize(const Size& size)
|
||||
|
||||
void Graphics::beginRender()
|
||||
{
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
@@ -435,6 +435,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1));
|
||||
g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2));
|
||||
g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui));
|
||||
g_lua.bindClassStaticFunction("g_ui", "getDraggingWidget", std::bind(&UIManager::getDraggingWidget, &g_ui));
|
||||
g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
|
||||
g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
|
||||
|
||||
|
@@ -40,6 +40,11 @@ public:
|
||||
uint8 g() const { return m_g; }
|
||||
uint8 r() const { return m_r; }
|
||||
|
||||
float aF() const { return m_a/255.0f; }
|
||||
float bF() const { return m_b/255.0f; }
|
||||
float gF() const { return m_g/255.0f; }
|
||||
float rF() const { return m_r/255.0f; }
|
||||
|
||||
uint32 rgba() const { return m_rgba; }
|
||||
|
||||
const uint8* rgbaPtr() const { return (const uint8*)&m_rgba; }
|
||||
|
@@ -72,7 +72,7 @@ void UIManager::inputEvent(const InputEvent& event)
|
||||
m_keyboardReceiver->propagateOnKeyUp(event.keyCode, event.keyboardModifiers);
|
||||
break;
|
||||
case Fw::MousePressInputEvent:
|
||||
m_keyboardReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
|
||||
m_mouseReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
|
||||
break;
|
||||
case Fw::MouseReleaseInputEvent:
|
||||
m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton);
|
||||
|
@@ -830,10 +830,11 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
|
||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||
{
|
||||
for(const UIWidgetPtr& child : m_children) {
|
||||
if(child->containsPoint(childPos)) {
|
||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
||||
if(UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos))
|
||||
return subChild;
|
||||
return child;
|
||||
else if(!child->isPhantom())
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -1113,7 +1114,7 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||
return callLuaField<bool>("onMousePress", mousePos, button);
|
||||
}
|
||||
|
||||
void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
if(isPressed() && getRect().contains(mousePos))
|
||||
callLuaField("onClick");
|
||||
@@ -1125,7 +1126,7 @@ void UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
draggedWidget->setDragging(false);
|
||||
}
|
||||
|
||||
callLuaField("onMouseRelease", mousePos, button);
|
||||
return callLuaField<bool>("onMouseRelease", mousePos, button);
|
||||
}
|
||||
|
||||
bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved)
|
||||
@@ -1260,16 +1261,16 @@ bool UIWidget::propagateOnMousePress(const Point& mousePos, Fw::MouseButton butt
|
||||
|
||||
// only non phatom widgets receives mouse press events
|
||||
if(!isPhantom()) {
|
||||
onMousePress(mousePos, button);
|
||||
bool ret = onMousePress(mousePos, button);
|
||||
if(button == Fw::MouseLeftButton && !isPressed())
|
||||
setPressed(true);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
// do a backup of children list, because it may change while looping it
|
||||
UIWidgetList children;
|
||||
@@ -1283,13 +1284,16 @@ void UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu
|
||||
}
|
||||
|
||||
for(const UIWidgetPtr& child : children) {
|
||||
child->propagateOnMouseRelease(mousePos, button);
|
||||
if(child->propagateOnMouseRelease(mousePos, button))
|
||||
return true;
|
||||
}
|
||||
|
||||
onMouseRelease(mousePos, button);
|
||||
bool ret = onMouseRelease(mousePos, button);
|
||||
|
||||
if(isPressed() && button == Fw::MouseLeftButton)
|
||||
setPressed(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool UIWidget::propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved)
|
||||
|
@@ -173,7 +173,7 @@ protected:
|
||||
virtual bool onKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
|
||||
virtual bool onKeyUp(uchar keyCode, int keyboardModifiers);
|
||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual void onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||
virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
|
||||
|
||||
@@ -182,7 +182,7 @@ protected:
|
||||
bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, bool wouldFilter);
|
||||
bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers);
|
||||
bool propagateOnMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
void propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
bool propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
bool propagateOnMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||
bool propagateOnMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
|
||||
|
||||
|
Reference in New Issue
Block a user