[studio/modlib] Make iterateSelection return errors properly
All checks were successful
Build / build (push) Successful in 2m29s
All checks were successful
Build / build (push) Successful in 2m29s
This commit is contained in:
parent
f69b8afa62
commit
19a4120113
@ -12,15 +12,19 @@ namespace studio {
|
||||
struct Selection {ox::Point a, b;};
|
||||
|
||||
constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
|
||||
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||
if constexpr(ox::is_same_v<decltype(cb(x, y)), ox::Error>) {
|
||||
return cb(x, y);
|
||||
if constexpr(retErr) {
|
||||
oxReturnError(cb(x, y));
|
||||
} else {
|
||||
cb(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
if constexpr(retErr) {
|
||||
return ox::Error{};
|
||||
}
|
||||
};
|
||||
|
||||
class SelectionTracker {
|
||||
|
Loading…
x
Reference in New Issue
Block a user