25static constexpr IntersectResult intersect(
int xa,
int ya,
int wa,
int ha,
26 int xb,
int yb,
int wb,
int hb)
28 int x1 = std::max<int>(xa, xb);
29 int y1 = std::max<int>(ya, yb);
30 int x2 = std::min<int>(xa + wa, xb + wb);
31 int y2 = std::min<int>(ya + ha, yb + hb);
32 int w = std::max(0, x2 - x1);
33 int h = std::max(0, y2 - y1);
34 return {x1, y1, w, h};
39static constexpr void normalize(T& x, T& w)
58 std::optional<std::array<GLint, 4>> origClip;
66 normalize(x, w); normalize(y, h);
72 auto [iw, ih] = round(wh *
scale);
74 if (glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE) {
76 glGetIntegerv(GL_SCISSOR_BOX, origClip->data());
77 auto [xn, yn, wn, hn] = intersect(
78 (*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3],
80 glScissor(xn, yn, wn, hn);
82 glScissor(ix, iy, iw, ih);
83 glEnable(GL_SCISSOR_TEST);
90 glScissor((*origClip)[0], (*origClip)[1], (*origClip)[2], (*origClip)[3]);
92 glDisable(GL_SCISSOR_TEST);
100 , name(
std::move(name_))
106 widget->setParent(
this);
116 float widgetZ = widget->getZ();
117 if (subWidgets.empty() || (subWidgets.back()->getZ() <= widgetZ)) {
118 subWidgets.push_back(std::move(widget));
120 auto it =
begin(subWidgets);
121 while ((*it)->getZ() <= widgetZ) ++it;
122 subWidgets.insert(it, std::move(widget));
130 [](
const auto& p) {
return p.get(); });
131 subWidgets.erase(it);
134void OSDWidget::resortUp(
const OSDWidget* elem)
137 auto it1 =
begin(subWidgets);
138 while (it1->get() != elem) ++it1;
140 float elemZ = elem->
getZ();
143 while ((it2 !=
end(subWidgets)) && ((*it2)->getZ() < elemZ)) ++it2;
145 rotate(it1, it1 + 1, it2);
150void OSDWidget::resortDown(
const OSDWidget* elem)
153 auto it1 =
begin(subWidgets);
154 float elemZ = elem->getZ();
155 while ((*it1)->getZ() <= elemZ) {
157 if (it1 ==
end(subWidgets))
return;
161 if ((it2 !=
begin(subWidgets)) && ((it2 - 1)->get() == elem))
return;
162 while (it2->get() != elem) ++it2;
164 rotate(it1, it2, it2 + 1);
173 if (propName ==
"-type") {
175 }
else if (propName ==
"-mousecoord") {
177 }
else if (propName ==
"-x") {
179 }
else if (propName ==
"-y") {
181 }
else if (propName ==
"-z") {
195 }
else if (propName ==
"-relx") {
197 }
else if (propName ==
"-rely") {
199 }
else if (propName ==
"-scaled") {
201 if (scaled != scaled2) {
205 }
else if (propName ==
"-clip") {
207 }
else if (propName ==
"-suppressErrors") {
216 if (propName ==
"-type") {
218 }
else if (propName ==
"-x") {
220 }
else if (propName ==
"-y") {
222 }
else if (propName ==
"-z") {
224 }
else if (propName ==
"-relx") {
226 }
else if (propName ==
"-rely") {
228 }
else if (propName ==
"-scaled") {
230 }
else if (propName ==
"-clip") {
232 }
else if (propName ==
"-mousecoord") {
233 auto [x, y] = getMouseCoord();
235 }
else if (propName ==
"-suppressErrors") {
236 result = suppressErrors;
255 for (
auto& s : subWidgets) {
256 s->invalidateRecursive();
262 if (suppressErrors)
return true;
264 return p->needSuppressErrors();
273 std::optional<GLScopedClip> scopedClip;
276 scopedClip.emplace(output, clipPos, size);
279 for (
auto& s : subWidgets) {
280 s->paintRecursive(output);
300 + (trRelPos *
getSize(output));
302 out = p->transformPos(output, out,
getRelPos());
310 trPos = p->transformReverse(output, trPos);
319vec2 OSDWidget::getMouseCoord()
const
322 if (!videoSystem.getCursorEnabled()) {
338 return vec2(std::numeric_limits<float>::infinity());
343 throw CommandException(
344 "Can't get mouse coordinates: no window visible");
347 vec2 out = transformReverse(*output,
vec2(videoSystem.getMouseCoord()));
349 if ((
size.x == 0.0f) || (
size.y == 0.0f)) {
350 throw CommandException(
351 "-can't get mouse coordinates: "
352 "widget has zero width or height");
361 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)