mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:57:35 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -76,7 +76,7 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, String const& offse
|
|||
};
|
||||
}
|
||||
|
||||
Optional<float> EditGuideDialog::offset_as_pixel(const ImageEditor& editor)
|
||||
Optional<float> EditGuideDialog::offset_as_pixel(ImageEditor const& editor)
|
||||
{
|
||||
float offset = 0;
|
||||
if (m_offset.ends_with('%')) {
|
||||
|
|
|
@ -64,7 +64,7 @@ GUI::ModelIndex FilterModel::index(int row, int column, const GUI::ModelIndex& p
|
|||
return {};
|
||||
return create_index(row, column, &m_filters[row]);
|
||||
}
|
||||
auto* parent = static_cast<const FilterInfo*>(parent_index.internal_data());
|
||||
auto* parent = static_cast<FilterInfo const*>(parent_index.internal_data());
|
||||
if (static_cast<size_t>(row) >= parent->children.size())
|
||||
return {};
|
||||
auto* child = &parent->children[row];
|
||||
|
@ -76,7 +76,7 @@ GUI::ModelIndex FilterModel::parent_index(const GUI::ModelIndex& index) const
|
|||
if (!index.is_valid())
|
||||
return {};
|
||||
|
||||
auto* child = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* child = static_cast<FilterInfo const*>(index.internal_data());
|
||||
auto* parent = child->parent;
|
||||
if (parent == nullptr)
|
||||
return {};
|
||||
|
@ -99,13 +99,13 @@ int FilterModel::row_count(const GUI::ModelIndex& index) const
|
|||
{
|
||||
if (!index.is_valid())
|
||||
return m_filters.size();
|
||||
auto* node = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* node = static_cast<FilterInfo const*>(index.internal_data());
|
||||
return node->children.size();
|
||||
}
|
||||
|
||||
GUI::Variant FilterModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||
{
|
||||
auto* filter = static_cast<const FilterInfo*>(index.internal_data());
|
||||
auto* filter = static_cast<FilterInfo const*>(index.internal_data());
|
||||
switch (role) {
|
||||
case GUI::ModelRole::Display:
|
||||
return filter->text;
|
||||
|
|
|
@ -21,7 +21,7 @@ FilterPreviewWidget::~FilterPreviewWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void FilterPreviewWidget::set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap)
|
||||
void FilterPreviewWidget::set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap)
|
||||
{
|
||||
m_bitmap = bitmap;
|
||||
clear_filter();
|
||||
|
|
|
@ -19,7 +19,7 @@ class FilterPreviewWidget final : public GUI::Frame {
|
|||
|
||||
public:
|
||||
virtual ~FilterPreviewWidget() override;
|
||||
void set_bitmap(const RefPtr<Gfx::Bitmap>& bitmap);
|
||||
void set_bitmap(RefPtr<Gfx::Bitmap> const& bitmap);
|
||||
void set_filter(Filter* filter);
|
||||
void clear_filter();
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
|
|||
MUST(json.add("height", m_size.height()));
|
||||
{
|
||||
auto json_layers = MUST(json.add_array("layers"));
|
||||
for (const auto& layer : m_layers) {
|
||||
for (auto const& layer : m_layers) {
|
||||
Gfx::BMPWriter bmp_writer;
|
||||
auto json_layer = MUST(json_layers.add_object());
|
||||
MUST(json_layer.add("width", layer.size().width()));
|
||||
|
@ -147,7 +147,7 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Image::write_to_file(const String& file_path) const
|
||||
ErrorOr<void> Image::write_to_file(String const& file_path) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
|
@ -228,7 +228,7 @@ void Image::add_layer(NonnullRefPtr<Layer> layer)
|
|||
ErrorOr<NonnullRefPtr<Image>> Image::take_snapshot() const
|
||||
{
|
||||
auto snapshot = TRY(try_create_with_size(m_size));
|
||||
for (const auto& layer : m_layers) {
|
||||
for (auto const& layer : m_layers) {
|
||||
auto layer_snapshot = TRY(Layer::try_create_snapshot(*snapshot, layer));
|
||||
snapshot->add_layer(move(layer_snapshot));
|
||||
}
|
||||
|
|
|
@ -162,49 +162,49 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
m_selection.paint(painter);
|
||||
|
||||
if (m_show_rulers) {
|
||||
const auto ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection);
|
||||
const auto ruler_fg_color = palette().color(Gfx::ColorRole::Ruler);
|
||||
const auto ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText);
|
||||
const auto mouse_indicator_color = Color::White;
|
||||
auto const ruler_bg_color = palette().color(Gfx::ColorRole::InactiveSelection);
|
||||
auto const ruler_fg_color = palette().color(Gfx::ColorRole::Ruler);
|
||||
auto const ruler_text_color = palette().color(Gfx::ColorRole::InactiveSelectionText);
|
||||
auto const mouse_indicator_color = Color::White;
|
||||
|
||||
// Ruler background
|
||||
painter.fill_rect({ { 0, 0 }, { m_ruler_thickness, rect().height() } }, ruler_bg_color);
|
||||
painter.fill_rect({ { 0, 0 }, { rect().width(), m_ruler_thickness } }, ruler_bg_color);
|
||||
|
||||
const auto ruler_step = calculate_ruler_step_size();
|
||||
const auto editor_origin_to_image = frame_to_content_position({ 0, 0 });
|
||||
const auto editor_max_to_image = frame_to_content_position({ width(), height() });
|
||||
auto const ruler_step = calculate_ruler_step_size();
|
||||
auto const editor_origin_to_image = frame_to_content_position({ 0, 0 });
|
||||
auto const editor_max_to_image = frame_to_content_position({ width(), height() });
|
||||
|
||||
// Horizontal ruler
|
||||
painter.draw_line({ 0, m_ruler_thickness }, { rect().width(), m_ruler_thickness }, ruler_fg_color);
|
||||
const auto x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step;
|
||||
auto const x_start = floor(editor_origin_to_image.x()) - ((int)floor(editor_origin_to_image.x()) % ruler_step) - ruler_step;
|
||||
for (int x = x_start; x < editor_max_to_image.x(); x += ruler_step) {
|
||||
const int num_sub_divisions = min(ruler_step, 10);
|
||||
int const num_sub_divisions = min(ruler_step, 10);
|
||||
for (int x_sub = 0; x_sub < num_sub_divisions; ++x_sub) {
|
||||
const int x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions);
|
||||
const int editor_x_sub = content_to_frame_position({ x_pos, 0 }).x();
|
||||
const int line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
int const x_pos = x + (int)(ruler_step * x_sub / num_sub_divisions);
|
||||
int const editor_x_sub = content_to_frame_position({ x_pos, 0 }).x();
|
||||
int const line_length = (x_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
painter.draw_line({ editor_x_sub, m_ruler_thickness - line_length }, { editor_x_sub, m_ruler_thickness }, ruler_fg_color);
|
||||
}
|
||||
|
||||
const int editor_x = content_to_frame_position({ x, 0 }).x();
|
||||
int const editor_x = content_to_frame_position({ x, 0 }).x();
|
||||
painter.draw_line({ editor_x, 0 }, { editor_x, m_ruler_thickness }, ruler_fg_color);
|
||||
painter.draw_text({ { editor_x + 2, 0 }, { m_ruler_thickness, m_ruler_thickness - 2 } }, String::formatted("{}", x), painter.font(), Gfx::TextAlignment::CenterLeft, ruler_text_color);
|
||||
}
|
||||
|
||||
// Vertical ruler
|
||||
painter.draw_line({ m_ruler_thickness, 0 }, { m_ruler_thickness, rect().height() }, ruler_fg_color);
|
||||
const auto y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step;
|
||||
auto const y_start = floor(editor_origin_to_image.y()) - ((int)floor(editor_origin_to_image.y()) % ruler_step) - ruler_step;
|
||||
for (int y = y_start; y < editor_max_to_image.y(); y += ruler_step) {
|
||||
const int num_sub_divisions = min(ruler_step, 10);
|
||||
int const num_sub_divisions = min(ruler_step, 10);
|
||||
for (int y_sub = 0; y_sub < num_sub_divisions; ++y_sub) {
|
||||
const int y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions);
|
||||
const int editor_y_sub = content_to_frame_position({ 0, y_pos }).y();
|
||||
const int line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
int const y_pos = y + (int)(ruler_step * y_sub / num_sub_divisions);
|
||||
int const editor_y_sub = content_to_frame_position({ 0, y_pos }).y();
|
||||
int const line_length = (y_sub % 2 == 0) ? m_ruler_thickness / 3 : m_ruler_thickness / 6;
|
||||
painter.draw_line({ m_ruler_thickness - line_length, editor_y_sub }, { m_ruler_thickness, editor_y_sub }, ruler_fg_color);
|
||||
}
|
||||
|
||||
const int editor_y = content_to_frame_position({ 0, y }).y();
|
||||
int const editor_y = content_to_frame_position({ 0, y }).y();
|
||||
painter.draw_line({ 0, editor_y }, { m_ruler_thickness, editor_y }, ruler_fg_color);
|
||||
painter.draw_text({ { 0, editor_y - m_ruler_thickness }, { m_ruler_thickness, m_ruler_thickness } }, String::formatted("{}", y), painter.font(), Gfx::TextAlignment::BottomRight, ruler_text_color);
|
||||
}
|
||||
|
@ -222,8 +222,8 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
int ImageEditor::calculate_ruler_step_size() const
|
||||
{
|
||||
const auto step_target = 80 / scale();
|
||||
const auto max_factor = 5;
|
||||
auto const step_target = 80 / scale();
|
||||
auto const max_factor = 5;
|
||||
for (int factor = 0; factor < max_factor; ++factor) {
|
||||
int ten_to_factor = AK::pow<int>(10, factor);
|
||||
if (step_target <= 1 * ten_to_factor)
|
||||
|
@ -619,7 +619,7 @@ Result<void, String> ImageEditor::save_project_to_file(Core::File& file) const
|
|||
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
m_image->serialize_as_json(json);
|
||||
auto json_guides = MUST(json.add_array("guides"));
|
||||
for (const auto& guide : m_guides) {
|
||||
for (auto const& guide : m_guides) {
|
||||
auto json_guide = MUST(json_guides.add_object());
|
||||
MUST(json_guide.add("offset"sv, (double)guide.offset()));
|
||||
if (guide.orientation() == Guide::Orientation::Vertical)
|
||||
|
|
|
@ -101,7 +101,7 @@ MainWidget::MainWidget()
|
|||
}
|
||||
|
||||
// Note: Update these together! v
|
||||
static const Vector<String> s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" };
|
||||
static Vector<String> const s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" };
|
||||
static constexpr int s_zoom_level_fit_width = 8;
|
||||
static constexpr int s_zoom_level_fit_height = 9;
|
||||
static constexpr int s_zoom_level_fit_image = 10;
|
||||
|
|
|
@ -36,7 +36,7 @@ void BrushTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
const int first_draw_opacity = 10;
|
||||
int const first_draw_opacity = 10;
|
||||
|
||||
for (int i = 0; i < first_draw_opacity; ++i)
|
||||
draw_point(layer->currently_edited_bitmap(), color_for(layer_event), layer_event.position());
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Guide> GuideTool::closest_guide(const Gfx::IntPoint& point)
|
||||
RefPtr<Guide> GuideTool::closest_guide(Gfx::IntPoint const& point)
|
||||
{
|
||||
auto guides = editor()->guides();
|
||||
Guide* closest_guide = nullptr;
|
||||
|
|
|
@ -157,7 +157,7 @@ GUI::Widget* RectangleSelectTool::get_properties_widget()
|
|||
feather_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
feather_label.set_fixed_size(80, 20);
|
||||
|
||||
const int feather_slider_max = 100;
|
||||
int const feather_slider_max = 100;
|
||||
auto& feather_slider = feather_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%");
|
||||
feather_slider.set_range(0, feather_slider_max);
|
||||
feather_slider.set_value((int)floorf(m_edge_feathering * (float)feather_slider_max));
|
||||
|
|
|
@ -43,13 +43,13 @@ void SprayTool::paint_it()
|
|||
auto& bitmap = layer->currently_edited_bitmap();
|
||||
GUI::Painter painter(bitmap);
|
||||
VERIFY(bitmap.bpp() == 32);
|
||||
const double minimal_radius = 2;
|
||||
const double base_radius = minimal_radius * m_thickness;
|
||||
double const minimal_radius = 2;
|
||||
double const base_radius = minimal_radius * m_thickness;
|
||||
for (int i = 0; i < M_PI * base_radius * base_radius * (m_density / 100.0); i++) {
|
||||
double radius = base_radius * nrand();
|
||||
double angle = 2 * M_PI * nrand();
|
||||
const int xpos = m_last_pos.x() + radius * AK::cos(angle);
|
||||
const int ypos = m_last_pos.y() - radius * AK::sin(angle);
|
||||
int const xpos = m_last_pos.x() + radius * AK::cos(angle);
|
||||
int const ypos = m_last_pos.y() - radius * AK::sin(angle);
|
||||
if (xpos < 0 || xpos >= bitmap.width())
|
||||
continue;
|
||||
if (ypos < 0 || ypos >= bitmap.height())
|
||||
|
|
|
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto app = GUI::Application::construct(arguments);
|
||||
Config::pledge_domain("PixelPaint");
|
||||
|
||||
const char* image_file = nullptr;
|
||||
char const* image_file = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue