mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Add '.clang-format' file, CI integration, and formatting exceptions
Co-authored-by: Vittorio Romeo <vittorio.romeo@outlook.com> Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com> Co-authored-by: kimci86 <kimci86@hotmail.fr>
This commit is contained in:
parent
c6f7fcaa2a
commit
88e9f82bee
167
.clang-format
Normal file
167
.clang-format
Normal file
@ -0,0 +1,167 @@
|
||||
---
|
||||
# Project
|
||||
Standard: c++17
|
||||
ColumnLimit: 120
|
||||
|
||||
# Indentation
|
||||
AccessModifierOffset: -4
|
||||
BitFieldColonSpacing: Both
|
||||
ContinuationIndentWidth: 4
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentExternBlock: Indent
|
||||
IndentPPDirectives: None
|
||||
IndentRequires: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
|
||||
# Alignment
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveBitFields: Consecutive
|
||||
AlignConsecutiveDeclarations: Consecutive
|
||||
AlignConsecutiveMacros: Consecutive
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
|
||||
# Allow
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
|
||||
# Break
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakInheritanceList: AfterColon
|
||||
BreakStringLiterals: true
|
||||
|
||||
# Initializers & arguments
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
Cpp11BracedListStyle: true
|
||||
|
||||
# Braces
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: true
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
|
||||
# Namespaces
|
||||
CompactNamespaces: false
|
||||
FixNamespaceComments: true
|
||||
NamespaceIndentation: None
|
||||
|
||||
# Derive
|
||||
DeriveLineEnding: false
|
||||
DerivePointerAlignment: false
|
||||
|
||||
# Empty lines
|
||||
EmptyLineBeforeAccessModifier: Always
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
|
||||
# Sorting
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Priority: 1
|
||||
Regex: '^<SFML\/Config.hpp>$'
|
||||
- Priority: 2
|
||||
Regex: '^<SFML\/(.+)\/Export.hpp>$'
|
||||
- Priority: 3
|
||||
Regex: '^<SFML\/'
|
||||
- Priority: 4
|
||||
Regex: '^<(glad|gl|X11|jni|android|stb_|GLES2|vorbis|doctest)'
|
||||
- Priority: 5
|
||||
Regex: '^<(.+)>$'
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
|
||||
# Penalties
|
||||
PenaltyBreakAssignment: 1000
|
||||
PenaltyBreakBeforeFirstCallParameter: 1000
|
||||
PenaltyBreakComment: 200
|
||||
PenaltyBreakFirstLessLess: 100
|
||||
PenaltyBreakString: 1
|
||||
PenaltyBreakTemplateDeclaration: 0
|
||||
PenaltyExcessCharacter: 5
|
||||
PenaltyIndentedWhitespace: 1
|
||||
PenaltyReturnTypeOnItsOwnLine: 500
|
||||
|
||||
# Pointer alignment
|
||||
PointerAlignment: Left
|
||||
|
||||
# Comments
|
||||
ReflowComments: false
|
||||
|
||||
# Spaces
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
|
||||
# Line endings
|
||||
UseCRLF: false
|
||||
|
||||
---
|
||||
Language: ObjC
|
||||
IndentWidth: 4
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterObjCDeclaration: true
|
||||
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
|
||||
...
|
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
@ -94,3 +94,30 @@ jobs:
|
||||
directory: ./build
|
||||
files: ./build/coverage.out
|
||||
fail_ci_if_error: true
|
||||
|
||||
format:
|
||||
name: Formatting on ${{ matrix.platform.name }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- { name: Windows, os: windows-2022, executable: clang-format }
|
||||
- { name: Linux, os: ubuntu-latest, executable: clang-format-12 }
|
||||
- { name: macOS, os: macos-12, executable: clang-format }
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install macOS Dependencies
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install clang-format
|
||||
|
||||
- name: Format Code
|
||||
shell: bash
|
||||
run: cmake -DCLANG_FORMAT_EXECUTABLE=${{ matrix.platform.executable }} -P $GITHUB_WORKSPACE/cmake/Format.cmake
|
||||
|
||||
- name: Check Formatting
|
||||
run: git diff --exit-code
|
||||
|
@ -536,3 +536,12 @@ string(REGEX REPLACE "/" "\\\\\\\\" NSIS_IMAGE_PATH ${NSIS_IMAGE_PATH})
|
||||
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "!define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${NSIS_IMAGE_PATH}sidebar.bmp\\\"\n!define MUI_HEADERIMAGE_BITMAP \\\"${NSIS_IMAGE_PATH}header.bmp\\\"\n!define MUI_ICON \\\"${NSIS_IMAGE_PATH}sfml.ico\\\"")
|
||||
|
||||
include(CPack)
|
||||
|
||||
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
return()
|
||||
endif()
|
||||
|
||||
sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires minimum version 12")
|
||||
add_custom_target(format
|
||||
COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" VERBATIM)
|
||||
|
30
cmake/Format.cmake
Normal file
30
cmake/Format.cmake
Normal file
@ -0,0 +1,30 @@
|
||||
# Check executable exists
|
||||
if(NOT EXISTS ${CLANG_FORMAT_EXECUTABLE})
|
||||
find_program(CLANG_FORMAT_EXEC_TEMP ${CLANG_FORMAT_EXECUTABLE})
|
||||
if(CLANG_FORMAT_EXEC_TEMP)
|
||||
set(CLANG_FORMAT_EXECUTABLE ${CLANG_FORMAT_EXEC_TEMP})
|
||||
unset(CLANG_FORMAT_EXEC_TEMP)
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find clang-format executable: \"${CLANG_FORMAT_EXECUTABLE}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check executable version
|
||||
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION)
|
||||
string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION})
|
||||
unset(CLANG_FORMAT_VERSION)
|
||||
if(CMAKE_MATCH_1 GREATER_EQUAL 12)
|
||||
message(STATUS "Using clang-format version ${CMAKE_MATCH_1}")
|
||||
else()
|
||||
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} is too low")
|
||||
endif()
|
||||
|
||||
# Run
|
||||
set(SOURCES "")
|
||||
foreach(FOLDER IN ITEMS examples include src test tools)
|
||||
file(GLOB_RECURSE folder_files "${FOLDER}/*.h" "${FOLDER}/*.hpp" "${FOLDER}/*.inl" "${FOLDER}/*.cpp" "${FOLDER}/*.mm")
|
||||
list(FILTER folder_files EXCLUDE REGEX "gl.h|vulkan.h|stb_perlin.h") # 3rd party code to exclude from formatting
|
||||
list(APPEND SOURCES ${folder_files})
|
||||
endforeach()
|
||||
|
||||
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} -i ${SOURCES})
|
@ -94,6 +94,7 @@
|
||||
glRotatef(elapsedTime * 18.f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
||||
// clang-format off
|
||||
constexpr std::array<GLfloat, 216> cube =
|
||||
{
|
||||
// positions // colors
|
||||
@ -139,6 +140,7 @@
|
||||
50, -50, 50, 0, 1, 1,
|
||||
50, 50, 50, 0, 1, 1
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Draw the cube
|
||||
glVertexPointer(3, GL_FLOAT, 6 * sizeof(GLfloat), cube.data());
|
||||
|
@ -49,7 +49,9 @@ struct SFMLmainWindow;
|
||||
}
|
||||
|
||||
@property (retain) IBOutlet NSWindow* window;
|
||||
|
||||
@property (assign) IBOutlet NSView* sfmlView;
|
||||
|
||||
@property (assign) IBOutlet NSTextField* textField;
|
||||
|
||||
-(IBAction)colorChanged:(NSPopUpButton*)sender;
|
||||
|
@ -125,6 +125,7 @@ int main()
|
||||
sf::Texture::bind(&texture);
|
||||
|
||||
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
||||
// clang-format off
|
||||
constexpr std::array<GLfloat, 180> cube =
|
||||
{
|
||||
// positions // texture coordinates
|
||||
@ -170,6 +171,7 @@ int main()
|
||||
20, -20, 20, 1, 0,
|
||||
20, 20, 20, 1, 1
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Enable position and texture coordinates vertex components
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -43,12 +43,15 @@ namespace
|
||||
void matrixRotateX(Matrix& result, sf::Angle angle)
|
||||
{
|
||||
float rad = angle.asRadians();
|
||||
|
||||
// clang-format off
|
||||
Matrix matrix = {
|
||||
{1.f, 0.f, 0.f, 0.f},
|
||||
{0.f, std::cos(rad), std::sin(rad), 0.f},
|
||||
{0.f, -std::sin(rad), std::cos(rad), 0.f},
|
||||
{0.f, 0.f, 0.f, 1.f}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
matrixMultiply(result, result, matrix);
|
||||
}
|
||||
@ -57,12 +60,15 @@ namespace
|
||||
void matrixRotateY(Matrix& result, sf::Angle angle)
|
||||
{
|
||||
float rad = angle.asRadians();
|
||||
|
||||
// clang-format off
|
||||
Matrix matrix = {
|
||||
{ std::cos(rad), 0.f, std::sin(rad), 0.f},
|
||||
{ 0.f, 1.f, 0.f, 0.f},
|
||||
{-std::sin(rad), 0.f, std::cos(rad), 0.f},
|
||||
{ 0.f, 0.f, 0.f, 1.f}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
matrixMultiply(result, result, matrix);
|
||||
}
|
||||
@ -71,12 +77,15 @@ namespace
|
||||
void matrixRotateZ(Matrix& result, sf::Angle angle)
|
||||
{
|
||||
float rad = angle.asRadians();
|
||||
|
||||
// clang-format off
|
||||
Matrix matrix = {
|
||||
{ std::cos(rad), std::sin(rad), 0.f, 0.f},
|
||||
{-std::sin(rad), std::cos(rad), 0.f, 0.f},
|
||||
{ 0.f, 0.f, 1.f, 0.f},
|
||||
{ 0.f, 0.f, 0.f, 1.f}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
matrixMultiply(result, result, matrix);
|
||||
}
|
||||
@ -85,11 +94,13 @@ namespace
|
||||
void matrixLookAt(Matrix& result, const Vec3& eye, const Vec3& center, const Vec3& up)
|
||||
{
|
||||
// Forward-looking vector
|
||||
// clang-format off
|
||||
Vec3 forward = {
|
||||
center[0] - eye[0],
|
||||
center[1] - eye[1],
|
||||
center[2] - eye[2]
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Normalize
|
||||
float factor = 1.0f / std::sqrt(forward[0] * forward[0] + forward[1] * forward[1] + forward[2] * forward[2]);
|
||||
@ -98,11 +109,13 @@ namespace
|
||||
f *= factor;
|
||||
|
||||
// Side vector (Forward cross product Up)
|
||||
// clang-format off
|
||||
Vec3 side = {
|
||||
forward[1] * up[2] - forward[2] * up[1],
|
||||
forward[2] * up[0] - forward[0] * up[2],
|
||||
forward[0] * up[1] - forward[1] * up[0]
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Normalize
|
||||
factor = 1.0f / std::sqrt(side[0] * side[0] + side[1] * side[1] + side[2] * side[2]);
|
||||
@ -1371,6 +1384,7 @@ public:
|
||||
// Create our vertex buffer and upload its data
|
||||
void setupVertexBuffer()
|
||||
{
|
||||
// clang-format off
|
||||
constexpr std::array vertexData = {
|
||||
// X Y Z R G B A U V
|
||||
-0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
|
||||
@ -1403,6 +1417,7 @@ public:
|
||||
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Create a staging buffer that is writable by the CPU
|
||||
VkBuffer stagingBuffer = 0;
|
||||
@ -1465,6 +1480,7 @@ public:
|
||||
// Create our index buffer and upload its data
|
||||
void setupIndexBuffer()
|
||||
{
|
||||
// clang-format off
|
||||
constexpr std::array<std::uint16_t, 36> indexData = {
|
||||
0, 1, 2,
|
||||
2, 3, 0,
|
||||
@ -1484,6 +1500,7 @@ public:
|
||||
20, 21, 22,
|
||||
22, 23, 20
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Create a staging buffer that is writable by the CPU
|
||||
VkBuffer stagingBuffer = 0;
|
||||
|
@ -74,6 +74,7 @@ int main()
|
||||
#endif
|
||||
|
||||
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
||||
// clang-format off
|
||||
constexpr std::array<GLfloat, 252> cube =
|
||||
{
|
||||
// positions // colors (r, g, b, a)
|
||||
@ -119,6 +120,7 @@ int main()
|
||||
50, -50, 50, 1, 1, 0, 1,
|
||||
50, 50, 50, 1, 1, 0, 1,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// Enable position and color vertex components
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
constexpr Transform::Transform()
|
||||
// Identity matrix
|
||||
: m_matrix{1.f, 0.f, 0.f, 0.f,
|
||||
@ -32,9 +33,11 @@ constexpr Transform::Transform()
|
||||
0.f, 0.f, 0.f, 1.f}
|
||||
{
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
constexpr Transform::Transform(float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22)
|
||||
@ -44,6 +47,7 @@ constexpr Transform::Transform(float a00, float a01, float a02,
|
||||
a02, a12, 0.f, a22}
|
||||
{
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -56,15 +60,18 @@ constexpr const float* Transform::getMatrix() const
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Transform Transform::getInverse() const
|
||||
{
|
||||
// clang-format off
|
||||
// Compute the determinant
|
||||
float det = m_matrix[0] * (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) -
|
||||
m_matrix[1] * (m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) +
|
||||
m_matrix[3] * (m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]);
|
||||
// clang-format on
|
||||
|
||||
// Compute the inverse if the determinant is not zero
|
||||
// (don't use an epsilon because the determinant may *really* be tiny)
|
||||
if (det != 0.f)
|
||||
{
|
||||
// clang-format off
|
||||
return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
|
||||
-(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
|
||||
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
|
||||
@ -74,6 +81,7 @@ constexpr Transform Transform::getInverse() const
|
||||
(m_matrix[7] * m_matrix[1] - m_matrix[3] * m_matrix[5]) / det,
|
||||
-(m_matrix[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det,
|
||||
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det);
|
||||
// clang-format on
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -107,12 +115,16 @@ constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
|
||||
float top = points[0].y;
|
||||
float right = points[0].x;
|
||||
float bottom = points[0].y;
|
||||
|
||||
for (int i = 1; i < 4; ++i)
|
||||
{
|
||||
if (points[i].x < left) left = points[i].x;
|
||||
else if (points[i].x > right) right = points[i].x;
|
||||
if (points[i].y < top) top = points[i].y;
|
||||
// clang-format off
|
||||
if (points[i].x < left) left = points[i].x;
|
||||
else if (points[i].x > right) right = points[i].x;
|
||||
|
||||
if (points[i].y < top) top = points[i].y;
|
||||
else if (points[i].y > bottom) bottom = points[i].y;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
return FloatRect({left, top}, {right - left, bottom - top});
|
||||
@ -125,6 +137,7 @@ constexpr Transform& Transform::combine(const Transform& transform)
|
||||
const float* a = m_matrix;
|
||||
const float* b = transform.m_matrix;
|
||||
|
||||
// clang-format off
|
||||
*this = Transform(a[0] * b[0] + a[4] * b[1] + a[12] * b[3],
|
||||
a[0] * b[4] + a[4] * b[5] + a[12] * b[7],
|
||||
a[0] * b[12] + a[4] * b[13] + a[12] * b[15],
|
||||
@ -134,6 +147,7 @@ constexpr Transform& Transform::combine(const Transform& transform)
|
||||
a[3] * b[0] + a[7] * b[1] + a[15] * b[3],
|
||||
a[3] * b[4] + a[7] * b[5] + a[15] * b[7],
|
||||
a[3] * b[12] + a[7] * b[13] + a[15] * b[15]);
|
||||
// clang-format on
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -142,9 +156,11 @@ constexpr Transform& Transform::combine(const Transform& transform)
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Transform& Transform::translate(const Vector2f& offset)
|
||||
{
|
||||
// clang-format off
|
||||
Transform translation(1, 0, offset.x,
|
||||
0, 1, offset.y,
|
||||
0, 0, 1);
|
||||
// clang-format on
|
||||
|
||||
return combine(translation);
|
||||
}
|
||||
@ -153,9 +169,11 @@ constexpr Transform& Transform::translate(const Vector2f& offset)
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Transform& Transform::scale(const Vector2f& factors)
|
||||
{
|
||||
// clang-format off
|
||||
Transform scaling(factors.x, 0, 0,
|
||||
0, factors.y, 0,
|
||||
0, 0, 1);
|
||||
// clang-format on
|
||||
|
||||
return combine(scaling);
|
||||
}
|
||||
@ -164,9 +182,11 @@ constexpr Transform& Transform::scale(const Vector2f& factors)
|
||||
////////////////////////////////////////////////////////////
|
||||
constexpr Transform& Transform::scale(const Vector2f& factors, const Vector2f& center)
|
||||
{
|
||||
// clang-format off
|
||||
Transform scaling(factors.x, 0, center.x * (1 - factors.x),
|
||||
0, factors.y, center.y * (1 - factors.y),
|
||||
0, 0, 1);
|
||||
// clang-format on
|
||||
|
||||
return combine(scaling);
|
||||
}
|
||||
@ -199,9 +219,11 @@ constexpr bool operator ==(const Transform& left, const Transform& right)
|
||||
const float* a = left.getMatrix();
|
||||
const float* b = right.getMatrix();
|
||||
|
||||
// clang-format off
|
||||
return ((a[0] == b[0]) && (a[1] == b[1]) && (a[3] == b[3]) &&
|
||||
(a[4] == b[4]) && (a[5] == b[5]) && (a[7] == b[7]) &&
|
||||
(a[12] == b[12]) && (a[13] == b[13]) && (a[15] == b[15]));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,6 +47,7 @@ OutputIt priv::copy(InputIt first, InputIt last, OutputIt d_first)
|
||||
template <typename In>
|
||||
In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
{
|
||||
// clang-format off
|
||||
// Some useful precomputed data
|
||||
static constexpr int trailing[256] =
|
||||
{
|
||||
@ -59,16 +60,20 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
|
||||
};
|
||||
|
||||
static constexpr Uint32 offsets[6] =
|
||||
{
|
||||
0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// decode the character
|
||||
int trailingBytes = trailing[static_cast<Uint8>(*begin)];
|
||||
if (begin + trailingBytes < end)
|
||||
{
|
||||
output = 0;
|
||||
|
||||
// clang-format off
|
||||
switch (trailingBytes)
|
||||
{
|
||||
case 5: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
|
||||
@ -78,6 +83,8 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
case 1: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
|
||||
case 0: output += static_cast<Uint8>(*begin++);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
output -= offsets[trailingBytes];
|
||||
}
|
||||
else
|
||||
@ -114,13 +121,18 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
|
||||
|
||||
// Get the number of bytes to write
|
||||
std::size_t bytestoWrite = 1;
|
||||
|
||||
// clang-format off
|
||||
if (input < 0x80) bytestoWrite = 1;
|
||||
else if (input < 0x800) bytestoWrite = 2;
|
||||
else if (input < 0x10000) bytestoWrite = 3;
|
||||
else if (input <= 0x0010FFFF) bytestoWrite = 4;
|
||||
// clang-format on
|
||||
|
||||
// Extract the bytes to write
|
||||
Uint8 bytes[4];
|
||||
|
||||
// clang-format off
|
||||
switch (bytestoWrite)
|
||||
{
|
||||
case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]];
|
||||
@ -128,6 +140,7 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
|
||||
case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]];
|
||||
case 1: bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// Add them to the output
|
||||
output = priv::copy(bytes, bytes + bytestoWrite, output);
|
||||
|
@ -139,6 +139,8 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||
|
||||
// Find the good format according to the number of channels
|
||||
int format = 0;
|
||||
|
||||
// clang-format off
|
||||
switch (channelCount)
|
||||
{
|
||||
case 1: format = AL_FORMAT_MONO16; break;
|
||||
@ -149,6 +151,7 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||
case 8: format = alGetEnumValue("AL_FORMAT_71CHN16"); break;
|
||||
default: format = 0; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// Fixes a bug on OS X
|
||||
if (format == -1)
|
||||
|
@ -80,6 +80,7 @@ namespace
|
||||
// Convert an sf::BlendMode::Factor constant to the corresponding OpenGL constant.
|
||||
sf::Uint32 factorToGlConstant(sf::BlendMode::Factor blendFactor)
|
||||
{
|
||||
// clang-format off
|
||||
switch (blendFactor)
|
||||
{
|
||||
case sf::BlendMode::Zero: return GL_ZERO;
|
||||
@ -93,6 +94,7 @@ namespace
|
||||
case sf::BlendMode::DstAlpha: return GL_DST_ALPHA;
|
||||
case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
sf::err() << "Invalid value for sf::BlendMode::Factor! Fallback to sf::BlendMode::Zero." << std::endl;
|
||||
assert(false);
|
||||
|
@ -748,10 +748,12 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
|
||||
// Check if we need to define a special texture matrix
|
||||
if ((coordinateType == Pixels) || texture->m_pixelsFlipped)
|
||||
{
|
||||
// clang-format off
|
||||
GLfloat matrix[16] = {1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f};
|
||||
// clang-format on
|
||||
|
||||
// If non-normalized coordinates (= pixels) are requested, we need to
|
||||
// setup scale factors that convert the range [0 .. size] to [0 .. 1]
|
||||
|
@ -39,9 +39,11 @@ Transform& Transform::rotate(Angle angle)
|
||||
float cos = std::cos(rad);
|
||||
float sin = std::sin(rad);
|
||||
|
||||
// clang-format off
|
||||
Transform rotation(cos, -sin, 0,
|
||||
sin, cos, 0,
|
||||
0, 0, 1);
|
||||
// clang-format on
|
||||
|
||||
return combine(rotation);
|
||||
}
|
||||
@ -54,9 +56,11 @@ Transform& Transform::rotate(Angle angle, const Vector2f& center)
|
||||
float cos = std::cos(rad);
|
||||
float sin = std::sin(rad);
|
||||
|
||||
// clang-format off
|
||||
Transform rotation(cos, -sin, center.x * (1 - cos) + center.y * sin,
|
||||
sin, cos, center.y * (1 - cos) - center.x * sin,
|
||||
0, 0, 1);
|
||||
// clang-format on
|
||||
|
||||
return combine(rotation);
|
||||
}
|
||||
|
@ -151,9 +151,11 @@ const Transform& Transformable::getTransform() const
|
||||
float tx = -m_origin.x * sxc - m_origin.y * sys + m_position.x;
|
||||
float ty = m_origin.x * sxs - m_origin.y * syc + m_position.y;
|
||||
|
||||
// clang-format off
|
||||
m_transform = Transform( sxc, sys, tx,
|
||||
-sxs, syc, ty,
|
||||
0.f, 0.f, 1.f);
|
||||
// clang-format on
|
||||
m_transformNeedUpdate = false;
|
||||
}
|
||||
|
||||
|
@ -188,9 +188,11 @@ const Transform& View::getTransform() const
|
||||
float d = -b * m_center.y;
|
||||
|
||||
// Rebuild the projection matrix
|
||||
// clang-format off
|
||||
m_transform = Transform( a * cosine, a * sine, a * tx + c,
|
||||
-b * sine, b * cosine, b * ty + d,
|
||||
0.f, 0.f, 1.f);
|
||||
// clang-format on
|
||||
m_transformUpdated = true;
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,7 @@ Packet& Packet::operator >>(Int64& data)
|
||||
// to network byte order (big endian) manually
|
||||
Uint8 bytes[sizeof(data)];
|
||||
std::memcpy(bytes, &m_data[m_readPos], sizeof(data));
|
||||
|
||||
data = (static_cast<Int64>(bytes[0]) << 56) |
|
||||
(static_cast<Int64>(bytes[1]) << 48) |
|
||||
(static_cast<Int64>(bytes[2]) << 40) |
|
||||
@ -230,6 +231,7 @@ Packet& Packet::operator >>(Int64& data)
|
||||
(static_cast<Int64>(bytes[5]) << 16) |
|
||||
(static_cast<Int64>(bytes[6]) << 8) |
|
||||
(static_cast<Int64>(bytes[7]) );
|
||||
|
||||
m_readPos += sizeof(data);
|
||||
}
|
||||
|
||||
@ -246,6 +248,7 @@ Packet& Packet::operator >>(Uint64& data)
|
||||
// to network byte order (big endian) manually
|
||||
Uint8 bytes[sizeof(data)];
|
||||
std::memcpy(bytes, &m_data[m_readPos], sizeof(data));
|
||||
|
||||
data = (static_cast<Uint64>(bytes[0]) << 56) |
|
||||
(static_cast<Uint64>(bytes[1]) << 48) |
|
||||
(static_cast<Uint64>(bytes[2]) << 40) |
|
||||
@ -254,6 +257,7 @@ Packet& Packet::operator >>(Uint64& data)
|
||||
(static_cast<Uint64>(bytes[5]) << 16) |
|
||||
(static_cast<Uint64>(bytes[6]) << 8) |
|
||||
(static_cast<Uint64>(bytes[7]) );
|
||||
|
||||
m_readPos += sizeof(data);
|
||||
}
|
||||
|
||||
@ -463,6 +467,7 @@ Packet& Packet::operator <<(Int64 data)
|
||||
{
|
||||
// Since htonll is not available everywhere, we have to convert
|
||||
// to network byte order (big endian) manually
|
||||
|
||||
Uint8 toWrite[] =
|
||||
{
|
||||
static_cast<Uint8>((data >> 56) & 0xFF),
|
||||
@ -474,6 +479,7 @@ Packet& Packet::operator <<(Int64 data)
|
||||
static_cast<Uint8>((data >> 8) & 0xFF),
|
||||
static_cast<Uint8>((data ) & 0xFF)
|
||||
};
|
||||
|
||||
append(&toWrite, sizeof(toWrite));
|
||||
return *this;
|
||||
}
|
||||
@ -484,6 +490,7 @@ Packet& Packet::operator <<(Uint64 data)
|
||||
{
|
||||
// Since htonll is not available everywhere, we have to convert
|
||||
// to network byte order (big endian) manually
|
||||
|
||||
Uint8 toWrite[] =
|
||||
{
|
||||
static_cast<Uint8>((data >> 56) & 0xFF),
|
||||
@ -495,6 +502,7 @@ Packet& Packet::operator <<(Uint64 data)
|
||||
static_cast<Uint8>((data >> 8) & 0xFF),
|
||||
static_cast<Uint8>((data ) & 0xFF)
|
||||
};
|
||||
|
||||
append(&toWrite, sizeof(toWrite));
|
||||
return *this;
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ Socket::Status SocketImpl::getErrorStatus()
|
||||
if ((errno == EAGAIN) || (errno == EINPROGRESS))
|
||||
return Socket::NotReady;
|
||||
|
||||
// clang-format off
|
||||
switch (errno)
|
||||
{
|
||||
case EWOULDBLOCK: return Socket::NotReady;
|
||||
@ -106,6 +107,7 @@ Socket::Status SocketImpl::getErrorStatus()
|
||||
case EPIPE: return Socket::Disconnected;
|
||||
default: return Socket::Error;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
@ -71,6 +71,7 @@ void SocketImpl::setBlocking(SocketHandle sock, bool block)
|
||||
////////////////////////////////////////////////////////////
|
||||
Socket::Status SocketImpl::getErrorStatus()
|
||||
{
|
||||
// clang-format off
|
||||
switch (WSAGetLastError())
|
||||
{
|
||||
case WSAEWOULDBLOCK: return Socket::NotReady;
|
||||
@ -83,6 +84,7 @@ Socket::Status SocketImpl::getErrorStatus()
|
||||
case WSAEISCONN: return Socket::Done; // when connecting a non-blocking socket
|
||||
default: return Socket::Error;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,7 +92,9 @@ struct ActivityStates
|
||||
};
|
||||
|
||||
SFML_SYSTEM_API ActivityStates*& getActivityStatesPtr();
|
||||
|
||||
SFML_SYSTEM_API void resetActivity(ActivityStates* initializedStates);
|
||||
|
||||
SFML_SYSTEM_API ActivityStates& getActivity();
|
||||
|
||||
} // namespace priv
|
||||
|
@ -564,6 +564,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
|
||||
////////////////////////////////////////////////////////////
|
||||
Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
||||
{
|
||||
// clang-format off
|
||||
switch (key)
|
||||
{
|
||||
case AKEYCODE_UNKNOWN:
|
||||
@ -680,6 +681,7 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
||||
case AKEYCODE_BUTTON_MODE:
|
||||
default: return Keyboard::Unknown;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,6 +176,7 @@ namespace
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
// clang-format off
|
||||
case KEY_ESC: return sf::Keyboard::Escape;
|
||||
case KEY_1: return sf::Keyboard::Num1;
|
||||
case KEY_2: return sf::Keyboard::Num2;
|
||||
@ -286,6 +287,7 @@ namespace
|
||||
case KEY_SCROLLLOCK:
|
||||
default:
|
||||
return sf::Keyboard::Unknown;
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
AutoreleasePool pool;
|
||||
NSCursor* newCursor = nil;
|
||||
|
||||
// clang-format off
|
||||
switch (type)
|
||||
{
|
||||
default: return false;
|
||||
@ -129,6 +130,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
break;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
if (newCursor)
|
||||
{
|
||||
|
@ -403,6 +403,7 @@ UInt8 HIDInputManager::usageToVirtualCode(UInt32 usage)
|
||||
{
|
||||
// Some usage key doesn't have any corresponding virtual
|
||||
// code or it was not found (return 0xff).
|
||||
// clang-format off
|
||||
switch (usage)
|
||||
{
|
||||
case kHIDUsage_KeyboardErrorRollOver: return 0xff;
|
||||
@ -602,12 +603,14 @@ UInt8 HIDInputManager::usageToVirtualCode(UInt32 usage)
|
||||
case kHIDUsage_Keyboard_Reserved: return 0xff;
|
||||
default: return 0xff;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
Keyboard::Key HIDInputManager::localizedKeys(UniChar ch)
|
||||
{
|
||||
// clang-format off
|
||||
switch (ch)
|
||||
{
|
||||
case 'a':
|
||||
@ -691,6 +694,7 @@ Keyboard::Key HIDInputManager::localizedKeys(UniChar ch)
|
||||
// The key is not 'localized'.
|
||||
default: return sf::Keyboard::Unknown;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
@ -699,6 +703,7 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode)
|
||||
{
|
||||
// (Some) 0x code based on https://forums.macrumors.com/showthread.php?t=780577
|
||||
// Some sf::Keyboard::Key are present twice.
|
||||
// clang-format off
|
||||
switch (virtualKeycode)
|
||||
{
|
||||
// These cases should not be used but anyway...
|
||||
@ -864,6 +869,7 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode)
|
||||
// An unknown key.
|
||||
default: return sf::Keyboard::Unknown;
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,6 +165,8 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
release();
|
||||
|
||||
unsigned int shape;
|
||||
|
||||
// clang-format off
|
||||
switch (type)
|
||||
{
|
||||
default: return false;
|
||||
@ -188,6 +190,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
case Cursor::Help: shape = XC_question_arrow; break;
|
||||
case Cursor::NotAllowed: shape = XC_X_cursor; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
m_cursor = XCreateFontCursor(m_display, shape);
|
||||
return true;
|
||||
|
@ -25,7 +25,11 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// clang-format off
|
||||
#include <SFML/Window/Unix/WindowImplX11.hpp> // important to be included first (conflict with None)
|
||||
// clang-format on
|
||||
|
||||
#include <SFML/Window/Unix/GlxContext.hpp>
|
||||
#include <SFML/Window/Unix/Display.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
@ -25,7 +25,11 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// clang-format off
|
||||
#include <SFML/Window/Window.hpp> // important to be included first (conflict with None)
|
||||
// clang-format on
|
||||
|
||||
#include <SFML/Window/Unix/InputImpl.hpp>
|
||||
#include <SFML/Window/Unix/Display.hpp>
|
||||
#include <X11/Xlib.h>
|
||||
@ -41,6 +45,8 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
||||
{
|
||||
// Get the corresponding X11 keysym
|
||||
KeySym keysym = 0;
|
||||
|
||||
// clang-format off
|
||||
switch (key)
|
||||
{
|
||||
case Keyboard::LShift: keysym = XK_Shift_L; break;
|
||||
@ -146,6 +152,7 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
||||
case Keyboard::Num9: keysym = XK_9; break;
|
||||
default: keysym = 0; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// Sanity checks
|
||||
if (key < 0 || key >= sf::Keyboard::KeyCount)
|
||||
@ -202,6 +209,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
||||
// Close the connection with the X server
|
||||
CloseDisplay(display);
|
||||
|
||||
// clang-format off
|
||||
switch (button)
|
||||
{
|
||||
case Mouse::Left: return buttons & Button1Mask;
|
||||
@ -211,6 +219,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
||||
case Mouse::XButton2: return false; // not supported by X
|
||||
default: return false;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -611,6 +611,7 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
||||
{
|
||||
switch (m_mapping[i])
|
||||
{
|
||||
// clang-format off
|
||||
case ABS_X: caps.axes[Joystick::X] = true; break;
|
||||
case ABS_Y: caps.axes[Joystick::Y] = true; break;
|
||||
case ABS_Z:
|
||||
@ -621,7 +622,8 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
||||
case ABS_RY: caps.axes[Joystick::V] = true; break;
|
||||
case ABS_HAT0X: caps.axes[Joystick::PovX] = true; break;
|
||||
case ABS_HAT0Y: caps.axes[Joystick::PovY] = true; break;
|
||||
default: break;
|
||||
default: break;
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,11 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// clang-format off
|
||||
#include <SFML/Window/Unix/WindowImplX11.hpp>
|
||||
// clang-format on
|
||||
|
||||
#include <SFML/Window/Unix/ClipboardImpl.hpp>
|
||||
#include <SFML/Window/Unix/Display.hpp>
|
||||
#include <SFML/Window/Unix/InputImpl.hpp>
|
||||
@ -386,6 +390,7 @@ namespace
|
||||
|
||||
sf::Keyboard::Key keysymToSF(KeySym symbol)
|
||||
{
|
||||
// clang-format off
|
||||
switch (symbol)
|
||||
{
|
||||
case XK_Shift_L: return sf::Keyboard::LShift;
|
||||
@ -491,6 +496,7 @@ namespace
|
||||
case XK_8: return sf::Keyboard::Num8;
|
||||
case XK_9: return sf::Keyboard::Num9;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return sf::Keyboard::Unknown;
|
||||
}
|
||||
@ -2015,6 +2021,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.x = windowEvent.xbutton.x;
|
||||
event.mouseButton.y = windowEvent.xbutton.y;
|
||||
|
||||
// clang-format off
|
||||
switch(button)
|
||||
{
|
||||
case Button1: event.mouseButton.button = Mouse::Left; break;
|
||||
@ -2023,6 +2031,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||
case 8: event.mouseButton.button = Mouse::XButton1; break;
|
||||
case 9: event.mouseButton.button = Mouse::XButton2; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,8 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
release();
|
||||
|
||||
LPCTSTR shape = nullptr;
|
||||
|
||||
// clang-format off
|
||||
switch (type)
|
||||
{
|
||||
case Cursor::Arrow: shape = IDC_ARROW; break;
|
||||
@ -170,6 +172,7 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
|
||||
case Cursor::Help: shape = IDC_HELP; break;
|
||||
case Cursor::NotAllowed: shape = IDC_NO; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// Get the shared system cursor and make sure not to destroy it
|
||||
m_cursor = LoadCursor(nullptr, shape);
|
||||
|
@ -38,6 +38,8 @@ namespace priv
|
||||
bool InputImpl::isKeyPressed(Keyboard::Key key)
|
||||
{
|
||||
int vkey = 0;
|
||||
|
||||
// clang-format off
|
||||
switch (key)
|
||||
{
|
||||
default: vkey = 0; break;
|
||||
@ -143,6 +145,7 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
||||
case Keyboard::F15: vkey = VK_F15; break;
|
||||
case Keyboard::Pause: vkey = VK_PAUSE; break;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
||||
}
|
||||
|
@ -992,6 +992,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
////////////////////////////////////////////////////////////
|
||||
Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags)
|
||||
{
|
||||
// clang-format off
|
||||
switch (key)
|
||||
{
|
||||
// Check the scancode to distinguish between left and right shift
|
||||
@ -1105,6 +1106,7 @@ Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags)
|
||||
case '8': return Keyboard::Num8;
|
||||
case '9': return Keyboard::Num9;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return Keyboard::Unknown;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
|
||||
// Prevent copies.
|
||||
TemporaryFile(const TemporaryFile&) = delete;
|
||||
|
||||
TemporaryFile& operator=(const TemporaryFile&) = delete;
|
||||
|
||||
// Return the randomly generated path.
|
||||
|
Loading…
Reference in New Issue
Block a user