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/Window.cpp',
|
||||||
'./src/Widget.cpp',
|
'./src/Widget.cpp',
|
||||||
'./src/Button.cpp',
|
'./src/Button.cpp',
|
||||||
'./src/Layout.cpp',
|
'./src/DocumentLayout.cpp',
|
||||||
'./src/Label.cpp',
|
'./src/Label.cpp',
|
||||||
'./src/main.cpp',
|
'./src/main.cpp',
|
||||||
dependencies : [cairomm_dep, xlib_dep, pangocairo_dep]
|
dependencies : [cairomm_dep, xlib_dep, pangocairo_dep]
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#include <iostream>
|
#include "DocumentLayout.hpp"
|
||||||
#include "Layout.hpp"
|
|
||||||
#include "Point.hpp"
|
#include "Point.hpp"
|
||||||
#include "Box.hpp"
|
|
||||||
#include "Widget.hpp"
|
#include "Widget.hpp"
|
||||||
|
|
||||||
namespace Raven {
|
namespace Raven {
|
||||||
|
|
||||||
void Layout::run() {
|
void DocumentLayout::run() {
|
||||||
if (!m_target)
|
if (!m_target)
|
||||||
return;
|
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 {
|
namespace Raven {
|
||||||
|
|
||||||
class Layout {
|
class Layout {
|
||||||
private:
|
protected:
|
||||||
double m_margin { 0.0 };
|
|
||||||
Widget *m_target { nullptr };
|
Widget *m_target { nullptr };
|
||||||
public:
|
public:
|
||||||
Layout() {}
|
Layout() {}
|
||||||
|
|
||||||
void run();
|
virtual void run() {};
|
||||||
|
|
||||||
double get_margin() { return m_margin; }
|
|
||||||
void set_margin(double margin) { m_margin = margin; run(); }
|
|
||||||
|
|
||||||
void bind_to(Widget *target) { m_target = target; }
|
void bind_to(Widget *target) { m_target = target; }
|
||||||
Widget *get_target() { return m_target; }
|
Widget *get_target() { return m_target; }
|
||||||
|
|
||||||
|
virtual ~Layout() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,9 +5,10 @@
|
||||||
#include "Box.hpp"
|
#include "Box.hpp"
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
#include "Layout.hpp"
|
#include "Layout.hpp"
|
||||||
|
#include "src/DocumentLayout.hpp"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Raven::Layout main_layout {};
|
Raven::DocumentLayout main_layout {};
|
||||||
Raven::Widget new_row { Raven::ControlWidgetType::NewRow };
|
Raven::Widget new_row { Raven::ControlWidgetType::NewRow };
|
||||||
Raven::Window window {};
|
Raven::Window window {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue