36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#include "ui/Layout.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace tahgibu {
|
|
namespace {
|
|
|
|
constexpr float kMenuBarHeight = 26.0f;
|
|
constexpr float kToolBarHeight = 40.0f;
|
|
constexpr float kPropertiesWidth = 280.0f;
|
|
constexpr float kTimelineHeight = 200.0f;
|
|
constexpr float kMinCanvasWidth = 400.0f;
|
|
constexpr float kMinCanvasHeight = 200.0f;
|
|
|
|
} // namespace
|
|
|
|
Layout Layout::compute(int windowWidth, int windowHeight) {
|
|
const float w = static_cast<float>(windowWidth);
|
|
const float h = static_cast<float>(windowHeight);
|
|
const float top = kMenuBarHeight + kToolBarHeight;
|
|
|
|
const float timelineH = std::min(kTimelineHeight, std::max(0.0f, h - top - kMinCanvasHeight));
|
|
const float propertiesW = std::min(kPropertiesWidth, std::max(0.0f, w - kMinCanvasWidth));
|
|
const float middleH = std::max(0.0f, h - top - timelineH);
|
|
|
|
Layout layout;
|
|
layout.menuBar = {0.0f, 0.0f, w, kMenuBarHeight};
|
|
layout.toolBar = {0.0f, kMenuBarHeight, w, kToolBarHeight};
|
|
layout.canvas = {0.0f, top, w - propertiesW, middleH};
|
|
layout.properties = {w - propertiesW, top, propertiesW, middleH};
|
|
layout.timeline = {0.0f, top + middleH, w, timelineH};
|
|
return layout;
|
|
}
|
|
|
|
} // namespace tahgibu
|