Skip to content

Commit 8969a98

Browse files
committed
Code style and formatting improvements across platforms
This commit applies consistent code formatting, improves readability, and fixes include order in multiple files for Android, iOS, Linux, and OHOS platforms. No functional changes were made; only whitespace, indentation, and minor style adjustments to maintain code quality and consistency.
1 parent 0d24273 commit 8969a98

36 files changed

+240
-259
lines changed

examples/menu_example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int main() {
143143
// Set up application started listener to open menu after event loop starts
144144
app.AddListener<ApplicationStartedEvent>([menu](const ApplicationStartedEvent& event) {
145145
std::cout << "Application started - opening menu at (100, 100)" << std::endl;
146-
146+
147147
// Open menu as context menu at screen coordinates (100, 100)
148148
if (menu->Open(PositioningStrategy::Absolute({100, 100}))) {
149149
std::cout << "Context menu opened successfully!" << std::endl;

examples/tray_icon_example/main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ int main() {
4848
std::cout << "Tray icon ID: " << event.GetTrayIconId() << std::endl;
4949
});
5050

51-
trayIcon->AddListener<TrayIconRightClickedEvent>([trayIcon](const TrayIconRightClickedEvent& event) {
52-
std::cout << "*** TRAY ICON RIGHT CLICKED! ***" << std::endl;
53-
std::cout << "This is the right click handler working!" << std::endl;
54-
std::cout << "Tray icon ID: " << event.GetTrayIconId() << std::endl;
55-
trayIcon->OpenContextMenu();
56-
});
51+
trayIcon->AddListener<TrayIconRightClickedEvent>(
52+
[trayIcon](const TrayIconRightClickedEvent& event) {
53+
std::cout << "*** TRAY ICON RIGHT CLICKED! ***" << std::endl;
54+
std::cout << "This is the right click handler working!" << std::endl;
55+
std::cout << "Tray icon ID: " << event.GetTrayIconId() << std::endl;
56+
trayIcon->OpenContextMenu();
57+
});
5758

5859
trayIcon->AddListener<TrayIconDoubleClickedEvent>([](const TrayIconDoubleClickedEvent& event) {
5960
std::cout << "*** TRAY ICON DOUBLE CLICKED! ***" << std::endl;

src/capi/menu_c.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ bool native_menu_item_get_accelerator(native_menu_item_t item,
371371
}
372372
}
373373

374-
375-
376374
void native_menu_item_set_enabled(native_menu_item_t item, bool enabled) {
377375
if (!item)
378376
return;
@@ -482,8 +480,6 @@ native_menu_t native_menu_item_get_submenu(native_menu_item_t item) {
482480
}
483481
}
484482

485-
486-
487483
// New event listener API implementation
488484
int native_menu_item_add_listener(native_menu_item_t item,
489485
native_menu_item_event_type_t event_type,
@@ -826,14 +822,16 @@ native_menu_item_list_t native_menu_get_all_items(native_menu_t menu) {
826822
}
827823
}
828824

829-
bool native_menu_open(native_menu_t menu, native_positioning_strategy_t strategy, native_placement_t placement) {
825+
bool native_menu_open(native_menu_t menu,
826+
native_positioning_strategy_t strategy,
827+
native_placement_t placement) {
830828
if (!menu || !strategy)
831829
return false;
832830

833831
try {
834832
auto menu_ptr = static_cast<Menu*>(menu);
835833
auto strategy_ptr = static_cast<PositioningStrategy*>(strategy);
836-
834+
837835
// Convert C placement enum to C++ placement enum
838836
Placement cpp_placement;
839837
switch (placement) {
@@ -877,7 +875,7 @@ bool native_menu_open(native_menu_t menu, native_positioning_strategy_t strategy
877875
cpp_placement = Placement::BottomStart;
878876
break;
879877
}
880-
878+
881879
return menu_ptr->Open(*strategy_ptr, cpp_placement);
882880
} catch (...) {
883881
return false;

src/capi/menu_c.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ FFI_PLUGIN_EXPORT
247247
bool native_menu_item_get_accelerator(native_menu_item_t item,
248248
native_keyboard_accelerator_t* accelerator);
249249

250-
251-
252250
/**
253251
* Set the enabled state of a menu item
254252
* @param item The menu item
@@ -313,8 +311,6 @@ void native_menu_item_set_submenu(native_menu_item_t item, native_menu_t submenu
313311
FFI_PLUGIN_EXPORT
314312
native_menu_t native_menu_item_get_submenu(native_menu_item_t item);
315313

316-
317-
318314
/**
319315
* Add event listener for a menu item
320316
* @param item The menu item
@@ -473,7 +469,9 @@ native_menu_item_list_t native_menu_get_all_items(native_menu_t menu);
473469
* @return true if menu was opened successfully, false otherwise
474470
*/
475471
FFI_PLUGIN_EXPORT
476-
bool native_menu_open(native_menu_t menu, native_positioning_strategy_t strategy, native_placement_t placement);
472+
bool native_menu_open(native_menu_t menu,
473+
native_positioning_strategy_t strategy,
474+
native_placement_t placement);
477475

478476
/**
479477
* Close the menu if it's currently showing

src/platform/android/accessibility_manager_android.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ bool AccessibilityManager::IsEnabled() {
1313
}
1414

1515
} // namespace nativeapi
16-

src/platform/android/display_android.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Display::Display(void* display) : pimpl_(std::make_unique<Impl>()) {}
1616
Display::~Display() {}
1717

1818
Display::Display(const Display& other) : pimpl_(std::make_unique<Impl>()) {}
19-
Display& Display::operator=(const Display& other) { return *this; }
19+
Display& Display::operator=(const Display& other) {
20+
return *this;
21+
}
2022
Display::Display(Display&& other) noexcept : pimpl_(std::move(other.pimpl_)) {}
2123
Display& Display::operator=(Display&& other) noexcept {
2224
pimpl_ = std::move(other.pimpl_);

src/platform/android/menu_item_android.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,3 @@ std::shared_ptr<Menu> MenuItem::GetSubmenu() const {
9696
}
9797

9898
} // namespace nativeapi
99-

src/platform/android/window_android.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <android/native_window.h>
21
#include <android/log.h>
2+
#include <android/native_window.h>
33
#include <iostream>
44
#include "../../window.h"
55
#include "../../window_manager.h"
@@ -20,25 +20,26 @@ class Window::Impl {
2020

2121
Window::Window() : pimpl_(std::make_unique<Impl>(nullptr)) {}
2222

23-
Window::Window(void* window) : pimpl_(std::make_unique<Impl>(static_cast<ANativeWindow*>(window))) {}
23+
Window::Window(void* window)
24+
: pimpl_(std::make_unique<Impl>(static_cast<ANativeWindow*>(window))) {}
2425

2526
Window::~Window() {}
2627

2728
WindowId Window::GetId() const {
2829
if (!pimpl_->native_window_) {
2930
return IdAllocator::kInvalidId;
3031
}
31-
32+
3233
// Store the allocated ID in a static map to ensure consistency
3334
static std::unordered_map<ANativeWindow*, WindowId> window_id_map;
3435
static std::mutex map_mutex;
35-
36+
3637
std::lock_guard<std::mutex> lock(map_mutex);
3738
auto it = window_id_map.find(pimpl_->native_window_);
3839
if (it != window_id_map.end()) {
3940
return it->second;
4041
}
41-
42+
4243
// Allocate new ID using the IdAllocator
4344
WindowId new_id = IdAllocator::Allocate<Window>();
4445
if (new_id != IdAllocator::kInvalidId) {
@@ -142,8 +143,8 @@ bool Window::IsFullScreen() const {
142143

143144
void Window::SetBounds(Rectangle bounds) {
144145
if (pimpl_->native_window_) {
145-
ALOGI("SetBounds called: x=%f, y=%f, w=%f, h=%f",
146-
bounds.x, bounds.y, bounds.width, bounds.height);
146+
ALOGI("SetBounds called: x=%f, y=%f, w=%f, h=%f", bounds.x, bounds.y, bounds.width,
147+
bounds.height);
147148
// Android windows resize is handled by the system
148149
}
149150
}
@@ -152,11 +153,11 @@ Rectangle Window::GetBounds() const {
152153
if (!pimpl_->native_window_) {
153154
return Rectangle{0.0, 0.0, 0.0, 0.0};
154155
}
155-
156+
156157
// Get window dimensions from ANativeWindow
157158
int32_t width = ANativeWindow_getWidth(pimpl_->native_window_);
158159
int32_t height = ANativeWindow_getHeight(pimpl_->native_window_);
159-
160+
160161
return Rectangle{0.0, 0.0, static_cast<double>(width), static_cast<double>(height)};
161162
}
162163

@@ -171,10 +172,10 @@ Size Window::GetSize() const {
171172
if (!pimpl_->native_window_) {
172173
return Size{0.0, 0.0};
173174
}
174-
175+
175176
int32_t width = ANativeWindow_getWidth(pimpl_->native_window_);
176177
int32_t height = ANativeWindow_getHeight(pimpl_->native_window_);
177-
178+
178179
return Size{static_cast<double>(width), static_cast<double>(height)};
179180
}
180181

@@ -328,4 +329,3 @@ void* Window::GetNativeObjectInternal() const {
328329
}
329330

330331
} // namespace nativeapi
331-

src/platform/android/window_manager_android.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include <android/native_window.h>
2-
#include <android/native_activity.h>
31
#include <android/log.h>
2+
#include <android/native_activity.h>
3+
#include <android/native_window.h>
44
#include <iostream>
5-
#include <unordered_map>
65
#include <mutex>
6+
#include <unordered_map>
77
#include "../../window.h"
88
#include "../../window_manager.h"
99

@@ -19,16 +19,16 @@ static WindowId GetOrCreateWindowId(ANativeWindow* native_window) {
1919
if (!native_window) {
2020
return IdAllocator::kInvalidId;
2121
}
22-
22+
2323
static std::unordered_map<ANativeWindow*, WindowId> window_id_map;
2424
static std::mutex map_mutex;
25-
25+
2626
std::lock_guard<std::mutex> lock(map_mutex);
2727
auto it = window_id_map.find(native_window);
2828
if (it != window_id_map.end()) {
2929
return it->second;
3030
}
31-
31+
3232
// Allocate new ID using the IdAllocator
3333
WindowId new_id = IdAllocator::Allocate<Window>();
3434
if (new_id != IdAllocator::kInvalidId) {
@@ -41,7 +41,7 @@ static WindowId GetOrCreateWindowId(ANativeWindow* native_window) {
4141
static ANativeWindow* FindNativeWindowById(WindowId id) {
4242
static std::unordered_map<ANativeWindow*, WindowId> window_id_map;
4343
static std::mutex map_mutex;
44-
44+
4545
std::lock_guard<std::mutex> lock(map_mutex);
4646
for (const auto& pair : window_id_map) {
4747
if (pair.second == id) {
@@ -63,9 +63,7 @@ class WindowManager::Impl {
6363
ALOGI("Window event monitoring setup");
6464
}
6565

66-
void CleanupEventMonitoring() {
67-
ALOGI("Window event monitoring cleanup");
68-
}
66+
void CleanupEventMonitoring() { ALOGI("Window event monitoring cleanup"); }
6967

7068
private:
7169
WindowManager* manager_;
@@ -110,11 +108,11 @@ std::shared_ptr<Window> WindowManager::Get(WindowId id) {
110108

111109
std::vector<std::shared_ptr<Window>> WindowManager::GetAll() {
112110
std::vector<std::shared_ptr<Window>> windows;
113-
111+
114112
for (const auto& [id, window] : windows_) {
115113
windows.push_back(window);
116114
}
117-
115+
118116
return windows;
119117
}
120118

@@ -141,10 +139,9 @@ std::shared_ptr<Window> WindowManager::Create(const WindowOptions& options) {
141139
// On Android, window creation is handled by the Activity lifecycle
142140
// This function would typically be called from onNativeWindowCreated callback
143141
ALOGI("Window creation requested (Android handles this through Activity lifecycle)");
144-
142+
145143
// Return nullptr as windows are created by the Android system
146144
return nullptr;
147145
}
148146

149147
} // namespace nativeapi
150-

src/platform/ios/accessibility_manager_ios.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#import <UIKit/UIKit.h>
21
#import <Foundation/Foundation.h>
2+
#import <UIKit/UIKit.h>
33
#include "../../accessibility_manager.h"
44

55
namespace nativeapi {
@@ -16,4 +16,3 @@
1616
}
1717

1818
} // namespace nativeapi
19-

0 commit comments

Comments
 (0)