Move logic from Layout into DocumentLayout

This commit is contained in:
hippoz 2022-04-03 13:25:09 +03:00
parent eedf38f9a8
commit 60a4dc51a7
Signed by: hippoz
GPG key ID: 7C52899193467641
5 changed files with 30 additions and 13 deletions

View file

@ -11,7 +11,7 @@ executable(
'./src/Window.cpp',
'./src/Widget.cpp',
'./src/Button.cpp',
'./src/Layout.cpp',
'./src/DocumentLayout.cpp',
'./src/Label.cpp',
'./src/main.cpp',
dependencies : [cairomm_dep, xlib_dep, pangocairo_dep]

View file

@ -1,12 +1,10 @@
#include <iostream>
#include "Layout.hpp"
#include "DocumentLayout.hpp"
#include "Point.hpp"
#include "Box.hpp"
#include "Widget.hpp"
namespace Raven {
void Layout::run() {
void DocumentLayout::run() {
if (!m_target)
return;

20
src/DocumentLayout.hpp Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include "Layout.hpp"
namespace Raven {
class DocumentLayout : public Layout {
private:
double m_margin { 0.0 };
public:
DocumentLayout()
: Layout() {}
void run();
double get_margin() { return m_margin; }
void set_margin(double margin) { m_margin = margin; run(); }
};
}

View file

@ -5,19 +5,17 @@
namespace Raven {
class Layout {
private:
double m_margin { 0.0 };
protected:
Widget *m_target { nullptr };
public:
Layout() {}
void run();
double get_margin() { return m_margin; }
void set_margin(double margin) { m_margin = margin; run(); }
virtual void run() {};
void bind_to(Widget *target) { m_target = target; }
Widget *get_target() { return m_target; }
virtual ~Layout() {}
};
}

View file

@ -5,9 +5,10 @@
#include "Box.hpp"
#include "Label.hpp"
#include "Layout.hpp"
#include "src/DocumentLayout.hpp"
int main() {
Raven::Layout main_layout {};
Raven::DocumentLayout main_layout {};
Raven::Widget new_row { Raven::ControlWidgetType::NewRow };
Raven::Window window {};