emote2ss

Animated webp to spritesheets converting tool
git clone git://bsandro.tech/emote2ss
Log | Files | Refs | README | LICENSE

commit 1c3df920be5b9486b7d045cdacd8f07d954b202b
parent ccf80260a0bd86a50a95e2e9613bd8e0d4aa03d5
Author: bsandro <email@bsandro.tech>
Date:   Sun, 21 Dec 2025 09:24:24 +0200

remove irritating trailing spaces

Diffstat:
Minclude/luigi.h | 300++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 150 insertions(+), 150 deletions(-)

diff --git a/include/luigi.h b/include/luigi.h @@ -348,7 +348,7 @@ typedef struct UIElement { struct UIWindow *window; UIRectangle bounds, clip; - + void *cp; // Context pointer (for user). int (*messageClass)(struct UIElement *element, UIMessage message, int di /* data integer */, void *dp /* data pointer */); @@ -384,9 +384,9 @@ typedef struct UIWindow { int cursorX, cursorY; int cursorStyle; - // Set when a textbox is modified. + // Set when a textbox is modified. // Useful for tracking whether changes to the loaded document have been saved. - bool textboxModifiedFlag; + bool textboxModifiedFlag; bool ctrl, shift, alt; @@ -585,7 +585,7 @@ typedef struct UIImageDisplay { uint32_t *bits; int width, height; float panX, panY, zoom; - + // Internals: int previousWidth, previousHeight; int previousPanPointX, previousPanPointY; @@ -598,7 +598,7 @@ typedef struct UIWrapPanel { void UIInitialise(); int UIMessageLoop(); -UIElement *UIElementCreate(size_t bytes, UIElement *parent, uint32_t flags, +UIElement *UIElementCreate(size_t bytes, UIElement *parent, uint32_t flags, int (*messageClass)(UIElement *, UIMessage, int, void *), const char *cClassName); UIButton *UIButtonCreate(UIElement *parent, uint32_t flags, const char *label, ptrdiff_t labelBytes); @@ -813,38 +813,38 @@ UITheme _uiThemeDark = { // Public domain. const uint64_t _uiFont[] = { - 0x0000000000000000UL, 0x0000000000000000UL, 0xBD8181A5817E0000UL, 0x000000007E818199UL, 0xC3FFFFDBFF7E0000UL, 0x000000007EFFFFE7UL, 0x7F7F7F3600000000UL, 0x00000000081C3E7FUL, - 0x7F3E1C0800000000UL, 0x0000000000081C3EUL, 0xE7E73C3C18000000UL, 0x000000003C1818E7UL, 0xFFFF7E3C18000000UL, 0x000000003C18187EUL, 0x3C18000000000000UL, 0x000000000000183CUL, - 0xC3E7FFFFFFFFFFFFUL, 0xFFFFFFFFFFFFE7C3UL, 0x42663C0000000000UL, 0x00000000003C6642UL, 0xBD99C3FFFFFFFFFFUL, 0xFFFFFFFFFFC399BDUL, 0x331E4C5870780000UL, 0x000000001E333333UL, - 0x3C666666663C0000UL, 0x0000000018187E18UL, 0x0C0C0CFCCCFC0000UL, 0x00000000070F0E0CUL, 0xC6C6C6FEC6FE0000UL, 0x0000000367E7E6C6UL, 0xE73CDB1818000000UL, 0x000000001818DB3CUL, - 0x1F7F1F0F07030100UL, 0x000000000103070FUL, 0x7C7F7C7870604000UL, 0x0000000040607078UL, 0x1818187E3C180000UL, 0x0000000000183C7EUL, 0x6666666666660000UL, 0x0000000066660066UL, - 0xD8DEDBDBDBFE0000UL, 0x00000000D8D8D8D8UL, 0x6363361C06633E00UL, 0x0000003E63301C36UL, 0x0000000000000000UL, 0x000000007F7F7F7FUL, 0x1818187E3C180000UL, 0x000000007E183C7EUL, - 0x1818187E3C180000UL, 0x0000000018181818UL, 0x1818181818180000UL, 0x00000000183C7E18UL, 0x7F30180000000000UL, 0x0000000000001830UL, 0x7F060C0000000000UL, 0x0000000000000C06UL, - 0x0303000000000000UL, 0x0000000000007F03UL, 0xFF66240000000000UL, 0x0000000000002466UL, 0x3E1C1C0800000000UL, 0x00000000007F7F3EUL, 0x3E3E7F7F00000000UL, 0x0000000000081C1CUL, - 0x0000000000000000UL, 0x0000000000000000UL, 0x18183C3C3C180000UL, 0x0000000018180018UL, 0x0000002466666600UL, 0x0000000000000000UL, 0x36367F3636000000UL, 0x0000000036367F36UL, - 0x603E0343633E1818UL, 0x000018183E636160UL, 0x1830634300000000UL, 0x000000006163060CUL, 0x3B6E1C36361C0000UL, 0x000000006E333333UL, 0x000000060C0C0C00UL, 0x0000000000000000UL, - 0x0C0C0C0C18300000UL, 0x0000000030180C0CUL, 0x30303030180C0000UL, 0x000000000C183030UL, 0xFF3C660000000000UL, 0x000000000000663CUL, 0x7E18180000000000UL, 0x0000000000001818UL, - 0x0000000000000000UL, 0x0000000C18181800UL, 0x7F00000000000000UL, 0x0000000000000000UL, 0x0000000000000000UL, 0x0000000018180000UL, 0x1830604000000000UL, 0x000000000103060CUL, - 0xDBDBC3C3663C0000UL, 0x000000003C66C3C3UL, 0x1818181E1C180000UL, 0x000000007E181818UL, 0x0C183060633E0000UL, 0x000000007F630306UL, 0x603C6060633E0000UL, 0x000000003E636060UL, - 0x7F33363C38300000UL, 0x0000000078303030UL, 0x603F0303037F0000UL, 0x000000003E636060UL, 0x633F0303061C0000UL, 0x000000003E636363UL, 0x18306060637F0000UL, 0x000000000C0C0C0CUL, - 0x633E6363633E0000UL, 0x000000003E636363UL, 0x607E6363633E0000UL, 0x000000001E306060UL, 0x0000181800000000UL, 0x0000000000181800UL, 0x0000181800000000UL, 0x000000000C181800UL, - 0x060C183060000000UL, 0x000000006030180CUL, 0x00007E0000000000UL, 0x000000000000007EUL, 0x6030180C06000000UL, 0x00000000060C1830UL, 0x18183063633E0000UL, 0x0000000018180018UL, - 0x7B7B63633E000000UL, 0x000000003E033B7BUL, 0x7F6363361C080000UL, 0x0000000063636363UL, 0x663E6666663F0000UL, 0x000000003F666666UL, 0x03030343663C0000UL, 0x000000003C664303UL, - 0x66666666361F0000UL, 0x000000001F366666UL, 0x161E1646667F0000UL, 0x000000007F664606UL, 0x161E1646667F0000UL, 0x000000000F060606UL, 0x7B030343663C0000UL, 0x000000005C666363UL, - 0x637F636363630000UL, 0x0000000063636363UL, 0x18181818183C0000UL, 0x000000003C181818UL, 0x3030303030780000UL, 0x000000001E333333UL, 0x1E1E366666670000UL, 0x0000000067666636UL, - 0x06060606060F0000UL, 0x000000007F664606UL, 0xC3DBFFFFE7C30000UL, 0x00000000C3C3C3C3UL, 0x737B7F6F67630000UL, 0x0000000063636363UL, 0x63636363633E0000UL, 0x000000003E636363UL, - 0x063E6666663F0000UL, 0x000000000F060606UL, 0x63636363633E0000UL, 0x000070303E7B6B63UL, 0x363E6666663F0000UL, 0x0000000067666666UL, 0x301C0663633E0000UL, 0x000000003E636360UL, - 0x18181899DBFF0000UL, 0x000000003C181818UL, 0x6363636363630000UL, 0x000000003E636363UL, 0xC3C3C3C3C3C30000UL, 0x00000000183C66C3UL, 0xDBC3C3C3C3C30000UL, 0x000000006666FFDBUL, - 0x18183C66C3C30000UL, 0x00000000C3C3663CUL, 0x183C66C3C3C30000UL, 0x000000003C181818UL, 0x0C183061C3FF0000UL, 0x00000000FFC38306UL, 0x0C0C0C0C0C3C0000UL, 0x000000003C0C0C0CUL, - 0x1C0E070301000000UL, 0x0000000040607038UL, 0x30303030303C0000UL, 0x000000003C303030UL, 0x0000000063361C08UL, 0x0000000000000000UL, 0x0000000000000000UL, 0x0000FF0000000000UL, - 0x0000000000180C0CUL, 0x0000000000000000UL, 0x3E301E0000000000UL, 0x000000006E333333UL, 0x66361E0606070000UL, 0x000000003E666666UL, 0x03633E0000000000UL, 0x000000003E630303UL, - 0x33363C3030380000UL, 0x000000006E333333UL, 0x7F633E0000000000UL, 0x000000003E630303UL, 0x060F0626361C0000UL, 0x000000000F060606UL, 0x33336E0000000000UL, 0x001E33303E333333UL, - 0x666E360606070000UL, 0x0000000067666666UL, 0x18181C0018180000UL, 0x000000003C181818UL, 0x6060700060600000UL, 0x003C666660606060UL, 0x1E36660606070000UL, 0x000000006766361EUL, - 0x18181818181C0000UL, 0x000000003C181818UL, 0xDBFF670000000000UL, 0x00000000DBDBDBDBUL, 0x66663B0000000000UL, 0x0000000066666666UL, 0x63633E0000000000UL, 0x000000003E636363UL, - 0x66663B0000000000UL, 0x000F06063E666666UL, 0x33336E0000000000UL, 0x007830303E333333UL, 0x666E3B0000000000UL, 0x000000000F060606UL, 0x06633E0000000000UL, 0x000000003E63301CUL, - 0x0C0C3F0C0C080000UL, 0x00000000386C0C0CUL, 0x3333330000000000UL, 0x000000006E333333UL, 0xC3C3C30000000000UL, 0x00000000183C66C3UL, 0xC3C3C30000000000UL, 0x0000000066FFDBDBUL, - 0x3C66C30000000000UL, 0x00000000C3663C18UL, 0x6363630000000000UL, 0x001F30607E636363UL, 0x18337F0000000000UL, 0x000000007F63060CUL, 0x180E181818700000UL, 0x0000000070181818UL, - 0x1800181818180000UL, 0x0000000018181818UL, 0x18701818180E0000UL, 0x000000000E181818UL, 0x000000003B6E0000UL, 0x0000000000000000UL, 0x63361C0800000000UL, 0x00000000007F6363UL, + 0x0000000000000000UL, 0x0000000000000000UL, 0xBD8181A5817E0000UL, 0x000000007E818199UL, 0xC3FFFFDBFF7E0000UL, 0x000000007EFFFFE7UL, 0x7F7F7F3600000000UL, 0x00000000081C3E7FUL, + 0x7F3E1C0800000000UL, 0x0000000000081C3EUL, 0xE7E73C3C18000000UL, 0x000000003C1818E7UL, 0xFFFF7E3C18000000UL, 0x000000003C18187EUL, 0x3C18000000000000UL, 0x000000000000183CUL, + 0xC3E7FFFFFFFFFFFFUL, 0xFFFFFFFFFFFFE7C3UL, 0x42663C0000000000UL, 0x00000000003C6642UL, 0xBD99C3FFFFFFFFFFUL, 0xFFFFFFFFFFC399BDUL, 0x331E4C5870780000UL, 0x000000001E333333UL, + 0x3C666666663C0000UL, 0x0000000018187E18UL, 0x0C0C0CFCCCFC0000UL, 0x00000000070F0E0CUL, 0xC6C6C6FEC6FE0000UL, 0x0000000367E7E6C6UL, 0xE73CDB1818000000UL, 0x000000001818DB3CUL, + 0x1F7F1F0F07030100UL, 0x000000000103070FUL, 0x7C7F7C7870604000UL, 0x0000000040607078UL, 0x1818187E3C180000UL, 0x0000000000183C7EUL, 0x6666666666660000UL, 0x0000000066660066UL, + 0xD8DEDBDBDBFE0000UL, 0x00000000D8D8D8D8UL, 0x6363361C06633E00UL, 0x0000003E63301C36UL, 0x0000000000000000UL, 0x000000007F7F7F7FUL, 0x1818187E3C180000UL, 0x000000007E183C7EUL, + 0x1818187E3C180000UL, 0x0000000018181818UL, 0x1818181818180000UL, 0x00000000183C7E18UL, 0x7F30180000000000UL, 0x0000000000001830UL, 0x7F060C0000000000UL, 0x0000000000000C06UL, + 0x0303000000000000UL, 0x0000000000007F03UL, 0xFF66240000000000UL, 0x0000000000002466UL, 0x3E1C1C0800000000UL, 0x00000000007F7F3EUL, 0x3E3E7F7F00000000UL, 0x0000000000081C1CUL, + 0x0000000000000000UL, 0x0000000000000000UL, 0x18183C3C3C180000UL, 0x0000000018180018UL, 0x0000002466666600UL, 0x0000000000000000UL, 0x36367F3636000000UL, 0x0000000036367F36UL, + 0x603E0343633E1818UL, 0x000018183E636160UL, 0x1830634300000000UL, 0x000000006163060CUL, 0x3B6E1C36361C0000UL, 0x000000006E333333UL, 0x000000060C0C0C00UL, 0x0000000000000000UL, + 0x0C0C0C0C18300000UL, 0x0000000030180C0CUL, 0x30303030180C0000UL, 0x000000000C183030UL, 0xFF3C660000000000UL, 0x000000000000663CUL, 0x7E18180000000000UL, 0x0000000000001818UL, + 0x0000000000000000UL, 0x0000000C18181800UL, 0x7F00000000000000UL, 0x0000000000000000UL, 0x0000000000000000UL, 0x0000000018180000UL, 0x1830604000000000UL, 0x000000000103060CUL, + 0xDBDBC3C3663C0000UL, 0x000000003C66C3C3UL, 0x1818181E1C180000UL, 0x000000007E181818UL, 0x0C183060633E0000UL, 0x000000007F630306UL, 0x603C6060633E0000UL, 0x000000003E636060UL, + 0x7F33363C38300000UL, 0x0000000078303030UL, 0x603F0303037F0000UL, 0x000000003E636060UL, 0x633F0303061C0000UL, 0x000000003E636363UL, 0x18306060637F0000UL, 0x000000000C0C0C0CUL, + 0x633E6363633E0000UL, 0x000000003E636363UL, 0x607E6363633E0000UL, 0x000000001E306060UL, 0x0000181800000000UL, 0x0000000000181800UL, 0x0000181800000000UL, 0x000000000C181800UL, + 0x060C183060000000UL, 0x000000006030180CUL, 0x00007E0000000000UL, 0x000000000000007EUL, 0x6030180C06000000UL, 0x00000000060C1830UL, 0x18183063633E0000UL, 0x0000000018180018UL, + 0x7B7B63633E000000UL, 0x000000003E033B7BUL, 0x7F6363361C080000UL, 0x0000000063636363UL, 0x663E6666663F0000UL, 0x000000003F666666UL, 0x03030343663C0000UL, 0x000000003C664303UL, + 0x66666666361F0000UL, 0x000000001F366666UL, 0x161E1646667F0000UL, 0x000000007F664606UL, 0x161E1646667F0000UL, 0x000000000F060606UL, 0x7B030343663C0000UL, 0x000000005C666363UL, + 0x637F636363630000UL, 0x0000000063636363UL, 0x18181818183C0000UL, 0x000000003C181818UL, 0x3030303030780000UL, 0x000000001E333333UL, 0x1E1E366666670000UL, 0x0000000067666636UL, + 0x06060606060F0000UL, 0x000000007F664606UL, 0xC3DBFFFFE7C30000UL, 0x00000000C3C3C3C3UL, 0x737B7F6F67630000UL, 0x0000000063636363UL, 0x63636363633E0000UL, 0x000000003E636363UL, + 0x063E6666663F0000UL, 0x000000000F060606UL, 0x63636363633E0000UL, 0x000070303E7B6B63UL, 0x363E6666663F0000UL, 0x0000000067666666UL, 0x301C0663633E0000UL, 0x000000003E636360UL, + 0x18181899DBFF0000UL, 0x000000003C181818UL, 0x6363636363630000UL, 0x000000003E636363UL, 0xC3C3C3C3C3C30000UL, 0x00000000183C66C3UL, 0xDBC3C3C3C3C30000UL, 0x000000006666FFDBUL, + 0x18183C66C3C30000UL, 0x00000000C3C3663CUL, 0x183C66C3C3C30000UL, 0x000000003C181818UL, 0x0C183061C3FF0000UL, 0x00000000FFC38306UL, 0x0C0C0C0C0C3C0000UL, 0x000000003C0C0C0CUL, + 0x1C0E070301000000UL, 0x0000000040607038UL, 0x30303030303C0000UL, 0x000000003C303030UL, 0x0000000063361C08UL, 0x0000000000000000UL, 0x0000000000000000UL, 0x0000FF0000000000UL, + 0x0000000000180C0CUL, 0x0000000000000000UL, 0x3E301E0000000000UL, 0x000000006E333333UL, 0x66361E0606070000UL, 0x000000003E666666UL, 0x03633E0000000000UL, 0x000000003E630303UL, + 0x33363C3030380000UL, 0x000000006E333333UL, 0x7F633E0000000000UL, 0x000000003E630303UL, 0x060F0626361C0000UL, 0x000000000F060606UL, 0x33336E0000000000UL, 0x001E33303E333333UL, + 0x666E360606070000UL, 0x0000000067666666UL, 0x18181C0018180000UL, 0x000000003C181818UL, 0x6060700060600000UL, 0x003C666660606060UL, 0x1E36660606070000UL, 0x000000006766361EUL, + 0x18181818181C0000UL, 0x000000003C181818UL, 0xDBFF670000000000UL, 0x00000000DBDBDBDBUL, 0x66663B0000000000UL, 0x0000000066666666UL, 0x63633E0000000000UL, 0x000000003E636363UL, + 0x66663B0000000000UL, 0x000F06063E666666UL, 0x33336E0000000000UL, 0x007830303E333333UL, 0x666E3B0000000000UL, 0x000000000F060606UL, 0x06633E0000000000UL, 0x000000003E63301CUL, + 0x0C0C3F0C0C080000UL, 0x00000000386C0C0CUL, 0x3333330000000000UL, 0x000000006E333333UL, 0xC3C3C30000000000UL, 0x00000000183C66C3UL, 0xC3C3C30000000000UL, 0x0000000066FFDBDBUL, + 0x3C66C30000000000UL, 0x00000000C3663C18UL, 0x6363630000000000UL, 0x001F30607E636363UL, 0x18337F0000000000UL, 0x000000007F63060CUL, 0x180E181818700000UL, 0x0000000070181818UL, + 0x1800181818180000UL, 0x0000000018181818UL, 0x18701818180E0000UL, 0x000000000E181818UL, 0x000000003B6E0000UL, 0x0000000000000000UL, 0x63361C0800000000UL, 0x00000000007F6363UL, }; void _UIWindowEndPaint(UIWindow *window, UIPainter *painter); @@ -1149,7 +1149,7 @@ void UIDrawBlock(UIPainter *painter, UIRectangle rectangle, uint32_t color) { _mm_storeu_si128((__m128i *) bits, color4); bits += 4; count -= 4; - } + } #endif while (count--) { @@ -1346,8 +1346,8 @@ void UIDrawGlyph(UIPainter *painter, int x0, int y0, int c, uint32_t color) { uint32_t g1 = ga * ((color & 0x0000FF00) >> 8); uint32_t b1 = ba * ((color & 0x00FF0000) >> 16); - uint32_t result = 0xFF000000 | (0x00FF0000 & ((b1 + b2) << 8)) - | (0x0000FF00 & ((g1 + g2) << 0)) + uint32_t result = 0xFF000000 | (0x00FF0000 & ((b1 + b2) << 8)) + | (0x0000FF00 & ((g1 + g2) << 0)) | (0x000000FF & ((r1 + r2) >> 8)); *destination = result; } @@ -1390,11 +1390,11 @@ char *UIStringCopy(const char *in, ptrdiff_t inBytes) { } char *buffer = (char *) UI_MALLOC(inBytes + 1); - + for (intptr_t i = 0; i < inBytes; i++) { buffer[i] = in[i]; } - + buffer[inBytes] = 0; return buffer; } @@ -1403,7 +1403,7 @@ int UIMeasureStringWidth(const char *string, ptrdiff_t bytes) { if (bytes == -1) { bytes = _UIStringLength(string); } - + return bytes * ui.activeFont->glyphWidth; } @@ -1435,7 +1435,7 @@ void UIDrawString(UIPainter *painter, UIRectangle r, const char *string, ptrdiff if (selection) { selectFrom = selection->carets[0]; selectTo = selection->carets[1]; - + if (selectFrom > selectTo) { UI_SWAP(int, selectFrom, selectTo); } @@ -1695,15 +1695,15 @@ int _UIPanelLayout(UIPanel *panel, UIRectangle bounds, bool measure) { if (horizontal) { int height = ((child->flags & UI_ELEMENT_V_FILL) || expand) ? vSpace : UIElementMessage(child, UI_MSG_GET_HEIGHT, 0, 0); int width = (child->flags & UI_ELEMENT_H_FILL) ? perFill : UIElementMessage(child, UI_MSG_GET_WIDTH, height, 0); - UIRectangle relative = UI_RECT_4(position, position + width, - scaledBorder2 + (vSpace - height) / 2, + UIRectangle relative = UI_RECT_4(position, position + width, + scaledBorder2 + (vSpace - height) / 2, scaledBorder2 + (vSpace + height) / 2); if (!measure) UIElementMove(child, UIRectangleTranslate(relative, bounds), false); position += width + panel->gap * scale; } else { int width = ((child->flags & UI_ELEMENT_H_FILL) || expand) ? hSpace : UIElementMessage(child, UI_MSG_GET_WIDTH, 0, 0); int height = (child->flags & UI_ELEMENT_V_FILL) ? perFill : UIElementMessage(child, UI_MSG_GET_HEIGHT, width, 0); - UIRectangle relative = UI_RECT_4(scaledBorder2 + (hSpace - width) / 2, + UIRectangle relative = UI_RECT_4(scaledBorder2 + (hSpace - width) / 2, scaledBorder2 + (hSpace + width) / 2, position, position + height); if (!measure) UIElementMove(child, UIRectangleTranslate(relative, bounds), false); position += height + panel->gap * scale; @@ -1749,8 +1749,8 @@ int _UIPanelMessage(UIElement *element, UIMessage message, int di, void *dp) { UIDrawBlock((UIPainter *) dp, element->bounds, ui.theme.panel1); } else if (element->flags & UI_PANEL_WHITE) { UIDrawBlock((UIPainter *) dp, element->bounds, ui.theme.panel2); - } - + } + if (element->flags & UI_PANEL_BORDER) { UIDrawBorder((UIPainter *) dp, element->bounds, ui.theme.border, UI_RECT_1((int) element->window->scale)); } @@ -1849,10 +1849,10 @@ void _UIButtonCalculateColors(UIElement *element, uint32_t *color, uint32_t *tex bool pressed = element == element->window->pressed; bool hovered = element == element->window->hovered; *color = disabled ? ui.theme.buttonDisabled - : (pressed && hovered) ? ui.theme.buttonPressed - : (pressed || hovered) ? ui.theme.buttonHovered + : (pressed && hovered) ? ui.theme.buttonPressed + : (pressed || hovered) ? ui.theme.buttonHovered : focused ? ui.theme.selected : ui.theme.buttonNormal; - *textColor = disabled ? ui.theme.textDisabled + *textColor = disabled ? ui.theme.textDisabled : *color == ui.theme.selected ? ui.theme.textSelected : ui.theme.text; } @@ -1861,7 +1861,7 @@ int _UIButtonMessage(UIElement *element, UIMessage message, int di, void *dp) { UIButton *button = (UIButton *) element; bool isMenuItem = element->flags & UI_BUTTON_MENU_ITEM; bool isDropDown = element->flags & UI_BUTTON_DROP_DOWN; - + if (message == UI_MSG_GET_HEIGHT) { if (isMenuItem) { return UI_SIZE_MENU_ITEM_HEIGHT * element->window->scale; @@ -1872,9 +1872,9 @@ int _UIButtonMessage(UIElement *element, UIMessage message, int di, void *dp) { int labelSize = UIMeasureStringWidth(button->label, button->labelBytes); int paddedSize = labelSize + UI_SIZE_BUTTON_PADDING * element->window->scale; if (isDropDown) paddedSize += ui.activeFont->glyphWidth * 2; - int minimumSize = ((element->flags & UI_BUTTON_SMALL) ? 0 - : isMenuItem ? UI_SIZE_MENU_ITEM_MINIMUM_WIDTH - : UI_SIZE_BUTTON_MINIMUM_WIDTH) + int minimumSize = ((element->flags & UI_BUTTON_SMALL) ? 0 + : isMenuItem ? UI_SIZE_MENU_ITEM_MINIMUM_WIDTH + : UI_SIZE_BUTTON_MINIMUM_WIDTH) * element->window->scale; return paddedSize > minimumSize ? paddedSize : minimumSize; } else if (message == UI_MSG_PAINT) { @@ -1886,7 +1886,7 @@ int _UIButtonMessage(UIElement *element, UIMessage message, int di, void *dp) { UIDrawRectangle(painter, element->bounds, color, ui.theme.border, UI_RECT_1(isMenuItem ? 0 : 1)); if (element->flags & UI_BUTTON_CHECKED) { - UIDrawBlock(painter, UIRectangleAdd(element->bounds, + UIDrawBlock(painter, UIRectangleAdd(element->bounds, UI_RECT_1I((int) (UI_SIZE_BUTTON_CHECKED_AREA * element->window->scale))), ui.theme.buttonPressed); } @@ -1921,7 +1921,7 @@ int _UIButtonMessage(UIElement *element, UIMessage message, int di, void *dp) { } } else if (message == UI_MSG_KEY_TYPED) { UIKeyTyped *m = (UIKeyTyped *) dp; - + if (m->textBytes == 1 && m->text[0] == ' ') { UIElementMessage(element, UI_MSG_CLICKED, 0, 0); UIElementRepaint(element, NULL); @@ -1943,7 +1943,7 @@ UIButton *UIButtonCreate(UIElement *parent, uint32_t flags, const char *label, p int _UICheckboxMessage(UIElement *element, UIMessage message, int di, void *dp) { UICheckbox *box = (UICheckbox *) element; - + if (message == UI_MSG_GET_HEIGHT) { return UI_SIZE_BUTTON_HEIGHT * element->window->scale; } else if (message == UI_MSG_GET_WIDTH) { @@ -1954,13 +1954,13 @@ int _UICheckboxMessage(UIElement *element, UIMessage message, int di, void *dp) uint32_t color, textColor; _UIButtonCalculateColors(element, &color, &textColor); int midY = (element->bounds.t + element->bounds.b) / 2; - UIRectangle boxBounds = UI_RECT_4(element->bounds.l, element->bounds.l + UI_SIZE_CHECKBOX_BOX, + UIRectangle boxBounds = UI_RECT_4(element->bounds.l, element->bounds.l + UI_SIZE_CHECKBOX_BOX, midY - UI_SIZE_CHECKBOX_BOX / 2, midY + UI_SIZE_CHECKBOX_BOX / 2); UIDrawRectangle(painter, boxBounds, color, ui.theme.border, UI_RECT_1(1)); - UIDrawString(painter, UIRectangleAdd(boxBounds, UI_RECT_4(1, 0, 0, 0)), - box->check == UI_CHECK_CHECKED ? "*" : box->check == UI_CHECK_INDETERMINATE ? "-" : " ", -1, + UIDrawString(painter, UIRectangleAdd(boxBounds, UI_RECT_4(1, 0, 0, 0)), + box->check == UI_CHECK_CHECKED ? "*" : box->check == UI_CHECK_INDETERMINATE ? "-" : " ", -1, textColor, UI_ALIGN_CENTER, NULL); - UIDrawString(painter, UIRectangleAdd(element->bounds, UI_RECT_4(UI_SIZE_CHECKBOX_BOX + UI_SIZE_CHECKBOX_GAP, 0, 0, 0)), + UIDrawString(painter, UIRectangleAdd(element->bounds, UI_RECT_4(UI_SIZE_CHECKBOX_BOX + UI_SIZE_CHECKBOX_GAP, 0, 0, 0)), box->label, box->labelBytes, textColor, UI_ALIGN_LEFT, NULL); } else if (message == UI_MSG_UPDATE) { UIElementRepaint(element, NULL); @@ -1968,7 +1968,7 @@ int _UICheckboxMessage(UIElement *element, UIMessage message, int di, void *dp) UI_FREE(box->label); } else if (message == UI_MSG_KEY_TYPED) { UIKeyTyped *m = (UIKeyTyped *) dp; - + if (m->textBytes == 1 && m->text[0] == ' ') { UIElementMessage(element, UI_MSG_CLICKED, 0, 0); UIElementRepaint(element, NULL); @@ -1990,7 +1990,7 @@ UICheckbox *UICheckboxCreate(UIElement *parent, uint32_t flags, const char *labe int _UILabelMessage(UIElement *element, UIMessage message, int di, void *dp) { UILabel *label = (UILabel *) element; - + if (message == UI_MSG_GET_HEIGHT) { return UIMeasureStringHeight(); } else if (message == UI_MSG_GET_WIDTH) { @@ -2036,7 +2036,7 @@ int _UISplitterMessage(UIElement *element, UIMessage message, int di, void *dp) if (splitPane->weight < 0.05f) splitPane->weight = 0.05f; if (splitPane->weight > 0.95f) splitPane->weight = 0.95f; - if (element->next->next->messageClass == _UISplitPaneMessage + if (element->next->next->messageClass == _UISplitPaneMessage && (element->next->next->flags & UI_SPLIT_PANE_VERTICAL) == (splitPane->e.flags & UI_SPLIT_PANE_VERTICAL)) { UISplitPane *subSplitPane = (UISplitPane *) element->next->next; subSplitPane->weight = (splitPane->weight - oldWeight - subSplitPane->weight + oldWeight * subSplitPane->weight) / (-1 + splitPane->weight); @@ -2091,7 +2091,7 @@ UISplitPane *UISplitPaneCreate(UIElement *parent, uint32_t flags, float weight) int _UITabPaneMessage(UIElement *element, UIMessage message, int di, void *dp) { UITabPane *tabPane = (UITabPane *) element; - + if (message == UI_MSG_PAINT) { UIPainter *painter = (UIPainter *) dp; UIRectangle top = element->bounds; @@ -2213,7 +2213,7 @@ UITabPane *UITabPaneCreate(UIElement *parent, uint32_t flags, const char *tabs) int _UISpacerMessage(UIElement *element, UIMessage message, int di, void *dp) { UISpacer *spacer = (UISpacer *) element; - + if (message == UI_MSG_GET_HEIGHT) { return spacer->height * element->window->scale; } else if (message == UI_MSG_GET_WIDTH) { @@ -2310,19 +2310,19 @@ int _UIScrollUpDownMessage(UIElement *element, UIMessage message, int di, void * if (message == UI_MSG_PAINT) { UIPainter *painter = (UIPainter *) dp; - uint32_t color = element == element->window->pressed ? ui.theme.buttonPressed + uint32_t color = element == element->window->pressed ? ui.theme.buttonPressed : element == element->window->hovered ? ui.theme.buttonHovered : ui.theme.panel2; UIDrawRectangle(painter, element->bounds, color, ui.theme.border, UI_RECT_1(0)); - + if (scrollBar->horizontal) { - UIDrawGlyph(painter, isDown ? (element->bounds.r - ui.activeFont->glyphWidth - 2 * element->window->scale) - : (element->bounds.l + 2 * element->window->scale), + UIDrawGlyph(painter, isDown ? (element->bounds.r - ui.activeFont->glyphWidth - 2 * element->window->scale) + : (element->bounds.l + 2 * element->window->scale), (element->bounds.t + element->bounds.b - ui.activeFont->glyphHeight) / 2, isDown ? 26 : 27, ui.theme.text); } else { - UIDrawGlyph(painter, (element->bounds.l + element->bounds.r - ui.activeFont->glyphWidth) / 2 + 1, - isDown ? (element->bounds.b - ui.activeFont->glyphHeight - 2 * element->window->scale) - : (element->bounds.t + 2 * element->window->scale), + UIDrawGlyph(painter, (element->bounds.l + element->bounds.r - ui.activeFont->glyphWidth) / 2 + 1, + isDown ? (element->bounds.b - ui.activeFont->glyphHeight - 2 * element->window->scale) + : (element->bounds.t + 2 * element->window->scale), isDown ? 25 : 24, ui.theme.text); } } else if (message == UI_MSG_UPDATE) { @@ -2354,7 +2354,7 @@ int _UIScrollThumbMessage(UIElement *element, UIMessage message, int di, void *d if (message == UI_MSG_PAINT) { UIPainter *painter = (UIPainter *) dp; - uint32_t color = element == element->window->pressed ? ui.theme.buttonPressed + uint32_t color = element == element->window->pressed ? ui.theme.buttonPressed : element == element->window->hovered ? ui.theme.buttonHovered : ui.theme.buttonNormal; UIDrawRectangle(painter, element->bounds, color, ui.theme.border, UI_RECT_1(2)); } else if (message == UI_MSG_UPDATE) { @@ -2362,7 +2362,7 @@ int _UIScrollThumbMessage(UIElement *element, UIMessage message, int di, void *d } else if (message == UI_MSG_MOUSE_DRAG && element->window->pressedButton == 1) { if (!scrollBar->inDrag) { scrollBar->inDrag = true; - + if (scrollBar->horizontal) { scrollBar->dragOffset = element->bounds.l - scrollBar->e.bounds.l - element->window->cursorX; } else { @@ -2513,7 +2513,7 @@ int UIDrawStringHighlighted(UIPainter *painter, UIRectangle lineBounds, const ch int _UICodeMessage(UIElement *element, UIMessage message, int di, void *dp) { UICode *code = (UICode *) element; - + if (message == UI_MSG_LAYOUT) { UIFont *previousFont = UIFontActivate(code->font); @@ -2868,7 +2868,7 @@ int _UITableMessage(UIElement *element, UIMessage message, int di, void *dp) { if (row.t > element->clip.b) { break; } - + row.b = row.t + rowHeight; m.index = i; m.isSelected = false; @@ -3054,8 +3054,8 @@ int _UITextboxMessage(UIElement *element, UIMessage message, int di, void *dp) { UIPainter *painter = (UIPainter *) dp; bool focused = element->window->focused == element; bool disabled = element->flags & UI_ELEMENT_DISABLED; - UIDrawRectangle(painter, element->bounds, - disabled ? ui.theme.buttonDisabled : focused ? ui.theme.textboxFocused : ui.theme.textboxNormal, + UIDrawRectangle(painter, element->bounds, + disabled ? ui.theme.buttonDisabled : focused ? ui.theme.textboxFocused : ui.theme.textboxNormal, ui.theme.border, UI_RECT_1(1)); #ifdef __cplusplus UIStringSelection selection = {}; @@ -3067,7 +3067,7 @@ int _UITextboxMessage(UIElement *element, UIMessage message, int di, void *dp) { selection.colorBackground = ui.theme.selected; selection.colorText = ui.theme.textSelected; textBounds.l -= textbox->scroll; - UIDrawString(painter, textBounds, textbox->string, textbox->bytes, + UIDrawString(painter, textBounds, textbox->string, textbox->bytes, disabled ? ui.theme.textDisabled : ui.theme.text, UI_ALIGN_LEFT, focused ? &selection : NULL); } else if (message == UI_MSG_GET_CURSOR) { return UI_CURSOR_TEXT; @@ -3111,7 +3111,7 @@ int _UITextboxMessage(UIElement *element, UIMessage message, int di, void *dp) { textbox->carets[0] = textbox->bytes; } else if (m->textBytes && !element->window->alt && !element->window->ctrl && m->text[0] >= 0x20) { UITextboxReplace(textbox, m->text, m->textBytes, true); - } else if ((m->code == UI_KEYCODE_LETTER('C') || m->code == UI_KEYCODE_LETTER('X') || m->code == UI_KEYCODE_INSERT) + } else if ((m->code == UI_KEYCODE_LETTER('C') || m->code == UI_KEYCODE_LETTER('X') || m->code == UI_KEYCODE_INSERT) && element->window->ctrl && !element->window->alt && !element->window->shift) { int to = textbox->carets[0] > textbox->carets[1] ? textbox->carets[0] : textbox->carets[1]; int from = textbox->carets[0] < textbox->carets[1] ? textbox->carets[0] : textbox->carets[1]; @@ -3121,7 +3121,7 @@ int _UITextboxMessage(UIElement *element, UIMessage message, int di, void *dp) { for (int i = from; i < to; i++) pasteText[i - from] = textbox->string[i]; _UIClipboardWriteText(element->window, pasteText); } - + if (m->code == UI_KEYCODE_LETTER('X')) { UITextboxReplace(textbox, NULL, 0, true); } @@ -3231,8 +3231,8 @@ int _UIColorSliderMessage(UIElement *element, UIMessage message, int di, void *d if (opacitySlider) { UIColorToRGB(colorPicker->hue, colorPicker->saturation, colorPicker->value, &color); - color = UI_COLOR_FROM_FLOAT(p * (UI_COLOR_RED_F(color) - 0.5f) + 0.5f, - p * (UI_COLOR_GREEN_F(color) - 0.5f) + 0.5f, + color = UI_COLOR_FROM_FLOAT(p * (UI_COLOR_RED_F(color) - 0.5f) + 0.5f, + p * (UI_COLOR_GREEN_F(color) - 0.5f) + 0.5f, p * (UI_COLOR_BLUE_F(color) - 0.5f) + 0.5f); } else { UIColorToRGB(colorPicker->hue, colorPicker->saturation, p, &color); @@ -3327,7 +3327,7 @@ int _UIMDIChildHitTest(UIMDIChild *mdiChild, int x, int y) { void _UIMDIChildCloseButton(void *_child) { UIElement *child = (UIElement *) _child; - + if (!UIElementMessage(child, UI_MSG_WINDOW_CLOSE, 0, 0)) { UIElementDestroy(child); UIElementRefresh(child->parent); @@ -3499,7 +3499,7 @@ UIMDIClient *UIMDIClientCreate(UIElement *parent, uint32_t flags) { int _UIExpandPaneMessage(UIElement *element, UIMessage message, int di, void *dp) { UIExpandPane *pane = (UIExpandPane *) element; - + if (message == UI_MSG_GET_HEIGHT) { int height = UIElementMessage(&pane->button->e, message, di, dp); @@ -3537,7 +3537,7 @@ void _UIExpandPaneButtonInvoke(void *cp) { while (ancestor) { UIElementRefresh(ancestor); - if ((ancestor->messageClass == _UIPanelMessage && (ancestor->flags & UI_PANEL_SCROLL)) + if ((ancestor->messageClass == _UIPanelMessage && (ancestor->flags & UI_PANEL_SCROLL)) || (ancestor->messageClass == _UIMDIChildMessage) || (ancestor->flags & UI_ELEMENT_V_FILL)) { break; @@ -3559,29 +3559,29 @@ UIExpandPane *UIExpandPaneCreate(UIElement *parent, uint32_t flags, const char * void _UIImageDisplayUpdateViewport(UIImageDisplay *display) { UIRectangle bounds = display->e.bounds; bounds.r -= bounds.l, bounds.b -= bounds.t; - + float minimumZoomX = 1, minimumZoomY = 1; if (display->width > bounds.r) minimumZoomX = (float) bounds.r / display->width; if (display->height > bounds.b) minimumZoomY = (float) bounds.b / display->height; float minimumZoom = minimumZoomX < minimumZoomY ? minimumZoomX : minimumZoomY; - + if (display->zoom < minimumZoom || (display->e.flags & _UI_IMAGE_DISPLAY_ZOOM_FIT)) { display->zoom = minimumZoom; display->e.flags |= _UI_IMAGE_DISPLAY_ZOOM_FIT; } - + if (display->panX < 0) display->panX = 0; if (display->panY < 0) display->panY = 0; if (display->panX > display->width - bounds.r / display->zoom) display->panX = display->width - bounds.r / display->zoom; if (display->panY > display->height - bounds.b / display->zoom) display->panY = display->height - bounds.b / display->zoom; - + if (bounds.r && display->width * display->zoom <= bounds.r) display->panX = display->width / 2 - bounds.r / display->zoom / 2; if (bounds.b && display->height * display->zoom <= bounds.b) display->panY = display->height / 2 - bounds.b / display->zoom / 2; } int _UIImageDisplayMessage(UIElement *element, UIMessage message, int di, void *dp) { UIImageDisplay *display = (UIImageDisplay *) element; - + if (message == UI_MSG_GET_HEIGHT) { return display->height; } else if (message == UI_MSG_GET_WIDTH) { @@ -3590,24 +3590,24 @@ int _UIImageDisplayMessage(UIElement *element, UIMessage message, int di, void * UI_FREE(display->bits); } else if (message == UI_MSG_PAINT) { UIPainter *painter = (UIPainter *) dp; - + int w = UI_RECT_WIDTH(element->bounds), h = UI_RECT_HEIGHT(element->bounds); int x = _UILinearMap(0, display->panX, display->panX + w / display->zoom, 0, w) + element->bounds.l; int y = _UILinearMap(0, display->panY, display->panY + h / display->zoom, 0, h) + element->bounds.t; - + UIRectangle image = UI_RECT_4(x, x + (int) (display->width * display->zoom), y, (int) (y + display->height * display->zoom)); UIRectangle bounds = UIRectangleIntersection(painter->clip, UIRectangleIntersection(display->e.bounds, image)); if (!UI_RECT_VALID(bounds)) return 0; - + if (display->zoom == 1) { uint32_t *lineStart = (uint32_t *) painter->bits + bounds.t * painter->width + bounds.l; uint32_t *sourceLineStart = display->bits + (bounds.l - image.l) + display->width * (bounds.t - image.t); - + for (int i = 0; i < bounds.b - bounds.t; i++, lineStart += painter->width, sourceLineStart += display->width) { uint32_t *destination = lineStart; uint32_t *source = sourceLineStart; int j = bounds.r - bounds.l; - + do { *destination = *source; destination++; @@ -3617,10 +3617,10 @@ int _UIImageDisplayMessage(UIElement *element, UIMessage message, int di, void * } else { float zr = 1.0f / display->zoom; uint32_t *destination = (uint32_t *) painter->bits; - + for (int i = bounds.t; i < bounds.b; i++) { int ty = (i - image.t) * zr; - + for (int j = bounds.l; j < bounds.r; j++) { int tx = (j - image.l) * zr; destination[i * painter->width + j] = display->bits[ty * display->width + tx]; @@ -3650,7 +3650,7 @@ int _UIImageDisplayMessage(UIElement *element, UIMessage message, int di, void * display->previousWidth = bounds.r, display->previousHeight = bounds.b; _UIImageDisplayUpdateViewport(display); } else if (message == UI_MSG_GET_CURSOR && (element->flags & UI_IMAGE_DISPLAY_INTERACTIVE) - && (UI_RECT_WIDTH(element->bounds) < display->width * display->zoom + && (UI_RECT_WIDTH(element->bounds) < display->width * display->zoom || UI_RECT_HEIGHT(element->bounds) < display->height * display->zoom)) { return UI_CURSOR_HAND; } else if (message == UI_MSG_MOUSE_DRAG) { @@ -3660,8 +3660,8 @@ int _UIImageDisplayMessage(UIElement *element, UIMessage message, int di, void * display->previousPanPointX = element->window->cursorX; display->previousPanPointY = element->window->cursorY; UIElementRepaint(element, NULL); - } else if (message == UI_MSG_LEFT_DOWN) { - display->e.flags &= ~_UI_IMAGE_DISPLAY_ZOOM_FIT; + } else if (message == UI_MSG_LEFT_DOWN) { + display->e.flags &= ~_UI_IMAGE_DISPLAY_ZOOM_FIT; display->previousPanPointX = element->window->cursorX; display->previousPanPointY = element->window->cursorY; } @@ -3930,7 +3930,7 @@ int _UIMenuMessage(UIElement *element, UIMessage message, int di, void *dp) { while (child) { if (~child->flags & UI_ELEMENT_NON_CLIENT) { int height = UIElementMessage(child, UI_MSG_GET_HEIGHT, 0, 0); - UIElementMove(child, UI_RECT_4(element->bounds.l + 2, element->bounds.r - scrollBarSize - 2, + UIElementMove(child, UI_RECT_4(element->bounds.l + 2, element->bounds.r - scrollBarSize - 2, position, position + height), false); position += height; totalHeight += height; @@ -4232,7 +4232,7 @@ UIElement *_UIElementPreviousSibling(UIElement *element) { sibling = sibling->next; UI_ASSERT(sibling); } - + return sibling; } @@ -4346,7 +4346,7 @@ bool _UIWindowInputEvent(UIWindow *window, UIMessage message, int di, void *dp) if (element->children && !(element->flags & (UI_ELEMENT_HIDE | UI_ELEMENT_DISABLED))) { element = window->shift ? _UIElementLastChild(element) : element->children; continue; - } + } while (element) { if (window->shift ? (element->parent && element->parent->children != element) : !!element->next) { @@ -4360,7 +4360,7 @@ bool _UIWindowInputEvent(UIWindow *window, UIMessage message, int di, void *dp) if (!element) { element = &window->e; } - } while (element != start && ((~element->flags & UI_ELEMENT_TAB_STOP) + } while (element != start && ((~element->flags & UI_ELEMENT_TAB_STOP) || (element->flags & (UI_ELEMENT_HIDE | UI_ELEMENT_DISABLED)))); if (~element->flags & UI_ELEMENT_WINDOW) { @@ -4372,7 +4372,7 @@ bool _UIWindowInputEvent(UIWindow *window, UIMessage message, int di, void *dp) for (intptr_t i = window->shortcutCount - 1; i >= 0; i--) { UIShortcut *shortcut = window->shortcuts + i; - if (shortcut->code == m->code && shortcut->ctrl == window->ctrl + if (shortcut->code == m->code && shortcut->ctrl == window->ctrl && shortcut->shift == window->shift && shortcut->alt == window->alt) { shortcut->invoke(shortcut->cp); handled = true; @@ -4412,7 +4412,7 @@ UIFont *UIFontCreate(const char *cPath, uint32_t size) { } } #endif - + font->glyphWidth = 9; font->glyphHeight = 16; return font; @@ -4477,7 +4477,7 @@ UIElement *_UIInspectorFindNthElement(UIElement *element, int *index, int *depth } *index = *index - 1; - + UIElement *child = element->children; while (child) { @@ -4635,10 +4635,10 @@ void UIAutomationKeyboardType(const char *string) { window->alt = false; window->shift = (c[0] >= 'A' && c[0] <= 'Z'); c[0] = string[i]; - m.code = (c[0] >= 'A' && c[0] <= 'Z') ? UI_KEYCODE_LETTER(c[0]) - : c[0] == '\n' ? UI_KEYCODE_ENTER - : c[0] == '\t' ? UI_KEYCODE_TAB - : c[0] == ' ' ? UI_KEYCODE_SPACE + m.code = (c[0] >= 'A' && c[0] <= 'Z') ? UI_KEYCODE_LETTER(c[0]) + : c[0] == '\n' ? UI_KEYCODE_ENTER + : c[0] == '\t' ? UI_KEYCODE_TAB + : c[0] == ' ' ? UI_KEYCODE_SPACE : (c[0] >= '0' && c[0] <= '9') ? UI_KEYCODE_DIGIT(c[0]) : 0; _UIWindowInputEvent(window, UI_MSG_KEY_TYPED, 0, &m); } @@ -4733,10 +4733,10 @@ UIWindow *UIWindowCreate(UIWindow *owner, uint32_t flags, const char *cTitle, in XSetWindowAttributes attributes = {}; attributes.override_redirect = flags & UI_WINDOW_MENU; - window->window = XCreateWindow(ui.display, DefaultRootWindow(ui.display), 0, 0, width, height, 0, 0, + window->window = XCreateWindow(ui.display, DefaultRootWindow(ui.display), 0, 0, width, height, 0, 0, InputOutput, CopyFromParent, CWOverrideRedirect, &attributes); if (cTitle) XStoreName(ui.display, window->window, cTitle); - XSelectInput(ui.display, window->window, SubstructureNotifyMask | ExposureMask | PointerMotionMask + XSelectInput(ui.display, window->window, SubstructureNotifyMask | ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask | KeymapStateMask | FocusChangeMask | PropertyChangeMask); @@ -4820,7 +4820,7 @@ char *_UIClipboardReadTextStart(UIWindow *window, size_t *bytes) { unsigned long size, itemAmount; char *data; int format; - XGetWindowProperty(ui.copyEvent.xselection.display, ui.copyEvent.xselection.requestor, ui.copyEvent.xselection.property, 0L, ~0L, 0, + XGetWindowProperty(ui.copyEvent.xselection.display, ui.copyEvent.xselection.requestor, ui.copyEvent.xselection.property, 0L, ~0L, 0, AnyPropertyType, &target, &format, &size, &itemAmount, (unsigned char **) &data); // We have to allocate for incremental transfers but we don't have to allocate for non-incremental transfers. @@ -4851,9 +4851,9 @@ char *_UIClipboardReadTextStart(UIWindow *window, size_t *bytes) { unsigned long chunkSize; // Note that this call deletes the property. - XGetWindowProperty(ui.display, ui.copyEvent.xproperty.window, ui.copyEvent.xproperty.atom, 0L, ~0L, + XGetWindowProperty(ui.display, ui.copyEvent.xproperty.window, ui.copyEvent.xproperty.atom, 0L, ~0L, True, AnyPropertyType, &target, &format, &chunkSize, &itemAmount, (unsigned char **) &data); - + if (chunkSize == 0) { return fullData; } else { @@ -4944,7 +4944,7 @@ void _UIX11ResetCursor(UIWindow *window) { void _UIWindowEndPaint(UIWindow *window, UIPainter *painter) { (void) painter; - XPutImage(ui.display, window->window, DefaultGC(ui.display, 0), window->image, + XPutImage(ui.display, window->window, DefaultGC(ui.display, 0), window->image, UI_RECT_TOP_LEFT(window->updateRegion), UI_RECT_TOP_LEFT(window->updateRegion), UI_RECT_SIZE(window->updateRegion)); } @@ -4965,7 +4965,7 @@ void UIMenuShow(UIMenu *menu) { Window child; XTranslateCoordinates(ui.display, screen->root, DefaultRootWindow(ui.display), 0, 0, &x, &y, &child); - if (menu->pointX >= x && menu->pointX < x + screen->width + if (menu->pointX >= x && menu->pointX < x + screen->width && menu->pointY >= y && menu->pointY < y + screen->height) { if (menu->pointX + width > x + screen->width) menu->pointX = x + screen->width - width; if (menu->pointY + height > y + screen->height) menu->pointY = y + screen->height - height; @@ -5063,7 +5063,7 @@ bool _UIProcessEvent(XEvent *event) { window->cursorY = event->xbutton.y; if (event->xbutton.button >= 1 && event->xbutton.button <= 3) { - _UIWindowInputEvent(window, (UIMessage) ((event->type == ButtonPress ? UI_MSG_LEFT_DOWN : UI_MSG_LEFT_UP) + _UIWindowInputEvent(window, (UIMessage) ((event->type == ButtonPress ? UI_MSG_LEFT_DOWN : UI_MSG_LEFT_UP) + event->xbutton.button * 2 - 2), 0, 0); } else if (event->xbutton.button == 4) { _UIWindowInputEvent(window, UI_MSG_MOUSE_WHEEL, -72, 0); @@ -5078,9 +5078,9 @@ bool _UIProcessEvent(XEvent *event) { if (event->xkey.x == 0x7123 && event->xkey.y == 0x7456) { // HACK! See UIWindowPostMessage. - UIElementMessage(&window->e, (UIMessage) event->xkey.state, 0, - (void *) (((uintptr_t) (event->xkey.time & 0xFFFFFFFF) << 32) - | ((uintptr_t) (event->xkey.x_root & 0xFFFF) << 0) + UIElementMessage(&window->e, (UIMessage) event->xkey.state, 0, + (void *) (((uintptr_t) (event->xkey.time & 0xFFFFFFFF) << 32) + | ((uintptr_t) (event->xkey.x_root & 0xFFFF) << 0) | ((uintptr_t) (event->xkey.y_root & 0xFFFF) << 16))); _UIUpdate(); } else { @@ -5089,7 +5089,7 @@ bool _UIProcessEvent(XEvent *event) { Status status; // printf("%ld, %s\n", symbol, text); UIKeyTyped m = { 0 }; - m.textBytes = Xutf8LookupString(window->xic, &event->xkey, text, sizeof(text) - 1, &symbol, &status); + m.textBytes = Xutf8LookupString(window->xic, &event->xkey, text, sizeof(text) - 1, &symbol, &status); m.text = text; m.code = XLookupKeysym(&event->xkey, 0); @@ -5257,7 +5257,7 @@ bool _UIProcessEvent(XEvent *event) { UIWindow *window = _UIFindWindow(event->xclient.window); if (!window) return false; - if ((XGetSelectionOwner(ui.display, ui.clipboardID) == window->window) + if ((XGetSelectionOwner(ui.display, ui.clipboardID) == window->window) && (event->xselectionrequest.selection == ui.clipboardID)) { XSelectionRequestEvent requestEvent = event->xselectionrequest; Atom utf8ID = XInternAtom(ui.display, "UTF8_STRING", 1); @@ -5268,10 +5268,10 @@ bool _UIProcessEvent(XEvent *event) { int changePropertyResult = 0; if(requestEvent.target == XA_STRING || requestEvent.target == ui.textID || requestEvent.target == utf8ID) { - changePropertyResult = XChangeProperty(requestEvent.display, requestEvent.requestor, requestEvent.property, + changePropertyResult = XChangeProperty(requestEvent.display, requestEvent.requestor, requestEvent.property, type, 8, PropModeReplace, (const unsigned char *) ui.pasteText, strlen(ui.pasteText)); } else if (requestEvent.target == ui.targetID) { - changePropertyResult = XChangeProperty(requestEvent.display, requestEvent.requestor, requestEvent.property, + changePropertyResult = XChangeProperty(requestEvent.display, requestEvent.requestor, requestEvent.property, XA_ATOM, 32, PropModeReplace, (unsigned char *) &utf8ID, 1); } @@ -5508,16 +5508,16 @@ LRESULT CALLBACK _UIWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR HDROP drop = (HDROP) wParam; int count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); char **files = (char **) UI_MALLOC(sizeof(char *) * count); - + for (int i = 0; i < count; i++) { int length = DragQueryFile(drop, i, NULL, 0); files[i] = (char *) UI_MALLOC(length + 1); files[i][length] = 0; DragQueryFile(drop, i, files[i], length + 1); } - + UIElementMessage(&window->e, UI_MSG_WINDOW_DROP_FILES, count, files); - for (int i = 0; i < count; i++) UI_FREE(files[i]); + for (int i = 0; i < count; i++) UI_FREE(files[i]); UI_FREE(files); DragFinish(drop); _UIUpdate(); @@ -5540,7 +5540,7 @@ LRESULT CALLBACK _UIWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR void UIInitialise() { ui.heap = GetProcessHeap(); - + _UIInitialiseCommon(); ui.cursors[UI_CURSOR_ARROW] = LoadCursor(NULL, IDC_ARROW); @@ -5613,10 +5613,10 @@ UIWindow *UIWindowCreate(UIWindow *owner, uint32_t flags, const char *cTitle, in if (flags & UI_WINDOW_MENU) { UI_ASSERT(owner); - window->hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_NOACTIVATE, "shadow", 0, WS_POPUP, + window->hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_NOACTIVATE, "shadow", 0, WS_POPUP, 0, 0, 0, 0, owner->hwnd, NULL, NULL, NULL); } else { - window->hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, "normal", cTitle, WS_OVERLAPPEDWINDOW, + window->hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, "normal", cTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width ? width : CW_USEDEFAULT, height ? height : CW_USEDEFAULT, owner ? owner->hwnd : NULL, NULL, NULL, NULL); } @@ -5637,9 +5637,9 @@ void _UIWindowEndPaint(UIWindow *window, UIPainter *painter) { info.biSize = sizeof(info); info.biWidth = window->width, info.biHeight = window->height; info.biPlanes = 1, info.biBitCount = 32; - StretchDIBits(dc, - UI_RECT_TOP_LEFT(window->updateRegion), UI_RECT_SIZE(window->updateRegion), - window->updateRegion.l, window->updateRegion.b + 1, + StretchDIBits(dc, + UI_RECT_TOP_LEFT(window->updateRegion), UI_RECT_SIZE(window->updateRegion), + window->updateRegion.l, window->updateRegion.b + 1, UI_RECT_WIDTH(window->updateRegion), -UI_RECT_HEIGHT(window->updateRegion), window->bits, (BITMAPINFO *) &info, DIB_RGB_COLORS, SRCCOPY); ReleaseDC(window->hwnd, dc); @@ -5695,23 +5695,23 @@ char *_UIClipboardReadTextStart(UIWindow *window, size_t *bytes) { if (!OpenClipboard(window->hwnd)) { return NULL; } - + HANDLE memory = GetClipboardData(CF_TEXT); - + if (!memory) { CloseClipboard(); return NULL; } - + char *buffer = (char *) GlobalLock(memory); - + if (!buffer) { CloseClipboard(); return NULL; } - + size_t byteCount = GlobalSize(memory); - + if (byteCount < 1) { GlobalUnlock(memory); CloseClipboard(); @@ -5721,10 +5721,10 @@ char *_UIClipboardReadTextStart(UIWindow *window, size_t *bytes) { char *copy = (char *) UI_MALLOC(byteCount + 1); for (uintptr_t i = 0; i < byteCount; i++) copy[i] = buffer[i]; copy[byteCount] = 0; // Just in case. - + GlobalUnlock(memory); CloseClipboard(); - + if (bytes) *bytes = _UIStringLength(copy); return copy; } @@ -5800,7 +5800,7 @@ void UIMenuAddItem(UIMenu *menu, uint32_t flags, const char *label, ptrdiff_t la EsAssert(ui.menuIndex < 128); ui.menuData[ui.menuIndex * 2 + 0] = (void *) invoke; ui.menuData[ui.menuIndex * 2 + 1] = cp; - EsMenuAddItem(menu, (flags & UI_BUTTON_CHECKED) ? ES_MENU_ITEM_CHECKED : ES_FLAGS_DEFAULT, + EsMenuAddItem(menu, (flags & UI_BUTTON_CHECKED) ? ES_MENU_ITEM_CHECKED : ES_FLAGS_DEFAULT, label, labelBytes, _UIMenuItemCallback, ui.menuIndex); ui.menuIndex++; } @@ -5828,7 +5828,7 @@ int _UIWindowCanvasMessage(EsElement *element, EsMessage *message) { _UIWindowInputEvent(window, UI_MSG_MOUSE_WHEEL, -message->scrollWheel.dy, 0); } else if (message->type == ES_MSG_MOUSE_MOVED || message->type == ES_MSG_HOVERED_END || message->type == ES_MSG_MOUSE_LEFT_DRAG || message->type == ES_MSG_MOUSE_RIGHT_DRAG || message->type == ES_MSG_MOUSE_MIDDLE_DRAG) { - EsPoint point = EsMouseGetPosition(element); + EsPoint point = EsMouseGetPosition(element); window->cursorX = point.x, window->cursorY = point.y; _UIWindowInputEvent(window, UI_MSG_MOUSE_MOVE, 0, 0); } else if (message->type == ES_MSG_KEY_UP) { @@ -5867,7 +5867,7 @@ int _UIWindowCanvasMessage(EsElement *element, EsMessage *message) { if (window->cursor == UI_CURSOR_RESIZE_DOWN_RIGHT) message->cursorStyle = ES_CURSOR_RESIZE_DIAGONAL_1; if (window->cursor == UI_CURSOR_RESIZE_DOWN_LEFT) message->cursorStyle = ES_CURSOR_RESIZE_DIAGONAL_2; } - + else if (message->type == ES_MSG_MOUSE_LEFT_DOWN) _UIWindowInputEvent(window, UI_MSG_LEFT_DOWN, 0, 0); else if (message->type == ES_MSG_MOUSE_LEFT_UP) _UIWindowInputEvent(window, UI_MSG_LEFT_UP, 0, 0); else if (message->type == ES_MSG_MOUSE_MIDDLE_DOWN) _UIWindowInputEvent(window, UI_MSG_MIDDLE_DOWN, 0, 0);