Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Breeze visual style
Commits
f53fb929
Commit
f53fb929
authored
Apr 12, 2021
by
Paul McAuley
Committed by
Nate Graham
May 06, 2021
Browse files
Scale corner radii by smallSpacing factor
BUG: 422551
parent
3e8a70d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
kdecoration/breeze.h
View file @
f53fb929
...
...
@@ -20,22 +20,22 @@ namespace Breeze
using
InternalSettingsListIterator
=
QListIterator
<
InternalSettingsPtr
>
;
//* metrics
enum
Metrics
namespace
Metrics
{
//* corner radius
(pixels)
Frame_FrameRadius
=
3
,
//* corner radius
, in units of small spacing
static
constexpr
qreal
Frame_FrameRadius
=
1.5
;
//* titlebar metrics, in units of small spacing
TitleBar_TopMargin
=
2
,
TitleBar_BottomMargin
=
2
,
TitleBar_SideMargin
=
2
,
TitleBar_ButtonSpacing
=
2
,
static
constexpr
int
TitleBar_TopMargin
=
2
;
static
constexpr
int
TitleBar_BottomMargin
=
2
;
static
constexpr
int
TitleBar_SideMargin
=
2
;
static
constexpr
int
TitleBar_ButtonSpacing
=
2
;
// shadow dimensions (pixels)
Shadow_Overlap
=
3
,
static
constexpr
int
Shadow_Overlap
=
3
;
}
;
}
//* standard pen widths
namespace
PenWidth
...
...
kdecoration/breezedecoration.cpp
View file @
f53fb929
...
...
@@ -2,6 +2,7 @@
* SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
* SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr>
* SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
* SPDX-FileCopyrightText: 2021 Paul McAuley <kde@paulmcauley.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
...
...
@@ -223,7 +224,7 @@ namespace Breeze
void
Decoration
::
init
()
{
auto
c
=
client
().
data
();
// active state change animation
// It is important start and end value are of the same type, hence 0.0 and not just 0
m_animation
->
setStartValue
(
0.0
);
...
...
@@ -388,6 +389,8 @@ namespace Breeze
{
m_internalSettings
=
SettingsProvider
::
self
()
->
internalSettings
(
this
);
setScaledCornerRadius
();
// animation
...
...
@@ -438,7 +441,7 @@ namespace Breeze
top
+=
baseSize
*
Metrics
::
TitleBar_BottomMargin
+
1
;
// padding above
top
+=
baseSize
*
TitleBar_TopMargin
;
top
+=
baseSize
*
Metrics
::
TitleBar_TopMargin
;
}
...
...
@@ -560,7 +563,7 @@ namespace Breeze
// clip away the top part
if
(
!
hideTitleBar
()
)
painter
->
setClipRect
(
0
,
borderTop
(),
size
().
width
(),
size
().
height
()
-
borderTop
(),
Qt
::
IntersectClip
);
if
(
s
->
isAlphaChannelSupported
()
)
painter
->
drawRoundedRect
(
rect
(),
Metrics
::
Frame_FrameRadius
,
Metrics
::
Frame_Frame
Radius
);
if
(
s
->
isAlphaChannelSupported
()
)
painter
->
drawRoundedRect
(
rect
(),
m_scaledCornerRadius
,
m_scaledCorner
Radius
);
else
painter
->
drawRect
(
rect
()
);
painter
->
restore
();
...
...
@@ -618,7 +621,7 @@ namespace Breeze
}
else
if
(
c
->
isShaded
()
)
{
painter
->
drawRoundedRect
(
titleRect
,
Metrics
::
Frame_FrameRadius
,
Metrics
::
Frame_Frame
Radius
);
painter
->
drawRoundedRect
(
titleRect
,
m_scaledCornerRadius
,
m_scaledCorner
Radius
);
}
else
{
...
...
@@ -626,11 +629,11 @@ namespace Breeze
// the rect is made a little bit larger to be able to clip away the rounded corners at the bottom and sides
painter
->
drawRoundedRect
(
titleRect
.
adjusted
(
isLeftEdge
()
?
-
Metrics
::
Frame_Frame
Radius
:
0
,
isTopEdge
()
?
-
Metrics
::
Frame_Frame
Radius
:
0
,
isRightEdge
()
?
Metrics
::
Frame_Frame
Radius
:
0
,
Metrics
::
Frame_Frame
Radius
),
Metrics
::
Frame_FrameRadius
,
Metrics
::
Frame_Frame
Radius
);
isLeftEdge
()
?
-
m_scaledCorner
Radius
:
0
,
isTopEdge
()
?
-
m_scaledCorner
Radius
:
0
,
isRightEdge
()
?
m_scaledCorner
Radius
:
0
,
m_scaledCorner
Radius
),
m_scaledCornerRadius
,
m_scaledCorner
Radius
);
}
...
...
@@ -735,10 +738,11 @@ namespace Breeze
//________________________________________________________________
void
Decoration
::
updateShadow
()
{
auto
s
=
settings
();
// Animated case, no cached shadow object
if
(
(
m_shadowAnimation
->
state
()
==
QAbstractAnimation
::
Running
)
&&
(
m_shadowOpacity
!=
0.0
)
&&
(
m_shadowOpacity
!=
1.0
)
)
{
setShadow
(
createShadowObject
(
m_internalSettings
,
0.5
+
m_shadowOpacity
*
0.5
));
setShadow
(
createShadowObject
(
0.5
+
m_shadowOpacity
*
0.5
));
return
;
}
...
...
@@ -757,15 +761,15 @@ namespace Breeze
auto
&
shadow
=
(
c
->
isActive
())
?
g_sShadow
:
g_sShadowInactive
;
if
(
!
shadow
)
{
shadow
=
createShadowObject
(
m_internalSettings
,
c
->
isActive
()
?
1.0
:
0.5
);
shadow
=
createShadowObject
(
c
->
isActive
()
?
1.0
:
0.5
);
}
setShadow
(
shadow
);
}
//________________________________________________________________
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
Decoration
::
createShadowObject
(
const
InternalSettingsPtr
&
internalSettings
,
const
float
strengthScale
)
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
Decoration
::
createShadowObject
(
const
float
strengthScale
)
{
const
CompositeShadowParams
params
=
lookupShadowParams
(
internalSettings
->
shadowSize
());
const
CompositeShadowParams
params
=
lookupShadowParams
(
m_
internalSettings
->
shadowSize
());
if
(
params
.
isNone
())
{
return
nullptr
;
...
...
@@ -782,15 +786,16 @@ namespace Breeze
.
expandedTo
(
BoxShadowRenderer
::
calculateMinimumBoxSize
(
params
.
shadow2
.
radius
));
BoxShadowRenderer
shadowRenderer
;
shadowRenderer
.
setBorderRadius
(
Metrics
::
Frame_Frame
Radius
+
0.5
);
shadowRenderer
.
setBorderRadius
(
m_scaledCorner
Radius
+
0.5
);
shadowRenderer
.
setBoxSize
(
boxSize
);
shadowRenderer
.
setDevicePixelRatio
(
1.0
);
// TODO: Create HiDPI shadows?
const
qreal
strength
=
internalSettings
->
shadowStrength
()
/
255.0
*
strengthScale
;
const
qreal
strength
=
m_internalSettings
->
shadowStrength
()
/
255.0
*
strengthScale
;
shadowRenderer
.
addShadow
(
params
.
shadow1
.
offset
,
params
.
shadow1
.
radius
,
withOpacity
(
internalSettings
->
shadowColor
(),
params
.
shadow1
.
opacity
*
strength
));
withOpacity
(
m_
internalSettings
->
shadowColor
(),
params
.
shadow1
.
opacity
*
strength
));
shadowRenderer
.
addShadow
(
params
.
shadow2
.
offset
,
params
.
shadow2
.
radius
,
withOpacity
(
internalSettings
->
shadowColor
(),
params
.
shadow2
.
opacity
*
strength
));
withOpacity
(
m_
internalSettings
->
shadowColor
(),
params
.
shadow2
.
opacity
*
strength
));
QImage
shadowTexture
=
shadowRenderer
.
render
();
...
...
@@ -815,17 +820,17 @@ namespace Breeze
painter
.
setCompositionMode
(
QPainter
::
CompositionMode_DestinationOut
);
painter
.
drawRoundedRect
(
innerRect
,
Metrics
::
Frame_Frame
Radius
+
0.5
,
Metrics
::
Frame_Frame
Radius
+
0.5
);
m_scaledCorner
Radius
+
0.5
,
m_scaledCorner
Radius
+
0.5
);
// Draw outline.
painter
.
setPen
(
withOpacity
(
internalSettings
->
shadowColor
(),
0.2
*
strength
));
painter
.
setPen
(
withOpacity
(
m_
internalSettings
->
shadowColor
(),
0.2
*
strength
));
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setCompositionMode
(
QPainter
::
CompositionMode_SourceOver
);
painter
.
drawRoundedRect
(
innerRect
,
Metrics
::
Frame_Frame
Radius
-
0.5
,
Metrics
::
Frame_Frame
Radius
-
0.5
);
m_scaledCorner
Radius
-
0.5
,
m_scaledCorner
Radius
-
0.5
);
painter
.
end
();
...
...
@@ -870,7 +875,12 @@ namespace Breeze
m_sizeGrip
=
nullptr
;
}
}
void
Decoration
::
setScaledCornerRadius
()
{
m_scaledCornerRadius
=
Metrics
::
Frame_FrameRadius
*
settings
()
->
smallSpacing
();
}
}
// namespace
...
...
kdecoration/breezedecoration.h
View file @
f53fb929
...
...
@@ -108,8 +108,9 @@ namespace Breeze
void
createButtons
();
void
paintTitleBar
(
QPainter
*
painter
,
const
QRect
&
repaintRegion
);
void
updateShadow
();
static
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
createShadowObject
(
const
InternalSettingsPtr
&
internalSettings
,
const
float
strengthScale
);
QSharedPointer
<
KDecoration2
::
DecorationShadow
>
createShadowObject
(
const
float
strengthScale
);
void
setScaledCornerRadius
();
//*@name border size
//@{
int
borderSize
(
bool
bottom
=
false
)
const
;
...
...
@@ -141,6 +142,9 @@ namespace Breeze
qreal
m_opacity
=
0
;
qreal
m_shadowOpacity
=
0
;
//*frame corner radius, scaled according to DPI
qreal
m_scaledCornerRadius
=
3
;
};
bool
Decoration
::
hasBorders
()
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment