Skip to content

Commit

Permalink
screen: forward-declare struct Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 11, 2024
1 parent 7fc2160 commit 4ffd1d0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
32 changes: 1 addition & 31 deletions src/screen.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,7 @@ class ScreenManager final : public ModalDock, public PageContainer {
*/
IdleEvent paint_event;

struct Layout {
Size size;

static constexpr Point title{0, 0};
static constexpr Point main{0, (int)TitleBar::GetHeight()};
static constexpr int progress_x = 0;
static constexpr int status_x = 0;

constexpr explicit Layout(Size _size) noexcept
:size(_size) {}

constexpr unsigned GetMainRows() const noexcept {
return GetProgress().y - main.y;
}

constexpr Size GetMainSize() const noexcept {
return {size.width, GetMainRows()};
}

constexpr Point GetProgress() const noexcept {
return {progress_x, GetStatus().y - 1};
}

constexpr Point GetStatus() const noexcept {
return {status_x, (int)size.height - 1};
}

constexpr Size GetStatusSize() const noexcept {
return {size.width, 1U};
}
};
struct Layout;

TitleBar title_bar;
public:
Expand Down
32 changes: 32 additions & 0 deletions src/screen_init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ GetCorrectedScreenSize() noexcept
};
}

struct ScreenManager::Layout {
Size size;

static constexpr Point title{0, 0};
static constexpr Point main{0, (int)TitleBar::GetHeight()};
static constexpr int progress_x = 0;
static constexpr int status_x = 0;

constexpr explicit Layout(Size _size) noexcept
:size(_size) {}

constexpr unsigned GetMainRows() const noexcept {
return GetProgress().y - main.y;
}

constexpr Size GetMainSize() const noexcept {
return {size.width, GetMainRows()};
}

constexpr Point GetProgress() const noexcept {
return {progress_x, GetStatus().y - 1};
}

constexpr Point GetStatus() const noexcept {
return {status_x, (int)size.height - 1};
}

constexpr Size GetStatusSize() const noexcept {
return {size.width, 1U};
}
};

inline
ScreenManager::ScreenManager(EventLoop &event_loop, const Layout &layout) noexcept
:paint_event(event_loop, BIND_THIS_METHOD(Paint)),
Expand Down

0 comments on commit 4ffd1d0

Please sign in to comment.