mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
PixelPaint: Ask the current tool for the preferred pixel location
When handling mouse events, different tools may want to interact with a different pixel in the image for the same input position.
This commit is contained in:
parent
c9fb380490
commit
3d756e89c8
1 changed files with 6 additions and 2 deletions
|
@ -269,9 +269,11 @@ void ImageEditor::second_paint_event(GUI::PaintEvent& event)
|
||||||
GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(GUI::MouseEvent const& event) const
|
GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(GUI::MouseEvent const& event) const
|
||||||
{
|
{
|
||||||
auto image_position = frame_to_content_position(event.position());
|
auto image_position = frame_to_content_position(event.position());
|
||||||
|
auto tool_adjusted_image_position = m_active_tool->point_position_to_preferred_cell(image_position);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
static_cast<GUI::Event::Type>(event.type()),
|
static_cast<GUI::Event::Type>(event.type()),
|
||||||
image_position.to_rounded<int>(),
|
tool_adjusted_image_position,
|
||||||
event.buttons(),
|
event.buttons(),
|
||||||
event.button(),
|
event.button(),
|
||||||
event.modifiers(),
|
event.modifiers(),
|
||||||
|
@ -286,9 +288,11 @@ GUI::MouseEvent ImageEditor::event_adjusted_for_layer(GUI::MouseEvent const& eve
|
||||||
{
|
{
|
||||||
auto image_position = frame_to_content_position(event.position());
|
auto image_position = frame_to_content_position(event.position());
|
||||||
image_position.translate_by(-layer.location().x(), -layer.location().y());
|
image_position.translate_by(-layer.location().x(), -layer.location().y());
|
||||||
|
auto tool_adjusted_image_position = m_active_tool->point_position_to_preferred_cell(image_position);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
static_cast<GUI::Event::Type>(event.type()),
|
static_cast<GUI::Event::Type>(event.type()),
|
||||||
image_position.to_rounded<int>(),
|
tool_adjusted_image_position,
|
||||||
event.buttons(),
|
event.buttons(),
|
||||||
event.button(),
|
event.button(),
|
||||||
event.modifiers(),
|
event.modifiers(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue