- Adds a taskbar that displays and manages open application windows - close, minimise and restore functionality - resizeable windows - Refactored desktop event handling to manage window focus and render order
40 lines
979 B
C++
40 lines
979 B
C++
#include <cstdio>
|
|
|
|
#include "cursor_manager.h"
|
|
#include <SDL3/SDL_error.h>
|
|
#include <SDL3/SDL_mouse.h>
|
|
|
|
SDL_Cursor* CursorManager::_arrow_cursor = nullptr;
|
|
SDL_Cursor* CursorManager::_resize_cursor = nullptr;
|
|
|
|
void CursorManager::init(void) {
|
|
_arrow_cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
|
_resize_cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NWSE_RESIZE);
|
|
|
|
if(!_arrow_cursor || !_resize_cursor) {
|
|
printf("Failed to create system cursors! SDL_Error: %s\n", SDL_GetError());
|
|
}
|
|
}
|
|
|
|
void CursorManager::set_cursor(CursorType type) {
|
|
SDL_Cursor* cursor_to_set = _arrow_cursor;
|
|
switch(type) {
|
|
case CursorType::ARROW:
|
|
cursor_to_set = _arrow_cursor;
|
|
break;
|
|
case CursorType::RESIZE_NWSE:
|
|
cursor_to_set = _resize_cursor;
|
|
break;
|
|
}
|
|
|
|
if(SDL_GetCursor() != cursor_to_set) {
|
|
SDL_SetCursor(cursor_to_set);
|
|
}
|
|
}
|
|
|
|
void CursorManager::quit(void) {
|
|
SDL_DestroyCursor(_arrow_cursor);
|
|
SDL_DestroyCursor(_resize_cursor);
|
|
}
|
|
|