Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmcssstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
7
8#include <QtCore/qstring.h>
9#include <QtCore/qfile.h>
10
12
13namespace {
14const char *Style = R"css(
15.qt-screen {
16 --border-width: 4px;
17 --resize-outline-width: 8px;
18 --resize-outline-half-width: var(--resize-outline-width) / 2;
19
20 position: relative;
21 border: none;
22 caret-color: transparent;
23 cursor: default;
24 width: 100%;
25 height: 100%;
26 overflow: hidden;
27}
28
29.qt-screen div {
30 touch-action: none;
31}
32
33.qt-decorated-window {
34 position: absolute;
35 background-color: lightgray;
36}
37
38.qt-window {
39 overflow: hidden;
40 position: relative;
41}
42
43.qt-decorated-window.transparent-for-input {
44 pointer-events: none;
45}
46
47.qt-decorated-window.has-shadow {
48 box-shadow: rgb(0 0 0 / 20%) 0px 10px 16px 0px, rgb(0 0 0 / 19%) 0px 6px 20px 0px;
49}
50
51.qt-decorated-window.has-border {
52 border: var(--border-width) solid lightgray;
53 caret-color: transparent;
54}
55
56.qt-decorated-window.frameless {
57 background-color: transparent;
58}
59
60.resize-outline {
61 position: absolute;
62 display: none;
63}
64
65.qt-decorated-window.no-resize > .resize-outline { display: none; }
66
67.qt-decorated-window.has-border:not(.maximized):not(.no-resize) > .resize-outline {
68 display: block;
69}
70
71.resize-outline.nw {
72 left: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
73 top: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
74 width: var(--resize-outline-width);
75 height: var(--resize-outline-width);
76 cursor: nwse-resize;
77}
78
79.resize-outline.n {
80 left: var(--resize-outline-half-width);
81 top: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
82 height: var(--resize-outline-width);
83 width: calc(100% + 2 * var(--border-width) - var(--resize-outline-width));
84 cursor: ns-resize;
85}
86
87.resize-outline.ne {
88 left: calc(100% + var(--border-width) - var(--resize-outline-half-width));
89 top: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
90 width: var(--resize-outline-width);
91 height: var(--resize-outline-width);
92 cursor: nesw-resize;
93}
94
95.resize-outline.w {
96 left: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
97 top: 0;
98 height: calc(100% + 2 * var(--border-width) - var(--resize-outline-width));
99 width: var(--resize-outline-width);
100 cursor: ew-resize;
101}
102
103.resize-outline.e {
104 left: calc(100% + var(--border-width) - var(--resize-outline-half-width));
105 top: 0;
106 height: calc(100% + 2 * var(--border-width) - var(--resize-outline-width));
107 width: var(--resize-outline-width);
108 cursor: ew-resize;
109}
110
111.resize-outline.sw {
112 left: calc(-1 * var(--resize-outline-half-width) - var(--border-width));
113 top: calc(100% + var(--border-width) - var(--resize-outline-half-width));
114 width: var(--resize-outline-width);
115 height: var(--resize-outline-width);
116 cursor: nesw-resize;
117}
118
119.resize-outline.s {
120 left: var(--resize-outline-half-width);
121 top: calc(100% + var(--border-width) - var(--resize-outline-half-width));
122 height: var(--resize-outline-width);
123 width: calc(100% + 2 * var(--border-width) - var(--resize-outline-width));
124 cursor: ns-resize;
125}
126
127.resize-outline.se {
128 left: calc(100% + var(--border-width) - var(--resize-outline-half-width));
129 top: calc(100% + var(--border-width) - var(--resize-outline-half-width));
130 width: var(--resize-outline-width);
131 height: var(--resize-outline-width);
132 cursor: nwse-resize;
133}
134
135.title-bar {
136 display: none;
137 align-items: center;
138 overflow: hidden;
139 height: 18px;
140 padding-bottom: 4px;
141}
142
143.qt-decorated-window.has-border > .title-bar {
144 display: flex;
145}
146
147.title-bar .window-name {
148 display: none;
149 font-family: 'Lucida Grande';
150 white-space: nowrap;
151 user-select: none;
152 overflow: hidden;
153}
154
155
156.qt-decorated-window.has-title .title-bar .window-name {
157 display: block;
158}
159
160.title-bar .spacer {
161 flex-grow: 1
162}
163
164.qt-decorated-window.inactive .title-bar {
165 opacity: 0.35;
166}
167
168.qt-window {
169 display: flex;
170}
171
172.title-bar div {
173 pointer-events: none;
174}
175
176.qt-window-a11y-container {
177 position: absolute;
178 z-index: -1;
179}
180
181.title-bar .image-button {
182 width: 18px;
183 height: 18px;
184 display: flex;
185 justify-content: center;
186 user-select: none;
187 align-items: center;
188}
189
190.title-bar .image-button img {
191 width: 10px;
192 height: 10px;
193 user-select: none;
194 pointer-events: none;
195 -webkit-user-drag: none;
196 background-size: 10px 10px;
197}
198
199.title-bar .action-button {
200 pointer-events: all;
201}
202
203.qt-decorated-window.blocked div {
204 pointer-events: none;
205}
206
207.title-bar .action-button img {
208 transition: filter 0.08s ease-out;
209}
210
211.title-bar .action-button:hover img {
212 filter: invert(0.45);
213}
214
215.title-bar .action-button:active img {
216 filter: invert(0.6);
217}
218
219/* This will clip the content within 50% frame in 1x1 pixel area, preventing it
220 from being rendered on the page, but it should still be read by modern
221 screen readers */
222.hidden-visually-read-by-screen-reader {
223 visibility: visible;
224 clip: rect(1px, 1px, 1px, 1px);
225 clip-path: inset(50%);
226 height: 100%;
227 width: 100%;
228 margin: -1px;
229 overflow: hidden;
230 padding: 0;
231 position: absolute;
232}
233
234)css";
235
236} // namespace
237
239{
240 auto document = parent["ownerDocument"];
241 auto screenStyle = document.call<emscripten::val>("createElement", emscripten::val("style"));
242
243 screenStyle.set("textContent", std::string(Style));
244 return screenStyle;
245}
246
247QT_END_NAMESPACE
Combined button and popup list for selecting options.
emscripten::val createStyleElement(emscripten::val parent)