mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-22 19:50:05 +02:00
libsdl2: add bitmap cursor support
This commit is contained in:
@@ -6,7 +6,7 @@ software, emulators, and popular games."
|
||||
HOMEPAGE="https://www.libsdl.org/"
|
||||
COPYRIGHT="1997-2021 Sam Lantinga"
|
||||
LICENSE="Zlib"
|
||||
REVISION="1"
|
||||
REVISION="2"
|
||||
SOURCE_URI="https://www.libsdl.org/release/SDL2-$portVersion.tar.gz"
|
||||
CHECKSUM_SHA256="c56aba1d7b5b0e7e999e4a7698c70b63a3394ff9704b5f6e1c57e0c16f04dd06"
|
||||
SOURCE_DIR="SDL2-$portVersion"
|
||||
|
||||
@@ -1212,3 +1212,56 @@ index 12cc2da..bc46aec 100644
|
||||
--
|
||||
2.30.2
|
||||
|
||||
|
||||
From 61510a4a211bc7b3fe8006d3c16447cef07e11a0 Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Sun, 12 Dec 2021 10:07:47 +1000
|
||||
Subject: Add bitmap cursor support
|
||||
|
||||
|
||||
diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc
|
||||
index c5026de..868512e 100644
|
||||
--- a/src/video/haiku/SDL_bvideo.cc
|
||||
+++ b/src/video/haiku/SDL_bvideo.cc
|
||||
@@ -190,6 +190,31 @@ HAIKU_FreeCursor(SDL_Cursor * cursor)
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
+static SDL_Cursor *
|
||||
+HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
+{
|
||||
+ SDL_Cursor *cursor;
|
||||
+ SDL_Surface *converted;
|
||||
+
|
||||
+ converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
|
||||
+ if (!converted) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ BBitmap *cursorBitmap = new BBitmap(BRect(0, 0, surface->w - 1, surface->h - 1), B_RGBA32);
|
||||
+ cursorBitmap->SetBits(converted->pixels, converted->h * converted->pitch, 0, B_RGBA32);
|
||||
+ SDL_FreeSurface(converted);
|
||||
+
|
||||
+ cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
|
||||
+ if (cursor) {
|
||||
+ cursor->driverdata = (void *)new BCursor(cursorBitmap, BPoint(hot_x, hot_y));
|
||||
+ } else {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return cursor;
|
||||
+}
|
||||
+
|
||||
static int HAIKU_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
@@ -235,6 +260,7 @@ static void HAIKU_MouseInit(_THIS)
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (!mouse)
|
||||
return;
|
||||
+ mouse->CreateCursor = HAIKU_CreateCursor;
|
||||
mouse->CreateSystemCursor = HAIKU_CreateSystemCursor;
|
||||
mouse->ShowCursor = HAIKU_ShowCursor;
|
||||
mouse->FreeCursor = HAIKU_FreeCursor;
|
||||
--
|
||||
2.30.2
|
||||
|
||||
Reference in New Issue
Block a user