Skip to content

Commit 683caa0

Browse files
committed
-
1 parent 8b06705 commit 683caa0

6 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/frontend/Components/CodeEditor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ void CodeEditor::SetBreakpointInteractionEnabled(bool aEnabled) {
395395
m_BreakpointInteractionEnabled = aEnabled;
396396
}
397397

398+
void CodeEditor::SetPendingFontScale(float aScale) {
399+
m_Editor.SetPendingFontScale(aScale);
400+
}
401+
402+
float CodeEditor::GetCurrentFontScale() const {
403+
return m_Editor.GetCurrentFontScale();
404+
}
405+
398406
void CodeEditor::m_RebuildMarkers() {
399407
m_Editor.ClearMarkers();
400408
// breakpoints are drawn by the line decorator (a red dot); markers carry errors + current line

src/frontend/Components/CodeEditor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ class CodeEditor {
9797
void SetHoverTokenCallback(std::function<void(const std::string& aToken)> aCallback);
9898
void SetBreakpoints(const std::unordered_set<int32_t>& aZeroBasedLines, int64_t aRevision);
9999
void SetCurrentExecLine(int32_t aZeroBasedLine);
100+
101+
// per-editor persistent font scale — pushes a one-shot value into the underlying TextEditor
102+
// (applied on the next render after BeginChild). GetCurrentFontScale reads back the effective
103+
// scale; the host polls it after OnImGui to detect interactive Ctrl+MouseWheel zoom and persist.
104+
void SetPendingFontScale(float aScale);
105+
float GetCurrentFontScale() const;
100106
void SetBreakpointInteractionEnabled(bool aEnabled);
101107

102108
private:

src/panes/misc/CodePane.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ bool CodePane::drawPanes(bool* apOpened, LayoutPaneUserDatas apUserDatas) {
135135
}
136136
sheet.codeEditor.SetBreakpointInteractionEnabled(isDebugArmed);
137137
sheet.codeEditor.OnImGui();
138+
// capture interactive Ctrl+MouseWheel zoom on the project-script sheet
139+
// and persist it via ProjectFile. Only the project-script sheet — external
140+
// file sheets are transient and not persisted in the project XML.
141+
if (sheet.filepathName == sc_PROJECT_SCRIPT_ID) {
142+
const float liveScale = sheet.codeEditor.GetCurrentFontScale();
143+
if (liveScale > 0.0f && std::fabs(liveScale - ProjectFile::ref()->m_ProjectScriptFontScale) > 0.001f) {
144+
ProjectFile::ref()->m_ProjectScriptFontScale = liveScale;
145+
ProjectFile::ref()->SetProjectChange(true);
146+
}
147+
}
138148
ImGui::EndTabItem();
139149
}
140150
ImGui::PopID();
@@ -379,6 +389,10 @@ void CodePane::OpenScript(const std::string& aCode) {
379389
scriptSheetPtr = &sheet;
380390
}
381391
scriptSheetPtr->codeEditor.SetCode(aCode, TextEditor::Language::Lua());
392+
// restore the persisted zoom — one-shot pending value that the editor applies on its next
393+
// Render after BeginChild. After that, ImGui's interactive Ctrl+MouseWheel takes over and the
394+
// drawPanes loop above captures any change back into ProjectFile.
395+
scriptSheetPtr->codeEditor.SetPendingFontScale(ProjectFile::ref()->m_ProjectScriptFontScale);
382396
}
383397

384398
std::string CodePane::GetScriptCode() {

src/project/ProjectFile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ ez::xml::Nodes ProjectFile::getXmlNodes(const std::string& /*vUserDatas*/) {
313313
node.addChild("auto_resize_columns_log_view").setContent(m_AutoResizeLogColumns);
314314
node.addChild("auto_resize_columns_log_2nd_view").setContent(m_AutoResizeLog2ndColumns);
315315
node.addChild("hovered_list_changed_text_rect_thickness").setContent(m_HoveredListChangedTextRectThickNess);
316+
node.addChild("project_script_font_scale").setContent(m_ProjectScriptFontScale);
316317
node.addChild("last_log_file_path").setContent(m_LastLogFilePath);
317318
node.addChild("script_file").setContent(m_ScriptFilePathName);
318319
auto& childNode = node.addChild("log_files");
@@ -398,6 +399,9 @@ bool ProjectFile::setFromXmlNodes(const ez::xml::Node& vNode, const ez::xml::Nod
398399
m_AutoResizeLog2ndColumns = ez::dvariant(strValue).GetB();
399400
} else if (strName == "hovered_list_changed_text_rect_thickness") {
400401
m_HoveredListChangedTextRectThickNess = ez::fvariant(strValue).GetF();
402+
} else if (strName == "project_script_font_scale") {
403+
m_ProjectScriptFontScale = ez::fvariant(strValue).GetF();
404+
if (m_ProjectScriptFontScale <= 0.0f) m_ProjectScriptFontScale = 1.0f;
401405
} else if (strName == "last_log_file_path") {
402406
m_LastLogFilePath = strValue;
403407
} else if (strName == "script_file") {

src/project/ProjectFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ProjectFile : public Ltg::IProject, public ez::xml::Config {
7676
bool m_AutoResizeLogColumns = false;
7777
bool m_AutoResizeLog2ndColumns = false;
7878
float m_HoveredListChangedTextRectThickNess = 2.0f;
79+
float m_ProjectScriptFontScale = 1.0f; // interactive Ctrl+MouseWheel zoom of the project-script code editor, persisted in the project XML
7980

8081
private: // dont save
8182
bool m_IsLoaded = false;

0 commit comments

Comments
 (0)