Skip to content

Commit bfbfc5b

Browse files
committed
Fix: Minimap inside editor window on right. v0.2.35
1 parent d5ee89f commit bfbfc5b

3 files changed

Lines changed: 19 additions & 22 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.34
1+
0.2.35

pcode-settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"show_status_bar": true,
66
"word_wrap": true,
77
"show_line_numbers": true,
8-
"show_minimap": false,
8+
"show_minimap": true,
99
"show_spaces": true,
1010
"highlight_line": 2,
1111
"show_tabs": true,
1212
"tab_size": 4,
1313
"font_size": 17,
1414
"font_name": "CascadiaMono",
1515
"last_open_dir": ".\\src",
16-
"recent_files": [".\\src\\main.cpp", ".\\src\\editor_app.cpp", ".\\src\\editor_app.h", ".\\docs\\versioning.md", ".\\docs\\imgui_tutorial.md", ".\\docs\\VIM_MOTIONS_SPEC.md", "./src/editor_app.h", "./src/main.cpp", "./src/editor_app.cpp", "VERSION"]
16+
"recent_files": [".\\src\\editor_app.h", ".\\src\\main.cpp", ".\\src\\editor_app.cpp", ".\\docs\\versioning.md", ".\\docs\\imgui_tutorial.md", ".\\docs\\VIM_MOTIONS_SPEC.md", "./src/editor_app.h", "./src/main.cpp", "./src/editor_app.cpp", "VERSION"]
1717
}

src/editor_app.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void settings_load(AppSettings& s, const std::string& path) {
159159
// Version
160160
// ============================================================================
161161
std::string EditorApp::get_version() {
162-
return "pCode Editor version 0.2.33";
162+
return "pCode Editor version 0.2.34";
163163
}
164164

165165
// ============================================================================
@@ -2799,7 +2799,7 @@ void EditorApp::render_status_bar() {
27992799
ImGui::SameLine();
28002800

28012801
// Version with git hash
2802-
ImGui::Text("v0.2.34");
2802+
ImGui::Text("v0.2.35");
28032803
}
28042804

28052805
ImGui::PopStyleColor();
@@ -2809,27 +2809,24 @@ ImGui::PopStyleColor();
28092809
void EditorApp::render_minimap(TextEditor* editor) {
28102810
if (!editor) return;
28112811

2812-
ImGuiViewport* viewport = ImGui::GetMainViewport();
2813-
ImVec2 vp = viewport->Pos;
2814-
ImVec2 vs = viewport->Size;
2812+
// Use current window dimensions instead of main viewport
2813+
ImVec2 window_pos = ImGui::GetWindowPos();
2814+
float window_width = ImGui::GetWindowWidth();
2815+
float window_height = ImGui::GetWindowHeight();
28152816

2816-
float sidebar_width = show_file_tree_ ? 220.0f : 0.0f;
2817-
float editor_x = vp.x + sidebar_width + 60;
2818-
float editor_width = vs.x - sidebar_width - 60 - 90;
2819-
float editor_height = vs.y - 80;
2820-
float minimap_width = 80;
2821-
float minimap_x = editor_x + editor_width + 5;
2817+
float minimap_width = 70;
2818+
float minimap_x = window_pos.x + window_width - minimap_width - 8;
2819+
float minimap_height = window_height - 48; // account for menu
28222820

28232821
auto lines = editor->GetTextLines();
28242822
int total_lines = (int)lines.size();
28252823
if (total_lines == 0) total_lines = 1;
2826-
float scale = (editor_height - 20) / (float)total_lines;
2827-
if (scale > 4) scale = 4;
2824+
float scale = (minimap_height - 20) / (float)total_lines;
2825+
if (scale > 3) scale = 3;
28282826
if (scale < 0.5f) scale = 0.5f;
28292827

2830-
ImGui::SetNextWindowPos(ImVec2(minimap_x, vp.y + 8));
2831-
ImGui::SetNextWindowSize(ImVec2(minimap_width, editor_height - 16));
2832-
ImGui::SetNextWindowViewport(viewport->ID);
2828+
ImGui::SetNextWindowPos(ImVec2(minimap_x, window_pos.y + 28));
2829+
ImGui::SetNextWindowSize(ImVec2(minimap_width, minimap_height));
28332830

28342831
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
28352832
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar |
@@ -2840,8 +2837,8 @@ void EditorApp::render_minimap(TextEditor* editor) {
28402837
auto cursor = editor->GetCursorPosition();
28412838

28422839
for (int i = 0; i < total_lines; i++) {
2843-
float y = vp.y + 10 + (i * scale);
2844-
if (y < vp.y + 10 || y > vp.y + editor_height - 10) continue;
2840+
float y = window_pos.y + 30 + (i * scale);
2841+
if (y < window_pos.y + 30 || y > window_pos.y + minimap_height + 20) continue;
28452842

28462843
if (i == cursor.mLine) {
28472844
ImGui::GetWindowDrawList()->AddRectFilled(
@@ -2864,7 +2861,7 @@ void EditorApp::render_minimap(TextEditor* editor) {
28642861
if (ImGui::IsMouseClicked(0)) {
28652862
ImVec2 mouse = ImGui::GetMousePos();
28662863
if (mouse.x >= minimap_x && mouse.x < minimap_x + minimap_width) {
2867-
float rel_y = mouse.y - (vp.y + 10);
2864+
float rel_y = mouse.y - (window_pos.y + 30);
28682865
int target_line = (int)(rel_y / scale);
28692866
if (target_line < 0) target_line = 0;
28702867
if (target_line >= total_lines) target_line = total_lines - 1;

0 commit comments

Comments
 (0)