mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:08:10 +00:00
PixelPaint: Move title
and path
from Image to ImageEditor
As noted in the latest hacking video, it doesn't seem to make much sense to store the title and path in the image itself. These fields have now been moved to the actual ImageEditor itself. This allows some nice simplicfications, including getting rid of the `image_did_change_title` hook of ImageClient (which was just a way to report back to the editor that the title had changed).
This commit is contained in:
parent
0b43a92eed
commit
2440d2c2fe
6 changed files with 45 additions and 56 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Mustafa Quraish <mustafa@serenityos.org>
|
||||
* Copyright (c) 2021, David Isaksson <davidisaksson93@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -12,6 +12,7 @@
|
|||
#include "Layer.h"
|
||||
#include "Tools/MoveTool.h"
|
||||
#include "Tools/Tool.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibGUI/Command.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -23,6 +24,7 @@ namespace PixelPaint {
|
|||
|
||||
ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
|
||||
: m_image(move(image))
|
||||
, m_title("Untitled")
|
||||
, m_selection(*this)
|
||||
{
|
||||
set_focus_policy(GUI::FocusPolicy::StrongFocus);
|
||||
|
@ -78,6 +80,19 @@ bool ImageEditor::redo()
|
|||
return true;
|
||||
}
|
||||
|
||||
void ImageEditor::set_title(String title)
|
||||
{
|
||||
m_title = move(title);
|
||||
if (on_title_change)
|
||||
on_title_change(m_title);
|
||||
}
|
||||
|
||||
void ImageEditor::set_path(String path)
|
||||
{
|
||||
m_path = move(path);
|
||||
set_title(LexicalPath::basename(m_path));
|
||||
}
|
||||
|
||||
void ImageEditor::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GUI::Frame::paint_event(event);
|
||||
|
@ -678,12 +693,6 @@ void ImageEditor::image_did_change_rect(Gfx::IntRect const& new_image_rect)
|
|||
update(m_editor_image_rect);
|
||||
}
|
||||
|
||||
void ImageEditor::image_did_change_title(String const& path)
|
||||
{
|
||||
if (on_image_title_change)
|
||||
on_image_title_change(path);
|
||||
}
|
||||
|
||||
void ImageEditor::image_select_layer(Layer* layer)
|
||||
{
|
||||
set_active_layer(layer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue