27 int x1 = std::max<int>(a.
x, b.
x);
28 int y1 = std::max<int>(a.
y, b.
y);
29 int x2 = std::min<int>(a.
x + a.
w, b.
x + b.
w);
30 int y2 = std::min<int>(a.
y + a.
h, b.
y + b.
h);
31 int w = std::max(0, x2 - x1);
32 int h = std::max(0, y2 - y1);
33 return {x1, y1, w, h};
38static constexpr void normalize(T& x, T& w)
57 std::optional<std::array<GLint, 4>> origClip;
65 normalize(x, w); normalize(y, h);
71 auto [iw, ih] = round(wh *
scale);
73 if (glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE) {
75 glGetIntegerv(GL_SCISSOR_BOX, origClip->data());
76 auto [xn, yn, wn, hn] = intersect(
77 Rectangle{(*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3]},
79 glScissor(xn, yn, wn, hn);
81 glScissor(ix, iy, iw, ih);
82 glEnable(GL_SCISSOR_TEST);
89 glScissor((*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3]);
91 glDisable(GL_SCISSOR_TEST);
99 , name(
std::move(name_))
105 widget->setParent(
this);
115 float widgetZ = widget->getZ();
116 if (subWidgets.empty() || (subWidgets.back()->getZ() <= widgetZ)) {
117 subWidgets.push_back(std::move(widget));
119 auto it =
begin(subWidgets);
120 while ((*it)->getZ() <= widgetZ) ++it;
121 subWidgets.insert(it, std::move(widget));
129 [](
const auto& p) {
return p.get(); });
130 subWidgets.erase(it);
133void OSDWidget::resortUp(
const OSDWidget* elem)
136 auto it1 =
begin(subWidgets);
137 while (it1->get() != elem) ++it1;
139 float elemZ = elem->
getZ();
142 while ((it2 !=
end(subWidgets)) && ((*it2)->getZ() < elemZ)) ++it2;
144 rotate(it1, it1 + 1, it2);
149void OSDWidget::resortDown(
const OSDWidget* elem)
152 auto it1 =
begin(subWidgets);
153 float elemZ = elem->getZ();
154 while ((*it1)->getZ() <= elemZ) {
156 if (it1 ==
end(subWidgets))
return;
160 if ((it2 !=
begin(subWidgets)) && ((it2 - 1)->get() == elem))
return;
161 while (it2->get() != elem) ++it2;
163 rotate(it1, it2, it2 + 1);
172 if (propName ==
"-type") {
174 }
else if (propName ==
"-mousecoord") {
176 }
else if (propName ==
"-x") {
178 }
else if (propName ==
"-y") {
180 }
else if (propName ==
"-z") {
194 }
else if (propName ==
"-relx") {
196 }
else if (propName ==
"-rely") {
198 }
else if (propName ==
"-scaled") {
200 if (scaled != scaled2) {
204 }
else if (propName ==
"-clip") {
206 }
else if (propName ==
"-suppressErrors") {
215 if (propName ==
"-type") {
217 }
else if (propName ==
"-x") {
219 }
else if (propName ==
"-y") {
221 }
else if (propName ==
"-z") {
223 }
else if (propName ==
"-relx") {
225 }
else if (propName ==
"-rely") {
227 }
else if (propName ==
"-scaled") {
229 }
else if (propName ==
"-clip") {
231 }
else if (propName ==
"-mousecoord") {
232 auto [x, y] = getMouseCoord();
234 }
else if (propName ==
"-suppressErrors") {
235 result = suppressErrors;
254 for (
auto& s : subWidgets) {
255 s->invalidateRecursive();
261 if (suppressErrors)
return true;
263 return p->needSuppressErrors();
272 std::optional<GLScopedClip> scopedClip;
275 scopedClip.emplace(output, clipPos, size);
278 for (
const auto& s : subWidgets) {
279 s->paintRecursive(output);
299 + (trRelPos *
getSize(output));
301 out = p->transformPos(output, out,
getRelPos());
309 trPos = p->transformReverse(output, trPos);
318vec2 OSDWidget::getMouseCoord()
const
321 if (!videoSystem.getCursorEnabled()) {
337 return vec2(std::numeric_limits<float>::infinity());
342 throw CommandException(
343 "Can't get mouse coordinates: no window visible");
346 vec2 out = transformReverse(*output,
vec2(videoSystem.getMouseCoord()));
348 if ((
size.x == 0.0f) || (
size.y == 0.0f)) {
349 throw CommandException(
350 "-can't get mouse coordinates: "
351 "widget has zero width or height");
360 return {topLeft, bottomRight - topLeft};
Represents the output window/screen of openMSX.
VideoSystem & getVideoSystem()
OutputSurface * getOutputSurface()
GLScopedClip(GLScopedClip &&)=delete
GLScopedClip(const GLScopedClip &)=delete
GLScopedClip(const OutputSurface &output, vec2 xy, vec2 wh)
GLScopedClip & operator=(const GLScopedClip &)=delete
GLScopedClip & operator=(GLScopedClip &&)=delete
A frame buffer where pixels can be written to.
int getLogicalWidth() const
gl::vec2 getViewScale() const
gl::ivec2 getViewOffset() const
int getLogicalHeight() const
bool getBoolean(Interpreter &interp) const
float getFloat(Interpreter &interp) const
void addListElement(const T &t)
mat4 rotate(float angle, const vec3 &axis)
constexpr mat4 scale(const vec3 &xyz)
This file implemented 3 utility functions:
bool is_sorted(ForwardRange &&range, Compare comp={}, Proj proj={})
size_t size(std::string_view utf8)
auto rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)