decrease button height

This commit is contained in:
Andrea Blankenstijn 2021-07-15 13:58:48 +02:00
parent c99bc3eac5
commit 4e4539695f
2 changed files with 7 additions and 17 deletions

View file

@ -15,7 +15,6 @@ namespace bwidgets::widget
protected:
widget::Caption _caption;
SDL_Rect _caption_area;
float _caption_height_multiplicator {1.2};
SDL_Color _color_foreground {0, 0, 0, SDL_ALPHA_OPAQUE};
void _handle_font_change() override;

View file

@ -34,23 +34,20 @@ void widget::Button::render(SDL_Renderer* r)
{
for (int i = 0; i < border_width; i++)
{
SDLError::success_or_throw(SDL_SetRenderDrawColor(
SDL_SetRenderDrawColor(
r,
color_shade(bg_color.r, i, border_width),
color_shade(bg_color.g, i, border_width),
color_shade(bg_color.b, i, border_width),
bg_color.a
),
__FILE__,
__LINE__
);
);
SDL_Rect rect = {
_widget_area.x + i,
_widget_area.y + i,
_widget_area.w - i * 2,
_widget_area.h - i * 2
};
SDLError::success_or_throw(SDL_RenderFillRect(r, &rect), __FILE__, __LINE__);
SDL_RenderFillRect(r, &rect);
}
}
else
@ -81,10 +78,8 @@ void widget::Button::render(SDL_Renderer* r)
abstract::Widget::Size widget::Button::size() const noexcept
{
return {
(int)(_caption.size().w * _caption_height_multiplicator)
+ 2 * border_width,
(int)(_caption.size().h * _caption_height_multiplicator)
+ 2 * border_width
_caption.size().w + 2 * border_width,
_caption.size().h + 2 * border_width
};
}
@ -107,15 +102,11 @@ void widget::Button::_handle_font_change()
void widget::Button::_update_widget_area() noexcept
{
int h = _caption.size().h * _caption_height_multiplicator
+ 2 * border_width;
int h = _caption.size().h + 2 * border_width;
_widget_area = {
0,
math::center_rect(
_viewport.h,
_caption.size().h * _caption_height_multiplicator
) - border_width,
math::center_rect(_viewport.h, _caption.size().h) - border_width,
_viewport.w,
h
};