mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
PaintBrush: Let's have Layer::rect() and Layer::relative_rect()
These two have the same semantics as GUI::Widget. The rect() is always at location { 0, 0 }, while the relative_rect()'s location is relative to the "parent", which in this case is the Layer's Image.
This commit is contained in:
parent
83d24dcb1d
commit
9566f6c8b3
2 changed files with 3 additions and 3 deletions
|
@ -58,14 +58,13 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
|
||||
if (m_active_layer) {
|
||||
painter.draw_rect(m_active_layer->rect().inflated(2, 2), Color::Black);
|
||||
painter.draw_rect(m_active_layer->relative_rect().inflated(2, 2), Color::Black);
|
||||
}
|
||||
}
|
||||
|
||||
static GUI::MouseEvent event_adjusted_for_layer(const GUI::MouseEvent& original_event, const Layer& layer)
|
||||
{
|
||||
auto position_in_active_layer_coordinates = original_event.position().translated(-layer.location());
|
||||
dbg() << "adjusted: " << position_in_active_layer_coordinates;
|
||||
return {
|
||||
static_cast<GUI::Event::Type>(original_event.type()),
|
||||
position_in_active_layer_coordinates, original_event.buttons(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue