mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
PixelPaint: Make sure that a layer is always selected
Make sure that a layer is selected after creating it, removing one or creating a new image. Also make layer_properties_widget update on tab change.
This commit is contained in:
parent
f3cdb9bfeb
commit
95710b0147
Notes:
sideshowbarker
2024-07-18 09:59:44 +09:00
Author: https://github.com/metmo Commit: https://github.com/SerenityOS/serenity/commit/95710b01473 Pull-request: https://github.com/SerenityOS/serenity/pull/8583
1 changed files with 13 additions and 4 deletions
|
@ -101,9 +101,9 @@ int main(int argc, char** argv)
|
|||
auto image_title = dialog->image_name().trim_whitespace();
|
||||
image->set_title(image_title.is_empty() ? "Untitled" : image_title);
|
||||
|
||||
auto& image_editor = create_new_editor(*image);
|
||||
create_new_editor(*image);
|
||||
layer_list_widget.set_image(image);
|
||||
image_editor.set_active_layer(bg_layer);
|
||||
layer_list_widget.set_selected_layer(bg_layer);
|
||||
}
|
||||
},
|
||||
window);
|
||||
|
@ -343,6 +343,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
editor->image().add_layer(layer.release_nonnull());
|
||||
editor->layers_did_change();
|
||||
layer_list_widget.select_top_layer();
|
||||
}
|
||||
},
|
||||
window));
|
||||
|
@ -400,8 +401,16 @@ int main(int argc, char** argv)
|
|||
auto active_layer = editor->active_layer();
|
||||
if (!active_layer)
|
||||
return;
|
||||
|
||||
auto active_layer_index = editor->image().index_of(*active_layer);
|
||||
editor->image().remove_layer(*active_layer);
|
||||
|
||||
if (editor->image().layer_count()) {
|
||||
auto& next_active_layer = editor->image().layer(active_layer_index > 0 ? active_layer_index - 1 : 0);
|
||||
editor->set_active_layer(&next_active_layer);
|
||||
} else {
|
||||
editor->set_active_layer(nullptr);
|
||||
}
|
||||
},
|
||||
window));
|
||||
|
||||
|
@ -594,7 +603,7 @@ int main(int argc, char** argv)
|
|||
auto& image_editor = verify_cast<PixelPaint::ImageEditor>(widget);
|
||||
palette_widget.set_image_editor(image_editor);
|
||||
layer_list_widget.set_image(&image_editor.image());
|
||||
layer_properties_widget.set_layer(nullptr);
|
||||
layer_properties_widget.set_layer(image_editor.active_layer());
|
||||
// FIXME: This is badly factored. It transfers tools from the previously active editor to the new one.
|
||||
toolbox.template for_each_tool([&](auto& tool) {
|
||||
if (tool.editor()) {
|
||||
|
|
Loading…
Reference in a new issue