Small UI fixes
This commit is contained in:
parent
bc0cab870b
commit
ca2875e92d
@ -77,7 +77,7 @@ static void doUIMouseDrag(double x, double y) {
|
|||||||
int deltaY = (int) y - mouseDownPosition.y;
|
int deltaY = (int) y - mouseDownPosition.y;
|
||||||
if(deltaX * deltaX + deltaY * deltaY >= KEK_UI_MIN_DRAG_DISTANCE_SQUARED) {
|
if(deltaX * deltaX + deltaY * deltaY >= KEK_UI_MIN_DRAG_DISTANCE_SQUARED) {
|
||||||
// Initiate drag
|
// Initiate drag
|
||||||
UIElement *draggedElement = UI::findElementAt(mousePosition);
|
UIElement *draggedElement = UI::findElementAt(mouseDownPosition);
|
||||||
|
|
||||||
if(draggedElement) {
|
if(draggedElement) {
|
||||||
IntPoint2 childPos = draggedElement->getScreenPosition();
|
IntPoint2 childPos = draggedElement->getScreenPosition();
|
||||||
|
@ -337,8 +337,9 @@ UIWindowTitleBar::UIWindowTitleBar(UIValue height)
|
|||||||
dragDownPos(0, 0) {
|
dragDownPos(0, 0) {
|
||||||
this->color = Colors::GRAY;
|
this->color = Colors::GRAY;
|
||||||
this->draggable = true;
|
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->setText("Window title");
|
||||||
text->textMode = TextMode::ORIGIN;
|
text->textMode = TextMode::ORIGIN;
|
||||||
text->origin = Origin::LEFT_CENTER;
|
text->origin = Origin::LEFT_CENTER;
|
||||||
|
@ -29,7 +29,7 @@ struct Color {
|
|||||||
return Color(r / factor, g / factor, b / factor, a);
|
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;
|
return r == other.r && g == other.g && b == other.g;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
namespace kek {
|
namespace kek {
|
||||||
|
|
||||||
enum class TextMode {
|
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,
|
BASELINE,
|
||||||
// Draw from the set origin
|
// Draw from the set origin
|
||||||
ORIGIN
|
ORIGIN
|
||||||
|
@ -173,6 +173,7 @@ int main(int argc, char **argv) {
|
|||||||
rect2->addChild(text);
|
rect2->addChild(text);
|
||||||
|
|
||||||
UIWindow *window = new UIWindow(uiPx(0), uiPx(0), uiPx(720), uiPx(480));
|
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);
|
UI::addElement(window);
|
||||||
|
|
||||||
if(Engine::start() != KEK_SUCCESS) return 1;
|
if(Engine::start() != KEK_SUCCESS) return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user