begin adding new style

This commit is contained in:
2026-02-25 10:07:40 +03:00
parent 61efa398a8
commit 0efce09425
14 changed files with 191 additions and 100 deletions

19
LICENSE Normal file
View File

@@ -0,0 +1,19 @@
MIT License
Copyright (c) 2026 chatlanin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -25,6 +25,7 @@ namespace monitor::components
utils::var::STATUS m_status;
libs::audio m_player;
std::filesystem::path m_file;
std::vector<std::string> m_domains = { "time", "frequensy"};
private:
void callback(sf::Time time, double pos);

View File

@@ -35,5 +35,23 @@ namespace monitor::components
VE::event e { utils::event_type::AUDIO_STOP, nullptr };
EMIT(e);
}
// HERE
// выбор устройства воспроизведения
auto ctx = ImGui::GetCurrentContext();
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
ImGui::SetNextItemWidth(120.f);
static std::size_t domain_id = 0;
if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
{
for (std::size_t i = 0; i < m_domains.size(); ++i)
{
const bool is_selected = (domain_id == i);
if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
domain_id = i;
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}
}

View File

@@ -42,4 +42,13 @@ namespace monitor::components
m_status = utils::var::STATUS::EMPTY;
});
}
void creator::set_domain(std::string name)
{
if (name == "frequensy")
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
else
m_setup.m_domain = hr::DOMAIN_PLUGIN::TIME;
}
}

View File

