add dirty hack for documentlayout
This commit is contained in:
parent
ce47b21e02
commit
e76e2b43a1
5 changed files with 20 additions and 3 deletions
|
@ -61,7 +61,8 @@ raven_header_files = [
|
|||
'./src/Widget.hpp',
|
||||
'./src/SvgWidget.hpp',
|
||||
'./src/Application.hpp',
|
||||
'./src/Window.hpp'
|
||||
'./src/Window.hpp',
|
||||
'./src/TextInput.hpp',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ bool BoxLayout::run() {
|
|||
for (unsigned int i = 0; i < m_target->children().size(); i++) {
|
||||
auto child = m_target->children()[i];
|
||||
|
||||
// dirty hack for DocumentLayout
|
||||
if (child->layout() && child->layout()->depends_on_width() && m_direction == Direction::Vertical && !m_justify_secondary_dimension) {
|
||||
child->rect().set_width(m_target->rect().width() - 2 * m_margin);
|
||||
}
|
||||
|
||||
if (child->layout() && child->layout()->dynamically_sizes_target()) {
|
||||
auto event = RelayoutSubtreeEvent();
|
||||
child->dispatch_event(event);
|
||||
|
@ -89,8 +94,13 @@ bool BoxLayout::run() {
|
|||
auto child = m_target->children()[i];
|
||||
Slot slot = working_slots[i];
|
||||
|
||||
std::cout << "SLOT! " << i << std::endl;
|
||||
|
||||
if (slot.type == SlotType::Auto) {
|
||||
std::cout << "auto - setting to " << space_per_unslotted_widget << std::endl;
|
||||
slot.pixel = space_per_unslotted_widget;
|
||||
} else {
|
||||
std::cout << "pixel: " << slot.pixel << std::endl;
|
||||
}
|
||||
|
||||
// make sure pixel values are aligned to the pixel grid
|
||||
|
|
|
@ -15,10 +15,13 @@ public:
|
|||
: Layout()
|
||||
, m_margin(margin) {}
|
||||
|
||||
bool run();
|
||||
bool run() override;
|
||||
|
||||
double margin() { return m_margin; }
|
||||
void set_margin(double margin) { m_margin = margin; run(); }
|
||||
|
||||
bool dynamically_sizes_target() override { return true; }
|
||||
bool depends_on_width() override { return true; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
Widget *target() { return m_target; }
|
||||
|
||||
virtual bool dynamically_sizes_target() { return false; }
|
||||
virtual bool depends_on_width() { return false; }
|
||||
|
||||
virtual ~Layout() {}
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
: Layout()
|
||||
, m_direction(direction) {}
|
||||
|
||||
bool run();
|
||||
bool run() override;
|
||||
|
||||
double margin() { return m_margin; }
|
||||
void set_margin(double margin) { m_margin = margin; run(); }
|
||||
|
@ -22,6 +22,8 @@ public:
|
|||
|
||||
bool inherit_secondary_dimension() { return m_inherit_secondary_dimension; }
|
||||
void set_inherit_secondary_dimension(bool inherit_secondary_dimension) { m_inherit_secondary_dimension = inherit_secondary_dimension; }
|
||||
|
||||
bool dynamically_sizes_target() override { return true; }
|
||||
private:
|
||||
double m_margin { 0.0 };
|
||||
double m_spacing { 0.0 };
|
||||
|
|
Loading…
Reference in a new issue