Compare commits
No commits in common. "19a4120113fa29a35c4bc60beb92da687ff1ac43" and "c0479604aa82ade60b6331726a6c64972f3e53cb" have entirely different histories.
19a4120113
...
c0479604aa
2
deps/ox/src/ox/claw/format.hpp
vendored
2
deps/ox/src/ox/claw/format.hpp
vendored
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
enum class ClawFormat {
|
enum class ClawFormat: int {
|
||||||
None,
|
None,
|
||||||
Metal,
|
Metal,
|
||||||
Organic,
|
Organic,
|
||||||
|
2
deps/ox/src/ox/preloader/preloader.hpp
vendored
2
deps/ox/src/ox/preloader/preloader.hpp
vendored
@ -381,6 +381,8 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
|
|||||||
|
|
||||||
template<typename PlatSpec>
|
template<typename PlatSpec>
|
||||||
constexpr ox::Error Preloader<PlatSpec>::fieldArray(CRStringView, ox::ModelValueArray const*val) noexcept {
|
constexpr ox::Error Preloader<PlatSpec>::fieldArray(CRStringView, ox::ModelValueArray const*val) noexcept {
|
||||||
|
oxDebugf("array size: {}", val->size());
|
||||||
|
oxDebugf("array sizeOf: {}", sizeOf<PlatSpec>(val));
|
||||||
oxReturnError(pad(&(*val)[0]));
|
oxReturnError(pad(&(*val)[0]));
|
||||||
for (auto const&v : *val) {
|
for (auto const&v : *val) {
|
||||||
oxReturnError(this->interface()->field({}, &v));
|
oxReturnError(this->interface()->field({}, &v));
|
||||||
|
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
1
deps/ox/src/ox/std/CMakeLists.txt
vendored
@ -96,7 +96,6 @@ install(
|
|||||||
buildinfo.hpp
|
buildinfo.hpp
|
||||||
byteswap.hpp
|
byteswap.hpp
|
||||||
concepts.hpp
|
concepts.hpp
|
||||||
conv.hpp
|
|
||||||
def.hpp
|
def.hpp
|
||||||
defer.hpp
|
defer.hpp
|
||||||
defines.hpp
|
defines.hpp
|
||||||
|
2
deps/ox/src/ox/std/bit.hpp
vendored
2
deps/ox/src/ox/std/bit.hpp
vendored
@ -32,7 +32,7 @@ constexpr To bit_cast(const From &src) noexcept requires(sizeof(To) == sizeof(Fr
|
|||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
template<typename To, typename From>
|
template<typename To, typename From>
|
||||||
constexpr To cbit_cast(From src) noexcept requires(sizeof(To) == sizeof(From)) {
|
constexpr typename enable_if<sizeof(To) == sizeof(From), To>::type cbit_cast(From src) noexcept {
|
||||||
To dst = {};
|
To dst = {};
|
||||||
ox::memcpy(&dst, &src, sizeof(src));
|
ox::memcpy(&dst, &src, sizeof(src));
|
||||||
return dst;
|
return dst;
|
||||||
|
45
deps/ox/src/ox/std/conv.hpp
vendored
45
deps/ox/src/ox/std/conv.hpp
vendored
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "point.hpp"
|
|
||||||
#include "size.hpp"
|
|
||||||
#include "vec.hpp"
|
|
||||||
|
|
||||||
namespace ox {
|
|
||||||
|
|
||||||
constexpr Vec2::operator Point() const noexcept {
|
|
||||||
return {
|
|
||||||
static_cast<int32_t>(x),
|
|
||||||
static_cast<int32_t>(y),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2::operator Size() const noexcept {
|
|
||||||
return {
|
|
||||||
static_cast<int32_t>(x),
|
|
||||||
static_cast<int32_t>(y),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Point::operator Vec2() const noexcept {
|
|
||||||
return {
|
|
||||||
static_cast<float>(x),
|
|
||||||
static_cast<float>(y),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Size::operator Vec2() const noexcept {
|
|
||||||
return {
|
|
||||||
static_cast<float>(width),
|
|
||||||
static_cast<float>(height),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
1
deps/ox/src/ox/std/point.hpp
vendored
1
deps/ox/src/ox/std/point.hpp
vendored
@ -64,7 +64,6 @@ class Point {
|
|||||||
|
|
||||||
constexpr bool operator!=(const Point&) const noexcept;
|
constexpr bool operator!=(const Point&) const noexcept;
|
||||||
|
|
||||||
explicit constexpr operator class Vec2() const noexcept;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Point::Point(int x, int y) noexcept {
|
constexpr Point::Point(int x, int y) noexcept {
|
||||||
|
1
deps/ox/src/ox/std/size.hpp
vendored
1
deps/ox/src/ox/std/size.hpp
vendored
@ -64,7 +64,6 @@ class Size {
|
|||||||
|
|
||||||
constexpr bool operator!=(const Size&) const noexcept;
|
constexpr bool operator!=(const Size&) const noexcept;
|
||||||
|
|
||||||
explicit constexpr operator class Vec2() const noexcept;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Size::Size(int width, int height) noexcept {
|
constexpr Size::Size(int width, int height) noexcept {
|
||||||
|
7
deps/ox/src/ox/std/smallmap.hpp
vendored
7
deps/ox/src/ox/std/smallmap.hpp
vendored
@ -39,6 +39,8 @@ class SmallMap {
|
|||||||
|
|
||||||
constexpr SmallMap(SmallMap &&other) noexcept;
|
constexpr SmallMap(SmallMap &&other) noexcept;
|
||||||
|
|
||||||
|
constexpr ~SmallMap();
|
||||||
|
|
||||||
constexpr bool operator==(SmallMap const&other) const;
|
constexpr bool operator==(SmallMap const&other) const;
|
||||||
|
|
||||||
constexpr SmallMap &operator=(SmallMap const&other);
|
constexpr SmallMap &operator=(SmallMap const&other);
|
||||||
@ -103,6 +105,11 @@ constexpr SmallMap<K, T, SmallSz>::SmallMap(SmallMap<K, T, SmallSz> &&other) noe
|
|||||||
m_pairs = std::move(other.m_pairs);
|
m_pairs = std::move(other.m_pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename K, typename T, size_t SmallSz>
|
||||||
|
constexpr SmallMap<K, T, SmallSz>::~SmallMap() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename K, typename T, size_t SmallSz>
|
template<typename K, typename T, size_t SmallSz>
|
||||||
constexpr bool SmallMap<K, T, SmallSz>::operator==(SmallMap const&other) const {
|
constexpr bool SmallMap<K, T, SmallSz>::operator==(SmallMap const&other) const {
|
||||||
return m_pairs == other.m_pairs;
|
return m_pairs == other.m_pairs;
|
||||||
|
1
deps/ox/src/ox/std/std.hpp
vendored
1
deps/ox/src/ox/std/std.hpp
vendored
@ -16,7 +16,6 @@
|
|||||||
#include "istring.hpp"
|
#include "istring.hpp"
|
||||||
#include "byteswap.hpp"
|
#include "byteswap.hpp"
|
||||||
#include "concepts.hpp"
|
#include "concepts.hpp"
|
||||||
#include "conv.hpp"
|
|
||||||
#include "cstringview.hpp"
|
#include "cstringview.hpp"
|
||||||
#include "cstrops.hpp"
|
#include "cstrops.hpp"
|
||||||
#include "def.hpp"
|
#include "def.hpp"
|
||||||
|
14
deps/ox/src/ox/std/test/tests.cpp
vendored
14
deps/ox/src/ox/std/test/tests.cpp
vendored
@ -18,12 +18,12 @@
|
|||||||
#include <ox/std/std.hpp>
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static uint64_t steadyNowMs() {
|
static uint64_t nowMs() {
|
||||||
#if __has_include(<chrono>)
|
#if __has_include(<chrono>)
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
return static_cast<uint64_t>(
|
return static_cast<uint64_t>(
|
||||||
duration_cast<milliseconds>(
|
duration_cast<milliseconds>(
|
||||||
steady_clock::now().time_since_epoch()).count());
|
system_clock::now().time_since_epoch()).count());
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@ -41,13 +41,13 @@ uint64_t timeMapStrToUuid(int elemCnt, int lookups, uint64_t seed = 4321) noexce
|
|||||||
auto const keys = map.keys();
|
auto const keys = map.keys();
|
||||||
ox::Random rand;
|
ox::Random rand;
|
||||||
// start
|
// start
|
||||||
auto const startTime = steadyNowMs();
|
auto const startTime = nowMs();
|
||||||
for (int i = 0; i < lookups; ++i) {
|
for (int i = 0; i < lookups; ++i) {
|
||||||
auto const&k = keys[rand.gen() % keys.size()];
|
auto const&k = keys[rand.gen() % keys.size()];
|
||||||
map[k];
|
map[k];
|
||||||
oxExpect(map[k], ox::UUID::fromString(k).unwrap());
|
oxExpect(map[k], ox::UUID::fromString(k).unwrap());
|
||||||
}
|
}
|
||||||
return steadyNowMs() - startTime;
|
return nowMs() - startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Map = ox::SmallMap<ox::UUID, ox::String>>
|
template<typename Map = ox::SmallMap<ox::UUID, ox::String>>
|
||||||
@ -62,16 +62,16 @@ uint64_t timeMapUuidToStr(int elemCnt, int lookups, uint64_t seed = 4321) noexce
|
|||||||
auto const keys = map.keys();
|
auto const keys = map.keys();
|
||||||
ox::Random rand;
|
ox::Random rand;
|
||||||
// start
|
// start
|
||||||
auto const startTime = steadyNowMs();
|
auto const startTime = nowMs();
|
||||||
for (int i = 0; i < lookups; ++i) {
|
for (int i = 0; i < lookups; ++i) {
|
||||||
auto const&k = keys[rand.gen() % keys.size()];
|
auto const&k = keys[rand.gen() % keys.size()];
|
||||||
oxExpect(map[k], k.toString());
|
oxExpect(map[k], k.toString());
|
||||||
}
|
}
|
||||||
return steadyNowMs() - startTime;
|
return nowMs() - startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error compareMaps(int lookupCnt = 1'000'000) {
|
static ox::Error compareMaps(int lookupCnt = 1'000'000) {
|
||||||
auto const seed = steadyNowMs();
|
auto const seed = nowMs();
|
||||||
uint64_t hashTime{};
|
uint64_t hashTime{};
|
||||||
uint64_t smallTime{};
|
uint64_t smallTime{};
|
||||||
int elemCnt = 1;
|
int elemCnt = 1;
|
||||||
|
2
deps/ox/src/ox/std/typetraits.hpp
vendored
2
deps/ox/src/ox/std/typetraits.hpp
vendored
@ -185,8 +185,6 @@ struct enable_if<true, T> {
|
|||||||
using type = T;
|
using type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<bool B, typename T>
|
|
||||||
using enable_if_t = typename enable_if<B, T>::type;
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_pointer {
|
struct is_pointer {
|
||||||
|
71
deps/ox/src/ox/std/vec.hpp
vendored
71
deps/ox/src/ox/std/vec.hpp
vendored
@ -23,16 +23,17 @@
|
|||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
class Vec2 {
|
template<typename T>
|
||||||
|
struct Vec {
|
||||||
public:
|
public:
|
||||||
using value_type = float;
|
using value_type = T;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
|
|
||||||
static constexpr auto TypeName = "net.drinkingtea.ox.Point";
|
static constexpr auto TypeName = "net.drinkingtea.ox.Point";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
|
|
||||||
float x = 0;
|
T x = 0;
|
||||||
float y = 0;
|
T y = 0;
|
||||||
|
|
||||||
template<typename RefType = value_type&, typename PtrType = value_type*, bool reverse = false>
|
template<typename RefType = value_type&, typename PtrType = value_type*, bool reverse = false>
|
||||||
struct iterator: public ox::Iterator<std::bidirectional_iterator_tag, value_type> {
|
struct iterator: public ox::Iterator<std::bidirectional_iterator_tag, value_type> {
|
||||||
@ -140,14 +141,14 @@ class Vec2 {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Vec2() noexcept = default;
|
constexpr Vec() noexcept = default;
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
constexpr Vec2(float pX, float pY) noexcept: x(pX), y(pY) {
|
constexpr Vec(T pX, T pY) noexcept: x(pX), y(pY) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __has_include(<imgui.h>)
|
#if __has_include(<imgui.h>)
|
||||||
explicit constexpr Vec2(const ImVec2 &v) noexcept: Vec2(v.x, v.y) {
|
explicit constexpr Vec(const ImVec2 &v) noexcept: Vec(v.x, v.y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit inline operator ImVec2() const noexcept {
|
explicit inline operator ImVec2() const noexcept {
|
||||||
@ -227,7 +228,7 @@ class Vec2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto operator==(const Vec2 &v) const noexcept {
|
constexpr auto operator==(const Vec &v) const noexcept {
|
||||||
for (auto i = 0u; i < v.size(); ++i) {
|
for (auto i = 0u; i < v.size(); ++i) {
|
||||||
if ((*this)[i] != v[i]) {
|
if ((*this)[i] != v[i]) {
|
||||||
return false;
|
return false;
|
||||||
@ -236,71 +237,29 @@ class Vec2 {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto operator!=(const Vec2 &v) const noexcept {
|
constexpr auto operator!=(const Vec &v) const noexcept {
|
||||||
return !operator==(v);
|
return !operator==(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit constexpr operator class Point() const noexcept;
|
|
||||||
|
|
||||||
explicit constexpr operator class Size() const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t size() const noexcept {
|
constexpr std::size_t size() const noexcept {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vec2 operator+(float i) const noexcept {
|
|
||||||
return {x + i, y + i};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator+=(float i) noexcept {
|
|
||||||
x += i;
|
|
||||||
y += i;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator-(float i) const noexcept {
|
|
||||||
return {x - i, y - i};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator-=(float i) noexcept {
|
|
||||||
x -= i;
|
|
||||||
y -= i;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator*(float i) const noexcept {
|
|
||||||
return {x * i, y * i};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator*=(float i) noexcept {
|
|
||||||
x *= i;
|
|
||||||
y *= i;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator/(float i) const noexcept {
|
|
||||||
return {x / i, y / i};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr Vec2 operator/=(float i) noexcept {
|
|
||||||
x /= i;
|
|
||||||
y /= i;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr float *start() noexcept {
|
constexpr T *start() noexcept {
|
||||||
return&x;
|
return &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr const float *start() const noexcept {
|
constexpr const T *start() const noexcept {
|
||||||
return &x;
|
return &x;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using Vec2 = Vec<float>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr Error model(T *io, ox::CommonPtrWith<Vec2> auto *obj) noexcept {
|
constexpr Error model(T *io, ox::CommonPtrWith<Vec2> auto *obj) noexcept {
|
||||||
oxReturnError(io->template setTypeInfo<Vec2>());
|
oxReturnError(io->template setTypeInfo<Vec2>());
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ox/std/math.hpp>
|
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
@ -136,7 +135,7 @@ constexpr Color16 color16(int r, int g, int b, int a = 0) noexcept {
|
|||||||
return static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(r), 31))
|
return static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(r), 31))
|
||||||
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(g), 31) << 5)
|
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(g), 31) << 5)
|
||||||
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(b), 31) << 10)
|
| static_cast<Color16>(ox::min<uint8_t>(static_cast<uint8_t>(b), 31) << 10)
|
||||||
| static_cast<Color16>(a << 15);
|
| static_cast<Color16>(a << 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
@ -152,13 +151,4 @@ static_assert(color16(16, 31, 0) == 1008);
|
|||||||
static_assert(color16(16, 31, 8) == 9200);
|
static_assert(color16(16, 31, 8) == 9200);
|
||||||
static_assert(color16(16, 32, 8) == 9200);
|
static_assert(color16(16, 32, 8) == 9200);
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr Color16 applySelectionColor(Color16 const color) noexcept {
|
|
||||||
namespace core = nostalgia::core;
|
|
||||||
auto const r = core::red16(color) / 2;
|
|
||||||
auto const g = (core::green16(color) + 20) / 2;
|
|
||||||
auto const b = (core::blue16(color) + 31) / 2;
|
|
||||||
return core::color16(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -385,8 +385,7 @@ static void setSprite(
|
|||||||
uint_t const idx,
|
uint_t const idx,
|
||||||
Sprite const&s) noexcept {
|
Sprite const&s) noexcept {
|
||||||
// Tonc Table 8.4
|
// Tonc Table 8.4
|
||||||
struct Sz { uint_t x{}, y{}; };
|
static constexpr ox::Array<ox::Vec<uint_t>, 12> dimensions{
|
||||||
static constexpr ox::Array<Sz, 12> dimensions{
|
|
||||||
// col 0
|
// col 0
|
||||||
{1, 1}, // 0, 0
|
{1, 1}, // 0, 0
|
||||||
{2, 2}, // 0, 1
|
{2, 2}, // 0, 1
|
||||||
|
@ -139,7 +139,10 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_model.pixelSelected(i)) {
|
if (m_model.pixelSelected(i)) {
|
||||||
color = applySelectionColor(color);
|
auto const r = red16(color) / 2;
|
||||||
|
auto const g = (green16(color) + 20) / 2;
|
||||||
|
auto const b = (blue16(color) + 31) / 2;
|
||||||
|
color = color16(r, g, b);
|
||||||
}
|
}
|
||||||
setPixelBufferObject(paneSize, static_cast<unsigned>(i * VertexVboRows), fx, fy, color, vbo, ebo);
|
setPixelBufferObject(paneSize, static_cast<unsigned>(i * VertexVboRows), fx, fy, color, vbo, ebo);
|
||||||
});
|
});
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <imgui.h>
|
|
||||||
|
|
||||||
#include <ox/std/math.hpp>
|
|
||||||
#include <ox/std/point.hpp>
|
|
||||||
#include <ox/std/typetraits.hpp>
|
|
||||||
|
|
||||||
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(retErr) {
|
|
||||||
oxReturnError(cb(x, y));
|
|
||||||
} else {
|
|
||||||
cb(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if constexpr(retErr) {
|
|
||||||
return ox::Error{};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SelectionTracker {
|
|
||||||
private:
|
|
||||||
bool m_selectionOngoing{};
|
|
||||||
ox::Point m_pointA;
|
|
||||||
ox::Point m_pointB;
|
|
||||||
public:
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr bool selectionOngoing() const noexcept {
|
|
||||||
return m_selectionOngoing;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void startSelection(ox::Point cursor) noexcept {
|
|
||||||
m_pointA = cursor;
|
|
||||||
m_pointB = cursor;
|
|
||||||
m_selectionOngoing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void updateCursorPoint(ox::Point cursor, bool allowStart = true) noexcept {
|
|
||||||
if (!m_selectionOngoing && allowStart) {
|
|
||||||
m_pointA = cursor;
|
|
||||||
m_selectionOngoing = true;
|
|
||||||
}
|
|
||||||
if (m_selectionOngoing) {
|
|
||||||
m_pointB = cursor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void updateCursorPoint(ox::Vec2 cursor, bool allowStart = true) noexcept {
|
|
||||||
updateCursorPoint(
|
|
||||||
ox::Point{
|
|
||||||
static_cast<int32_t>(cursor.x),
|
|
||||||
static_cast<int32_t>(cursor.y),
|
|
||||||
},
|
|
||||||
allowStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void updateCursorPoint(ImVec2 cursor, bool allowStart = true) noexcept {
|
|
||||||
updateCursorPoint(
|
|
||||||
ox::Point{
|
|
||||||
static_cast<int32_t>(cursor.x),
|
|
||||||
static_cast<int32_t>(cursor.y),
|
|
||||||
},
|
|
||||||
allowStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void finishSelection() noexcept {
|
|
||||||
m_selectionOngoing = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr Selection selection() const noexcept {
|
|
||||||
return {
|
|
||||||
{
|
|
||||||
ox::min(m_pointA.x, m_pointB.x),
|
|
||||||
ox::min(m_pointA.y, m_pointB.y),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ox::max(m_pointA.x, m_pointB.x),
|
|
||||||
ox::max(m_pointA.y, m_pointB.y),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -12,7 +12,6 @@
|
|||||||
#include <studio/itemmaker.hpp>
|
#include <studio/itemmaker.hpp>
|
||||||
#include <studio/popup.hpp>
|
#include <studio/popup.hpp>
|
||||||
#include <studio/project.hpp>
|
#include <studio/project.hpp>
|
||||||
#include <studio/selectiontracker.hpp>
|
|
||||||
#include <studio/task.hpp>
|
#include <studio/task.hpp>
|
||||||
#include <studio/undocommand.hpp>
|
#include <studio/undocommand.hpp>
|
||||||
#include <studio/undostack.hpp>
|
#include <studio/undostack.hpp>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user