strips and keys

This commit is contained in:
lachrymaLF 2024-06-05 14:20:27 -04:00
parent 7b91f99ac4
commit adb32dc5cc
15 changed files with 142 additions and 31 deletions

View file

@ -32,7 +32,7 @@ endif()
if (WIN32)
include_directories("include/windows")
target_link_libraries (Keishiki PRIVATE freetype bgfx bx ${PROJECT_SOURCE_DIR}/lib/x64/SDL2.lib ${PROJECT_SOURCE_DIR}/lib/x64/SDL2main.lib imgui-sdl2)
target_link_libraries (Keishiki PRIVATE freetype bgfx bx ${PROJECT_SOURCE_DIR}/lib/x64/SDL2.lib ${PROJECT_SOURCE_DIR}/lib/x64/SDL2main.lib)
elseif (APPLE)
find_package(SDL2 REQUIRED)
target_link_libraries (Keishiki PRIVATE freetype bgfx bx SDL2::SDL2)

View file

@ -10,6 +10,8 @@
#include "backends/imgui_impl_sdl2.h"
#include "imgui_impl_bgfx.h"
#include <algorithm>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
@ -230,7 +232,6 @@ namespace K::UI {
ImGui::PushID(id);
ImGui::PushStyleColor(ImGuiCol_ChildBg, selected ? 0xAA202040 : 0xAA080813);
if (ImGui::BeginChild(n.node->name.c_str(), {}, ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_Border)) {
ImGui::PopStyleColor();
if (ImGui::BeginTable(n.node->name.c_str(), 3)) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, row_height);
ImGui::TableNextColumn();
@ -258,6 +259,7 @@ namespace K::UI {
ImGui::EndTable();
}
}
ImGui::PopStyleColor();
ImGui::EndChild();
ImGui::PopID();
return stat;
@ -271,6 +273,7 @@ namespace K::UI {
bgfx::blit(Graphics::K_VIEW_COMP_COMPOSITE, composite_blit, 0, 0, composite);
for (u32 i = s.layers.size() - 1; i != u32(-1); i--) {
if (s.disabled.contains(i)) continue;
if (s.current_frame > s.layers[i].out || s.current_frame < s.layers[i].in) continue;
Graphics::Composite( composite_fb, composite_blit, s.layers[i].track.get_frame(s, render_fb, s.width, s.height, proj, view, transform),
i == s.layers.size() - 1 ? Graphics::K_V_AlphaOver : s.layers[i].mode, s.width, s.height, proj, transform);
bgfx::blit(Graphics::K_VIEW_COMP_COMPOSITE, composite_blit, 0, 0, composite);
@ -428,8 +431,6 @@ namespace K::UI {
ImGui::PushStyleColor(ImGuiCol_ChildBg, 0xFF100500);
ImGui::SetNextWindowSizeConstraints({avail.x * .1f, -1}, { avail.x * .8f, -1 });
if (ImGui::BeginChild("Nodes", {avail.x * .4f, avail.y}, ImGuiChildFlags_ResizeX, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar)) {
ImGui::PopStyleColor();
static u32 selected;
ImGuiWindow *window = ImGui::GetCurrentWindow();
@ -480,6 +481,7 @@ namespace K::UI {
ImGui::EndChild();
}
ImGui::PopStyleColor();
ImGui::EndChild();
ImGui::SameLine(0.0f, 0.5f);
@ -594,13 +596,13 @@ namespace K::UI {
// Frame Grid
static f32 frame_grid_min_width = 20.0f;
f32 fr_step = 1.0f / static_cast<f32>(s.frame_max + 1) * view_width / view_amt;
fr_step =
f32 fr_step = 1.0f / static_cast<f32>(s.frame_max + 1) * view_width / view_amt,
grid_step =
fr_step >= frame_grid_min_width ? fr_step : std::ceil(frame_grid_min_width / fr_step) * fr_step;
for (f32 fr = TimelineFrameToScreenView(view_left, view_amt, view_width,
std::ceil(view_left * static_cast<f32>(s.frame_max + 1)),
s.frame_max) + tl_init_pos.x;
fr < tl_init_pos.x + view_width; fr += fr_step)
fr < tl_init_pos.x + view_width; fr += grid_step)
window->DrawList->AddLine({fr, tl_init_pos.y + row_height},
{fr, ImGui::GetWindowSize().y + tl_init_pos.y}, 0x11FFFFFF, 1.0f);
@ -709,13 +711,55 @@ namespace K::UI {
f32 init_y = ImGui::GetCursorScreenPos().y;
ImGui::Dummy({TimelineFrameToScreenView(view_left, view_amt, view_width, current_layer.in, s.frame_max) + tl_init_pos.x, 0.0f});
ImGui::Button(current_layer.name.c_str(), {std::min(TimelineFrameToScreenView(view_left, view_amt, view_width, current_layer.out, s.frame_max) + fr_step, view_width), view_height});
static f32 layer_bound_width = 5.0f;
i32 l_in = TimelineFrameInView(view_left, view_right, current_layer.in, s.frame_max), l_out = TimelineFrameInView(view_left, view_right, current_layer.out, s.frame_max);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + TimelineFrameToScreenView(view_left, view_amt, view_width, current_layer.in, s.frame_max));
if (l_in) {
ImGui::PushStyleColor(ImGuiCol_Button, 0xFF666666);
ImGui::Button("##Layer_L", {layer_bound_width, view_height});
if (ImGui::IsItemHovered()) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
}
if (ImGui::IsItemActive()) {
current_layer.in = std::min(TimelineScreenViewToFrame(view_left, view_amt, view_width, std::clamp(io.MousePos.x - tl_init_pos.x, 0.0f, view_width), s.frame_max), current_layer.out);
}
ImGui::PopStyleColor();
ImGui::SameLine(0.0f, 0.0f);
}
f32 in_pos = TimelineFrameToScreenView(view_left, view_amt, view_width, current_layer.in, s.frame_max);
ImGui::PushID(0);
ImGui::Button(current_layer.name.c_str(), {std::min(TimelineFrameToScreenView(view_left, view_amt, view_width, current_layer.out, s.frame_max) + fr_step, view_width) - in_pos - layer_bound_width * static_cast<f32>(l_in + l_out), view_height});
static f32 layer_strip_drag_begin{};
static u32 in_old, out_old;
if (ImGui::IsItemClicked()) {
layer_strip_drag_begin = io.MousePos.x;
in_old = current_layer.in;
out_old = current_layer.out;
}
if (ImGui::IsItemActive()) {
i32 off = static_cast<i32>(std::trunc((io.MousePos.x - layer_strip_drag_begin) / fr_step));
off = std::max(-static_cast<i32>(in_old), off);
current_layer.in = in_old + off;
current_layer.out = out_old + off;
}
ImGui::PopID();
if (l_out) {
ImGui::SameLine(0.0f, 0.0f);
ImGui::PushStyleColor(ImGuiCol_Button, 0xFF666666);
ImGui::Button("##Layer_R", {layer_bound_width, view_height});
if (ImGui::IsItemHovered()) {
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
}
if (ImGui::IsItemActive()) {
current_layer.out = std::max(TimelineScreenViewToFrame(view_left, view_amt, view_width, std::clamp(io.MousePos.x - tl_init_pos.x - fr_step, 0.0f, view_width), s.frame_max), current_layer.in);
}
ImGui::PopStyleColor();
}
ImGui::SetCursorScreenPos(ImVec2{tl_init_pos.x, init_y} - style.CellPadding);
ImGui::InvisibleButton("##TL_BG", ImVec2{ view_width + style.CellPadding.x * 2, row_height + style.CellPadding.y});
if (ImGui::IsItemActive()) {
s.current_frame = TimelineScreenViewToFrame(view_left, view_amt, view_width, std::clamp(ImGui::GetMousePos().x - tl_init_pos.x, 0.0f, view_width), s.frame_max);
s.current_frame = TimelineScreenViewToFrame(view_left, view_amt, view_width, std::clamp(io.MousePos.x - tl_init_pos.x, 0.0f, view_width), s.frame_max);
}
ImGui::PopStyleVar(3);
@ -799,7 +843,7 @@ namespace K::UI {
ImGui::TableSetColumnIndex(4);
auto p = ImGui::GetCursorScreenPos();
// draw on tl
// draw on tl -- implot probably
ImGui::SetCursorScreenPos(p);
@ -818,8 +862,17 @@ namespace K::UI {
ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_FramePadding);
ImGui::TableSetColumnIndex(2);
auto *m = std::any_cast<std::map<u32, PlugboardNodes::ChainSegment>>(&std::get<1>(connected_v).p->extra);
bool m_empty = m->empty();
ImGui::BeginDisabled(m_empty || m->begin()->first >= s.current_frame);
if (ImGui::Button("<")) {
auto it = std::prev(m->upper_bound(s.current_frame));
s.current_frame = (it->first == s.current_frame ? std::prev(it) : it)->first;
}
ImGui::SameLine();
ImGui::EndDisabled();
f32 v = std::get<PlugboardGraph::T_Map<PlugboardGraph::T_Float>::type>(PlugboardGraph::Eval(s, std::get<1>(connected_v))), copy = v;
ImGui::DragFloat("##value", &v);
ImGui::SameLine();
if (v != copy) {
auto l = m->lower_bound(s.current_frame);
auto interp = l == m->end() ? PlugboardNodes::K_I_Linear : l->second.interp.interp;
@ -830,22 +883,77 @@ namespace K::UI {
}
});
}
ImGui::BeginDisabled(m_empty || m->rbegin()->first <= s.current_frame);
if (ImGui::Button(">")) {
s.current_frame = m->upper_bound(s.current_frame)->first;
}
ImGui::EndDisabled();
ImGui::TableSetColumnIndex(3);
ImGui::Text("%lu", m->size());
ImGui::TableSetColumnIndex(4);
ImVec2 begin_tl = ImGui::GetCursorScreenPos();
static u32 drag_old{};
for (auto& [k, segment] : *m)
if (TimelineFrameInView(view_left, view_right, k, s.frame_max)) {
ImGui::SetCursorScreenPos({TimelineFrameToScreenView(view_left, view_amt, view_width, k, s.frame_max) + begin_tl.x - 2.5f, begin_tl.y});
ImGui::Button("k", {0.0f, row_height * .8f});
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
drag_old = k;
}
if (ImGui::IsItemActive()) {
// ...
static std::map<u32, PlugboardNodes::ChainSegment> m_copy{};
static u32 dragging{};
static i64 drag_og = -1;
if (drag_og == -1) {
for (auto& [k, segment] : *m) {
if (TimelineFrameInView(view_left, view_right, k, s.frame_max)) {
ImGui::SetCursorScreenPos(
{TimelineFrameToScreenView(view_left, view_amt, view_width, k,
s.frame_max) + begin_tl.x - 2.5f, begin_tl.y});
ImGui::Button("k", {0.0f, row_height * .8f});
if (ImGui::IsItemClicked()) {
m_copy = *m;
drag_og = k;
}
if (ImGui::IsItemActive()) {
dragging = TimelineScreenViewToFrame(view_left, view_amt, view_width,
std::clamp(ImGui::GetMousePos().x -
tl_init_pos.x, 0.0f,
view_width), s.frame_max);
}
if (drag_og == k && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
drag_og = -1;
}
}
}
}
else {
m->clear();
for (auto& [k, segment] : m_copy) {
if (drag_og != k) {
if (TimelineFrameInView(view_left, view_right, k, s.frame_max)) {
ImGui::SetCursorScreenPos(
{TimelineFrameToScreenView(view_left, view_amt, view_width, k,
s.frame_max) + begin_tl.x - 2.5f, begin_tl.y});
ImGui::Button("k", {0.0f, row_height * .8f});
m->emplace(k, segment);
}
}
else {
ImGui::SetCursorScreenPos(
{TimelineFrameToScreenView(view_left, view_amt, view_width, dragging,
s.frame_max) + begin_tl.x - 2.5f, begin_tl.y});
ImGui::Button("k", {0.0f, row_height * .8f});
if (ImGui::IsItemClicked()) {
m_copy = *m;
drag_og = k;
}
if (ImGui::IsItemActive()) {
dragging = TimelineScreenViewToFrame(view_left, view_amt, view_width,
std::clamp(ImGui::GetMousePos().x -
tl_init_pos.x, 0.0f,
view_width), s.frame_max);
m->emplace(dragging, segment);
}
if (drag_og == k && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
m->emplace(dragging, segment);
drag_og = -1;
}
}
}
}
ImGui::SetCursorScreenPos(begin_tl);
ImGui::InvisibleButton("##TL_BG", ImVec2{ view_width + style.CellPadding.x * 2, row_height + style.CellPadding.y});
@ -1117,7 +1225,7 @@ namespace K::UI {
ImGui_Implbgfx_NewFrame();
ImGui::NewFrame();
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
ImGui::ShowDemoWindow();
// static ImGuiStyle& style = ImGui::GetStyle();

@ -1 +1 @@
Subproject commit 701d84c2227e9219ad44c760e75c3c6f24a2cff0
Subproject commit 19cb98d40b3d43482bca299ec752aeacd83b21eb

@ -1 +1 @@
Subproject commit 70299c924fc6782edf0249bd28ca234dcc9d7c2c
Subproject commit d41a855aab6d8ce131c465ce01f0f536e0fb2269

@ -1 +1 @@
Subproject commit b39fc84f8919b87c9d79f6ffaf43efb61d2beb3d
Subproject commit fdc084f532189fda8474079f79e74fa5e3541c9f

View file

@ -8,7 +8,7 @@
namespace {
template <K::PlugboardGraph::Type type>
static K::PlugboardGraph::T_Map<type>::type GetNodeInputArg(const K::CompState& s, const K::PlugboardGraph::NodeInstance& n, u32 index) {
typename K::PlugboardGraph::T_Map<type>::type GetNodeInputArg(const K::CompState& s, const K::PlugboardGraph::NodeInstance& n, u32 index) {
bool good;
typename K::PlugboardGraph::T_Map<type>::type v = std::get<typename K::PlugboardGraph::T_Map<type>::type>(K::PlugboardGraph::ConvertValue(std::visit([&s](auto&& arg) {
using U = std::decay_t<decltype(arg)>;
@ -552,9 +552,9 @@ namespace K::PlugboardNodes {
auto *v = std::any_cast<std::map<u32, ChainSegment>>(&n.extra);
if (v->empty())
return 0.0f;
if (frame < v->begin()->first)
if (frame <= v->begin()->first)
return v->begin()->second.value;
if (frame > v->rbegin()->first)
if (frame >= v->rbegin()->first)
return v->rbegin()->second.value;
auto nit = v->upper_bound(frame), it = std::prev(nit);

BIN
Keishiki/runtime/mmaker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,4 @@
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec3 a_position : POSITION;
vec2 a_texcoord0 : TEXCOORD0;

View file

@ -1,10 +1,9 @@
import subprocess, os
#SHADERC = "..\\out\\install\\x64-Debug\\bin\\shaderc"
#SHADERC = "..\\build\\Keishiki\\ext\\bgfx\\cmake\\bgfx\\Debug\\shaderc"
# SHADERC = "/Users/lachrymal/Projects/NouVeL/build/ADVect/ext/bgfx/Debug/shaderc"
SHADERC = "/home/lach/Projects/Keishiki/cmake-build-debug/Keishiki/ext/bgfx/cmake/bgfx/shaderc"
#OUT = "..\\out\\build\\x64-Debug\\ADVect\\shaders\\"
# OUT = "..\\build\\ADVect\\shaders\\"
#OUT = "..\\build\\Keishiki\\Debug\\shaders\\"
# OUT = "/Users/lachrymal/Projects/NouVeL/ADVect/runtime/shaders/"
OUT = "/home/lach/Projects/Keishiki/cmake-build-debug/Keishiki/shaders/"
I = "/home/lach/Projects/Keishiki/cmake-build-debug/Keishiki/"