1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

PixelPaint: Remove try_ prefix from fallible Image methods

This commit is contained in:
Linus Groh 2023-01-28 20:12:17 +00:00 committed by Jelle Raaijmakers
parent 39f1a6eb6f
commit 8a884b2581
5 changed files with 32 additions and 32 deletions

View file

@ -158,7 +158,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
return;
}
auto image = image_result.release_value();
auto bg_layer_result = PixelPaint::Layer::try_create_with_size(*image, image->size(), "Background");
auto bg_layer_result = PixelPaint::Layer::create_with_size(*image, image->size(), "Background");
if (bg_layer_result.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Failed to create layer with size {}, error: {}", image->size(), bg_layer_result.error()));
return;
@ -285,9 +285,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
dbgln("Cannot cut with no active layer selected");
return;
}
auto bitmap = editor->active_layer()->try_copy_bitmap(editor->image().selection());
auto bitmap = editor->active_layer()->copy_bitmap(editor->image().selection());
if (!bitmap) {
dbgln("try_copy_bitmap() from Layer failed");
dbgln("copy_bitmap() from Layer failed");
return;
}
GUI::Clipboard::the().set_bitmap(*bitmap);
@ -302,9 +302,9 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
dbgln("Cannot copy with no active layer selected");
return;
}
auto bitmap = editor->active_layer()->try_copy_bitmap(editor->image().selection());
auto bitmap = editor->active_layer()->copy_bitmap(editor->image().selection());
if (!bitmap) {
dbgln("try_copy_bitmap() from Layer failed");
dbgln("copy_bitmap() from Layer failed");
return;
}
auto layer_rect = editor->active_layer()->relative_rect();
@ -343,7 +343,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
if (!bitmap)
return;
auto layer_result = PixelPaint::Layer::try_create_with_bitmap(editor->image(), *bitmap, "Pasted layer");
auto layer_result = PixelPaint::Layer::create_with_bitmap(editor->image(), *bitmap, "Pasted layer");
if (layer_result.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Could not create bitmap when pasting: {}", layer_result.error()));
return;
@ -701,7 +701,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
VERIFY(editor);
auto dialog = PixelPaint::CreateNewLayerDialog::construct(editor->image().size(), &window);
if (dialog->exec() == GUI::Dialog::ExecResult::OK) {
auto layer_or_error = PixelPaint::Layer::try_create_with_size(editor->image(), dialog->layer_size(), dialog->layer_name());
auto layer_or_error = PixelPaint::Layer::create_with_size(editor->image(), dialog->layer_size(), dialog->layer_name());
if (layer_or_error.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Unable to create layer with size {}", dialog->size()));
return;
@ -825,7 +825,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
auto& next_active_layer = editor->image().layer(active_layer_index > 0 ? active_layer_index - 1 : 0);
editor->set_active_layer(&next_active_layer);
} else {
auto layer_result = PixelPaint::Layer::try_create_with_size(editor->image(), editor->image().size(), "Background");
auto layer_result = PixelPaint::Layer::create_with_size(editor->image(), editor->image().size(), "Background");
if (layer_result.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Failed to create layer with size {}, error: {}", editor->image().size(), layer_result.error()));
return;
@ -1115,7 +1115,7 @@ ErrorOr<void> MainWidget::create_default_image()
{
auto image = TRY(Image::create_with_size({ 510, 356 }));
auto bg_layer = TRY(Layer::try_create_with_size(*image, image->size(), "Background"));
auto bg_layer = TRY(Layer::create_with_size(*image, image->size(), "Background"));
image->add_layer(*bg_layer);
bg_layer->content_bitmap().fill(Color::Transparent);
@ -1137,7 +1137,7 @@ ErrorOr<void> MainWidget::create_image_from_clipboard()
}
auto image = TRY(PixelPaint::Image::create_with_size(bitmap->size()));
auto layer = TRY(PixelPaint::Layer::try_create_with_bitmap(image, *bitmap, "Pasted layer"));
auto layer = TRY(PixelPaint::Layer::create_with_bitmap(image, *bitmap, "Pasted layer"));
image->add_layer(*layer);
auto& editor = create_new_editor(*image);