Skip to content

Commit 9ec78d6

Browse files
committed
Refactor tray and window example usage
Rename C API accessibility manager functions Add enum type to display orientation Add documentation comments to geometry structs Remove debug prints from macOS app runner
1 parent 286a24c commit 9ec78d6

File tree

5 files changed

+19
-31
lines changed

5 files changed

+19
-31
lines changed

examples/window_example/main.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using nativeapi::WindowManager;
99
using nativeapi::WindowOptions;
1010

1111
int main() {
12+
TrayManager tray_manager = TrayManager();
1213
WindowManager window_manager = WindowManager();
1314

1415
// Create a new window with options
@@ -17,23 +18,14 @@ int main() {
1718
options.size.width = 800;
1819
options.size.height = 600;
1920
std::shared_ptr<Window> window_ptr = window_manager.Create(options);
20-
if (window_ptr != nullptr) {
21-
Window& window = *window_ptr;
22-
std::cout << "New Window Information:" << std::endl;
23-
std::cout << "ID: " << window.id << std::endl;
24-
std::cout << std::endl;
25-
window.Show();
26-
window.Focus();
27-
}
2821

29-
TrayManager trayManager = TrayManager();
3022

31-
std::shared_ptr<Tray> newTrayPtr = trayManager.Create();
32-
if (newTrayPtr != nullptr) {
33-
Tray& newTray = *newTrayPtr;
34-
newTray.SetTitle("Hello, World!");
35-
std::cout << "Tray ID: " << newTray.id << std::endl;
36-
std::cout << "Tray Title: " << newTray.GetTitle() << std::endl;
23+
std::shared_ptr<Tray> tray_ptr = tray_manager.Create();
24+
if (tray_ptr != nullptr) {
25+
Tray& tray = *tray_ptr;
26+
tray.SetTitle("Hello, World!");
27+
std::cout << "Tray ID: " << tray.id << std::endl;
28+
std::cout << "Tray Title: " << tray.GetTitle() << std::endl;
3729
} else {
3830
std::cerr << "Failed to create tray." << std::endl;
3931
}

src/capi/accessibility_manager_c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ using namespace nativeapi;
99
static AccessibilityManager g_accessibility_manager = AccessibilityManager();
1010

1111
FFI_PLUGIN_EXPORT
12-
void accessibility_manager_enable() {
12+
void native_accessibility_manager_enable() {
1313
g_accessibility_manager.Enable();
1414
}
1515

1616
FFI_PLUGIN_EXPORT
17-
bool accessibility_manager_is_enabled() {
17+
bool native_accessibility_manager_is_enabled() {
1818
return g_accessibility_manager.IsEnabled();
1919
}

src/capi/display_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" {
1212
/**
1313
* Display orientation enumeration
1414
*/
15-
typedef enum {
15+
typedef enum : int {
1616
NATIVE_DISPLAY_ORIENTATION_PORTRAIT = 0,
1717
NATIVE_DISPLAY_ORIENTATION_LANDSCAPE = 90,
1818
NATIVE_DISPLAY_ORIENTATION_PORTRAIT_FLIPPED = 180,

src/capi/geometry_c.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
#pragma once
22

3+
/**
4+
* Representation of a point
5+
*/
36
typedef struct {
47
double x;
58
double y;
69
} native_point_t;
710

11+
/**
12+
* Representation of a point
13+
*/
814
typedef struct {
915
double width;
1016
double height;
1117
} native_size_t;
1218

19+
/**
20+
* Representation of a rectangle
21+
*/
1322
typedef struct {
1423
double x;
1524
double y;

src/platform/macos/app_runner_macos.mm

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
4040
AppRunner::~AppRunner() {}
4141

4242
int AppRunner::Run(std::shared_ptr<Window> window) {
43-
std::cout << "Starting macOS application..." << std::endl;
44-
4543
// Initialize NSApplication if not already done
4644
NSApplication* app = [NSApplication sharedApplication];
4745

@@ -50,14 +48,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
5048

5149
// If a window is provided, show it and make it the main window
5250
if (window) {
53-
// Access the NSWindow from the Window object
54-
// We need to get the native window handle
5551
window->Show();
56-
window->Focus();
57-
58-
// Get the NSWindow from the Window object
59-
// This assumes the Window class has access to the native NSWindow
60-
std::cout << "Window shown and focused" << std::endl;
6152
}
6253

6354
// Activate the application
@@ -69,13 +60,9 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
6960
// Finish launching if not already done
7061
[app finishLaunching];
7162

72-
std::cout << "Starting main run loop..." << std::endl;
73-
7463
// Start the main event loop
7564
[app run];
7665

77-
std::cout << "Application event loop ended" << std::endl;
78-
7966
return 0;
8067
}
8168

0 commit comments

Comments
 (0)