ghj
This commit is contained in:
1 parent
e756769780
commit
6c17fd9b2f
17 files changed
+36944
-65087
No files matched your search
@@ -6,6 +6,7 @@
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
@@ -67,14 +68,12 @@ int main(int, char**)
|
||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||
|
||||
ImFontConfig cfg;
|
||||
// cfg.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_;
|
||||
cfg.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_LoadColor;
|
||||
cfg.PixelSnapH = true;
|
||||
cfg.SizePixels = 15.0f;
|
||||
cfg.SizePixels = 18.0f;
|
||||
cfg.RasterizerMultiply = 1.0f;
|
||||
|
||||
|
||||
// ImFont* tahoma = io.Fonts->AddFontFromFileTTF(tahoma_font_directory.c_str(), 13.0f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||
ImFont* font = io.Fonts->AddFontFromMemoryTTF(montserrat, sizeof(montserrat), 15.0f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||
ImFont* font = io.Fonts->AddFontFromMemoryTTF(montserrat, sizeof(montserrat), 18.0f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||
|
||||
// Our state
|
||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
@@ -123,16 +122,103 @@ int main(int, char**)
|
||||
ImGui::PushFontShadow(IM_COL32(0, 0, 0, 0));
|
||||
ImGui::SetNextWindowBgAlpha(1.f);
|
||||
ImGui::SetNextWindowSize(ImVec2(620, 620));
|
||||
// ``ImGui::PushStyleColor()
|
||||
ImGui::Begin("##test_window", 0, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollbar);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.f);
|
||||
ImGui::Begin("##mocha_main", 0, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBackground);
|
||||
{
|
||||
auto pos = ImGui::GetWindowPos();
|
||||
auto size = ImGui::GetWindowSize();
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
auto b_draw = ImGui::GetBackgroundDrawList();
|
||||
|
||||
draw->
|
||||
const int shadow_layers = 10;
|
||||
const float shadow_size = 5.0f;
|
||||
for (int i = 0; i < shadow_layers; ++i)
|
||||
{
|
||||
const float t = (float)(i + 1) / (float)shadow_layers;
|
||||
const float expand = t * shadow_size;
|
||||
const int alpha = (int)(40.0f * (1.0f - t));
|
||||
b_draw->AddRectFilled(
|
||||
ImVec2(pos.x - expand, pos.y - expand),
|
||||
ImVec2(pos.x + size.x + expand, pos.y + size.y + expand),
|
||||
IM_COL32(40, 46, 60, alpha),
|
||||
10.0f + expand
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::Text("astral");
|
||||
draw->AddRectFilled(ImGui::GetWindowPos(), ImGui::GetWindowPos() + ImGui::GetWindowSize(), IM_COL32(40, 46, 60, 255), 10.f);
|
||||
// titlebar
|
||||
{
|
||||
const float title_h = 30.0f;
|
||||
const float title_r = 10.0f;
|
||||
const ImU32 col_l = IM_COL32(129, 183, 255, 255);
|
||||
const ImU32 col_r = IM_COL32(137, 120, 255, 255);
|
||||
|
||||
// i want to die
|
||||
draw->AddRectFilledMultiColor(
|
||||
ImVec2(pos.x, pos.y + title_r),
|
||||
ImVec2(pos.x + size.x, pos.y + title_h),
|
||||
col_l, col_r, col_r, col_l
|
||||
);
|
||||
|
||||
draw->AddRectFilledMultiColor(
|
||||
ImVec2(pos.x + title_r, pos.y),
|
||||
ImVec2(pos.x + size.x - title_r, pos.y + title_r),
|
||||
col_l, col_r, col_r, col_l
|
||||
);
|
||||
|
||||
draw->AddCircleFilled(ImVec2(pos.x + title_r, pos.y + title_r), title_r, col_l, 24);
|
||||
draw->AddCircleFilled(ImVec2(pos.x + size.x - title_r, pos.y + title_r), title_r, col_r, 24);
|
||||
ImGui::Text("Mocha");
|
||||
}
|
||||
|
||||
// content
|
||||
{
|
||||
ImGui::SetCursorPos(ImVec2(ImGui::GetCursorPosX() + 5.f, ImGui::GetCursorPosY() + 15.f));
|
||||
ImGui::BeginChild("##mocha_test_child", ImVec2(300, 330));
|
||||
{
|
||||
pos = ImGui::GetWindowPos();
|
||||
size = ImGui::GetWindowSize();
|
||||
draw = ImGui::GetWindowDrawList();
|
||||
|
||||
draw->AddRectFilled(pos, pos + size, IM_COL32(45, 50, 65, 255), 10.f);
|
||||
|
||||
// titlebar
|
||||
{
|
||||
const float title_h = 30.0f;
|
||||
const float title_r = 10.0f;
|
||||
const ImU32 col_top = IM_COL32(45, 50, 65, 255);
|
||||
const ImU32 col_bottom = IM_COL32(40, 45, 60, 255);
|
||||
|
||||
draw->AddRectFilled(
|
||||
ImVec2(pos.x, pos.y),
|
||||
ImVec2(pos.x + size.x, pos.y + title_h),
|
||||
col_top,
|
||||
title_r
|
||||
);
|
||||
|
||||
// Reverse gradient under the titlebar to mimic a drop shadow
|
||||
draw->AddRectFilledMultiColor(
|
||||
ImVec2(pos.x, pos.y + title_h),
|
||||
ImVec2(pos.x + size.x, pos.y + title_h + title_r),
|
||||
col_bottom, col_bottom, col_top, col_top
|
||||
);
|
||||
|
||||
draw->AddCircleFilled(ImVec2(pos.x + title_r, pos.y + title_r), title_r, col_top, 24);
|
||||
draw->AddCircleFilled(ImVec2(pos.x + size.x - title_r, pos.y + title_r), title_r, col_top, 24);
|
||||
const char* text = "Test";
|
||||
ImVec2 text_size = ImGui::CalcTextSize(text);
|
||||
ImGui::SetCursorPos(ImVec2(((size.x - text_size.x) * 0.5f), 5.f));
|
||||
ImGui::Text(text);
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(4);
|
||||
ImGui::PopFontShadow();
|
||||
|
||||
// Rendering
|
||||
|
||||
Reference in new issue
Block a user