diff --git a/src/LBackend.c b/src/LBackend.c index a61bdfc43..32d976f81 100644 --- a/src/LBackend.c +++ b/src/LBackend.c @@ -60,7 +60,7 @@ void LBackend_ResetArea(int x, int y, int width, int height) { if (Launcher_ClassicBackground && dirtBmp.scan0) { ClearTile(x, y, width, height, &stoneBmp); } else { - Gradient_Noise(&Launcher_Framebuffer, Launcher_BackgroundCol, 6, x, y, width, height); + Gradient_Noise(&Launcher_Framebuffer, Launcher_BackgroundColor, 6, x, y, width, height); } } @@ -112,7 +112,7 @@ static void LButton_DrawBackground(struct LButton* w) { w->x + xBorder, w->y + yBorder, w->width - xBorder2, w->height - yBorder2); } else { - col = w->hovered ? Launcher_ButtonForeActiveCol : Launcher_ButtonForeCol; + col = w->hovered ? Launcher_ButtonForeActiveColor : Launcher_ButtonForeColor; Gradient_Vertical(&Launcher_Framebuffer, LButton_Expand(col, 8), LButton_Expand(col, -8), w->x + xBorder, w->y + yBorder, w->width - xBorder2, w->height - yBorder2); @@ -121,7 +121,7 @@ static void LButton_DrawBackground(struct LButton* w) { static void LButton_DrawBorder(struct LButton* w) { BitmapCol black = BitmapCol_Make(0, 0, 0, 255); - BitmapCol backCol = Launcher_ClassicBackground ? black : Launcher_ButtonBorderCol; + BitmapCol backCol = Launcher_ClassicBackground ? black : Launcher_ButtonBorderColor; Drawer2D_Clear(&Launcher_Framebuffer, backCol, w->x + xBorder, w->y, @@ -151,7 +151,7 @@ static void LButton_DrawHighlight(struct LButton* w) { w->x + xBorder, w->y + yBorder2, xBorder, w->height - yBorder4); } else if (!w->hovered) { - Drawer2D_Clear(&Launcher_Framebuffer, Launcher_ButtonHighlightCol, + Drawer2D_Clear(&Launcher_Framebuffer, Launcher_ButtonHighlightColor, w->x + xBorder2, w->y + yBorder, w->width - xBorder4, yBorder); } @@ -289,7 +289,7 @@ void LBackend_DrawLabel(struct LLabel* w) { *#########################################################################################################################*/ #define CLASSIC_LINE_COL BitmapCol_Make(128,128,128, 255) void LBackend_DrawLine(struct LLine* w) { - BitmapCol col = Launcher_ClassicBackground ? CLASSIC_LINE_COL : Launcher_ButtonBorderCol; + BitmapCol col = Launcher_ClassicBackground ? CLASSIC_LINE_COL : Launcher_ButtonBorderColor; Gradient_Blend(&Launcher_Framebuffer, col, 128, w->x, w->y, w->width, w->height); } diff --git a/src/LScreens.c b/src/LScreens.c index a9755b23a..eb76eabe5 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -340,11 +340,11 @@ CC_NOINLINE static void ColoursScreen_Update(struct ColoursScreen* s, int i, Bit } CC_NOINLINE static void ColoursScreen_UpdateAll(struct ColoursScreen* s) { - ColoursScreen_Update(s, 0, Launcher_BackgroundCol); - ColoursScreen_Update(s, 3, Launcher_ButtonBorderCol); - ColoursScreen_Update(s, 6, Launcher_ButtonHighlightCol); - ColoursScreen_Update(s, 9, Launcher_ButtonForeCol); - ColoursScreen_Update(s, 12, Launcher_ButtonForeActiveCol); + ColoursScreen_Update(s, 0, Launcher_BackgroundColor); + ColoursScreen_Update(s, 3, Launcher_ButtonBorderColor); + ColoursScreen_Update(s, 6, Launcher_ButtonHighlightColor); + ColoursScreen_Update(s, 9, Launcher_ButtonForeColor); + ColoursScreen_Update(s, 12, Launcher_ButtonForeActiveColor); } static void ColoursScreen_TextChanged(struct LInput* w) { @@ -353,11 +353,11 @@ static void ColoursScreen_TextChanged(struct LInput* w) { BitmapCol* col; cc_uint8 r, g, b; - if (index < 3) col = &Launcher_BackgroundCol; - else if (index < 6) col = &Launcher_ButtonBorderCol; - else if (index < 9) col = &Launcher_ButtonHighlightCol; - else if (index < 12) col = &Launcher_ButtonForeCol; - else col = &Launcher_ButtonForeActiveCol; + if (index < 3) col = &Launcher_BackgroundColor; + else if (index < 6) col = &Launcher_ButtonBorderColor; + else if (index < 9) col = &Launcher_ButtonHighlightColor; + else if (index < 12) col = &Launcher_ButtonForeColor; + else col = &Launcher_ButtonForeActiveColor; /* if index of G input, changes to index of R input */ index = (index / 3) * 3; diff --git a/src/LWidgets.c b/src/LWidgets.c index d74cd2b63..4b9efb4b4 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -676,14 +676,14 @@ static void LTable_DrawGridlines(struct LTable* w) { if (Launcher_ClassicBackground) return; x = w->x; - Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundCol, + Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundColor, x, w->y + w->hdrHeight, w->width, gridlineHeight); for (i = 0; i < w->numColumns; i++) { x += w->columns[i].width; if (!w->columns[i].hasGridline) continue; - Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundCol, + Drawer2D_Clear(&Launcher_Framebuffer, Launcher_BackgroundColor, x, w->y, gridlineWidth, w->height); x += gridlineWidth; } @@ -757,8 +757,8 @@ static void LTable_DrawRows(struct LTable* w) { static void LTable_DrawScrollbar(struct LTable* w) { BitmapCol classicBack = BitmapCol_Make( 80, 80, 80, 255); BitmapCol classicScroll = BitmapCol_Make(160, 160, 160, 255); - BitmapCol backCol = Launcher_ClassicBackground ? classicBack : Launcher_ButtonBorderCol; - BitmapCol scrollCol = Launcher_ClassicBackground ? classicScroll : Launcher_ButtonForeActiveCol; + BitmapCol backCol = Launcher_ClassicBackground ? classicBack : Launcher_ButtonBorderColor; + BitmapCol scrollCol = Launcher_ClassicBackground ? classicScroll : Launcher_ButtonForeActiveColor; int x, y, height; x = w->x + w->width - scrollbarWidth; diff --git a/src/Launcher.c b/src/Launcher.c index b973e35c6..64cbc4d70 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -355,24 +355,24 @@ void Launcher_Run(void) { /*########################################################################################################################* *---------------------------------------------------------Colours/Skin----------------------------------------------------* *#########################################################################################################################*/ -#define DEFAULT_BACKGROUND_COL BitmapCol_Make(153, 127, 172, 255) -#define DEFAULT_BUTTON_BORDER_COL BitmapCol_Make( 97, 81, 110, 255) -#define DEFAULT_BUTTON_FORE_ACTIVE_COL BitmapCol_Make(189, 168, 206, 255) -#define DEFAULT_BUTTON_FORE_COL BitmapCol_Make(141, 114, 165, 255) -#define DEFAULT_BUTTON_HIGHLIGHT_COL BitmapCol_Make(162, 131, 186, 255) +#define DEFAULT_BACKGROUND_COLOR BitmapCol_Make(153, 127, 172, 255) +#define DEFAULT_BUTTON_BORDER_COLOR BitmapCol_Make( 97, 81, 110, 255) +#define DEFAULT_BUTTON_FORE_ACTIVE_COLOR BitmapCol_Make(189, 168, 206, 255) +#define DEFAULT_BUTTON_FORE_COLOR BitmapCol_Make(141, 114, 165, 255) +#define DEFAULT_BUTTON_HIGHLIGHT_COLOR BitmapCol_Make(162, 131, 186, 255) -BitmapCol Launcher_BackgroundCol = DEFAULT_BACKGROUND_COL; -BitmapCol Launcher_ButtonBorderCol = DEFAULT_BUTTON_BORDER_COL; -BitmapCol Launcher_ButtonForeActiveCol = DEFAULT_BUTTON_FORE_ACTIVE_COL; -BitmapCol Launcher_ButtonForeCol = DEFAULT_BUTTON_FORE_COL; -BitmapCol Launcher_ButtonHighlightCol = DEFAULT_BUTTON_HIGHLIGHT_COL; +BitmapCol Launcher_BackgroundColor = DEFAULT_BACKGROUND_COLOR; +BitmapCol Launcher_ButtonBorderColor = DEFAULT_BUTTON_BORDER_COLOR; +BitmapCol Launcher_ButtonForeActiveColor = DEFAULT_BUTTON_FORE_ACTIVE_COLOR; +BitmapCol Launcher_ButtonForeColor = DEFAULT_BUTTON_FORE_COLOR; +BitmapCol Launcher_ButtonHighlightColor = DEFAULT_BUTTON_HIGHLIGHT_COLOR; void Launcher_ResetSkin(void) { - Launcher_BackgroundCol = DEFAULT_BACKGROUND_COL; - Launcher_ButtonBorderCol = DEFAULT_BUTTON_BORDER_COL; - Launcher_ButtonForeActiveCol = DEFAULT_BUTTON_FORE_ACTIVE_COL; - Launcher_ButtonForeCol = DEFAULT_BUTTON_FORE_COL; - Launcher_ButtonHighlightCol = DEFAULT_BUTTON_HIGHLIGHT_COL; + Launcher_BackgroundColor = DEFAULT_BACKGROUND_COLOR; + Launcher_ButtonBorderColor = DEFAULT_BUTTON_BORDER_COLOR; + Launcher_ButtonForeActiveColor = DEFAULT_BUTTON_FORE_ACTIVE_COLOR; + Launcher_ButtonForeColor = DEFAULT_BUTTON_FORE_COLOR; + Launcher_ButtonHighlightColor = DEFAULT_BUTTON_HIGHLIGHT_COLOR; } CC_NOINLINE static void Launcher_GetCol(const char* key, BitmapCol* col) { @@ -385,11 +385,11 @@ CC_NOINLINE static void Launcher_GetCol(const char* key, BitmapCol* col) { } void Launcher_LoadSkin(void) { - Launcher_GetCol("launcher-back-col", &Launcher_BackgroundCol); - Launcher_GetCol("launcher-btn-border-col", &Launcher_ButtonBorderCol); - Launcher_GetCol("launcher-btn-fore-active-col", &Launcher_ButtonForeActiveCol); - Launcher_GetCol("launcher-btn-fore-inactive-col", &Launcher_ButtonForeCol); - Launcher_GetCol("launcher-btn-highlight-inactive-col", &Launcher_ButtonHighlightCol); + Launcher_GetCol("launcher-back-col", &Launcher_BackgroundColor); + Launcher_GetCol("launcher-btn-border-col", &Launcher_ButtonBorderColor); + Launcher_GetCol("launcher-btn-fore-active-col", &Launcher_ButtonForeActiveColor); + Launcher_GetCol("launcher-btn-fore-inactive-col", &Launcher_ButtonForeColor); + Launcher_GetCol("launcher-btn-highlight-inactive-col", &Launcher_ButtonHighlightColor); } CC_NOINLINE static void Launcher_SetCol(const char* key, BitmapCol col) { @@ -403,11 +403,11 @@ CC_NOINLINE static void Launcher_SetCol(const char* key, BitmapCol col) { } void Launcher_SaveSkin(void) { - Launcher_SetCol("launcher-back-col", Launcher_BackgroundCol); - Launcher_SetCol("launcher-btn-border-col", Launcher_ButtonBorderCol); - Launcher_SetCol("launcher-btn-fore-active-col", Launcher_ButtonForeActiveCol); - Launcher_SetCol("launcher-btn-fore-inactive-col", Launcher_ButtonForeCol); - Launcher_SetCol("launcher-btn-highlight-inactive-col", Launcher_ButtonHighlightCol); + Launcher_SetCol("launcher-back-col", Launcher_BackgroundColor); + Launcher_SetCol("launcher-btn-border-col", Launcher_ButtonBorderColor); + Launcher_SetCol("launcher-btn-fore-active-col", Launcher_ButtonForeActiveColor); + Launcher_SetCol("launcher-btn-fore-inactive-col", Launcher_ButtonForeColor); + Launcher_SetCol("launcher-btn-highlight-inactive-col", Launcher_ButtonHighlightColor); } diff --git a/src/Launcher.h b/src/Launcher.h index cffe045bb..d0d6211ee 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -26,15 +26,15 @@ extern cc_string Launcher_AutoHash; extern cc_string Launcher_Username; /* Base colour of pixels before any widgets are drawn. */ -extern BitmapCol Launcher_BackgroundCol; +extern BitmapCol Launcher_BackgroundColor; /* Colour of pixels on the 4 line borders around buttons. */ -extern BitmapCol Launcher_ButtonBorderCol; +extern BitmapCol Launcher_ButtonBorderColor; /* Colour of button when user has mouse over it. */ -extern BitmapCol Launcher_ButtonForeActiveCol; +extern BitmapCol Launcher_ButtonForeActiveColor; /* Colour of button when user does not have mouse over it. */ -extern BitmapCol Launcher_ButtonForeCol; +extern BitmapCol Launcher_ButtonForeColor; /* Colour of line at top of buttons to give them a less flat look.*/ -extern BitmapCol Launcher_ButtonHighlightCol; +extern BitmapCol Launcher_ButtonHighlightColor; /* Resets colours to default. */ void Launcher_ResetSkin(void); diff --git a/src/Window.c b/src/Window.c index 6dd6ee3a0..6a4133373 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2141,6 +2141,60 @@ CC_OBJC_VISIBLE int MapNativeKey(UInt32 key) { return key < Array_Elems(key_map) /*Return = 52, (0x34, ??? according to that link)*/ /*Menu = 110, (0x6E, ??? according to that link)*/ +void Cursor_SetPosition(int x, int y) { + CGPoint point; + point.x = x + windowX; + point.y = y + windowY; + CGDisplayMoveCursorToPoint(CGMainDisplayID(), point); +} + +static void Cursor_DoSetVisible(cc_bool visible) { + if (visible) { + CGDisplayShowCursor(CGMainDisplayID()); + } else { + CGDisplayHideCursor(CGMainDisplayID()); + } +} + +void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { } +void Window_SetKeyboardText(const cc_string* text) { } +void Window_CloseKeyboard(void) { } + +void Window_EnableRawMouse(void) { + DefaultEnableRawMouse(); + CGAssociateMouseAndMouseCursorPosition(0); +} + +void Window_UpdateRawMouse(void) { CentreMousePosition(); } +void Window_DisableRawMouse(void) { + CGAssociateMouseAndMouseCursorPosition(1); + DefaultDisableRawMouse(); +} + + +/*########################################################################################################################* +*------------------------------------------------------Carbon window------------------------------------------------------* +*#########################################################################################################################*/ +#if defined CC_BUILD_CARBON +#include + +static WindowRef win_handle; +static cc_bool win_fullscreen, showingDialog; + +/* fullscreen is tied to OpenGL context unfortunately */ +static cc_result GLContext_UnsetFullscreen(void); +static cc_result GLContext_SetFullscreen(void); + +static void RefreshWindowBounds(void) { + Rect r; + if (win_fullscreen) return; + + /* TODO: kWindowContentRgn ??? */ + GetWindowBounds(win_handle, kWindowGlobalPortRgn, &r); + windowX = r.left; WindowInfo.Width = r.right - r.left; + windowY = r.top; WindowInfo.Height = r.bottom - r.top; +} + /* NOTE: All Pasteboard functions are OSX 10.3 or later */ static PasteboardRef Window_GetPasteboard(void) { PasteboardRef pbRef; @@ -2202,60 +2256,6 @@ void Clipboard_SetText(const cc_string* value) { PasteboardPutItemFlavor(pbRef, 1, FMT_UTF8, cfData, 0); } -void Cursor_SetPosition(int x, int y) { - CGPoint point; - point.x = x + windowX; - point.y = y + windowY; - CGDisplayMoveCursorToPoint(CGMainDisplayID(), point); -} - -static void Cursor_DoSetVisible(cc_bool visible) { - if (visible) { - CGDisplayShowCursor(CGMainDisplayID()); - } else { - CGDisplayHideCursor(CGMainDisplayID()); - } -} - -void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { } -void Window_SetKeyboardText(const cc_string* text) { } -void Window_CloseKeyboard(void) { } - -void Window_EnableRawMouse(void) { - DefaultEnableRawMouse(); - CGAssociateMouseAndMouseCursorPosition(0); -} - -void Window_UpdateRawMouse(void) { CentreMousePosition(); } -void Window_DisableRawMouse(void) { - CGAssociateMouseAndMouseCursorPosition(1); - DefaultDisableRawMouse(); -} - - -/*########################################################################################################################* -*------------------------------------------------------Carbon window------------------------------------------------------* -*#########################################################################################################################*/ -#if defined CC_BUILD_CARBON -#include - -static WindowRef win_handle; -static cc_bool win_fullscreen, showingDialog; - -/* fullscreen is tied to OpenGL context unfortunately */ -static cc_result GLContext_UnsetFullscreen(void); -static cc_result GLContext_SetFullscreen(void); - -static void RefreshWindowBounds(void) { - Rect r; - if (win_fullscreen) return; - - /* TODO: kWindowContentRgn ??? */ - GetWindowBounds(win_handle, kWindowGlobalPortRgn, &r); - windowX = r.left; WindowInfo.Width = r.right - r.left; - windowY = r.top; WindowInfo.Height = r.bottom - r.top; -} - static OSStatus Window_ProcessKeyboardEvent(EventRef inEvent) { UInt32 kind, code; int key; diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index 21838b126..520976583 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -44,6 +44,35 @@ static void RefreshWindowBounds(void) { WindowInfo.Height = (int)view.size.height; } +void Clipboard_GetText(cc_string* value) { + NSPasteboard* pasteboard; + const char* src; + NSString* str; + int len; + + pasteboard = [NSPasteboard generalPasteboard]; + str = [pasteboard stringForType:NSStringPboardType]; + + if (!str) return; + src = [str UTF8String]; + len = String_Length(src); + String_AppendUtf8(value, src, len); +} + +void Clipboard_SetText(const cc_string* value) { + NSPasteboard* pasteboard; + char raw[NATIVE_STR_LEN]; + NSString* str; + + Platform_EncodeUtf8(raw, value); + str = [[NSString alloc] initWithUTF8String:raw]; + pasteboard = [NSPasteboard generalPasteboard]; + + [pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; + [pasteboard setString:str forType:NSStringPboardType]; +} + + @interface CCWindow : NSWindow { } @end @implementation CCWindow @@ -182,11 +211,11 @@ void Window_Create(int width, int height) { } void Window_SetTitle(const cc_string* title) { - char buffer[NATIVE_STR_LEN]; + char raw[NATIVE_STR_LEN]; NSString* str; - Platform_EncodeUtf8(buffer, title); + Platform_EncodeUtf8(raw, title); - str = [[NSString alloc] initWithUTF8String:buffer]; + str = [[NSString alloc] initWithUTF8String:raw]; [winHandle setTitle:str]; [str release]; } diff --git a/src/interop_ios.m b/src/interop_ios.m index e589faeee..8147506f3 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -7,7 +7,7 @@ void Clipboard_GetText(cc_string* value) { const char* raw; NSString* str; - int len; + int len; str = [UIPasteboard generalPasteboard].string; if (!str) return;