ugh silly
parent
e164a1537c
commit
80dee921b4
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(graphs VERSION 0.1.9)
|
project(graphs VERSION 0.1.10)
|
||||||
|
|
||||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||||
|
|
|
@ -29,7 +29,8 @@ namespace conf
|
||||||
inline constexpr float DEFAULT_SPRING_LENGTH = 175.0;
|
inline constexpr float DEFAULT_SPRING_LENGTH = 175.0;
|
||||||
inline constexpr float DEFAULT_INITIAL_TEMPERATURE = 100;
|
inline constexpr float DEFAULT_INITIAL_TEMPERATURE = 100;
|
||||||
|
|
||||||
inline constexpr float POINT_SIZE = 35;
|
inline constexpr float POINT_SIZE = 75;
|
||||||
|
inline constexpr float OUTLINE_SCALE = 1.25f;
|
||||||
inline constexpr auto DEFAULT_IMAGE = "unknown";
|
inline constexpr auto DEFAULT_IMAGE = "unknown";
|
||||||
inline constexpr auto POINT_OUTLINE_COLOR = blt::make_color(0, 0.6, 0.6);
|
inline constexpr auto POINT_OUTLINE_COLOR = blt::make_color(0, 0.6, 0.6);
|
||||||
inline constexpr auto POINT_HIGHLIGHT_COLOR = blt::make_color(0, 1.0, 1.0);
|
inline constexpr auto POINT_HIGHLIGHT_COLOR = blt::make_color(0, 1.0, 1.0);
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct node_t
|
||||||
|
|
||||||
blt::gfx::point2d_t point;
|
blt::gfx::point2d_t point;
|
||||||
blt::vec2 velocity;
|
blt::vec2 velocity;
|
||||||
float outline_scale = 1.25f;
|
float outline_scale = conf::OUTLINE_SCALE;
|
||||||
blt::color4 outline_color = conf::POINT_OUTLINE_COLOR;
|
blt::color4 outline_color = conf::POINT_OUTLINE_COLOR;
|
||||||
|
|
||||||
explicit node_t(const blt::gfx::point2d_t& point): name(get_name()), point(point)
|
explicit node_t(const blt::gfx::point2d_t& point): name(get_name()), point(point)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ff2c8e3be8aea2c3324cd9d7c2575085a7f1b56e
|
Subproject commit c01cb757a1d19fa8e06292dcb61a5b5769979f11
|
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
|
@ -71,11 +71,24 @@ std::optional<loader_t> loader_t::load_for(engine_t& engine, const blt::gfx::win
|
||||||
auto size = static_cast<blt::f32>(load_with_default(node, "size", static_cast<blt::f64>(conf::POINT_SIZE)));
|
auto size = static_cast<blt::f32>(load_with_default(node, "size", static_cast<blt::f64>(conf::POINT_SIZE)));
|
||||||
auto name = load_with_default<std::string>(node, "name", get_name());
|
auto name = load_with_default<std::string>(node, "name", get_name());
|
||||||
auto texture = load_with_default<std::string>(node, "texture", conf::DEFAULT_IMAGE);
|
auto texture = load_with_default<std::string>(node, "texture", conf::DEFAULT_IMAGE);
|
||||||
|
auto outline_scale = load_with_default(node, "scale", conf::OUTLINE_SCALE);
|
||||||
|
auto outline_color = load_with_default(node, "color", json::array());
|
||||||
|
|
||||||
BLT_ASSERT(!graph.names_to_node.contains(name) && "Graph node name must be unique!");
|
BLT_ASSERT(!graph.names_to_node.contains(name) && "Graph node name must be unique!");
|
||||||
graph.names_to_node.insert({name, static_cast<blt::u64>(graph.nodes.size())});
|
graph.names_to_node.insert({name, static_cast<blt::u64>(graph.nodes.size())});
|
||||||
graph.nodes.emplace_back(blt::gfx::point2d_t{x, y, size}, std::move(name));
|
graph.nodes.emplace_back(blt::gfx::point2d_t{x, y, size}, std::move(name));
|
||||||
graph.nodes.back().texture = std::move(texture);
|
graph.nodes.back().texture = std::move(texture);
|
||||||
|
graph.nodes.back().outline_scale = outline_scale;
|
||||||
|
if (outline_color.is_array() && outline_color.size() >= 3)
|
||||||
|
{
|
||||||
|
auto r = static_cast<float>(outline_color[0].get<double>());
|
||||||
|
auto g = static_cast<float>(outline_color[1].get<double>());
|
||||||
|
auto b = static_cast<float>(outline_color[2].get<double>());
|
||||||
|
if (outline_color > 3)
|
||||||
|
graph.nodes.back().outline_color = blt::vec4{r, g, b, static_cast<float>(outline_color[3].get<double>())};
|
||||||
|
else
|
||||||
|
graph.nodes.back().outline_color = blt::make_color(r, g, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +171,15 @@ void loader_t::save_for(engine_t& engine, const loader_t& loader, std::string_vi
|
||||||
|
|
||||||
for (const auto& node : graph.nodes)
|
for (const auto& node : graph.nodes)
|
||||||
{
|
{
|
||||||
|
const auto& color = node.outline_color;
|
||||||
data["nodes"].push_back(json{
|
data["nodes"].push_back(json{
|
||||||
{"name", node.name},
|
{"name", node.name},
|
||||||
{"texture", node.texture},
|
{"texture", node.texture},
|
||||||
{"size", node.getRenderObj().scale},
|
{"size", node.getRenderObj().scale},
|
||||||
{"x", node.getPosition().x()},
|
{"x", node.getPosition().x()},
|
||||||
{"y", node.getPosition().y()},
|
{"y", node.getPosition().y()},
|
||||||
|
{"scale", node.outline_scale},
|
||||||
|
{"color", json::array({color.x(), color.y(), color.z(), color.w()})}
|
||||||
});
|
});
|
||||||
data["descriptions"].push_back(json{
|
data["descriptions"].push_back(json{
|
||||||
{"name", node.name},
|
{"name", node.name},
|
||||||
|
|
|
@ -61,6 +61,7 @@ void init(const blt::gfx::window_data& data)
|
||||||
resources.enqueue("res/ben.jpg", "ben");
|
resources.enqueue("res/ben.jpg", "ben");
|
||||||
resources.enqueue("res/no_image.jpg", "unknown");
|
resources.enqueue("res/no_image.jpg", "unknown");
|
||||||
resources.enqueue("res/me.png", "me");
|
resources.enqueue("res/me.png", "me");
|
||||||
|
resources.enqueue("res/jim.jpg", "jim");
|
||||||
|
|
||||||
if (auto loader = loader_t::load_for(engine, data, "default.json", "save.json"))
|
if (auto loader = loader_t::load_for(engine, data, "default.json", "save.json"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,8 +89,11 @@ void selector_t::process_mouse(blt::i32 width, blt::i32 height)
|
||||||
{
|
{
|
||||||
set_drag_selection(static_cast<blt::i64>(index));
|
set_drag_selection(static_cast<blt::i64>(index));
|
||||||
if (blt::gfx::isKeyPressed(GLFW_KEY_LEFT_SHIFT))
|
if (blt::gfx::isKeyPressed(GLFW_KEY_LEFT_SHIFT))
|
||||||
|
{
|
||||||
|
if (secondary_selection != -1)
|
||||||
|
set_primary_selection(secondary_selection);
|
||||||
set_secondary_selection(drag_selection);
|
set_secondary_selection(drag_selection);
|
||||||
else
|
} else
|
||||||
{
|
{
|
||||||
set_primary_selection(drag_selection);
|
set_primary_selection(drag_selection);
|
||||||
set_secondary_selection(-1);
|
set_secondary_selection(-1);
|
||||||
|
@ -146,9 +149,28 @@ void selector_t::draw_gui(blt::i32 width, blt::i32 height)
|
||||||
{
|
{
|
||||||
if (secondary_selection >= 0)
|
if (secondary_selection >= 0)
|
||||||
{
|
{
|
||||||
|
auto edge_i = graph.edges.find({static_cast<blt::u64>(primary_selection), static_cast<blt::u64>(secondary_selection)});
|
||||||
|
if (edge_i == graph.edges.end())
|
||||||
|
return;
|
||||||
|
auto edge = *edge_i;
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
changed |= im::SliderFloat("Ideal Length", &edge.ideal_spring_length, conf::POINT_SIZE, conf::DEFAULT_SPRING_LENGTH * 4);
|
||||||
|
callback_data_t description_data{edge.description, description_input};
|
||||||
|
changed |= im::InputTextMultiline("Description", description_input.data(), description_input.size(), {},
|
||||||
|
ImGuiInputTextFlags_CallbackResize | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackCompletion,
|
||||||
|
text_input_callback, &description_data);
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
graph.edges.erase(edge_i);
|
||||||
|
graph.edges.insert(edge);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
im::InputFloat("Size", &graph.nodes[primary_selection].point.scale);
|
im::SliderFloat("Size", &graph.nodes[primary_selection].point.scale, 1, 100);
|
||||||
|
im::ColorPicker4("Color", graph.nodes[primary_selection].outline_color.data());
|
||||||
|
im::SliderFloat("Scale", &graph.nodes[primary_selection].outline_scale, 1, 2);
|
||||||
callback_data_t name_data{graph.nodes[primary_selection].name, name_input};
|
callback_data_t name_data{graph.nodes[primary_selection].name, name_input};
|
||||||
callback_data_t texture_data{graph.nodes[primary_selection].texture, texture_input};
|
callback_data_t texture_data{graph.nodes[primary_selection].texture, texture_input};
|
||||||
callback_data_t description_data{graph.nodes[primary_selection].description, description_input};
|
callback_data_t description_data{graph.nodes[primary_selection].description, description_input};
|
||||||
|
|
Loading…
Reference in New Issue