mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibGfx: Move a bunch of LogStream::operator<< to cpp files
This commit is contained in:
parent
3866e0d4d4
commit
34b5ff7c29
12 changed files with 162 additions and 28 deletions
|
@ -37,4 +37,10 @@ ImageDecoder::ImageDecoder(const u8* data, size_t size)
|
|||
ImageDecoder::~ImageDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> ImageDecoder::bitmap() const
|
||||
{
|
||||
return m_plugin->bitmap();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
Size size() const { return m_plugin->size(); }
|
||||
int width() const { return size().width(); }
|
||||
int height() const { return size().height(); }
|
||||
RefPtr<Gfx::Bitmap> bitmap() const { return m_plugin->bitmap(); }
|
||||
RefPtr<Gfx::Bitmap> bitmap() const;
|
||||
void set_volatile() { m_plugin->set_volatile(); }
|
||||
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
|
||||
|
||||
|
|
|
@ -10,9 +10,12 @@ OBJS = \
|
|||
PNGLoader.o \
|
||||
Painter.o \
|
||||
Palette.o \
|
||||
Point.o \
|
||||
Rect.o \
|
||||
Size.o \
|
||||
StylePainter.o \
|
||||
SystemTheme.o
|
||||
SystemTheme.o \
|
||||
Triangle.o
|
||||
|
||||
LIBRARY = libgfx.a
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
|
|
42
Libraries/LibGfx/Point.cpp
Normal file
42
Libraries/LibGfx/Point.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
String Point::to_string() const
|
||||
{
|
||||
return String::format("[%d,%d]", x(), y());
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Point& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
}
|
||||
Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
|
||||
|
||||
String to_string() const { return String::format("[%d,%d]", x(), y()); }
|
||||
String to_string() const;
|
||||
|
||||
bool is_null() const { return !m_x && !m_y; }
|
||||
|
||||
|
@ -156,9 +156,6 @@ private:
|
|||
int m_y { 0 };
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Point& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
const LogStream& operator<<(const LogStream&, const Point&);
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
|
@ -130,4 +131,14 @@ void Rect::align_within(const Rect& other, TextAlignment alignment)
|
|||
}
|
||||
}
|
||||
|
||||
String Rect::to_string() const
|
||||
{
|
||||
return String::format("[%d,%d %dx%d]", x(), y(), width(), height());
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
@ -313,7 +312,7 @@ public:
|
|||
set_y(other.center().y() - height() / 2);
|
||||
}
|
||||
|
||||
String to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); }
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
Point m_location;
|
||||
|
@ -332,9 +331,6 @@ inline void Point::constrain(const Rect& rect)
|
|||
set_y(rect.bottom());
|
||||
}
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
const LogStream& operator<<(const LogStream&, const Rect&);
|
||||
|
||||
}
|
||||
|
|
42
Libraries/LibGfx/Size.cpp
Normal file
42
Libraries/LibGfx/Size.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
String Size::to_string() const
|
||||
{
|
||||
return String::format("[%dx%d]", m_width, m_height);
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Size& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -102,16 +101,13 @@ public:
|
|||
set_height(value);
|
||||
}
|
||||
|
||||
String to_string() const { return String::format("[%dx%d]", m_width, m_height); }
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
int m_width { 0 };
|
||||
int m_height { 0 };
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Size& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
const LogStream& operator<<(const LogStream&, const Size&);
|
||||
|
||||
}
|
||||
|
|
42
Libraries/LibGfx/Triangle.cpp
Normal file
42
Libraries/LibGfx/Triangle.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Shannon Booth <shannon.ml.booth@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Triangle.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
String Triangle::to_string() const
|
||||
{
|
||||
return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters());
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -64,7 +65,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
String to_string() const { return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters()); }
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
int m_det;
|
||||
|
@ -73,9 +74,6 @@ private:
|
|||
Point m_c;
|
||||
};
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
||||
{
|
||||
return stream << value.to_string();
|
||||
}
|
||||
const LogStream& operator<<(const LogStream&, const Triangle&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue