Move logic from Layout into DocumentLayout
This commit is contained in:
parent
eedf38f9a8
commit
60a4dc51a7
5 changed files with 30 additions and 13 deletions
|
@ -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]
|
||||
|
|
|
@ -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
20
src/DocumentLayout.hpp
Normal 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(); }
|
||||
};
|
||||
|
||||
}
|
|
@ -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() {}
|
||||
};
|
||||
|
||||
}
|
|
@ -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 {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue