add screenEdgeMargin and update border accordingly

pull/11/head
Michail Vourlakos 5 years ago
parent 945a034a8c
commit 0ebef42513

@ -60,6 +60,7 @@ void Effects::init()
});
connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::screenEdgeMarginChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects);
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows);
connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask);
@ -489,25 +490,27 @@ void Effects::updateEnabledBorders()
Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders;
switch (m_view->location()) {
case Plasma::Types::TopEdge:
borders &= ~Plasma::FrameSvg::TopBorder;
break;
if (!m_view->screenEdgeMarginEnabled()) {
switch (m_view->location()) {
case Plasma::Types::TopEdge:
borders &= ~Plasma::FrameSvg::TopBorder;
break;
case Plasma::Types::LeftEdge:
borders &= ~Plasma::FrameSvg::LeftBorder;
break;
case Plasma::Types::LeftEdge:
borders &= ~Plasma::FrameSvg::LeftBorder;
break;
case Plasma::Types::RightEdge:
borders &= ~Plasma::FrameSvg::RightBorder;
break;
case Plasma::Types::RightEdge:
borders &= ~Plasma::FrameSvg::RightBorder;
break;
case Plasma::Types::BottomEdge:
borders &= ~Plasma::FrameSvg::BottomBorder;
break;
case Plasma::Types::BottomEdge:
borders &= ~Plasma::FrameSvg::BottomBorder;
break;
default:
break;
default:
break;
}
}
if ((m_view->location() == Plasma::Types::LeftEdge || m_view->location() == Plasma::Types::RightEdge)) {

@ -809,6 +809,26 @@ void View::setOffset(int offset)
emit offsetChanged();
}
bool View::screenEdgeMarginEnabled() const
{
return (m_screenEdgeMargin > -1);
}
int View::screenEdgeMargin() const
{
return m_screenEdgeMargin;
}
void View::setScreenEdgeMargin(int margin)
{
if (m_screenEdgeMargin == margin) {
return;
}
m_screenEdgeMargin = margin;
emit screenEdgeMarginChanged();
}
int View::fontPixelSize() const
{
return m_fontPixelSize;

@ -101,6 +101,8 @@ class View : public PlasmaQuick::ContainmentView
Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged)
Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged)
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(int screenEdgeMargin READ screenEdgeMargin WRITE setScreenEdgeMargin NOTIFY screenEdgeMarginChanged)
Q_PROPERTY(float maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged)
@ -160,6 +162,8 @@ public:
bool isTouchingTopViewAndIsBusy() const;
void setIsTouchingTopViewAndIsBusy(bool touchAndBusy);
bool screenEdgeMarginEnabled() const;
float maxLength() const;
void setMaxLength(float length);
@ -178,6 +182,9 @@ public:
int offset() const;
void setOffset(int offset);
int screenEdgeMargin() const;
void setScreenEdgeMargin(int margin);
int alignment() const;
void setAlignment(int alignment);
@ -278,6 +285,7 @@ signals:
void offsetChanged();
void onPrimaryChanged();
void positionerChanged();
void screenEdgeMarginChanged();
void screenGeometryChanged();
void typeChanged();
void visibilityChanged();
@ -333,6 +341,7 @@ private:
int m_maxThickness{24};
int m_normalThickness{24};
int m_offset{0};
int m_screenEdgeMargin{-1};
float m_maxLength{1};
Types::Alignment m_alignment{Types::Center};

@ -53,6 +53,10 @@
<default>-1</default>
<label>this is a percentage value, -1 means disabled</label>
</entry>
<entry name="screenEdgeMargin" type="Int">
<default>-1</default>
<label>margin from screen edge in pixels, -1 means disabled</label>
</entry>
<entry name="inConfigureAppletsMode" type="Bool">
<default>false</default>
</entry>

@ -45,6 +45,8 @@ Item{
property int animationTime: 6*root.durationTime*units.shortDuration
property int screenEdgeMargin: root.screenEdgeMarginEnabled ? root.screenEdgeMargin - shadowsSvgItem.screenEdgeShadow : 0
property int lengthMargins: {
return root.isVertical ? shadowsSvgItem.marginsHeight : shadowsSvgItem.marginsWidth
}
@ -180,6 +182,22 @@ Item{
NumberAnimation { duration: 0 }
}
property int screenEdgeShadow: {
if (imagePath === "" || !root.screenEdgeMarginEnabled) {
return 0;
}
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
return margins.left;
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
return margins.right;
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
return margins.top;
} else if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
return margins.bottom;
}
}
property int marginsWidth: {
if (imagePath === "") {
return 0;
@ -625,7 +643,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0);
}
},
@ -644,7 +662,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -663,7 +681,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.leftMargin: barLine.screenEdgeMargin; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -682,7 +700,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0);
}
},
@ -700,7 +718,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:root.offset; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -718,7 +736,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.leftMargin: 0; anchors.rightMargin: barLine.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:root.offset;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -737,7 +755,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin;
anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0;
}
},
@ -757,7 +775,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
@ -778,7 +796,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin: barLine.screenEdgeMargin;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -797,7 +815,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0;
}
},
@ -817,7 +835,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
},
@ -837,7 +855,7 @@ Item{
}
PropertyChanges{
target: barLine
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0;
anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin: barLine.screenEdgeMargin; anchors.bottomMargin:0;
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
}
}

@ -175,6 +175,13 @@ Item{
value: plasmoid.configuration.offset
}
Binding{
target: latteView
property: "screenEdgeMargin"
when: latteView
value: plasmoid.configuration.screenEdgeMargin
}
Binding{
target: latteView
property: "alignment"

@ -387,6 +387,9 @@ Item {
}
property int thickMargin: thickMarginFactor * root.iconSize
property bool screenEdgeMarginEnabled: plasmoid.configuration.screenEdgeMargin >= 0
property int screenEdgeMargin: plasmoid.configuration.screenEdgeMargin <=0 ? 0 : plasmoid.configuration.screenEdgeMargin
//! thickness margins are always two and equal in order for items
//! to be always correctly centered
property int thickMargins: 2 * thickMargin

@ -585,6 +585,44 @@ PlasmaComponents.Page {
readonly property int currentValue: Math.max(thickMarginSlider.minimumInternalValue, thickMarginSlider.value)
}
}
RowLayout {
Layout.minimumWidth: dialog.optionsWidth
Layout.maximumWidth: Layout.minimumWidth
spacing: units.smallSpacing
enabled: !plasmoid.configuration.shrinkThickMargins
PlasmaComponents.Label {
text: i18n("Screen")
horizontalAlignment: Text.AlignLeft
}
LatteComponents.Slider {
id: screenEdgeMarginSlider
Layout.fillWidth: true
value: plasmoid.configuration.screenEdgeMargin
from: -1
to: 25
stepSize: 1
wheelEnabled: false
onPressedChanged: {
if (!pressed) {
plasmoid.configuration.screenEdgeMargin = value;
}
}
}
PlasmaComponents.Label {
text: currentValue < 0 ? "---" : i18nc("number in pixels, e.g. 85 px.","%0 px.").arg(currentValue)
horizontalAlignment: Text.AlignRight
Layout.minimumWidth: theme.mSize(theme.defaultFont).width * 4
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 4
readonly property int currentValue: screenEdgeMarginSlider.value
}
}
}
}
//! END: Margins

Loading…
Cancel
Save