Skip to content

Commit

Permalink
Allow KDUtils to build for Android
Browse files Browse the repository at this point in the history
Update platform Window implementation for base class changes.
Ensure logging headers are included.

Change-Id: I5499ff4d8e234e66d8877bd5ed7d09350fbc7085
Reviewed-on: https://codereview.kdab.com/c/kdab/kdutils/+/136322
Tested-by: Continuous Integration <[email protected]>
Reviewed-by: Miłosz Kosobucki <[email protected]>
  • Loading branch information
alistair-baxter-kdab committed Jan 15, 2024
1 parent 50014a2 commit 36f3130
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/KDGui/abstract_platform_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class KDGUI_API AbstractPlatformWindow
Win32,
Cocoa,
XCB,
Wayland
Wayland,
Android
};

explicit AbstractPlatformWindow(Window *window, AbstractPlatformWindow::Type type);
Expand Down
2 changes: 2 additions & 0 deletions src/KDGui/platform/android/android_platform_event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <KDFoundation/file_descriptor_notifier.h>
#include <KDFoundation/postman.h>

#include <android/log.h>

#include "android_platform_integration.h"

using namespace KDFoundation;
Expand Down
4 changes: 3 additions & 1 deletion src/KDGui/platform/android/android_platform_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "android_platform_event_loop.h"
#include "android_platform_window.h"

#include <android/log.h>

namespace KDGui {

android_app *KDGui::AndroidPlatformIntegration::s_androidApp = nullptr;
Expand All @@ -37,7 +39,7 @@ AbstractPlatformWindow *AndroidPlatformIntegration::createPlatformWindowImpl(Win

AndroidPlatformIntegration::AndroidPlatformIntegration()
{
KDUtils::File::setAssetManager(s_androidApp->activity->assetManager);
KDUtils::setAssetManager(s_androidApp->activity->assetManager);
}

void AndroidPlatformIntegration::handleWindowResize()
Expand Down
14 changes: 7 additions & 7 deletions src/KDGui/platform/android/android_platform_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace KDFoundation;
namespace KDGui {

AndroidPlatformWindow::AndroidPlatformWindow(AndroidPlatformIntegration *androidPlatformIntegrationSerenity, Window *window)
: AbstractPlatformWindow(window)
: AbstractPlatformWindow(window, Type::Android)
, m_androidPlatformIntegrationSerenity(androidPlatformIntegrationSerenity)
{
}
Expand Down Expand Up @@ -78,21 +78,21 @@ void AndroidPlatformWindow::handleResize(uint32_t width, uint32_t height)
CoreApplication::instance()->sendEvent(m_window, &ev);
}

void AndroidPlatformWindow::handleMousePress(uint32_t timestamp, uint8_t button, int16_t xPos, int16_t yPos)
void AndroidPlatformWindow::handleMousePress(uint32_t timestamp, KDGui::MouseButtons buttons, int16_t xPos, int16_t yPos)
{
MousePressEvent ev{ timestamp, button, xPos, yPos };
MousePressEvent ev{ timestamp, buttons, xPos, yPos };
CoreApplication::instance()->sendEvent(m_window, &ev);
}

void AndroidPlatformWindow::handleMouseRelease(uint32_t timestamp, uint8_t button, int16_t xPos, int16_t yPos)
void AndroidPlatformWindow::handleMouseRelease(uint32_t timestamp, KDGui::MouseButtons buttons, int16_t xPos, int16_t yPos)
{
MouseReleaseEvent ev{ timestamp, button, xPos, yPos };
MouseReleaseEvent ev{ timestamp, buttons, xPos, yPos };
CoreApplication::instance()->sendEvent(m_window, &ev);
}

void AndroidPlatformWindow::handleMouseMove(uint32_t timestamp, uint8_t button, int64_t xPos, int64_t yPos)
void AndroidPlatformWindow::handleMouseMove(uint32_t timestamp, KDGui::MouseButtons buttons, int64_t xPos, int64_t yPos)
{
MouseMoveEvent ev{ timestamp, button, xPos, yPos };
MouseMoveEvent ev{ timestamp, buttons, xPos, yPos };
CoreApplication::instance()->sendEvent(m_window, &ev);
}

Expand Down
6 changes: 3 additions & 3 deletions src/KDGui/platform/android/android_platform_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class KDGUI_API AndroidPlatformWindow : public AbstractPlatformWindow
void setSize(uint32_t width, uint32_t height) final;

void handleResize(uint32_t width, uint32_t height) final;
void handleMousePress(uint32_t timestamp, uint8_t button, int16_t xPos, int16_t yPos) final;
void handleMouseRelease(uint32_t timestamp, uint8_t button, int16_t xPos, int16_t yPos) final;
void handleMouseMove(uint32_t timestamp, uint8_t button, int64_t xPos, int64_t yPos) final;
void handleMousePress(uint32_t timestamp, MouseButtons buttons, int16_t xPos, int16_t yPos) final;
void handleMouseRelease(uint32_t timestamp, MouseButtons buttons, int16_t xPos, int16_t yPos) final;
void handleMouseMove(uint32_t timestamp, MouseButtons buttons, int64_t xPos, int64_t yPos) final;
void handleMouseWheel(uint32_t timestamp, int32_t xDelta, int32_t yDelta) final;
void handleKeyPress(uint32_t timestamp, uint8_t nativeKeyCode, Key key, KeyboardModifiers modifiers) final;
void handleKeyRelease(uint32_t timestamp, uint8_t nativeKeyCode, Key key, KeyboardModifiers modifiers) final;
Expand Down
4 changes: 3 additions & 1 deletion src/KDUtils/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*/

#include "logging.h"

#if defined(ANDROID)
#include <spdlog/sinks/android_sink.h>
#endif
namespace KDUtils {

Logger::LoggerFactoryFunction Logger::ms_loggerFactory = {};
Expand Down

0 comments on commit 36f3130

Please sign in to comment.