code formatting.
This commit is contained in:
parent
d1cd97809e
commit
5cb15abe11
|
@ -44,8 +44,7 @@ namespace bwidgets
|
|||
[[nodiscard]] auto blend_mode() -> SDL_BlendMode;
|
||||
auto blend_mode(SDL_BlendMode) -> Renderer*;
|
||||
auto clear() -> Renderer*;
|
||||
auto copy(const Texture*, const SDL_Rect*, const SDL_Rect*)
|
||||
-> Renderer*;
|
||||
auto copy(const Texture*, const SDL_Rect*, const SDL_Rect*) -> Renderer*;
|
||||
[[nodiscard]] auto draw_color() -> Color;
|
||||
auto draw_color(const Color&) -> Renderer*;
|
||||
auto draw_line(const SDL_Point&, const SDL_Point&) -> Renderer*;
|
||||
|
@ -61,20 +60,17 @@ namespace bwidgets
|
|||
[[nodiscard]] auto viewport() noexcept -> SDL_Rect;
|
||||
auto viewport(const SDL_Rect*) -> Renderer*;
|
||||
|
||||
inline auto copy(const Texture* t, const SDL_Rect* src,
|
||||
const SDL_Rect& dst)
|
||||
inline auto copy(const Texture* t, const SDL_Rect* src, const SDL_Rect& dst)
|
||||
{
|
||||
const auto d = dst;
|
||||
return copy(t, src, &d);
|
||||
}
|
||||
inline auto copy(const Texture* t, const SDL_Rect& src,
|
||||
const SDL_Rect* dst)
|
||||
inline auto copy(const Texture* t, const SDL_Rect& src, const SDL_Rect* dst)
|
||||
{
|
||||
const auto s = src;
|
||||
return copy(t, &s, dst);
|
||||
}
|
||||
inline auto copy(const Texture* t, const SDL_Rect& src,
|
||||
const SDL_Rect& dst)
|
||||
inline auto copy(const Texture* t, const SDL_Rect& src, const SDL_Rect& dst)
|
||||
{
|
||||
const auto s = src;
|
||||
const auto d = dst;
|
||||
|
|
|
@ -29,8 +29,7 @@ namespace bwidgets
|
|||
|
||||
public:
|
||||
Texture(SDL_Texture*);
|
||||
Texture(Renderer*, SDL_PixelFormatEnum, SDL_TextureAccess,
|
||||
int, int);
|
||||
Texture(Renderer*, SDL_PixelFormatEnum, SDL_TextureAccess, int, int);
|
||||
Texture(Renderer*, SDL_Surface*);
|
||||
Texture(const Texture&) = delete;
|
||||
Texture(Texture&&) = delete;
|
||||
|
@ -65,9 +64,10 @@ namespace bwidgets
|
|||
[[nodiscard]] static inline auto attributes(SDL_Texture* t)
|
||||
{
|
||||
Attr attr {};
|
||||
SDLError::success_or_throw(SDL_QueryTexture(t, &attr.format_raw,
|
||||
(int*)&attr.access, &attr.w,
|
||||
&attr.h),
|
||||
SDLError::success_or_throw(
|
||||
SDL_QueryTexture(t, &attr.format_raw,
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
(int*)&attr.access, &attr.w, &attr.h),
|
||||
__FILE__, __FUNCTION__, __LINE__);
|
||||
attr.format = SDLError::ptr_or_throw(SDL_AllocFormat(attr.format_raw),
|
||||
__FILE__, __FUNCTION__, __LINE__);
|
||||
|
|
|
@ -30,8 +30,7 @@ namespace bwidgets
|
|||
bool _operate_on_colors;
|
||||
|
||||
template<Numeric N>
|
||||
inline auto
|
||||
_operate(N operand,
|
||||
inline auto _operate(N operand,
|
||||
const std::function<N(N, N)>& operator_) const noexcept
|
||||
{
|
||||
Color c(sdl_type, _operate_on_alpha, _operate_on_colors);
|
||||
|
|
|
@ -17,7 +17,9 @@ namespace bwidgets
|
|||
VERTICAL
|
||||
} alignment;
|
||||
|
||||
AlignedLayout(Alignment align, Widget* p = nullptr) noexcept : Layout(p), alignment(align) {}
|
||||
AlignedLayout(Alignment align, Widget* p = nullptr) noexcept
|
||||
: Layout(p), alignment(align)
|
||||
{}
|
||||
|
||||
[[nodiscard]] auto size() const noexcept -> Size override;
|
||||
};
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace bwidgets
|
|||
[[nodiscard]] auto size() const noexcept -> Size override = 0;
|
||||
|
||||
virtual auto add_widget(const std::shared_ptr<Widget>&) -> Layout*;
|
||||
virtual void
|
||||
for_widgets(const std::function<void(Widget*)>&);
|
||||
virtual void for_widgets(const std::function<void(Widget*)>&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ using namespace bwidgets;
|
|||
const Color Font::default_color_bg {255, 255, 255, SDL_ALPHA_OPAQUE};
|
||||
const Color Font::default_color_fg {0, 0, 0, SDL_ALPHA_OPAQUE};
|
||||
|
||||
Font::Font(TTF_Font* f)
|
||||
Font::Font(TTF_Font* f)
|
||||
: Wrapper(ptr_or_throw<SDLError>(f, __FILE__, __FUNCTION__, __LINE__),
|
||||
[f](TTF_Font*) noexcept { TTF_CloseFont(f); }),
|
||||
ascent(TTF_FontAscent(f)),
|
||||
|
@ -23,48 +23,46 @@ const Color Font::default_color_fg {0, 0, 0, SDL_ALPHA_OPAQUE};
|
|||
height(TTF_FontHeight(f)),
|
||||
line_skip(TTF_FontLineSkip(f)),
|
||||
style_name(TTF_FontFaceStyleName(f))
|
||||
{}
|
||||
{}
|
||||
|
||||
Font::Font(const std::string& file, int size)
|
||||
: Font(TTF_OpenFont(file.c_str(), size))
|
||||
{}
|
||||
Font::Font(const std::string& file, int size) : Font(TTF_OpenFont(file.c_str(), size)) {}
|
||||
|
||||
auto Font::hinting() const noexcept -> Font::Hinting
|
||||
{
|
||||
auto Font::hinting() const noexcept -> Font::Hinting
|
||||
{
|
||||
return (Hinting)TTF_GetFontHinting(_data());
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::hinting(const Font::Hinting h) noexcept -> Font*
|
||||
{
|
||||
auto Font::hinting(const Font::Hinting h) noexcept -> Font*
|
||||
{
|
||||
TTF_SetFontHinting(_data(), (int)h);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::kerning() const noexcept -> bool
|
||||
{
|
||||
auto Font::kerning() const noexcept -> bool
|
||||
{
|
||||
return TTF_GetFontKerning(_data()) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::kerning(const bool allowed) noexcept -> Font*
|
||||
{
|
||||
auto Font::kerning(const bool allowed) noexcept -> Font*
|
||||
{
|
||||
TTF_SetFontKerning(_data(), static_cast<int>(allowed));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::outline() const noexcept -> int
|
||||
{
|
||||
auto Font::outline() const noexcept -> int
|
||||
{
|
||||
return TTF_GetFontOutline(_data());
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::outline(const int size) noexcept -> Font*
|
||||
{
|
||||
auto Font::outline(const int size) noexcept -> Font*
|
||||
{
|
||||
TTF_SetFontOutline(_data(), size);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::render(const RenderMode m, const std::string& str, const Color& fg,
|
||||
auto Font::render(const RenderMode m, const std::string& str, const Color& fg,
|
||||
const Color& bg) -> SDL_Surface*
|
||||
{
|
||||
{
|
||||
std::function<SDL_Surface*()> renderer;
|
||||
const char* c_str = str.empty() ? " " : str.c_str();
|
||||
|
||||
|
@ -87,28 +85,28 @@ const Color Font::default_color_fg {0, 0, 0, SDL_ALPHA_OPAQUE};
|
|||
}
|
||||
|
||||
return ptr_or_throw<SDLError>(renderer(), __FILE__, __FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::style() const noexcept -> uint8_t
|
||||
{
|
||||
auto Font::style() const noexcept -> uint8_t
|
||||
{
|
||||
return TTF_GetFontStyle(_data());
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::style(const uint8_t s) noexcept -> Font*
|
||||
{
|
||||
auto Font::style(const uint8_t s) noexcept -> Font*
|
||||
{
|
||||
TTF_SetFontStyle(_data(), s);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::text_size(const std::string& str) const noexcept -> Size
|
||||
{
|
||||
auto Font::text_size(const std::string& str) const noexcept -> Size
|
||||
{
|
||||
Size s {};
|
||||
TTF_SizeUTF8(_data(), str.c_str(), &s.w, &s.h);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
auto Font::find(const std::string& pat) -> std::string
|
||||
{
|
||||
auto Font::find(const std::string& pat) -> std::string
|
||||
{
|
||||
std::stack<std::function<void()>> cleaners;
|
||||
|
||||
FcConfig* conf = ptr_or_throw<FCError>(FcInitLoadConfigAndFonts(), __FILE__,
|
||||
|
@ -155,4 +153,4 @@ const Color Font::default_color_fg {0, 0, 0, SDL_ALPHA_OPAQUE};
|
|||
throw FCError {__FILE__, __FUNCTION__, __LINE__, "no font found"};
|
||||
|
||||
return file_path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ auto Renderer::clear() -> Renderer*
|
|||
return this;
|
||||
}
|
||||
|
||||
auto Renderer::copy(const Texture* t, const SDL_Rect* src,
|
||||
const SDL_Rect* dst) -> Renderer*
|
||||
auto Renderer::copy(const Texture* t, const SDL_Rect* src, const SDL_Rect* dst)
|
||||
-> Renderer*
|
||||
{
|
||||
SDLError::success_or_throw(SDL_RenderCopy(_data(), t->_data(), src, dst), __FILE__,
|
||||
__FUNCTION__, __LINE__);
|
||||
|
|
|
@ -10,8 +10,8 @@ Texture::Texture(SDL_Texture* t)
|
|||
_attributes = attributes(t);
|
||||
}
|
||||
|
||||
Texture::Texture(Renderer* r, const SDL_PixelFormatEnum f,
|
||||
const SDL_TextureAccess a, int w, int h)
|
||||
Texture::Texture(Renderer* r, const SDL_PixelFormatEnum f, const SDL_TextureAccess a,
|
||||
int w, int h)
|
||||
: Texture(SDL_CreateTexture(r->_data(), f, a, w, h))
|
||||
{}
|
||||
|
||||
|
|
Loading…
Reference in a new issue