CoolFace
Datasetpublic

dlxjj/imradv3

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes263downloads
ui_about_dlg.cpp214 linesDownload Raw Back to src
1// Generated with ImRAD 0.12// github.com/xyz3 4#include "ui_about_dlg.h"5#include "utils.h"6 7AboutDlg aboutDlg;8 9void AboutDlg::OpenPopup(std::function<void(ImRad::ModalResult)> clb)10{11    callback = clb;12    modalResult = ImRad::None;13    auto *ioUserData = (ImRad::IOUserData *)ImGui::GetIO().UserData;14    ioUserData->dimBgRatio = 1.f;15    ImGui::OpenPopup(ID);16    Init();17}18 19void AboutDlg::ClosePopup(ImRad::ModalResult mr)20{21    modalResult = mr;22    auto *ioUserData = (ImRad::IOUserData *)ImGui::GetIO().UserData;23    ioUserData->dimBgRatio = 0.f;24}25 26 27void AboutDlg::Init()28{29    // TODO: Add your code here30}31 32void AboutDlg::Draw()33{34    /// @style imrad35    /// @unit px36    /// @begin TopWindow37    auto* ioUserData = (ImRad::IOUserData*)ImGui::GetIO().UserData;38    ID = ImGui::GetID("###AboutDlg");39    ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGui::GetStyleColorVec4(ImGuiCol_TitleBgActive));40    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 60, 15 });41    ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 10, 7 });42    ImGui::SetNextWindowPos(ioUserData->WorkRect().GetCenter(), 0, { 0.5f, 0.5f }); //Center43    ImGui::SetNextWindowSize({ 0, 0 }); //{ 0, 0 }44    bool tmpOpen = true;45    if (ImGui::BeginPopupModal("About###AboutDlg", &tmpOpen, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize))46    {47        if (ioUserData->activeActivity != "")48            ImRad::RenderDimmedBackground(ioUserData->WorkRect(), ioUserData->dimBgRatio);49        if (modalResult != ImRad::None)50        {51            ImGui::CloseCurrentPopup();52            if (modalResult != ImRad::Cancel)53                callback(modalResult);54        }55        /// @separator56 57        // TODO: Add Draw calls of dependent popup windows here58 59        /// @begin Image60        if (!value1)61            value1 = ImRad::LoadTextureFromFile("style/icon-40.png");62        ImGui::Image(value1.id, { (float)value1.w, (float)value1.h });63        /// @end Image64 65        // TODO: Add Draw calls of dependent popup windows here66 67        /// @begin Text68        ImGui::SameLine(0, 2 * ImGui::GetStyle().ItemSpacing.x);69        ImGui::PushFont(ImRad::GetFontByName("imrad.H1"));70        ImGui::TextUnformatted(ImRad::Format("{}", VER_STR).c_str());71        ImGui::PopFont();72        /// @end Text73 74        /// @begin Separator75        ImRad::Spacing(1);76        ImRect r1 = ImGui::GetCurrentWindow()->InnerRect;77        ImGui::PushClipRect(r1.Min, r1.Max, false);78        ImGui::SetCursorScreenPos({ r1.Min.x, ImGui::GetCursorScreenPos().y });79        ImVec2 wr1 = ImGui::GetCurrentWindow()->WorkRect.Max;80        ImGui::GetCurrentWindow()->WorkRect.Max.x = r1.Max.x;81        ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);82        ImGui::PopClipRect();83        ImGui::GetCurrentWindow()->WorkRect.Max = wr1;84        /// @end Separator85 86        /// @begin Text87        ImRad::Spacing(2);88        ImGui::TextUnformatted(ImRad::Format("built with ImGui {}", IMGUI_VERSION).c_str());89        /// @end Text90 91        /// @begin Text92        ImGui::TextUnformatted("Tomas Pecholt");93        /// @end Text94 95        /// @begin Text96        ImRad::Spacing(2);97        ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));98        ImGui::TextUnformatted("For more information and updates visit");99        ImGui::PopStyleColor();100        /// @end Text101 102        /// @begin Table103        if (ImGui::BeginTable("table2", 2, ImGuiTableFlags_None, { -1, 0 }))104        {105            ImGui::TableSetupColumn("A", ImGuiTableColumnFlags_WidthFixed, 0);106            ImGui::TableSetupColumn("B", ImGuiTableColumnFlags_WidthStretch, 0);107            ImGui::TableNextRow(0, 0);108            ImGui::TableSetColumnIndex(0);109            /// @separator110 111            /// @begin Text112            ImGui::PushStyleColor(ImGuiCol_Text, 0xff003398);113            ImGui::TextUnformatted("Project page");114            ImGui::PopStyleColor();115            if (ImGui::IsItemHovered())116                ImGui::SetMouseCursor(7);117            if (ImGui::IsItemHovered())118                HoverURL();119            if (ImGui::IsItemClicked())120                OpenURL();121            /// @end Text122 123            /// @begin Text124            ImRad::TableNextColumn(2);125            ImRad::Spacing(1);126            ImGui::PushStyleColor(ImGuiCol_Text, 0xff003398);127            ImGui::TextUnformatted("Tutorials & How To");128            ImGui::PopStyleColor();129            if (ImGui::IsItemHovered())130                ImGui::SetMouseCursor(7);131            if (ImGui::IsItemHovered())132                HoverURL();133            if (ImGui::IsItemClicked())134                OpenURL();135            /// @end Text136 137            /// @begin Text138            ImRad::TableNextColumn(2);139            ImRad::Spacing(1);140            ImGui::PushStyleColor(ImGuiCol_Text, 0xff003398);141            ImGui::TextUnformatted("Report a bug");142            ImGui::PopStyleColor();143            if (ImGui::IsItemHovered())144                ImGui::SetMouseCursor(7);145            if (ImGui::IsItemHovered())146                HoverURL();147            if (ImGui::IsItemClicked())148                OpenURL();149            /// @end Text150 151 152            /// @separator153            ImGui::EndTable();154        }155        /// @end Table156 157        /// @begin Table158        ImRad::Spacing(2);159        if (ImGui::BeginTable("table3", 2, ImGuiTableFlags_NoPadOuterX | ImGuiTableFlags_NoPadInnerX, { 0, 0 }))160        {161            ImGui::TableSetupColumn("left-stretch", ImGuiTableColumnFlags_WidthStretch, 0);162            ImGui::TableSetupColumn("content", ImGuiTableColumnFlags_WidthFixed, 0);163            ImGui::TableNextRow(0, 0);164            ImGui::TableSetColumnIndex(0);165            /// @separator166 167            /// @begin Button168            ImRad::TableNextColumn(1);169            if (ImGui::Button("OK", { 100, 30 }) || ImGui::Shortcut(ImGuiKey_Escape))170            {171                ClosePopup(ImRad::Ok);172            }173            /// @end Button174 175 176            /// @separator177            ImGui::EndTable();178        }179        /// @end Table180 181        /// @separator182        ImGui::EndPopup();183    }184    ImGui::PopStyleVar();185    ImGui::PopStyleVar();186    ImGui::PopStyleColor();187    /// @end TopWindow188}189 190 191void AboutDlg::OpenURL()192{193    switch (ImGui::TableGetRowIndex())194    {195    case 0:196        ShellExec(GITHUB_URL);197        break;198    case 1:199        ShellExec(GITHUB_URL + "/wiki");200        break;201    case 2:202        ShellExec(GITHUB_URL + "/issues");203        break;204    }205}206 207void AboutDlg::HoverURL()208{209    ImVec2 p1 = ImGui::GetItemRectMin();210    ImVec2 p2 = ImGui::GetItemRectMax();211    auto* dl = ImGui::GetWindowDrawList();212    dl->AddLine({ p1.x, p2.y }, { p2.x, p2.y }, 0xff003399);213}214