@@ -5,32 +5,11 @@ namespace monitor::components
{
void creator::render_combo()
{
ImGui::SetNextItemWidth(200.f);
if (ImGui::BeginCombo(VE_NO_NAME("select_signal_type"), m_signal_type.m_id < 0 ? "---" : hr::all_types()[m_signal_type.m_id].get_name().c_str()))
{
for (std::size_t i = 0; i < hr::all_types().size(); ++i)
{
const bool is_selected = (m_signal_type.m_id == static_cast<int>(i));
if (ImGui::Selectable(hr::all_types()[i].get_name().c_str(), is_selected))
{
m_signal_type.init(i, hr::all_types()[i].get_name());
m_setup.m_signal_type = hr::all_types()[i];
if (m_setup.m_signal_type.m_type != hr::signal_type::type::FILE)
m_status = utils::var::STATUS::READY;
}
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
auto ctx = ImGui::GetCurrentContext();
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
ImGui::SetNextItemWidth(400.f);
if (ImGui::BeginCombo(VE_NO_NAME("select_dir"), m_dir.m_id < 0 ? "---" : m_dirs[m_dir.m_id].c_str()))
{
if (m_setup.m_signal_type.m_type == hr::signal_type::type::FILE)
{
for (std::size_t i = 0; i < m_dirs.size(); ++i)
{
@@ -44,7 +23,6 @@ namespace monitor::components
}
if (is_selected) ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}

View File

@@ -27,7 +27,7 @@ namespace monitor::components
ImGui::SameLine(0.0f, spacing);
ImGui::Text("%zu", m_setup.m_block_size);
// тут нужно жестко, а то при изменении циферек прагает в сторону поле
ImGui::SameLine(1200.0f);
ImGui::SameLine(1000.0f);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
@@ -60,7 +60,7 @@ namespace monitor::components
ImGui::SameLine(0.0f, spacing);
ImGui::Text("%zu", m_setup.m_step_size);
// тут нужно жестко, а то при изменении циферек прагает в сторону поле
ImGui::SameLine(1395.0f);
ImGui::SameLine(1195.0f);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);

View File

@@ -9,7 +9,7 @@ namespace monitor::components
{
auto ctx = ImGui::GetCurrentContext();
auto s = ctx->CurrentWindow->Size;
ImVec2 pos{ 1030.f, s.y / 2.f };
ImVec2 pos{ 830.f, s.y / 2.f };
if (m_status == utils::var::STATUS::COMPLETED) m_spinner.render(pos);
else if (m_status == utils::var::STATUS::READY) m_spinner.render(pos, "#B4CF16");

View File

@@ -28,7 +28,6 @@ namespace monitor::components
private:
std::vector<std::string> m_dirs;
std::vector<std::string> m_files;
combo m_signal_type;
combo m_dir;
combo m_file;
utils::var::STATUS m_status = utils::var::STATUS::EMPTY;
@@ -36,6 +35,7 @@ namespace monitor::components
hr::setup m_setup;
private:
void set_domain(std::string name);
void create();
void clear();
void render_combo();

View File

@@ -9,6 +9,9 @@ namespace monitor::components
CONNECT(this);
m_audio.on_attach();
m_markers.on_attach();
m_plugins.emplace_back(combo{ .m_id = 0, .m_name = "Magnitude", .m_type = utils::var::PLUGIN_TYPE::MAGNITUDE });
m_plugins.emplace_back(combo{ .m_id = 1, .m_name = "Energy", .m_type = utils::var::PLUGIN_TYPE::ENERGY });
}
void snapshot::on_detach()
@@ -37,38 +40,62 @@ namespace monitor::components
{
m_setup = setup;
hr::result r;
if (m_setup.m_signal_type.m_type != hr::signal_type::type::FILE)
auto r = hr::run<hr::plugins::raw_data>(m_setup);
if (fill_raw_data(r))
{
// HERE
// когда генерируем, то нужно и звук сделать !!!
hr::signal_generator sg;
r = sg.generate(setup.m_signal_type);
// можно например так
// auto path_to_gen_sound = "путь до сгенерированного звука";
// m_setup.m_file = path_to_gen_sound;
// sg.generate(r, path_to_gen_sound);
}
else
{
// HERE
// тут нужно как то решать штуку с временной и частотными областями
// для отрисовки на графиках
r = hr::run<hr::plugins::magnitude>(m_setup);
}
fill(r);
m_audio.init(m_setup.m_file);
m_audio.set_step(r.m_data.size());
m_markers.init();
set_status(utils::var::STATUS::ACTIVE);
}
}
void snapshot::fill(hr::result& r)
bool snapshot::fill_raw_data(hr::result& r)
{
bool ok = true;
// Общая длинна всех данных
auto total_size = r.m_data.size();
hack::log()(total_size);
// if (total_size > utils::var::MAX_RENDER_SIZE)
// {
// hack::warn()("Данный файл превышает максимально допустимый размер рендеринга");
// hack::log()("Возможно пришло время чтобы написать тут код... см. dspv.v3");
// hack::log()("но там есть tmp, которая может ту быть сомнительной...");
// }
// else if (total_size == 0)
if (total_size == 0)
{
hack::error()("Пусто в расчетах!");
hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
return !ok;
}
else
{
utils::types::graph_data data;
data.m_render_data.push_back(hr::fvec_t());
// тут резирвируем именно длинну по оси X всех линий
data.m_ox.reserve(total_size);
// заполняем данными все линии графиков
for (auto el : r.m_data)
{
data.m_max_element = hack::math::max(el.m_value[0], data.m_max_element);
data.m_render_data[0].push_back(el.m_value[0]);
}
for (std::size_t i = 0; i < total_size; ++i) data.m_ox.push_back(i);
data.m_name = m_plugin.m_name;
data.m_type = m_plugin.m_type;
m_graphs.push_back(data);
}
return ok;
}
bool snapshot::fill(hr::result& r)
{
bool is_ok = false;
auto base_size = r.m_data.size();
utils::types::graph_data data;
@@ -78,6 +105,11 @@ namespace monitor::components
hack::log()("Возможно пришло время чтобы написать тут код... см. dspv.v3");
hack::log()("но там есть tmp, которая может ту быть сомнительной...");
}
else if (base_size == 0)
{
hack::error()("Пусто в расчетах!");
hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
}
else
{
// резервируем кол-во линий графиков исходя из того сколько данных нужно отрисовать в каждом бине из dsp
@@ -98,11 +130,12 @@ namespace monitor::components
}
}
for (std::size_t i = 0; i < data.m_render_data[0].size(); ++i) data.m_ox.push_back(i);
}
data.m_name = m_plugin.m_name;
data.m_type = m_plugin.m_type;
m_graphs.push_back(data);
is_ok = true;
}
return is_ok;
}
void snapshot::add_plugin()
@@ -111,12 +144,16 @@ namespace monitor::components
switch (m_plugin.m_type)
{
// case utils::var::PLUGIN_TYPE::SEGMENTER:
// {
// r = hr::run<hr::plugins::segmenter>(m_setup);
// break;
// }
//
case utils::var::PLUGIN_TYPE::MAGNITUDE:
{
// HERE
// это нужно устанавливать в combo
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
r = hr::run<hr::plugins::magnitude>(m_setup);
hack::log()("asdf");
break;
}
// case utils::var::PLUGIN_TYPE::ENERGY:
// {
// r = hr::run<hr::plugins::energy>(m_setup);

View File

@@ -6,6 +6,27 @@ namespace monitor::components
void snapshot::render()
{
m_audio.render();
ImGui::SameLine();
// HERE
// выбор домена для плагина
auto ctx = ImGui::GetCurrentContext();
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
ImGui::SetNextItemWidth(120.f);
static std::size_t domain_id = 0;
if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
{
for (std::size_t i = 0; i < m_domains.size(); ++i)
{
const bool is_selected = (domain_id == i);
if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
domain_id = i;
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::SameLine();
ImGui::SetNextItemWidth(400.f);
@@ -69,6 +90,7 @@ namespace monitor::components
}
ImPlot::EndSubplots();
}
is_first_render = false;
}
}

