Small UI fixes

This commit is contained in:
MrLetsplay 2024-08-26 12:55:25 +02:00
parent bc0cab870b
commit ca2875e92d
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
5 changed files with 6 additions and 4 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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;
}
};

View File

@ -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

View File

@ -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;