23static constexpr IntersectResult intersect(
int xa,
int ya,
int wa,
int ha,
24 int xb,
int yb,
int wb,
int hb)
26 int x1 = std::max<int>(xa, xb);
27 int y1 = std::max<int>(ya, yb);
28 int x2 = std::min<int>(xa + wa, xb + wb);
29 int y2 = std::min<int>(ya + ha, yb + hb);
32 return {x1, y1, w, h};
37static constexpr void normalize(T& x, T& w)
54 std::optional<std::array<GLint, 4>> origClip;
62 normalize(x, w); normalize(y, h);
68 auto [iw, ih] = round(wh *
scale);
70 if (glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE) {
72 glGetIntegerv(GL_SCISSOR_BOX, origClip->data());
73 auto [xn, yn, wn, hn] = intersect(
74 (*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3],
76 glScissor(xn, yn, wn, hn);
78 glScissor(ix, iy, iw, ih);
79 glEnable(GL_SCISSOR_TEST);
86 glScissor((*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3]);
88 glDisable(GL_SCISSOR_TEST);
96 , name(
std::move(name_))
102 widget->setParent(
this);
112 float widgetZ = widget->getZ();
113 if (subWidgets.empty() || (subWidgets.back()->getZ() <= widgetZ)) {
114 subWidgets.push_back(std::move(widget));
116 auto it =
begin(subWidgets);
117 while ((*it)->getZ() <= widgetZ) ++it;
118 subWidgets.insert(it, std::move(widget));
126 [](
const auto& p) {
return p.get(); });
127 subWidgets.erase(it);
133 auto it1 =
begin(subWidgets);
134 while (it1->get() != elem) ++it1;
136 float elemZ = elem->
getZ();
139 while ((it2 !=
end(subWidgets)) && ((*it2)->getZ() < elemZ)) ++it2;
141 rotate(it1, it1 + 1, it2);
146void OSDWidget::resortDown(OSDWidget* elem)
149 auto it1 =
begin(subWidgets);
150 float elemZ = elem->getZ();
151 while ((*it1)->getZ() <= elemZ) {
153 if (it1 ==
end(subWidgets))
return;
157 if ((it2 !=
begin(subWidgets)) && ((it2 - 1)->get() == elem))
return;
158 while (it2->get() != elem) ++it2;
160 rotate(it1, it2, it2 + 1);
169 if (propName ==
"-type") {
171 }
else if (propName ==
"-mousecoord") {
173 }
else if (propName ==
"-x") {
175 }
else if (propName ==
"-y") {
177 }
else if (propName ==
"-z") {
191 }
else if (propName ==
"-relx") {
193 }
else if (propName ==
"-rely") {
195 }
else if (propName ==
"-scaled") {
197 if (scaled != scaled2) {
201 }
else if (propName ==
"-clip") {
203 }
else if (propName ==
"-suppressErrors") {
212 if (propName ==
"-type") {
214 }
else if (propName ==
"-x") {
216 }
else if (propName ==
"-y") {
218 }
else if (propName ==
"-z") {
220 }
else if (propName ==
"-relx") {
222 }
else if (propName ==
"-rely") {
224 }
else if (propName ==
"-scaled") {
226 }
else if (propName ==
"-clip") {
228 }
else if (propName ==
"-mousecoord") {
229 auto [x, y] = getMouseCoord();
231 }
else if (propName ==
"-suppressErrors") {
232 result = suppressErrors;
251 for (
auto& s : subWidgets) {
252 s->invalidateRecursive();
258 if (suppressErrors)
return true;
260 return p->needSuppressErrors();
269 std::optional<GLScopedClip> scopedClip;
273 scopedClip.emplace(output, clipPos,
size);
276 for (
auto& s : subWidgets) {
277 s->paintRecursive(output);
297 + (trRelPos *
getSize(output));
299 out = p->transformPos(output, out,
getRelPos());
307 trPos = p->transformReverse(output, trPos);
316vec2 OSDWidget::getMouseCoord()
const
319 if (!videoSystem.getCursorEnabled()) {
335 return vec2(std::numeric_limits<float>::infinity());
340 throw CommandException(
341 "Can't get mouse coordinates: no window visible");
344 vec2 out = transformReverse(*output,
vec2(videoSystem.getMouseCoord()));
346 if ((
size[0] == 0.0f) || (
size[1] == 0.0f)) {
347 throw CommandException(
348 "-can't get mouse coordinates: "
349 "widget has zero width or height");
360 bbSize = bottomRight - topLeft;
Represents the output window/screen of openMSX.
VideoSystem & getVideoSystem()
OutputSurface * getOutputSurface()
GLScopedClip(const GLScopedClip &)=delete
GLScopedClip(OutputSurface &output, vec2 xy, vec2 wh)
GLScopedClip & operator=(const 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 vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
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)