View File

@@ -20,17 +20,9 @@ namespace monitor::components
audio m_audio;
hr::setup m_setup;
public:
void set_status(utils::var::STATUS s);
void init(hr::setup setup);
private:
ImVec2 m_size = { 0.f, 0.f };
private:
void fill(hr::result& r);
void add_plugin();
private:
std::vector<utils::types::graph_data> m_graphs;
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_None };
@@ -46,11 +38,22 @@ namespace monitor::components
struct combo
{
int m_id = -1;
std::string m_name { "Magnitude" };
utils::var::PLUGIN_TYPE m_type { utils::var::PLUGIN_TYPE::MAGNITUDE };
std::string m_name;
utils::var::PLUGIN_TYPE m_type;
void clear() { m_id = -1; m_name.clear(); }
} m_plugin;
std::vector<combo> m_plugins;
std::vector<std::string> m_domains = { "time", "frequensy"};
public:
void set_status(utils::var::STATUS s);
void init(hr::setup setup);
private:
bool fill(hr::result& r);
bool fill_raw_data(hr::result& r);
void add_plugin();
};
}

View File

@@ -11,9 +11,11 @@ namespace monitor::libs
hack::error()("Не удалось найти устройство воспроизведения");
return;
}
// HERE
// сделать выбор устройства из интерфейса
// поставь, то которое есть в списке устройств
// for (auto& d : devices) std::cout << d << std::endl;
std::string target_device = devices[1];
for (auto& d : devices) std::cout << d << std::endl;
std::string target_device = devices[2];
if (sf::PlaybackDevice::setDevice(target_device))
hack::log()("Устройство успешно установлено: ", target_device);
else

View File

@@ -1,13 +1,14 @@
[wrap-file]
directory = imgui-1.91.6
source_url = https://github.com/ocornut/imgui/archive/refs/tags/v1.91.6.tar.gz
source_filename = imgui-1.91.6.tar.gz
source_hash = c5fbc5dcab1d46064001c3b84d7a88812985cde7e0e9ced03f5677bec1ba502a
patch_filename = imgui_1.91.6-2_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/imgui_1.91.6-2/get_patch
patch_hash = 515e31b18e3928aafce2c62c94fa6d8426f5132e9c3f2d9951b7e96b6381f33a
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/imgui_1.91.6-2/imgui-1.91.6.tar.gz
wrapdb_version = 1.91.6-2
directory = imgui-1.92.5
source_url = https://github.com/ocornut/imgui/archive/refs/tags/v1.92.5.tar.gz
source_filename = imgui-1.92.5.tar.gz
source_hash = 0eb50fe9aeba1a51f96b5843c7f630a32ed2e9362d693c61b87e4fa870cf826d
source_fallback_url = https://wrapdb.mesonbuild.com/v2/imgui_1.92.5-1/get_source/imgui-1.92.5.tar.gz
patch_filename = imgui_1.92.5-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/imgui_1.92.5-1/get_patch
patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/imgui_1.92.5-1/imgui_1.92.5-1_patch.zip
patch_hash = 636e9099a55869f25a95739b345e844c6b42166a0a0d22837ffbedd8e7af0bce
wrapdb_version = 1.92.5-1
[provide]
imgui = imgui_dep
dependency_names = imgui

View File

@@ -1,13 +1,14 @@
[wrap-file]
directory = SFML-3.0.1
source_url = https://github.com/SFML/SFML/archive/refs/tags/3.0.1.tar.gz
source_filename = SFML-3.0.1.tar.gz
source_hash = f99f71bb2f2608835b1a37e078512b75dd39d52b89e13e12246603a950da3c1f
patch_filename = sfml_3.0.1-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/sfml_3.0.1-1/get_patch
patch_hash = a516faf20d41d144c3fb8c34038bf1183bd702eb2e1ffd43260560af3fb09048
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sfml_3.0.1-1/SFML-3.0.1.tar.gz
wrapdb_version = 3.0.1-1
directory = SFML-3.0.2
source_url = https://github.com/SFML/SFML/archive/refs/tags/3.0.2.tar.gz
source_filename = SFML-3.0.2.tar.gz
source_hash = 0034e05f95509e5d3fb81b1625713e06da7b068f210288ce3fd67106f8f46995
source_fallback_url = https://wrapdb.mesonbuild.com/v2/sfml_3.0.2-1/get_source/SFML-3.0.2.tar.gz
patch_filename = sfml_3.0.2-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/sfml_3.0.2-1/get_patch
patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sfml_3.0.2-1/sfml_3.0.2-1_patch.zip
patch_hash = dee492138ec6a71bc45eeadcdb3ac9988cb26c3221c5e82454d97c02004986d8
wrapdb_version = 3.0.2-1
[provide]
sfml = sfml_dep
dependency_names = sfml, sfml-all