mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
PixelPaint: Use LibConfig to allow custom pixel grid threshold
Depending on the size / scaling of the UI, someone might want to change what the threshold is to show the pixel grid. For instance if you are working on a 50x50 image, and want to see the grid while still fitting the whole image in the editor. Since there's no UI for settings in PixelPaint right now, this commit just uses LibConfig to read the following entry: ("PixelPaint", "PixelGrid", "Threshold") which is then used when drawing the grid.
This commit is contained in:
parent
451cba8b47
commit
3141d51164
Notes:
sideshowbarker
2024-07-18 04:14:13 +09:00
Author: https://github.com/mustafaquraish Commit: https://github.com/SerenityOS/serenity/commit/3141d511644 Pull-request: https://github.com/SerenityOS/serenity/pull/9974 Issue: https://github.com/SerenityOS/serenity/issues/9971 Reviewed-by: https://github.com/Granddave ✅ Reviewed-by: https://github.com/TobyAsE
4 changed files with 8 additions and 3 deletions
|
@ -44,4 +44,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(PixelPaint ICON app-pixel-paint)
|
||||
target_link_libraries(PixelPaint LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient)
|
||||
target_link_libraries(PixelPaint LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient LibConfig)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Layer.h"
|
||||
#include "MoveTool.h"
|
||||
#include "Tool.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibGUI/Command.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/DisjointRectSet.h>
|
||||
|
@ -29,6 +30,7 @@ ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
|
|||
m_undo_stack = make<GUI::UndoStack>();
|
||||
m_undo_stack->push(make<ImageUndoCommand>(*m_image));
|
||||
m_image->add_client(*this);
|
||||
m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15);
|
||||
}
|
||||
|
||||
ImageEditor::~ImageEditor()
|
||||
|
@ -86,8 +88,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
painter.draw_rect(enclosing_int_rect(image_rect_to_editor_rect(m_active_layer->relative_rect())).inflated(2, 2), Color::Black);
|
||||
}
|
||||
|
||||
const float pixel_grid_threshold = 15.0f;
|
||||
if (m_show_pixel_grid && m_scale > pixel_grid_threshold) {
|
||||
if (m_show_pixel_grid && m_scale > m_pixel_grid_threshold) {
|
||||
auto event_image_rect = enclosing_int_rect(editor_rect_to_image_rect(event.rect())).inflated(1, 1);
|
||||
auto image_rect = m_image->rect().inflated(1, 1).intersected(event_image_rect);
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ private:
|
|||
int m_ruler_thickness { 20 };
|
||||
int m_mouse_indicator_triangle_size { 5 };
|
||||
|
||||
float m_pixel_grid_threshold { 15.0f };
|
||||
|
||||
Gfx::StandardCursor m_active_cursor { Gfx::StandardCursor::None };
|
||||
|
||||
Selection m_selection;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "MainWidget.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
|
@ -26,6 +27,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
Config::pledge_domains("PixelPaint");
|
||||
|
||||
const char* image_file = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
|
|
Loading…
Reference in a new issue