Canvas Gui and styling improvements, helper fns

This commit is contained in:
scawful
2024-01-23 10:14:52 -05:00
parent db51acd12a
commit d183f1d784
8 changed files with 113 additions and 53 deletions

View File

@@ -81,7 +81,7 @@ void GraphicsBinCanvasPipeline(int width, int height, int tile_size,
if (key >= 1) {
top_left_y = canvas.zero_point().y + height * key;
}
canvas.GetDrawList()->AddImage(
canvas.draw_list()->AddImage(
(void*)value.texture(),
ImVec2(canvas.zero_point().x + 2, top_left_y),
ImVec2(canvas.zero_point().x + 0x100,
@@ -113,7 +113,7 @@ void GraphicsManagerCanvasPipeline(int width, int height, int tile_size,
if (key >= 1) {
top_left_y = canvas.zero_point().y + height * key;
}
canvas.GetDrawList()->AddImage(
canvas.draw_list()->AddImage(
(void*)value->texture(),
ImVec2(canvas.zero_point().x + 2, top_left_y),
ImVec2(canvas.zero_point().x + 0x100,

View File

@@ -7,8 +7,9 @@ namespace yaze {
namespace app {
namespace gui {
void BeginWindowWithDisplaySettings(const char* id, bool* active, const ImVec2& size,
ImGuiWindowFlags flags) {
void BeginWindowWithDisplaySettings(const char* id, bool* active,
const ImVec2& size,
ImGuiWindowFlags flags) {
ImGuiStyle* ref = &ImGui::GetStyle();
static float childBgOpacity = 0.75f;
auto color = ImVec4(0.f, 0.f, 0.f, childBgOpacity);
@@ -31,6 +32,31 @@ void EndWindowWithDisplaySettings() {
ImGui::PopStyleColor(3);
}
void BeginPadding(int i) {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(i, i));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(i, i));
}
void EndPadding() { EndNoPadding(); }
void BeginNoPadding() {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
}
void EndNoPadding() { ImGui::PopStyleVar(2); }
void BeginChildWithScrollbar(int id) {
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)id);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar);
}
void BeginChildBothScrollbars(int id) {
ImGuiID child_id = ImGui::GetID((void*)(intptr_t)id);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar |
ImGuiWindowFlags_AlwaysHorizontalScrollbar);
}
void DrawDisplaySettings(ImGuiStyle* ref) {
// You can pass in a reference ImGuiStyle structure to compare to, revert to
// and save to (without a reference style pointer, we will use one compared

View File

@@ -15,6 +15,16 @@ void BeginWindowWithDisplaySettings(const char* id, bool* active,
void EndWindowWithDisplaySettings();
void BeginPadding(int i);
void EndPadding();
void BeginNoPadding();
void EndNoPadding();
void BeginChildWithScrollbar(int id);
void BeginChildBothScrollbars(int id);
void DrawDisplaySettings(ImGuiStyle* ref = nullptr);
void TextWithSeparators(const absl::string_view& text);