| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- #include <algorithm>
- #include <cstddef>
- #include <cstring>
- #include <fmt/format.h>
- #include <iterator>
- #include <memory>
- #include <span>
- #include <sstream>
- #include <string>
- #include <vector>
- #include "saura/core/base/types.hpp"
- #include "saura/core/memory/arena.hpp"
- #include <saura/core/app_base/app_base.hpp>
- #include <saura/core/os/os.hpp>
- #include <imgui.h>
- #include <imgui_internal.h>
- #include <spdlog/spdlog.h>
- namespace saura {
- struct SandboxApp : AppBase {
- std::unique_ptr<MemoryArena> def_mem_arena;
- std::unique_ptr<MemoryArenaTemp> mem_arena_temp;
- void start() override {
- spdlog::info("Sandbox start!");
- spdlog::info("DPI scale: {}", os_ctx->get_dpi_scale());
- this->def_mem_arena = std::make_unique<MemoryArena>();
- this->mem_arena_temp = std::make_unique<MemoryArenaTemp>();
- }
- void update(double dt) override {}
- void draw() override {
- ImGui::SetNextWindowPos({0.0f, 0.0f});
- ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
- ImGui::Begin("Demo", 0,
- ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
- ImGuiWindowFlags_NoFocusOnAppearing |
- ImGuiWindowFlags_NoSavedSettings);
- ImGuiTableFlags flags =
- ImGuiTableFlags_Resizable | ImGuiTableFlags_Borders |
- ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_ScrollY;
- ImGui::Text("Маркировка товаров");
- // ===== Layout =====
- struct FormLayout {
- float label_w;
- float field_w;
- };
- FormLayout layout{
- .label_w = 130.0f,
- .field_w = 260.0f,
- };
- // ===== Helpers =====
- auto form_row = [&](const char *label, auto draw_field) {
- ImGui::TextUnformatted(label);
- ImGui::SameLine();
- ImGui::SetCursorPosX(layout.label_w);
- ImGui::SetNextItemWidth(layout.field_w);
- draw_field();
- };
- // ===== Sizes =====
- float row_h = ImGui::GetFrameHeightWithSpacing();
- float top_height = row_h * 6.0f;
- // ===== Top Left =====
- ImGui::BeginChild("TopLeft", ImVec2(400, top_height), true);
- {
- form_row("Организация:", [&] {
- if (ImGui::BeginCombo("##org", "Фламинго ООО"))
- ImGui::EndCombo();
- });
- form_row("Продукция:", [&] {
- if (ImGui::BeginCombo("##prod", "Basic Premium - M 30 шт/уп"))
- ImGui::EndCombo();
- });
- form_row("Серия:", [&] {
- if (ImGui::BeginCombo("##series", "53698677 до 11.01.31"))
- ImGui::EndCombo();
- });
- static char series_num[128] = "A-08";
- form_row("Номер серии:", [&] {
- ImGui::InputText("##series_num", series_num, sizeof(series_num));
- });
- static char batch_num[128] = "A-08";
- form_row("Номер партии:", [&] {
- ImGui::InputText("##batch_num", batch_num, sizeof(batch_num));
- });
- }
- ImGui::EndChild();
- // ===== Top Right =====
- ImGui::SameLine();
- ImGui::BeginChild("TopRight", ImVec2(0, top_height), true);
- {
- static int box_count = 4;
- form_row("Кол-во в коробке:",
- [&] { ImGui::InputInt("##box", &box_count); });
- static int pallet_count = 18;
- form_row("Кол-во в паллете:",
- [&] { ImGui::InputInt("##pallet", &pallet_count); });
- static char prod_date[64] = "11.01.2026";
- form_row("Дата произв.:", [&] {
- ImGui::InputText("##prod_date", prod_date, sizeof(prod_date));
- });
- static char exp_date[64] = "11.01.2031";
- form_row("Срок годн.:", [&] {
- ImGui::InputText("##exp_date", exp_date, sizeof(exp_date));
- });
- }
- ImGui::EndChild();
- if (ImGui::BeginTabBar("Tabs")) {
- if (ImGui::BeginTabItem("Сканирование")) {
- if (ImGui::BeginTable("DataTable", 2, flags)) {
- ImGui::TableSetupColumn("#");
- ImGui::TableSetupColumn("Упаковка");
- ImGui::TableHeadersRow();
- int32_t selected_row_idx = -1;
- for (size_t idx = 0; idx < 3; idx++) {
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("%03d", (int)idx + 1);
- ImGui::TableNextColumn();
- ImGui::Text(
- "0104650098830926215Roc(yep49_q291EE1192NB7hBGPH9j2lRWm57z2+"
- "YygvLInYURU8/6I/luU1Xj0=");
- }
- ImGui::EndTable();
- }
- ImGui::EndTabItem();
- }
- if (ImGui::BeginTabItem("Упаковки")) {
- ImGui::EndTabItem();
- }
- if (ImGui::BeginTabItem("Коробки")) {
- ImGui::EndTabItem();
- }
- if (ImGui::BeginTabItem("Паллеты")) {
- ImGui::EndTabItem();
- }
- ImGui::EndTabBar();
- }
- ImGui::End();
- // ImGui::ShowDemoWindow();
- }
- void stop() override { spdlog::info("Sandbox stop!"); }
- };
- } // namespace saura
- int main() {
- auto app = std::make_unique<saura::SandboxApp>();
- app->run();
- return 0;
- }
|