From 19a08cb84e6e8c3a2aeb4f354968e157e0d628b1 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Wed, 17 Jun 2020 14:50:49 +0200 Subject: [PATCH 1/2] + add: .clang-format file for coding style guidelines --- src/.clang-format | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/.clang-format diff --git a/src/.clang-format b/src/.clang-format new file mode 100644 index 000000000..07056def7 --- /dev/null +++ b/src/.clang-format @@ -0,0 +1,133 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +IndentPPDirectives: AfterHash +IndentWidth: 4 +IndentWrappedFunctionNames: true +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: "^\ +BEGIN_MSG_MAP|\ +BEGIN_MESSAGE_MAP|\ +BEGIN_MSG_MAP_EX|\ +BEGIN_MESSAGE_MAP_EX|\ +BEGIN_SAFE_MSG_MAP_EX|\ +CR_BEGIN_MSG_MAP_EX|\ +IPC_BEGIN_MESSAGE_MAP|\ +IPC_BEGIN_MESSAGE_MAP_WITH_PARAM|\ +IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN|\ +IPC_STRUCT_BEGIN|\ +IPC_STRUCT_BEGIN_WITH_PARENT|\ +IPC_STRUCT_TRAITS_BEGIN|\ +POLPARAMS_BEGIN|\ +PPAPI_BEGIN_MESSAGE_MAP$" +MacroBlockEnd: "^\ +CR_END_MSG_MAP|\ +END_MSG_MAP|\ +END_MESSAGE_MAP|\ +IPC_END_MESSAGE_MAP|\ +IPC_PROTOBUF_MESSAGE_TRAITS_END|\ +IPC_STRUCT_END|\ +IPC_STRUCT_TRAITS_END|\ +POLPARAMS_END|\ +PPAPI_END_MESSAGE_MAP$" +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + From f345f3f814841bf23bc83041dcfdbb8633c0a3f8 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Wed, 17 Jun 2020 16:23:31 +0200 Subject: [PATCH 2/2] + fix: DPI Aware relative positioning of position managed dialog boxes --- src/Dialogs.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index ee6ed8909..79fd3d836 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -3896,6 +3896,8 @@ void GetDlgPos(HWND hDlg, LPINT xDlg, LPINT yDlg) { if (!hDlg) { return; } + DPI_T const dpi = Scintilla_GetWindowDPI(hDlg); + RECT rcDlg; GetWindowRect(hDlg, &rcDlg); @@ -3903,9 +3905,15 @@ void GetDlgPos(HWND hDlg, LPINT xDlg, LPINT yDlg) RECT rcParent; GetWindowRect(hParent, &rcParent); - // return positions relative to parent window - if (xDlg) { *xDlg = (rcDlg.left - rcParent.left); } - if (yDlg) { *yDlg = (rcDlg.top - rcParent.top); } + // return positions relative to parent window (normalized DPI) + if (xDlg) + { + *xDlg = MulDiv((rcDlg.left - rcParent.left), USER_DEFAULT_SCREEN_DPI, (dpi.x ? dpi.x : USER_DEFAULT_SCREEN_DPI)); + } + if (yDlg) + { + *yDlg = MulDiv((rcDlg.top - rcParent.top), USER_DEFAULT_SCREEN_DPI, (dpi.y ? dpi.y : USER_DEFAULT_SCREEN_DPI)); + } } @@ -3917,6 +3925,8 @@ void SetDlgPos(HWND hDlg, int xDlg, int yDlg) { if (!hDlg) { return; } + DPI_T const dpi = Scintilla_GetWindowDPI(hDlg); + RECT rcDlg; GetWindowRect(hDlg, &rcDlg); @@ -3936,9 +3946,9 @@ void SetDlgPos(HWND hDlg, int xDlg, int yDlg) int const xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); int const yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); - // desired positions relative to parent window - int const x = rcParent.left + xDlg; - int const y = rcParent.top + yDlg; + // desired positions relative to parent window (normalized DPI) + int const x = rcParent.left + MulDiv(xDlg, dpi.x, USER_DEFAULT_SCREEN_DPI); + int const y = rcParent.top + MulDiv(yDlg, dpi.y, USER_DEFAULT_SCREEN_DPI); SetWindowPos(hDlg, NULL, clampi(x, xMin, xMax), clampi(y, yMin, yMax), 0, 0, SWP_NOZORDER | SWP_NOSIZE); }