Skip to content

Commit

Permalink
Merge pull request #1362 from nicholasrobertm/notepad_font_size
Browse files Browse the repository at this point in the history
feat(notepad) add font size to notepad
  • Loading branch information
3vcloud authored Mar 3, 2025
2 parents f0fb6dd + 3c2c2d4 commit 57dcce0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions GWToolboxdll/Windows/NotePadWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

#include <Modules/Resources.h>
#include <Windows/NotePadWindow.h>
#include <Utils/FontLoader.h>

constexpr auto TEXT_SIZE = 2024 * 16;
const int MIN_FONT_SIZE = 16;

float font_size = static_cast<float>(FontLoader::FontSize::widget_label);

void NotePadWindow::Draw(IDirect3DDevice9*)
{
Expand All @@ -16,10 +20,13 @@ void NotePadWindow::Draw(IDirect3DDevice9*)
if (ImGui::Begin(Name(), GetVisiblePtr(), GetWinFlags())) {
const ImVec2 cmax = ImGui::GetWindowContentRegionMax();
const ImVec2 cmin = ImGui::GetWindowContentRegionMin();
const auto font = FontLoader::GetFontByPx(font_size);
ImGui::PushFont(font);
if (ImGui::InputTextMultiline("##source", text, TEXT_SIZE,
ImVec2(cmax.x - cmin.x, cmax.y - cmin.y), ImGuiInputTextFlags_AllowTabInput)) {
filedirty = true;
}
ImGui::PopFont();
}
ImGui::End();
ImGui::PopStyleVar();
Expand Down Expand Up @@ -49,3 +56,9 @@ void NotePadWindow::SaveSettings(ToolboxIni* ini)
}
}
}

void NotePadWindow::DrawSettingsInternal()
{
ToolboxWindow::DrawSettingsInternal();
ImGui::DragFloat("Text size", &font_size, 1.0, MIN_FONT_SIZE, FontLoader::text_size_max, "%.0f");
}
1 change: 1 addition & 0 deletions GWToolboxdll/Windows/NotePadWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class NotePadWindow : public ToolboxWindow {

void LoadSettings(ToolboxIni* ini) override;
void SaveSettings(ToolboxIni* ini) override;
void DrawSettingsInternal() override;

private:
char text[2024 * 16]{}; // 2024 characters max
Expand Down

0 comments on commit 57dcce0

Please sign in to comment.