KWin
Loading...
Searching...
No Matches
src
core
pixelgrid.h
Go to the documentation of this file.
1
/*
2
SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4
SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#pragma once
8
9
#include "kwin_export.h"
10
11
#include <QRect>
12
13
namespace
KWin
14
{
15
16
KWIN_EXPORT
inline
QPoint
snapToPixelGrid
(
const
QPointF &point)
17
{
18
return
QPoint(std::round(point.x()), std::round(point.y()));
19
}
20
21
KWIN_EXPORT
inline
QPointF
snapToPixelGridF
(
const
QPointF &point)
22
{
23
return
QPointF(std::round(point.x()), std::round(point.y()));
24
}
25
26
KWIN_EXPORT
inline
QRect
snapToPixelGrid
(
const
QRectF &rect)
27
{
28
const
QPoint topLeft =
snapToPixelGrid
(rect.topLeft());
29
const
QPoint bottomRight =
snapToPixelGrid
(rect.bottomRight());
30
return
QRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y());
31
}
32
33
KWIN_EXPORT
inline
QRectF
snapToPixelGridF
(
const
QRectF &rect)
34
{
35
return
QRectF(
snapToPixelGridF
(rect.topLeft()),
snapToPixelGridF
(rect.bottomRight()));
36
}
37
38
}
// namespace KWin
KWin
Definition
activation_test.cpp:20
KWin::snapToPixelGridF
KWIN_EXPORT QPointF snapToPixelGridF(const QPointF &point)
Definition
pixelgrid.h:21
KWin::snapToPixelGrid
KWIN_EXPORT QPoint snapToPixelGrid(const QPointF &point)
Definition
pixelgrid.h:16
Generated on Sat Feb 17 2024 01:42:09 for KWin by
1.10.0