CoolFace
Datasetpublic

dlxjj/imradv3

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes262downloads
ui_input_name.cpp100 linesDownload Raw Back to src
1// Generated with ImRAD 0.82// visit https://github.com/tpecholt/imrad3 4#include "ui_input_name.h"5#include "ui_message_box.h"6 7InputName inputName;8 9 10void InputName::OpenPopup(std::function<void(ImRad::ModalResult)> clb)11{12    callback = clb;13    modalResult = ImRad::None;14    auto *ioUserData = (ImRad::IOUserData *)ImGui::GetIO().UserData;15    ioUserData->dimBgRatio = 1.f;16    ImGui::OpenPopup(ID);17    Init();18}19 20void InputName::ClosePopup(ImRad::ModalResult mr)21{22    modalResult = mr;23    auto *ioUserData = (ImRad::IOUserData *)ImGui::GetIO().UserData;24    ioUserData->dimBgRatio = 0.f;25}26 27void InputName::Init()28{29    // TODO: Add your code here30    name = "";31}32 33void InputName::Draw()34{35    /// @style imrad36    /// @unit px37    /// @begin TopWindow38    auto* ioUserData = (ImRad::IOUserData*)ImGui::GetIO().UserData;39    ID = ImGui::GetID("###InputName");40    ImGui::SetNextWindowSize({ 250, 120 }, ImGuiCond_FirstUseEver); //{ 250, 120 }41    bool tmpOpen = true;42    if (ImGui::BeginPopupModal(ImRad::Format("{}###InputName", title).c_str(), &tmpOpen, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse))43    {44        if (ioUserData->activeActivity != "")45            ImRad::RenderDimmedBackground(ioUserData->WorkRect(), ioUserData->dimBgRatio);46        if (modalResult != ImRad::None)47        {48            ImGui::CloseCurrentPopup();49            if (modalResult != ImRad::Cancel)50                callback(modalResult);51        }52        if (ImGui::Shortcut(ImGuiKey_Escape))53            ClosePopup();54        /// @separator55 56        // TODO: Add Draw calls of dependent popup windows here57        messageBox.Draw();58 59        /// @begin Input60        if (ImGui::IsWindowAppearing())61            ImGui::SetKeyboardFocusHere();62        ImGui::SetNextItemWidth(-1);63        ImGui::InputTextWithHint("##name", ImRad::Format("{}", hint).c_str(), &name, ImGuiInputTextFlags_CharsNoBlank);64        if (ImGui::IsItemActive())65            ioUserData->imeType = ImRad::ImeText;66        /// @end Input67 68        /// @begin Table69        ImRad::Spacing(3);70        if (ImGui::BeginTable("table1", 3, ImGuiTableFlags_NoPadOuterX | ImGuiTableFlags_NoPadInnerX, { 0, 0 }))71        {72            ImGui::TableSetupColumn("left-stretch", ImGuiTableColumnFlags_WidthStretch, 0);73            ImGui::TableSetupColumn("content", ImGuiTableColumnFlags_WidthFixed, 0);74            ImGui::TableSetupColumn("right-stretch", ImGuiTableColumnFlags_WidthStretch, 0);75            ImGui::TableNextRow(0, 0);76            ImGui::TableSetColumnIndex(0);77            /// @separator78 79            /// @begin Button80            ImRad::TableNextColumn(1);81            ImGui::BeginDisabled(name==""||name=="Classic"||name=="Dark"||name=="Light");82            if (ImGui::Button("OK", { 100, 30 }))83            {84                ClosePopup(ImRad::Ok);85            }86            ImGui::EndDisabled();87            /// @end Button88 89 90            /// @separator91            ImGui::EndTable();92        }93        /// @end Table94 95        /// @separator96        ImGui::EndPopup();97    }98    /// @end TopWindow99}100