clang-format brightray

This commit is contained in:
Shelley Vohr 2018-04-17 21:46:27 -04:00
parent 7a8a0f6b4b
commit 284aca68c0
No known key found for this signature in database
GPG key ID: F13993A75599653C
25 changed files with 268 additions and 273 deletions

View file

@ -4,51 +4,57 @@
namespace brightray {
struct NotificationData {
DesktopNotificationController* controller = nullptr;
DesktopNotificationController* controller = nullptr;
std::wstring caption;
std::wstring body_text;
HBITMAP image = NULL;
std::wstring caption;
std::wstring body_text;
HBITMAP image = NULL;
NotificationData() = default;
NotificationData() = default;
~NotificationData() {
if (image) DeleteObject(image);
}
~NotificationData() {
if (image)
DeleteObject(image);
}
NotificationData(const NotificationData& other) = delete;
NotificationData& operator=(const NotificationData& other) = delete;
NotificationData(const NotificationData& other) = delete;
NotificationData& operator=(const NotificationData& other) = delete;
};
template<typename T>
template <typename T>
constexpr T ScaleForDpi(T value, unsigned dpi, unsigned source_dpi = 96) {
return value * dpi / source_dpi;
return value * dpi / source_dpi;
}
struct ScreenMetrics {
UINT dpi_x, dpi_y;
UINT dpi_x, dpi_y;
ScreenMetrics() {
typedef HRESULT WINAPI GetDpiForMonitor_t(HMONITOR, int, UINT*, UINT*);
ScreenMetrics() {
typedef HRESULT WINAPI GetDpiForMonitor_t(HMONITOR, int, UINT*, UINT*);
auto GetDpiForMonitor = reinterpret_cast<GetDpiForMonitor_t*>(
GetProcAddress(GetModuleHandle(TEXT("shcore")),
"GetDpiForMonitor"));
auto GetDpiForMonitor = reinterpret_cast<GetDpiForMonitor_t*>(
GetProcAddress(GetModuleHandle(TEXT("shcore")), "GetDpiForMonitor"));
if (GetDpiForMonitor) {
auto monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
if (GetDpiForMonitor(monitor, 0, &dpi_x, &dpi_y) == S_OK)
return;
}
HDC hdc = GetDC(NULL);
dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
if (GetDpiForMonitor) {
auto monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
if (GetDpiForMonitor(monitor, 0, &dpi_x, &dpi_y) == S_OK)
return;
}
template<class T> T X(T value) const { return ScaleForDpi(value, dpi_x); }
template<class T> T Y(T value) const { return ScaleForDpi(value, dpi_y); }
HDC hdc = GetDC(NULL);
dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
}
template <class T>
T X(T value) const {
return ScaleForDpi(value, dpi_x);
}
template <class T>
T Y(T value) const {
return ScaleForDpi(value, dpi_y);
}
};
} // namespace brightray
} // namespace brightray