Skip to content

Commit

Permalink
Drop the ColumnLimit to 80 for clang-format
Browse files Browse the repository at this point in the history
This gives better support for smaller screens and side-by-side windows.

Also standardize the formatting check on GitHub on version 17.

Diffs=
e52e9fff29 Drop the ColumnLimit to 80 for clang-format (#8320)
52913023ba add support for listeners on layout components (#8317)
1b5e50fcec Optimize atomic rendering for input attachments (#8310)
1cc5f2b6f6 Prep for rhi (#8270)
f9715435dd Nnnn fix databind state machine shared data context (#8307)
708a913eae Implement isHidden in DrawableProxy (#8302)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Oct 11, 2024
1 parent 049e6e8 commit b4bfa2d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eed8230f84e2894d0436dd1d94566c59f4dfcb6f
e52e9fff2973ce63a689e9d11ea283214109ca18
3 changes: 2 additions & 1 deletion example/ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ - (BOOL)application:(UIApplication*)application
{
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
return [super application:application
didFinishLaunchingWithOptions:launchOptions];
}

@end
3 changes: 2 additions & 1 deletion example/ios/Runner/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ int main(int argc, char* argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return UIApplicationMain(
argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
23 changes: 15 additions & 8 deletions example/windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(const flutter::DartProject& project) : project_(project) {}
FlutterWindow::FlutterWindow(const flutter::DartProject& project) :
project_(project)
{}

FlutterWindow::~FlutterWindow() {}

Expand All @@ -17,11 +19,12 @@ bool FlutterWindow::OnCreate()

RECT frame = GetClientArea();

// The size here must match the window dimensions to avoid unnecessary surface
// creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(frame.right - frame.left,
frame.bottom - frame.top,
project_);
// The size here must match the window dimensions to avoid unnecessary
// surface creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
frame.right - frame.left,
frame.bottom - frame.top,
project_);
// Ensure that basic setup of the controller was successful.
if (!flutter_controller_->engine() || !flutter_controller_->view())
{
Expand All @@ -48,11 +51,15 @@ FlutterWindow::MessageHandler(HWND hwnd,
WPARAM const wparam,
LPARAM const lparam) noexcept
{
// Give Flutter, including plugins, an opportunity to handle window messages.
// Give Flutter, including plugins, an opportunity to handle window
// messages.
if (flutter_controller_)
{
std::optional<LRESULT> result =
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, lparam);
flutter_controller_->HandleTopLevelWindowProc(hwnd,
message,
wparam,
lparam);
if (result)
{
return *result;
Expand Down
38 changes: 26 additions & 12 deletions example/windows/runner/win32_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);

// Scale helper to convert logical scaler values to physical using passed in
// scale factor
int Scale(int source, double scale_factor) { return static_cast<int>(source * scale_factor); }
int Scale(int source, double scale_factor)
{
return static_cast<int>(source * scale_factor);
}

// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
// This API is only needed for PerMonitor V1 awareness mode.
Expand All @@ -27,8 +30,9 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd)
{
return;
}
auto enable_non_client_dpi_scaling = reinterpret_cast<EnableNonClientDpiScaling*>(
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
auto enable_non_client_dpi_scaling =
reinterpret_cast<EnableNonClientDpiScaling*>(
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
if (enable_non_client_dpi_scaling != nullptr)
{
enable_non_client_dpi_scaling(hwnd);
Expand Down Expand Up @@ -83,7 +87,8 @@ const wchar_t* WindowClassRegistrar::GetWindowClass()
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandle(nullptr);
window_class.hIcon = LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
window_class.hIcon =
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
window_class.hbrBackground = 0;
window_class.lpszMenuName = nullptr;
window_class.lpfnWndProc = Win32Window::WndProc;
Expand All @@ -107,13 +112,17 @@ Win32Window::~Win32Window()
Destroy();
}

bool Win32Window::CreateAndShow(const std::wstring& title, const Point& origin, const Size& size)
bool Win32Window::CreateAndShow(const std::wstring& title,
const Point& origin,
const Size& size)
{
Destroy();

const wchar_t* window_class = WindowClassRegistrar::GetInstance()->GetWindowClass();
const wchar_t* window_class =
WindowClassRegistrar::GetInstance()->GetWindowClass();

const POINT target_point = {static_cast<LONG>(origin.x), static_cast<LONG>(origin.y)};
const POINT target_point = {static_cast<LONG>(origin.x),
static_cast<LONG>(origin.y)};
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
Expand Down Expand Up @@ -147,9 +156,10 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
if (message == WM_NCCREATE)
{
auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
SetWindowLongPtr(window,
GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
SetWindowLongPtr(
window,
GWLP_USERDATA,
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));

auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
EnableFullDpiSupportIfAvailable(window);
Expand Down Expand Up @@ -240,7 +250,8 @@ void Win32Window::Destroy()

Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept
{
return reinterpret_cast<Win32Window*>(GetWindowLongPtr(window, GWLP_USERDATA));
return reinterpret_cast<Win32Window*>(
GetWindowLongPtr(window, GWLP_USERDATA));
}

void Win32Window::SetChildContent(HWND content)
Expand Down Expand Up @@ -268,7 +279,10 @@ RECT Win32Window::GetClientArea()

HWND Win32Window::GetHandle() { return window_handle_; }

void Win32Window::SetQuitOnClose(bool quit_on_close) { quit_on_close_ = quit_on_close; }
void Win32Window::SetQuitOnClose(bool quit_on_close)
{
quit_on_close_ = quit_on_close;
}

bool Win32Window::OnCreate()
{
Expand Down
18 changes: 11 additions & 7 deletions example/windows/runner/win32_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ class Win32Window
{
unsigned int width;
unsigned int height;
Size(unsigned int width, unsigned int height) : width(width), height(height) {}
Size(unsigned int width, unsigned int height) :
width(width), height(height)
{}
};

Win32Window();
virtual ~Win32Window();

// Creates and shows a win32 window with |title| and position and size using
// |origin| and |size|. New windows are created on the default monitor. Window
// sizes are specified to the OS in physical pixels, hence to ensure a
// consistent size to will treat the width height passed in to this function
// as logical pixels and scale to appropriate for the default monitor. Returns
// true if the window was created successfully.
bool CreateAndShow(const std::wstring& title, const Point& origin, const Size& size);
// |origin| and |size|. New windows are created on the default monitor.
// Window sizes are specified to the OS in physical pixels, hence to ensure
// a consistent size to will treat the width height passed in to this
// function as logical pixels and scale to appropriate for the default
// monitor. Returns true if the window was created successfully.
bool CreateAndShow(const std::wstring& title,
const Point& origin,
const Size& size);

// Release OS resources associated with window.
void Destroy();
Expand Down

0 comments on commit b4bfa2d

Please sign in to comment.