WIP Lane Layout edition

This commit is contained in:
Stepland 2022-11-16 02:00:09 +01:00
parent 9ab1845941
commit 7924ad2000
4 changed files with 68 additions and 19 deletions

View File

@ -2742,18 +2742,18 @@ static void ShowDemoWindowLayout()
"IsItemHovered()/IsItemActive() or SameLine() etc. on the whole group.");
ImGui::BeginGroup();
{
ImGui::BeginGroup();
ImGui::Button("AAA");
ImGui::SameLine();
ImGui::Button("BBB");
ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Button("CCC");
ImGui::Button("DDD");
ImGui::EndGroup();
ImGui::SameLine();
ImGui::Button("EEE");
ImGui::EndGroup();
ImGui::BeginGroup(); {
ImGui::Button("AAA");
ImGui::SameLine();
ImGui::Button("BBB");
ImGui::SameLine();
ImGui::BeginGroup(); {
ImGui::Button("CCC");
ImGui::Button("DDD");
} ImGui::EndGroup();
ImGui::SameLine();
ImGui::Button("EEE");
} ImGui::EndGroup();
if (ImGui::IsItemHovered())
ImGui::SetTooltip("First group hovered");
}

View File

@ -531,7 +531,7 @@ int main() {
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit")) {
if (ImGui::BeginMenu("Edit", editor_state.has_value())) {
if (ImGui::MenuItem("Undo", "Ctrl+Z")) {
if (editor_state) {
editor_state->undo(notificationsQueue);

View File

@ -3,6 +3,7 @@
#include <SFML/Graphics/Color.hpp>
#include <SFML/System/Vector2.hpp>
#include <cmath>
#include <cstddef>
#include <functional>
#include <iostream>
#include <variant>
@ -28,7 +29,8 @@ void SelectionRectangle::reset() {
}
LinearView::LinearView(std::filesystem::path assets) :
beats_to_pixels_proportional(0, 1, 0, 100)
beats_to_pixels_proportional(0, 1, 0, 100),
lane_order({0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})
{}
void LinearView::draw(
@ -363,9 +365,19 @@ void LinearView::set_zoom(int newZoom) {
reload_transforms();
}
const std::array<std::string, 16> letters = {
"1","2","3","4",
"5","6","7","8",
"9","a","b","c",
"d","e","f","g"
};
void LinearView::display_settings() {
if (ImGui::Begin("Linear View Settings", &shouldDisplaySettings)) {
if (ImGui::TreeNode("Colors##Linear View Settings")) {
if (ImGui::CollapsingHeader("Lane Layout##Linear View Settings")) {
LaneOrderPreview(lane_order);
}
if (ImGui::CollapsingHeader("Colors##Linear View Settings")) {
feis::ColorEdit4("Cursor", cursor_color);
feis::ColorEdit4("Measure Lines", measure_lines_color);
feis::ColorEdit4("Measure Numbers", measure_numbers_color);
@ -399,12 +411,10 @@ void LinearView::display_settings() {
feis::ColorEdit4("Selected Outline##Color settings", selected_note_outline);
ImGui::TreePop();
}
ImGui::TreePop();
}
if (ImGui::TreeNode("Metrics##Linear View Settings")) {
if (ImGui::CollapsingHeader("Metrics##Linear View Settings")) {
ImGui::DragInt("Cursor Height", &cursor_height);
ImGui::DragInt("Timeline Margin", &timeline_margin);
ImGui::TreePop();
}
}
ImGui::End();
@ -509,3 +519,41 @@ bool draw_selection_rect(
}
return ImGui::IsMouseReleased(mouse_button);
}
void LaneOrderPreview(const std::array<std::optional<unsigned int>, 16>& order) {
static float scale = 16.f;
static sf::Vector2f offset = {0, 0};
static float decalage_output = 5.f;
if (ImGui::Begin("Debug Linear View Settings")) {
ImGui::SliderFloat("Scale", &scale, 0, 20, "%.3f", ImGuiSliderFlags_Logarithmic);
ImGui::SliderFloat2("Offset", &offset.x, 0, 1000);
ImGui::SliderFloat("Décalage output", &decalage_output, 0, 10);
}
ImGui::End();
const auto origin = sf::Vector2f{ImGui::GetCursorPos()};
auto col = ImColor(sf::Color::White);
for (auto y = 0; y < 4; y++) {
for (auto x = 0; x < 4; x++) {
const auto index = x + 4*y;
ImGui::SetCursorPos(origin + offset + sf::Vector2f{static_cast<float>(x), static_cast<float>(y)} * scale);
ImGui::ColorConvertHSVtoRGB(static_cast<float>(index)/16.f, 1, 1, col.Value.x, col.Value.y, col.Value.z);
ImGui::TextColored(col, "%s", letters[index].c_str());
if (x != 3) {
ImGui::SameLine();
}
}
}
const auto screen_origin = sf::Vector2f{ImGui::GetCursorScreenPos()};
ImGui::RenderArrow(ImGui::GetWindowDrawList(), screen_origin + offset + sf::Vector2f{decalage_output, 1.5f} * scale, ImColor(sf::Color::White), ImGuiDir_Right);
for (std::size_t i = 0; i < order.size(); i++) {
const auto button = order.at(i);
if (button) {
const auto index = *button % 16;
ImGui::SetCursorPos(origin + offset + sf::Vector2f{static_cast<float>(decalage_output+2+index), 1.5f} * scale);
ImGui::ColorConvertHSVtoRGB(static_cast<float>(index)/16.f, 1, 1, col.Value.x, col.Value.y, col.Value.z);
ImGui::TextColored(col, "%s", letters[index].c_str());
}
}
ImGui::SetCursorPos(origin);
ImGui::Dummy(sf::Vector2f{23, 4}*scale);
}

View File

@ -95,6 +95,7 @@ private:
SelectionRectangle selection_rectangle;
bool started_selection_inside_window = false;
bool any_bpm_button_hovered = false;
std::array<std::optional<unsigned int>, 16> lane_order;
};
void draw_rectangle(
@ -121,4 +122,4 @@ bool draw_selection_rect(
ImGuiMouseButton mouse_button = ImGuiMouseButton_Left
);
void select_everything_inside(const sf::Vector2f& rect);
void LaneOrderPreview(const std::array<std::optional<unsigned int>, 16>& order);