[0.1.21] Right-click an OCR box in the image view to copy its text

This commit is contained in:
Musa Mahmood 2026-10-14 20:05:25 +01:00
parent e12622700d
commit 7cee21122c
3 changed files with 20 additions and 3 deletions

View File

@ -47,7 +47,7 @@ APP_NAME :: "mcap";
APP_FOLDER_NAME :: "mcap";
GIT_BRANCH :: "check";
GIT_HASH :: "-";
VERSION :: "0.1.20";
VERSION :: "0.1.21";
BUILD_DATE :: "-";
DEBUG :: true;
COMPILE_TESTS :: true;

View File

@ -8,7 +8,7 @@ APP_NAME :: "mcap";
APP_FOLDER_NAME :: "mcap";
APP_BUNDLE_IDENTIFIER :: "com.example.mcap";
VERSION :: "0.1.20";
VERSION :: "0.1.21";
// Where everything goes: bin/, or bin-headless/ for builds made with no_crash_dialog, so automated
// builds never write over the ones you run by hand.
build_directory := "bin";

View File

@ -53,6 +53,7 @@ ocr_ui: struct {
show_boxes := true;
match_cursor: s64 = -1; // which match Next and Previous last went to
scroll_to_match: bool;
menu_text: string; // heap: the line right-clicked, for its menu's Copy
window_open := false;
toast_shown := false;
@ -943,6 +944,7 @@ ocr_ui_capture_overlay :: (index: s32, image_min: ImGui.ImVec2, zoom: float) { u
plain := GetColorU32(.PlotHistogram, ifx searching then 0.35 else 1.0);
matching := GetColorU32(.PlotLinesHovered);
match_number := 0;
clicked: string; // the line right-clicked this frame; the last drawn, which is on top, where they overlap
for section.lines {
p0 := ImVec2.{image_min.x + it.x * scale_x, image_min.y + it.y * scale_y};
p1 := ImVec2.{p0.x + it.width * scale_x, p0.y + it.height * scale_y};
@ -963,6 +965,21 @@ ocr_ui_capture_overlay :: (index: s32, image_min: ImGui.ImVec2, zoom: float) { u
} else {
draw.AddQuad(draw, q[0], q[1], q[2], q[3], plain, 1.5);
}
if IsMouseHoveringRect(p0, p1) SetTooltip("% (%)", it.text, FF(it.confidence, 2));
if IsMouseHoveringRect(p0, p1) {
SetTooltip("% (%)", it.text, FF(it.confidence, 2));
if IsWindowHovered() && IsMouseClicked(.Right) clicked = it.text;
}
}
// Right-click a box for its menu. The text is kept, since the reading may change while the menu is up.
MENU :: "##ocr_line_menu";
if clicked {
free(ocr_ui.menu_text,, context.default_allocator);
ocr_ui.menu_text = copy_string(clicked,, context.default_allocator);
OpenPopup(MENU);
}
if BeginPopup(MENU) {
if MenuItem("Copy") clipboard_set_text(ocr_ui.menu_text);
EndPopup();
}
}