From 948898faa8d68c70979b98f01937f48d0f1584d5 Mon Sep 17 00:00:00 2001 From: Heapnotizer Date: Tue, 7 Oct 2025 09:21:50 +0530 Subject: [PATCH 1/4] Add Dialog to ask user for resetting the opacity of transparent objects --- src/ui/tools/select-tool.cpp | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f351015c51..a3c61e56fe 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -30,7 +30,10 @@ #include "actions/actions-tools.h" // set_active_tool() +#include + #include "display/drawing-item.h" +#include "ui/dialog-run.h" #include "display/control/canvas-item-catchall.h" #include "display/control/canvas-item-drawing.h" #include "display/control/snap-indicator.h" @@ -236,6 +239,50 @@ bool SelectTool::item_handler(SPItem *local_item, CanvasEvent const &event) } item = sp_event_context_find_item (_desktop, event.pos, force_drag, false); + if (item) { + unsigned int fill_opacity = item->style->fill_opacity.value; + unsigned int opacity = item->style->opacity.value; + unsigned int stroke_opacity = item->style->stroke_opacity.value; + + // Check if object is too transparent (less than 10% opacity) + const unsigned int min_visible_opacity = 1677721; // ~10% of SPIScale24 max (16777215) + + bool is_too_transparent = (opacity < min_visible_opacity) || + (fill_opacity < min_visible_opacity && stroke_opacity < min_visible_opacity); + + // Show popup dialog for transparent object + if (is_too_transparent) { + char const *msg = _("This object has very low opacity and may be difficult to see or select.\n\nWould you like to increase its opacity?"); + Gtk::MessageDialog dialog(msg, false, Gtk::MessageType::WARNING, Gtk::ButtonsType::OK_CANCEL, true); + + if (Inkscape::UI::dialog_run(dialog) == Gtk::ResponseType::OK) { + // Increase the opacity which are less than threshold + const unsigned int safe_opacity = 8388608; + + // Increase overall opacity if it's too low + if (opacity < min_visible_opacity) { + item->style->opacity.set = TRUE; + item->style->opacity.value = safe_opacity; + } + + // Increase fill opacity if it's too low + if (fill_opacity < min_visible_opacity) { + item->style->fill_opacity.set = TRUE; + item->style->fill_opacity.value = safe_opacity; + } + + // Increase stroke opacity if it's too low + if (stroke_opacity < min_visible_opacity) { + item->style->stroke_opacity.set = TRUE; + item->style->stroke_opacity.value = safe_opacity; + } + + // Update the display and create undo entry + item->updateRepr(); + DocumentUndo::done(_desktop->getDocument(), _("Increase object opacity"), ""); + } + } + } sp_object_ref(item, nullptr); rb_escaped = drag_escaped = 0; -- GitLab From 08d7ce3b6d5fd8588140c17239cced70b6c4fccf Mon Sep 17 00:00:00 2001 From: Heapnotizer Date: Tue, 7 Oct 2025 09:29:37 +0530 Subject: [PATCH 2/4] Fix comment --- src/ui/tools/select-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index a3c61e56fe..6e4c035b90 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -245,7 +245,7 @@ bool SelectTool::item_handler(SPItem *local_item, CanvasEvent const &event) unsigned int stroke_opacity = item->style->stroke_opacity.value; // Check if object is too transparent (less than 10% opacity) - const unsigned int min_visible_opacity = 1677721; // ~10% of SPIScale24 max (16777215) + const unsigned int min_visible_opacity = 1677721; bool is_too_transparent = (opacity < min_visible_opacity) || (fill_opacity < min_visible_opacity && stroke_opacity < min_visible_opacity); -- GitLab From 0e3508296af48488840a8d676bfd4addd6fe966b Mon Sep 17 00:00:00 2001 From: Heapnotizer Date: Tue, 7 Oct 2025 09:46:05 +0530 Subject: [PATCH 3/4] Fix formatting --- src/ui/tools/select-tool.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 6e4c035b90..21e1cac042 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -245,20 +245,23 @@ bool SelectTool::item_handler(SPItem *local_item, CanvasEvent const &event) unsigned int stroke_opacity = item->style->stroke_opacity.value; // Check if object is too transparent (less than 10% opacity) - const unsigned int min_visible_opacity = 1677721; - - bool is_too_transparent = (opacity < min_visible_opacity) || - (fill_opacity < min_visible_opacity && stroke_opacity < min_visible_opacity); - + unsigned int const min_visible_opacity = 1677721; + + bool is_too_transparent = + (opacity < min_visible_opacity) || + (fill_opacity < min_visible_opacity && stroke_opacity < min_visible_opacity); + // Show popup dialog for transparent object if (is_too_transparent) { - char const *msg = _("This object has very low opacity and may be difficult to see or select.\n\nWould you like to increase its opacity?"); - Gtk::MessageDialog dialog(msg, false, Gtk::MessageType::WARNING, Gtk::ButtonsType::OK_CANCEL, true); + char const *msg = _("This object has very low opacity and may be difficult to see or " + "select.\n\nWould you like to increase its opacity?"); + Gtk::MessageDialog dialog(msg, false, Gtk::MessageType::WARNING, + Gtk::ButtonsType::OK_CANCEL, true); if (Inkscape::UI::dialog_run(dialog) == Gtk::ResponseType::OK) { // Increase the opacity which are less than threshold - const unsigned int safe_opacity = 8388608; - + unsigned int const safe_opacity = 8388608; + // Increase overall opacity if it's too low if (opacity < min_visible_opacity) { item->style->opacity.set = TRUE; -- GitLab From 0c7bafe90658e91a70005f0e8d77093d8e86dd3c Mon Sep 17 00:00:00 2001 From: Heapnotizer Date: Tue, 7 Oct 2025 09:47:51 +0530 Subject: [PATCH 4/4] Fix formatting --- src/ui/tools/select-tool.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 21e1cac042..3d43a6e54a 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -243,7 +243,7 @@ bool SelectTool::item_handler(SPItem *local_item, CanvasEvent const &event) unsigned int fill_opacity = item->style->fill_opacity.value; unsigned int opacity = item->style->opacity.value; unsigned int stroke_opacity = item->style->stroke_opacity.value; - + // Check if object is too transparent (less than 10% opacity) unsigned int const min_visible_opacity = 1677721; @@ -267,19 +267,19 @@ bool SelectTool::item_handler(SPItem *local_item, CanvasEvent const &event) item->style->opacity.set = TRUE; item->style->opacity.value = safe_opacity; } - + // Increase fill opacity if it's too low if (fill_opacity < min_visible_opacity) { item->style->fill_opacity.set = TRUE; item->style->fill_opacity.value = safe_opacity; } - + // Increase stroke opacity if it's too low if (stroke_opacity < min_visible_opacity) { item->style->stroke_opacity.set = TRUE; item->style->stroke_opacity.value = safe_opacity; } - + // Update the display and create undo entry item->updateRepr(); DocumentUndo::done(_desktop->getDocument(), _("Increase object opacity"), ""); -- GitLab