File size: 2,493 Bytes
17f5b5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Generated with ImRAD 0.1
// github.com/tpecholt/imrad

#include "ui_combo_dlg.h"

ComboDlg comboDlg;


void ComboDlg::Draw()
{
    /// @begin TopWindow
    std::string id = title + "###" + std::to_string((uint64_t)this);
    ImGui::SetNextWindowSize({ 320, 420 }, ImGuiCond_Appearing);
    if (requestOpen) {
        requestOpen = false;
        ImGui::OpenPopup(id.c_str());
    }
    ImVec2 center = ImGui::GetMainViewport()->GetCenter();
    ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
    bool tmpOpen = true;
    if (ImGui::BeginPopupModal(id.c_str(), &tmpOpen, ImGuiWindowFlags_NoCollapse))
    {
        if (requestClose)
            ImGui::CloseCurrentPopup();
        /// @separator

        /// @begin Input
        if (ImGui::IsWindowAppearing())
            ImGui::SetKeyboardFocusHere();
        ImGui::PushFont(font);
        ImGui::InputTextMultiline("##value", &value, { -1, -44 }, ImGuiInputTextFlags_Multiline);
        ImGui::PopFont();
        /// @end Input

        /// @begin Table
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 1, 1 });
        if (ImGui::BeginTable("table2416128940960", 2, ImGuiTableFlags_None, { 0, 0 }))
        {
            ImGui::TableSetupColumn("A", ImGuiTableColumnFlags_WidthStretch, 0);
            ImGui::TableSetupColumn("B", ImGuiTableColumnFlags_WidthFixed, 0);
            ImGui::TableNextRow();
            ImGui::TableSetColumnIndex(0);
            /// @separator

            /// @begin Button
            ImGui::TableNextColumn();
            if (ImGui::Button("OK", { 100, 30 }))
            {
                ClosePopup();
                callback(ImRad::Ok);
            }
            /// @end Button

            /// @begin Button
            ImGui::SameLine(0, 1 * ImGui::GetStyle().ItemSpacing.x);
            if (ImGui::Button("Cancel", { 100, 30 }) ||
                ImGui::IsKeyPressed(ImGuiKey_Escape))
            {
                ClosePopup();
            }
            /// @end Button


            /// @separator
            ImGui::EndTable();
        }
        ImGui::PopStyleVar();
        /// @end Table

        /// @separator
        ImGui::EndPopup();
    }
    /// @end TopWindow
}

void ComboDlg::OpenPopup(std::function<void(ImRad::ModalResult)> clb)
{
    callback = clb;
    requestOpen = true;
    requestClose = false;

// Add your init code here
}

void ComboDlg::ClosePopup()
{
    requestClose = true;
}