summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2022-12-04 22:09:42 +0100
committerSam Atkins <atkinssj@gmail.com>2022-12-23 12:16:46 +0000
commit808eafcf1e7d227da9055b0c784cda7cc1afbb3e (patch)
treecd644a60e964bf118023b5946983082feea1b00f /Userland/Applications
parent2b635b5330804bf6ba79a40d81d25e5ae14c1a4f (diff)
downloadserenity-808eafcf1e7d227da9055b0c784cda7cc1afbb3e.zip
Magnifier: Add option to choose grid color
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Magnifier/MagnifierWidget.cpp14
-rw-r--r--Userland/Applications/Magnifier/MagnifierWidget.h3
-rw-r--r--Userland/Applications/Magnifier/main.cpp10
3 files changed, 23 insertions, 4 deletions
diff --git a/Userland/Applications/Magnifier/MagnifierWidget.cpp b/Userland/Applications/Magnifier/MagnifierWidget.cpp
index 66953b1c0d..941fb27d9a 100644
--- a/Userland/Applications/Magnifier/MagnifierWidget.cpp
+++ b/Userland/Applications/Magnifier/MagnifierWidget.cpp
@@ -40,6 +40,14 @@ void MagnifierWidget::show_grid(bool new_value)
update();
}
+void MagnifierWidget::set_grid_color(Gfx::Color new_color)
+{
+ if (m_grid_color == new_color)
+ return;
+ m_grid_color = new_color;
+ update();
+}
+
void MagnifierWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter)
{
m_color_filter = move(color_filter);
@@ -92,8 +100,6 @@ void MagnifierWidget::paint_event(GUI::PaintEvent& event)
painter.draw_scaled_bitmap(frame_inner_rect(), *m_grabbed_bitmap, m_grabbed_bitmap->rect(), 1.0, Gfx::Painter::ScalingMode::NearestFractional);
if (m_show_grid) {
- auto line_color = Color(Color::NamedColor::Magenta);
- line_color.set_alpha(100);
auto grid_rect = frame_inner_rect();
if (m_grabbed_bitmap)
@@ -109,10 +115,10 @@ void MagnifierWidget::paint_event(GUI::PaintEvent& event)
end_x = grid_rect.right();
for (int current_y = start_y; current_y <= end_y; current_y += m_scale_factor)
- painter.draw_line({ start_x, current_y }, { end_x, current_y }, line_color);
+ painter.draw_line({ start_x, current_y }, { end_x, current_y }, m_grid_color);
for (int current_x = start_y; current_x <= end_x; current_x += m_scale_factor)
- painter.draw_line({ current_x, start_y }, { current_x, end_y }, line_color);
+ painter.draw_line({ current_x, start_y }, { current_x, end_y }, m_grid_color);
}
}
diff --git a/Userland/Applications/Magnifier/MagnifierWidget.h b/Userland/Applications/Magnifier/MagnifierWidget.h
index 5cd94ff8ef..452efe376b 100644
--- a/Userland/Applications/Magnifier/MagnifierWidget.h
+++ b/Userland/Applications/Magnifier/MagnifierWidget.h
@@ -22,6 +22,8 @@ public:
void set_scale_factor(int scale_factor);
virtual void set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter>) override;
void show_grid(bool);
+ Gfx::Color grid_color() { return m_grid_color; }
+ void set_grid_color(Gfx::Color);
void pause_capture(bool pause)
{
@@ -50,4 +52,5 @@ private:
bool m_pause_capture { false };
Optional<Gfx::IntPoint> m_locked_location {};
bool m_show_grid { false };
+ Gfx::Color m_grid_color { 255, 0, 255, 100 };
};
diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp
index 10d8758e61..27bce36e19 100644
--- a/Userland/Applications/Magnifier/main.cpp
+++ b/Userland/Applications/Magnifier/main.cpp
@@ -11,6 +11,7 @@
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
+#include <LibGUI/ColorPicker.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Menubar.h>
@@ -121,6 +122,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
magnifier->show_grid(action.is_checked());
});
+ auto choose_grid_color_action = GUI::Action::create(
+ "Choose Grid &Color", [&](auto& action [[maybe_unused]]) {
+ auto dialog = GUI::ColorPicker::construct(magnifier->grid_color(), window, "Magnifier: choose grid color");
+ dialog->set_color_has_alpha_channel(true);
+ if (dialog->exec() == GUI::Dialog::ExecResult::OK)
+ magnifier->set_grid_color(dialog->color());
+ });
+
size_action_group->add_action(two_x_action);
size_action_group->add_action(four_x_action);
size_action_group->add_action(eight_x_action);
@@ -136,6 +145,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(view_menu->try_add_action(pause_action));
TRY(view_menu->try_add_action(lock_location_action));
TRY(view_menu->try_add_action(show_grid_action));
+ TRY(view_menu->try_add_action(choose_grid_color_action));
auto timeline_menu = TRY(window->try_add_menu("&Timeline"));
auto previous_frame_action = GUI::Action::create(