diff --git a/src/kekengine/cpp/common/defaults.cpp b/src/kekengine/cpp/common/defaults.cpp index 7182f8e..c11341d 100644 --- a/src/kekengine/cpp/common/defaults.cpp +++ b/src/kekengine/cpp/common/defaults.cpp @@ -77,7 +77,7 @@ static void doUIMouseDrag(double x, double y) { int deltaY = (int) y - mouseDownPosition.y; if(deltaX * deltaX + deltaY * deltaY >= KEK_UI_MIN_DRAG_DISTANCE_SQUARED) { // Initiate drag - UIElement *draggedElement = UI::findElementAt(mousePosition); + UIElement *draggedElement = UI::findElementAt(mouseDownPosition); if(draggedElement) { IntPoint2 childPos = draggedElement->getScreenPosition(); diff --git a/src/kekengine/cpp/ui/uielements.cpp b/src/kekengine/cpp/ui/uielements.cpp index 8a0492d..3d198c0 100644 --- a/src/kekengine/cpp/ui/uielements.cpp +++ b/src/kekengine/cpp/ui/uielements.cpp @@ -337,8 +337,9 @@ UIWindowTitleBar::UIWindowTitleBar(UIValue height) dragDownPos(0, 0) { this->color = Colors::GRAY; this->draggable = true; + this->enableClipping = true; - text = new TextElement(x, uiPh(0.5)); + text = new TextElement(uiPx(5), uiPh(0.5)); text->setText("Window title"); text->textMode = TextMode::ORIGIN; text->origin = Origin::LEFT_CENTER; diff --git a/src/kekengine/include/color.h b/src/kekengine/include/color.h index 24b68eb..730f729 100644 --- a/src/kekengine/include/color.h +++ b/src/kekengine/include/color.h @@ -29,7 +29,7 @@ struct Color { return Color(r / factor, g / factor, b / factor, a); } - constexpr bool operator==(const Color &other) { + constexpr bool operator==(const Color &other) const { return r == other.r && g == other.g && b == other.g; } }; diff --git a/src/kekengine/include/uielements.h b/src/kekengine/include/uielements.h index 3c945aa..3aeac17 100644 --- a/src/kekengine/include/uielements.h +++ b/src/kekengine/include/uielements.h @@ -7,7 +7,7 @@ namespace kek { enum class TextMode { - // Draw with y as baseline, disables vertical offset from the origin position specified using setOrigin() + // Draw with y as baseline, disables vertical offset from the origin position BASELINE, // Draw from the set origin ORIGIN diff --git a/src/kekgame/cpp/kekgame.cpp b/src/kekgame/cpp/kekgame.cpp index 32d1736..4e0e796 100644 --- a/src/kekgame/cpp/kekgame.cpp +++ b/src/kekgame/cpp/kekgame.cpp @@ -173,6 +173,7 @@ int main(int argc, char **argv) { rect2->addChild(text); UIWindow *window = new UIWindow(uiPx(0), uiPx(0), uiPx(720), uiPx(480)); + window->titleBar->text->setText("This is a really long window title to test whether the text will overflow or not"); UI::addElement(window); if(Engine::start() != KEK_SUCCESS) return 1;