Compare commits

..

No commits in common. "4f4e5326ee26e797fdff74ec7cc8393913ee8bc1" and "8dbddb79fab658fa47d5b0201c08e36c55779afa" have entirely different histories.

4 changed files with 22 additions and 23 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(graphs VERSION 0.0.49) project(graphs VERSION 0.0.44)
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)

@ -1 +1 @@
Subproject commit c9475afb2a37ce4126b5519b456f6e3ea4f9f978 Subproject commit ae2ad8d1ab9f9fc557de8dd51065d5dae77b98fe

View File

@ -86,7 +86,7 @@ void graph_t::process_mouse_drag(const blt::i32 width, const blt::i32 height)
global_matrices.getOrtho())); global_matrices.getOrtho()));
bool mouse_pressed = blt::gfx::isMousePressed(0); bool mouse_pressed = blt::gfx::isMousePressed(0);
blt::i32 new_selection = -1; blt::i32 new_selection = selected_node;
for (const auto& [index, node] : blt::enumerate(nodes)) for (const auto& [index, node] : blt::enumerate(nodes))
{ {
@ -95,7 +95,7 @@ void graph_t::process_mouse_drag(const blt::i32 width, const blt::i32 height)
const auto mag = dist.magnitude(); const auto mag = dist.magnitude();
if (mag < POINT_SIZE && mouse_pressed) if (mag < POINT_SIZE && (selected_node == -1 || !mouse_pressed))
{ {
new_selection = static_cast<blt::i32>(index); new_selection = static_cast<blt::i32>(index);
break; break;
@ -108,29 +108,38 @@ void graph_t::process_mouse_drag(const blt::i32 width, const blt::i32 height)
nodes[selected_node].setOutlineColor(color::POINT_OUTLINE_COLOR); nodes[selected_node].setOutlineColor(color::POINT_OUTLINE_COLOR);
} }
if (mouse_pressed && new_selection == -1 && selected_node != -1)
{
selected_node = -1;
}
selected_node = new_selection;
if (!mouse_pressed && blt::gfx::mouseReleaseLastFrame()) if (!mouse_pressed && blt::gfx::mouseReleaseLastFrame())
{ {
reset_mouse_drag(); reset_mouse_drag();
} }
selected_node = new_selection;
// if (!mouse_pressed && selected_node != -1 && found && nodes[selected_node].getOutlineColor() != color::POINT_HIGHLIGHT_COLOR)
// {
// highlight_easing.progress(8 * static_cast<float>(blt::gfx::getFrameDeltaSeconds()));
// nodes[selected_node].setOutlineColor(highlight_easing.apply(color::POINT_OUTLINE_COLOR, color::POINT_HIGHLIGHT_COLOR));
// }
//
// if (!found)
// reset_mouse_highlight();
if (selected_node != -1 && mouse_pressed) if (selected_node != -1 && mouse_pressed)
{ {
auto& node = nodes[selected_node]; auto& node = nodes[selected_node];
easing.progress(8 * static_cast<float>(blt::gfx::getFrameDeltaSeconds())); easing.progress(8 * static_cast<float>(blt::gfx::getFrameDeltaSeconds()));
node.setOutlineColor(color::POINT_SELECT_COLOR); node.setOutlineColor(easing.apply(color::POINT_OUTLINE_COLOR, color::POINT_SELECT_COLOR));
node.getPositionRef() = mouse_pos; node.getPositionRef() = mouse_pos;
} }
} }
void graph_t::handle_mouse() void graph_t::handle_mouse()
{} {
for (const auto& node : nodes)
{
}
}
void graph_t::create_random_graph(bounding_box bb, const blt::size_t min_nodes, const blt::size_t max_nodes, const blt::f64 connectivity, void graph_t::create_random_graph(bounding_box bb, const blt::size_t min_nodes, const blt::size_t max_nodes, const blt::f64 connectivity,
const blt::f64 scaling_connectivity, const blt::f64 distance_factor) const blt::f64 scaling_connectivity, const blt::f64 distance_factor)

View File

@ -31,16 +31,6 @@ blt::gfx::first_person_camera_2d camera;
namespace im = ImGui; namespace im = ImGui;
/*
* TODO:
* - Highlighted Node
* + transitions to other states
* - Selected Node
* - ability to add nodes to the graph
* - ability to add edges to the graph
* - ability to remove edges from the graph (multi selection?)
* - ability to remove nodes from graph (make use of multi selection?)
*/
engine_t engine; engine_t engine;
void init(const blt::gfx::window_data& data) void init(const blt::gfx::window_data& data)