mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibGUI: Add a GFrame class that can be inherited by framey widgets.
This will gather the code for painting sunken/raised frames etc in a single place and make it easier add a bit of pleasant shading to UI's. :^)
This commit is contained in:
parent
b6c5bd3d28
commit
cb296ffede
7 changed files with 110 additions and 12 deletions
33
LibGUI/GFrame.h
Normal file
33
LibGUI/GFrame.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GFrame : public GWidget {
|
||||
public:
|
||||
explicit GFrame(GWidget* parent);
|
||||
virtual ~GFrame() override;
|
||||
|
||||
enum Shadow { Plain, Raised, Sunken };
|
||||
enum Shape { NoFrame, Box, Panel, VerticalLine, HorizontalLine };
|
||||
|
||||
int frame_thickness() const { return m_thickness; }
|
||||
void set_frame_thickness(int thickness) { m_thickness = thickness; }
|
||||
|
||||
Shadow frame_shadow() const { return m_shadow; }
|
||||
void set_frame_shadow(Shadow shadow) { m_shadow = shadow; }
|
||||
|
||||
Shape frame_shape() const { return m_shape; }
|
||||
void set_frame_shape(Shape shape) { m_shape = shape; }
|
||||
|
||||
Rect frame_inner_rect() const { return rect().shrunken(m_thickness * 2, m_thickness * 2); }
|
||||
|
||||
virtual const char* class_name() const override { return "GFrame"; }
|
||||
|
||||
protected:
|
||||
void paint_event(GPaintEvent&) override;
|
||||
|
||||
private:
|
||||
int m_thickness { 0 };
|
||||
Shadow m_shadow { Plain };
|
||||
Shape m_shape { NoFrame };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue