Commit abccb34f authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

gui: enable generator/buffer external sources

parent acb8b5f8
...@@ -1910,6 +1910,23 @@ show_dynamics_inputs(buffer& dyn) ...@@ -1910,6 +1910,23 @@ show_dynamics_inputs(buffer& dyn)
{ {
ImGui::InputDouble("value", &dyn.default_value); ImGui::InputDouble("value", &dyn.default_value);
ImGui::InputDouble("offset", &dyn.default_offset); ImGui::InputDouble("offset", &dyn.default_offset);
{
const char* title = "Select time sources";
if (ImGui::Button("Times"))
ImGui::OpenPopup(title);
ImGui::SameLine();
if (dyn.default_lambda_source.data == nullptr) {
ImGui::TextUnformatted("<None>");
} else {
ImGui::Text("%" PRIu32 "-%" PRIu32,
dyn.default_lambda_source.type,
dyn.default_lambda_source.id);
}
app.srcs.show_menu(title, dyn.default_lambda_source);
}
} }
static void static void
...@@ -1918,17 +1935,39 @@ show_dynamics_inputs(generator& dyn) ...@@ -1918,17 +1935,39 @@ show_dynamics_inputs(generator& dyn)
ImGui::InputDouble("value", &dyn.default_value); ImGui::InputDouble("value", &dyn.default_value);
ImGui::InputDouble("offset", &dyn.default_offset); ImGui::InputDouble("offset", &dyn.default_offset);
if (ImGui::Button("Select..")) {
ImGui::OpenPopup("Select source"); const char* title = "Select values sources";
ImGui::SameLine(); if (ImGui::Button("Values"))
if (dyn.default_value_source_id == external_source_id{ 0 }) { ImGui::OpenPopup(title);
ImGui::TextUnformatted("<None>"); ImGui::SameLine();
} else {
ImGui::Text("%" PRIu64, static_cast<u64>(dyn.default_value_source_id)); if (dyn.default_value_source.data == nullptr) {
ImGui::TextUnformatted("<None>");
} else {
ImGui::Text("%" PRIu32 "-%" PRIu32,
dyn.default_value_source.type,
dyn.default_value_source.id);
}
app.srcs.show_menu(title, dyn.default_value_source);
} }
external_source src; {
app.srcs.show_menu(src); const char* title = "Select time sources";
if (ImGui::Button("Times"))
ImGui::OpenPopup(title);
ImGui::SameLine();
if (dyn.default_lambda_source.data == nullptr) {
ImGui::TextUnformatted("<None>");
} else {
ImGui::Text("%" PRIu32 "-%" PRIu32,
dyn.default_lambda_source.type,
dyn.default_lambda_source.id);
}
app.srcs.show_menu(title, dyn.default_lambda_source);
}
} }
static void static void
......
...@@ -311,7 +311,7 @@ struct sources ...@@ -311,7 +311,7 @@ struct sources
irt::source::text_file* new_text_file() noexcept; irt::source::text_file* new_text_file() noexcept;
void show(bool* is_show); void show(bool* is_show);
void show_menu(external_source& src); void show_menu(const char *title, external_source& src);
}; };
struct editor struct editor
......
...@@ -763,14 +763,14 @@ sources::show(bool* is_show) ...@@ -763,14 +763,14 @@ sources::show(bool* is_show)
} }
void void
sources::show_menu(external_source& src) sources::show_menu(const char* title, external_source& src)
{ {
small_string<16> tmp; small_string<16> tmp;
std::pair<const int, source::constant>* constant_ptr = nullptr; std::pair<const int, source::constant>* constant_ptr = nullptr;
std::pair<const int, source::binary_file>* binary_file_ptr = nullptr; std::pair<const int, source::binary_file>* binary_file_ptr = nullptr;
std::pair<const int, source::text_file>* text_file_ptr = nullptr; std::pair<const int, source::text_file>* text_file_ptr = nullptr;
if (ImGui::BeginPopup("Select source")) { if (ImGui::BeginPopup(title)) {
if (!csts.empty() && ImGui::BeginMenu("Constant")) { if (!csts.empty() && ImGui::BeginMenu("Constant")) {
for (auto& elem : csts) { for (auto& elem : csts) {
fmt::format_to_n(tmp.begin(), tmp.capacity(), "{}", elem.first); fmt::format_to_n(tmp.begin(), tmp.capacity(), "{}", elem.first);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment