// Dims everything except one rectangle, GNOME-style. // // Four dimming rectangles laid around the hole, because QML has no way to // subtract a shape from another without an OpacityMask shader — and a shader // here would mean a full-screen 4500x3000 offscreen texture on every pointer // move. import QtQuick import qs.config Item { id: root // The region left undimmed, in this item's coordinates. property rect hole: Qt.rect(0, 0, 0, 0) // When false the whole item dims uniformly (nothing selected yet). property bool holeVisible: false property color dimColor: Theme.alpha(Theme.bgDark, Theme.overlayAlpha) readonly property real _l: Math.max(0, Math.min(root.width, root.hole.x)) readonly property real _t: Math.max(0, Math.min(root.height, root.hole.y)) readonly property real _r: Math.max(root._l, Math.min(root.width, root.hole.x + root.hole.width)) readonly property real _b: Math.max(root._t, Math.min(root.height, root.hole.y + root.hole.height)) Rectangle { anchors.fill: parent visible: !root.holeVisible color: root.dimColor border.width: 0 } // Above the hole Rectangle { visible: root.holeVisible x: 0 y: 0 width: root.width height: root._t color: root.dimColor border.width: 0 } // Below Rectangle { visible: root.holeVisible x: 0 y: root._b width: root.width height: Math.max(0, root.height - root._b) color: root.dimColor border.width: 0 } // Left of the hole, between top and bottom bands Rectangle { visible: root.holeVisible x: 0 y: root._t width: root._l height: Math.max(0, root._b - root._t) color: root.dimColor border.width: 0 } // Right Rectangle { visible: root.holeVisible x: root._r y: root._t width: Math.max(0, root.width - root._r) height: Math.max(0, root._b - root._t) color: root.dimColor border.width: 0 } }