mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Add clang-tidy modernize-return-braced-init-list
check
This commit is contained in:
parent
434effd6a1
commit
9dc2e541e8
@ -29,7 +29,6 @@ Checks: >
|
|||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-modernize-avoid-c-arrays,
|
-modernize-avoid-c-arrays,
|
||||||
-modernize-macro-to-enum,
|
-modernize-macro-to-enum,
|
||||||
-modernize-return-braced-init-list,
|
|
||||||
-modernize-use-nodiscard,
|
-modernize-use-nodiscard,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-performance-inefficient-string-concatenation,
|
-performance-inefficient-string-concatenation,
|
||||||
|
@ -341,7 +341,7 @@ float getMoisture(unsigned int x, unsigned int y)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sf::Color colorFromFloats(float r, float g, float b)
|
sf::Color colorFromFloats(float r, float g, float b)
|
||||||
{
|
{
|
||||||
return sf::Color(static_cast<std::uint8_t>(r), static_cast<std::uint8_t>(g), static_cast<std::uint8_t>(b));
|
return {static_cast<std::uint8_t>(r), static_cast<std::uint8_t>(g), static_cast<std::uint8_t>(b)};
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Color getLowlandsTerrainColor(float moisture)
|
sf::Color getLowlandsTerrainColor(float moisture)
|
||||||
@ -451,7 +451,7 @@ sf::Vector2f computeNormal(float left, float right, float bottom, float top)
|
|||||||
crossProduct /= crossProduct.z;
|
crossProduct /= crossProduct.z;
|
||||||
|
|
||||||
// Return "compressed" normal
|
// Return "compressed" normal
|
||||||
return sf::Vector2f(crossProduct.x, crossProduct.y);
|
return {crossProduct.x, crossProduct.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,10 +77,10 @@ constexpr Color operator+(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(intResult < 255 ? intResult : 255);
|
return static_cast<std::uint8_t>(intResult < 255 ? intResult : 255);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Color(clampedAdd(left.r, right.r),
|
return {clampedAdd(left.r, right.r),
|
||||||
clampedAdd(left.g, right.g),
|
clampedAdd(left.g, right.g),
|
||||||
clampedAdd(left.b, right.b),
|
clampedAdd(left.b, right.b),
|
||||||
clampedAdd(left.a, right.a));
|
clampedAdd(left.a, right.a)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,10 +93,10 @@ constexpr Color operator-(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(intResult > 0 ? intResult : 0);
|
return static_cast<std::uint8_t>(intResult > 0 ? intResult : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Color(clampedSub(left.r, right.r),
|
return {clampedSub(left.r, right.r),
|
||||||
clampedSub(left.g, right.g),
|
clampedSub(left.g, right.g),
|
||||||
clampedSub(left.b, right.b),
|
clampedSub(left.b, right.b),
|
||||||
clampedSub(left.a, right.a));
|
clampedSub(left.a, right.a)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,10 +109,7 @@ constexpr Color operator*(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(uint16Result / 255u);
|
return static_cast<std::uint8_t>(uint16Result / 255u);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Color(scaledMul(left.r, right.r),
|
return {scaledMul(left.r, right.r), scaledMul(left.g, right.g), scaledMul(left.b, right.b), scaledMul(left.a, right.a)};
|
||||||
scaledMul(left.g, right.g),
|
|
||||||
scaledMul(left.b, right.b),
|
|
||||||
scaledMul(left.a, right.a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ constexpr Transform Transform::getInverse() const
|
|||||||
if (det != 0.f)
|
if (det != 0.f)
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
|
return {(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[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
|
||||||
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
|
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
|
||||||
-(m_matrix[15] * m_matrix[1] - m_matrix[3] * m_matrix[13]) / det,
|
-(m_matrix[15] * m_matrix[1] - m_matrix[3] * m_matrix[13]) / det,
|
||||||
@ -71,7 +71,7 @@ constexpr Transform Transform::getInverse() const
|
|||||||
-(m_matrix[13] * m_matrix[0] - m_matrix[1] * m_matrix[12]) / det,
|
-(m_matrix[13] * m_matrix[0] - m_matrix[1] * m_matrix[12]) / det,
|
||||||
(m_matrix[7] * m_matrix[1] - m_matrix[3] * m_matrix[5]) / det,
|
(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[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det,
|
||||||
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det);
|
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -84,8 +84,8 @@ constexpr Transform Transform::getInverse() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
|
constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
|
||||||
{
|
{
|
||||||
return Vector2f(m_matrix[0] * point.x + m_matrix[4] * point.y + m_matrix[12],
|
return {m_matrix[0] * point.x + m_matrix[4] * point.y + m_matrix[12],
|
||||||
m_matrix[1] * point.x + m_matrix[5] * point.y + m_matrix[13]);
|
m_matrix[1] * point.x + m_matrix[5] * point.y + m_matrix[13]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
return FloatRect({left, top}, {right - left, bottom - top});
|
return {{left, top}, {right - left, bottom - top}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,21 +73,21 @@ constexpr Time::operator std::chrono::duration<Rep, Period>() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time seconds(float amount)
|
constexpr Time seconds(float amount)
|
||||||
{
|
{
|
||||||
return Time(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<float>(amount)));
|
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<float>(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time milliseconds(std::int32_t amount)
|
constexpr Time milliseconds(std::int32_t amount)
|
||||||
{
|
{
|
||||||
return Time(std::chrono::milliseconds(amount));
|
return std::chrono::milliseconds(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time microseconds(std::int64_t amount)
|
constexpr Time microseconds(std::int64_t amount)
|
||||||
{
|
{
|
||||||
return Time(std::chrono::microseconds(amount));
|
return std::chrono::microseconds(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ Vector2f CircleShape::getPoint(std::size_t index) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f CircleShape::getGeometricCenter() const
|
Vector2f CircleShape::getGeometricCenter() const
|
||||||
{
|
{
|
||||||
return Vector2f(m_radius, m_radius);
|
return {m_radius, m_radius};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -755,7 +755,7 @@ IntRect Font::findGlyphRect(Page& page, const Vector2u& size) const
|
|||||||
if (!newTexture.create(textureSize * 2u))
|
if (!newTexture.create(textureSize * 2u))
|
||||||
{
|
{
|
||||||
err() << "Failed to create new page texture" << std::endl;
|
err() << "Failed to create new page texture" << std::endl;
|
||||||
return IntRect({0, 0}, {2, 2});
|
return {{0, 0}, {2, 2}};
|
||||||
}
|
}
|
||||||
|
|
||||||
newTexture.setSmooth(m_isSmooth);
|
newTexture.setSmooth(m_isSmooth);
|
||||||
@ -767,7 +767,7 @@ IntRect Font::findGlyphRect(Page& page, const Vector2u& size) const
|
|||||||
// Oops, we've reached the maximum texture size...
|
// Oops, we've reached the maximum texture size...
|
||||||
err() << "Failed to add a new character to the font: the maximum texture size has been reached"
|
err() << "Failed to add a new character to the font: the maximum texture size has been reached"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return IntRect({0, 0}, {2, 2});
|
return {{0, 0}, {2, 2}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void Image::setPixel(const Vector2u& coords, const Color& color)
|
|||||||
Color Image::getPixel(const Vector2u& coords) const
|
Color Image::getPixel(const Vector2u& coords) const
|
||||||
{
|
{
|
||||||
const std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
const std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
||||||
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
return {pixel[0], pixel[1], pixel[2], pixel[3]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ Vector2f RectangleShape::getPoint(std::size_t index) const
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
return Vector2f(0, 0);
|
return {0, 0};
|
||||||
case 1:
|
case 1:
|
||||||
return Vector2f(m_size.x, 0);
|
return {m_size.x, 0};
|
||||||
case 2:
|
case 2:
|
||||||
return Vector2f(m_size.x, m_size.y);
|
return {m_size.x, m_size.y};
|
||||||
case 3:
|
case 3:
|
||||||
return Vector2f(0, m_size.y);
|
return {0, m_size.y};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ FloatRect Sprite::getLocalBounds() const
|
|||||||
const auto width = static_cast<float>(std::abs(m_textureRect.width));
|
const auto width = static_cast<float>(std::abs(m_textureRect.width));
|
||||||
const auto height = static_cast<float>(std::abs(m_textureRect.height));
|
const auto height = static_cast<float>(std::abs(m_textureRect.height));
|
||||||
|
|
||||||
return FloatRect({0.f, 0.f}, {width, height});
|
return {{0.f, 0.f}, {width, height}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ Image Texture::copyToImage() const
|
|||||||
{
|
{
|
||||||
// Easy case: empty texture
|
// Easy case: empty texture
|
||||||
if (!m_texture)
|
if (!m_texture)
|
||||||
return Image();
|
return {};
|
||||||
|
|
||||||
const TransientContextLock lock;
|
const TransientContextLock lock;
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ FloatRect VertexArray::getBounds() const
|
|||||||
bottom = position.y;
|
bottom = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FloatRect({left, top}, {right - left, bottom - top});
|
return {{left, top}, {right - left, bottom - top}};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Array is empty
|
// Array is empty
|
||||||
return FloatRect();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ Ftp::Response Ftp::keepAlive()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
||||||
{
|
{
|
||||||
return DirectoryResponse(sendCommand("PWD"));
|
return {sendCommand("PWD")};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ Ftp::ListingResponse Ftp::getDirectoryListing(const std::string& directory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListingResponse(response, directoryData.str());
|
return {response, directoryData.str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace sf::priv
|
|||||||
String ClipboardImpl::getString()
|
String ClipboardImpl::getString()
|
||||||
{
|
{
|
||||||
sf::err() << "Clipboard API not implemented for Android.\n";
|
sf::err() << "Clipboard API not implemented for Android.\n";
|
||||||
return String();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return JoystickCaps();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return JoystickState();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -125,7 +125,7 @@ void WindowImplAndroid::processEvents()
|
|||||||
Vector2i WindowImplAndroid::getPosition() const
|
Vector2i WindowImplAndroid::getPosition() const
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i(0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger)
|
|||||||
return slot.pos;
|
return slot.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ WindowHandle WindowImplDRM::getNativeHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplDRM::getPosition() const
|
Vector2i WindowImplDRM::getPosition() const
|
||||||
{
|
{
|
||||||
return Vector2i(0, 0);
|
return {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
// Should never happen...
|
// Should never happen...
|
||||||
err() << "No GLX visual found. You should check your graphics driver" << std::endl;
|
err() << "No GLX visual found. You should check your graphics driver" << std::endl;
|
||||||
|
|
||||||
return XVisualInfo();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ Vector2i InputImpl::getMousePosition()
|
|||||||
// Close the connection with the X server
|
// Close the connection with the X server
|
||||||
closeDisplay(display);
|
closeDisplay(display);
|
||||||
|
|
||||||
return Vector2i(gx, gy);
|
return {gx, gy};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
// Close the connection with the X server
|
// Close the connection with the X server
|
||||||
closeDisplay(display);
|
closeDisplay(display);
|
||||||
|
|
||||||
return Vector2i(x, y);
|
return {x, y};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -407,7 +407,7 @@ std::string getJoystickName(unsigned int index)
|
|||||||
::close(fd);
|
::close(fd);
|
||||||
|
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
return std::string(name);
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to manual USB chain walk via udev
|
// Fall back to manual USB chain walk via udev
|
||||||
@ -421,13 +421,13 @@ std::string getJoystickName(unsigned int index)
|
|||||||
udev_device_unref(udevDevice);
|
udev_device_unref(udevDevice);
|
||||||
|
|
||||||
if (product)
|
if (product)
|
||||||
return std::string(product);
|
return {product};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
||||||
|
|
||||||
return std::string("Unknown Joystick");
|
return "Unknown Joystick";
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
|||||||
const char32_t unicode = keysymToUnicode(keysym);
|
const char32_t unicode = keysymToUnicode(keysym);
|
||||||
|
|
||||||
if (unicode != 0)
|
if (unicode != 0)
|
||||||
return String(unicode);
|
return {unicode};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to our best guess for the keys that are known to be independent of the layout.
|
// Fallback to our best guess for the keys that are known to be independent of the layout.
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return Vector3f(0, 0, 0);
|
return {0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
// it to, even with decorations and such, which get shifted back.
|
// it to, even with decorations and such, which get shifted back.
|
||||||
// In these rare cases, we can use the absolute value directly.
|
// In these rare cases, we can use the absolute value directly.
|
||||||
if (isWMAbsolutePositionGood())
|
if (isWMAbsolutePositionGood())
|
||||||
return Vector2i(xAbsRelToRoot, yAbsRelToRoot);
|
return {xAbsRelToRoot, yAbsRelToRoot};
|
||||||
|
|
||||||
// CASE 2: most modern WMs support EWMH and can define _NET_FRAME_EXTENTS
|
// CASE 2: most modern WMs support EWMH and can define _NET_FRAME_EXTENTS
|
||||||
// with the exact frame size to subtract, so if present, we prefer it and
|
// with the exact frame size to subtract, so if present, we prefer it and
|
||||||
@ -830,7 +830,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
{
|
{
|
||||||
// Get final X/Y coordinates: subtract EWMH frame extents from
|
// Get final X/Y coordinates: subtract EWMH frame extents from
|
||||||
// absolute window position.
|
// absolute window position.
|
||||||
return Vector2i((xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent)));
|
return {(xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent))};
|
||||||
}
|
}
|
||||||
|
|
||||||
// CASE 3: EWMH frame extents were not available, use geometry.
|
// CASE 3: EWMH frame extents were not available, use geometry.
|
||||||
@ -866,7 +866,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
|
|
||||||
XGetGeometry(m_display, ancestor, &root, &xRelToRoot, &yRelToRoot, &width, &height, &borderWidth, &depth);
|
XGetGeometry(m_display, ancestor, &root, &xRelToRoot, &yRelToRoot, &width, &height, &borderWidth, &depth);
|
||||||
|
|
||||||
return Vector2i(xRelToRoot, yRelToRoot);
|
return {xRelToRoot, yRelToRoot};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ Vector2i InputImpl::getMousePosition()
|
|||||||
{
|
{
|
||||||
POINT point;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
return Vector2i(point.x, point.y);
|
return {point.x, point.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -660,11 +660,11 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
POINT point;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
ScreenToClient(handle, &point);
|
ScreenToClient(handle, &point);
|
||||||
return Vector2i(point.x, point.y);
|
return {point.x, point.y};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +701,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return Vector3f(0, 0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ String getErrorString(DWORD errorCode)
|
|||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "Error " << errorCode;
|
ss << "Error " << errorCode;
|
||||||
return String(ss.str());
|
return {ss.str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ Vector2i WindowImplWin32::getPosition() const
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(m_handle, &rect);
|
GetWindowRect(m_handle, &rect);
|
||||||
|
|
||||||
return Vector2i(rect.left, rect.top);
|
return {rect.left, rect.top};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ Vector2u WindowImplWin32::getSize() const
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(m_handle, &rect);
|
GetClientRect(m_handle, &rect);
|
||||||
|
|
||||||
return Vector2u(static_cast<unsigned int>(rect.right - rect.left), static_cast<unsigned int>(rect.bottom - rect.top));
|
return Vector2u(Vector2<LONG>(rect.right - rect.left, rect.bottom - rect.top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ String ClipboardImpl::getString()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return String();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button /* button */)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i InputImpl::getMousePosition()
|
Vector2i InputImpl::getMousePosition()
|
||||||
{
|
{
|
||||||
return Vector2i(0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return JoystickCaps();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||||||
Joystick::Identification JoystickImpl::getIdentification() const
|
Joystick::Identification JoystickImpl::getIdentification() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return Joystick::Identification();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return JoystickState();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -109,8 +109,8 @@ WindowHandle WindowImplUIKit::getNativeHandle() const
|
|||||||
Vector2i WindowImplUIKit::getPosition() const
|
Vector2i WindowImplUIKit::getPosition() const
|
||||||
{
|
{
|
||||||
const CGPoint origin = m_window.frame.origin;
|
const CGPoint origin = m_window.frame.origin;
|
||||||
return Vector2i(static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
|
return {static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
|
||||||
static_cast<int>(origin.y * static_cast<double>(m_backingScale)));
|
static_cast<int>(origin.y * static_cast<double>(m_backingScale))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,8 +124,8 @@ void WindowImplUIKit::setPosition(const Vector2i& /* position */)
|
|||||||
Vector2u WindowImplUIKit::getSize() const
|
Vector2u WindowImplUIKit::getSize() const
|
||||||
{
|
{
|
||||||
const CGRect physicalFrame = m_window.frame;
|
const CGRect physicalFrame = m_window.frame;
|
||||||
return Vector2u(static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
|
return {static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
|
||||||
static_cast<unsigned int>(physicalFrame.size.height * static_cast<double>(m_backingScale)));
|
static_cast<unsigned int>(physicalFrame.size.height * static_cast<double>(m_backingScale))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ String HIDInputManager::getDescription(Keyboard::Scancode code)
|
|||||||
// Phase 2: Try to convert the key to unicode
|
// Phase 2: Try to convert the key to unicode
|
||||||
const UniChar unicode = toUnicode(localize(code));
|
const UniChar unicode = toUnicode(localize(code));
|
||||||
if (unicode != 0x00)
|
if (unicode != 0x00)
|
||||||
return String(static_cast<char32_t>(unicode));
|
return {static_cast<char32_t>(unicode)};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 3: Return final fallback
|
// Phase 3: Return final fallback
|
||||||
|
@ -191,7 +191,7 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
|
|
||||||
// No view ?
|
// No view ?
|
||||||
if (view == nil)
|
if (view == nil)
|
||||||
return Vector2i();
|
return {};
|
||||||
|
|
||||||
// Use -cursorPositionFromEvent: with nil.
|
// Use -cursorPositionFromEvent: with nil.
|
||||||
const NSPoint pos = [view cursorPositionFromEvent:nil];
|
const NSPoint pos = [view cursorPositionFromEvent:nil];
|
||||||
@ -250,7 +250,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return Vector3f(0, 0, 0);
|
return {0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ public:
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
return sf::Vector2f(m_size.x / 2, 0);
|
return {m_size.x / 2, 0};
|
||||||
case 1:
|
case 1:
|
||||||
return sf::Vector2f(0, m_size.y);
|
return {0, m_size.y};
|
||||||
case 2:
|
case 2:
|
||||||
return sf::Vector2f(m_size.x, m_size.y);
|
return {m_size.x, m_size.y};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user