mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] Add vertical borders to StackView
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#ifndef ESCHER_STACK_VIEW_H
|
||||
#define ESCHER_STACK_VIEW_H
|
||||
|
||||
#include <escher/bordered.h>
|
||||
#include <escher/view.h>
|
||||
#include <escher/view_controller.h>
|
||||
|
||||
class StackView : public View {
|
||||
class StackView : public View, public Bordered {
|
||||
public:
|
||||
StackView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
|
||||
@@ -30,13 +30,11 @@ void StackView::setNamedController(ViewController * controller) {
|
||||
}
|
||||
|
||||
void StackView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
const KDFont * font = KDFont::SmallFont;
|
||||
KDCoordinate height = bounds().height();
|
||||
KDCoordinate width = bounds().width();
|
||||
ctx->fillRect(KDRect(0, 0, width, 1), m_separatorColor);
|
||||
ctx->fillRect(KDRect(0, 1, width, height-2), m_backgroundColor);
|
||||
ctx->fillRect(KDRect(0, height-1, width, 1), m_separatorColor);
|
||||
KDRect b = bounds();
|
||||
drawBorderOfRect(ctx, b, m_separatorColor);
|
||||
drawInnerRect(ctx, b, m_backgroundColor);
|
||||
// Write title
|
||||
const KDFont * font = KDFont::SmallFont;
|
||||
KDSize textSize = font->stringSize(m_controller->title());
|
||||
KDPoint origin((m_frame.width() - textSize.width())/2,(m_frame.height() - textSize.height())/2);
|
||||
ctx->drawString(m_controller->title(), origin, font, m_textColor, m_backgroundColor);
|
||||
|
||||
Reference in New Issue
Block a user