diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f351015c5113ddca9b11af6553cad6ca5efaeb18..3d43a6e54a92f82890ff362adf47595fa74a9491 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,53 @@ 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) + 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); + + if (Inkscape::UI::dialog_run(dialog) == Gtk::ResponseType::OK) { + // Increase the opacity which are less than threshold + unsigned int const 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;