diff options
author | Florian Jung <flo@windfisch.org> | 2011-09-14 17:17:31 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-09-14 17:17:31 +0000 |
commit | 2529ef06d1227b457af051a494ddb579ef590fe3 (patch) | |
tree | e4f3d3c77d39a5395fc3fa6806af85bb3ea77392 /muse2/muse/widgets/utils.cpp | |
parent | 187665d84e56b63f569731550c652a89cb650309 (diff) | |
parent | 42269af2e0cc7a8c7b70d89ffa270184acde3dec (diff) |
merged with trunk
tiny fix: removed bool initalizing completely
reindented cobject.cpp
Diffstat (limited to 'muse2/muse/widgets/utils.cpp')
-rw-r--r-- | muse2/muse/widgets/utils.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/muse2/muse/widgets/utils.cpp b/muse2/muse/widgets/utils.cpp index e46d265c..1ed9001a 100644 --- a/muse2/muse/widgets/utils.cpp +++ b/muse2/muse/widgets/utils.cpp @@ -404,4 +404,56 @@ QGradient gGradientFromQColor(const QColor& c, const QPointF& start, const QPoin return gradient; } +QPainterPath roundedPath(QRect r, int xrad, int yrad, Corner roundCorner) +{ + return roundedPath(r.x(), r.y(), + r.width(), r.height(), + xrad, yrad, + roundCorner); +} + +QPainterPath roundedPath(int x, int y, int w, int h, int xrad, int yrad, Corner roundCorner) +{ + QPainterPath rounded_rect; + rounded_rect.addRect(x, y, w, h); + + if (roundCorner & UpperLeft) + { + QPainterPath top_left_corner; + top_left_corner.addRect(x, y, xrad, yrad); + top_left_corner.moveTo(x + xrad, y + yrad); + top_left_corner.arcTo(x, y, xrad*2, yrad*2, 180, -90); + rounded_rect = rounded_rect.subtracted(top_left_corner); + } + + if (roundCorner & UpperRight) + { + QPainterPath top_right_corner; + top_right_corner.addRect(x + w - xrad, y, xrad, yrad); + top_right_corner.moveTo(x + w - xrad, y + yrad); + top_right_corner.arcTo(x + w - xrad * 2, y, xrad*2, yrad*2, 90, -90); + rounded_rect = rounded_rect.subtracted(top_right_corner); + } + + if (roundCorner & LowerLeft) + { + QPainterPath bottom_left_corner; + bottom_left_corner.addRect(x, y + h - yrad, xrad, yrad); + bottom_left_corner.moveTo(x + xrad, y + h - yrad); + bottom_left_corner.arcTo(x, y + h - yrad*2, xrad*2, yrad*2, 180, 90); + rounded_rect = rounded_rect.subtracted(bottom_left_corner); + } + + if (roundCorner & LowerRight) + { + QPainterPath bottom_right_corner; + bottom_right_corner.addRect(x + w - xrad, y + h - yrad, xrad, yrad); + bottom_right_corner.moveTo(x + w - xrad, y + h - yrad); + bottom_right_corner.arcTo(x + w - xrad*2, y + h - yrad*2, xrad*2, yrad*2, 270, 90); + rounded_rect = rounded_rect.subtracted(bottom_right_corner); + } + + return rounded_rect; +} + } // namespace MusEUtils |