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/Widget.hpp',
|
||||||
'./src/SvgWidget.hpp',
|
'./src/SvgWidget.hpp',
|
||||||
'./src/Application.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++) {
|
for (unsigned int i = 0; i < m_target->children().size(); i++) {
|
||||||
auto child = m_target->children()[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()) {
|
if (child->layout() && child->layout()->dynamically_sizes_target()) {
|
||||||
auto event = RelayoutSubtreeEvent();
|
auto event = RelayoutSubtreeEvent();
|
||||||
child->dispatch_event(event);
|
child->dispatch_event(event);
|
||||||
|
@ -89,8 +94,13 @@ bool BoxLayout::run() {
|
||||||
auto child = m_target->children()[i];
|
auto child = m_target->children()[i];
|
||||||
Slot slot = working_slots[i];
|
Slot slot = working_slots[i];
|
||||||
|
|
||||||
|
std::cout << "SLOT! " << i << std::endl;
|
||||||
|
|
||||||
if (slot.type == SlotType::Auto) {
|
if (slot.type == SlotType::Auto) {
|
||||||
|
std::cout << "auto - setting to " << space_per_unslotted_widget << std::endl;
|
||||||
slot.pixel = space_per_unslotted_widget;
|
slot.pixel = space_per_unslotted_widget;
|
||||||
|
} else {
|
||||||
|
std::cout << "pixel: " << slot.pixel << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure pixel values are aligned to the pixel grid
|
// make sure pixel values are aligned to the pixel grid
|
||||||
|
|
|
@ -15,10 +15,13 @@ public:
|
||||||
: Layout()
|
: Layout()
|
||||||
, m_margin(margin) {}
|
, m_margin(margin) {}
|
||||||
|
|
||||||
bool run();
|
bool run() override;
|
||||||
|
|
||||||
double margin() { return m_margin; }
|
double margin() { return m_margin; }
|
||||||
void set_margin(double margin) { m_margin = margin; run(); }
|
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; }
|
Widget *target() { return m_target; }
|
||||||
|
|
||||||
virtual bool dynamically_sizes_target() { return false; }
|
virtual bool dynamically_sizes_target() { return false; }
|
||||||
|
virtual bool depends_on_width() { return false; }
|
||||||
|
|
||||||
virtual ~Layout() {}
|
virtual ~Layout() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ public:
|
||||||
: Layout()
|
: Layout()
|
||||||
, m_direction(direction) {}
|
, m_direction(direction) {}
|
||||||
|
|
||||||
bool run();
|
bool run() override;
|
||||||
|
|
||||||
double margin() { return m_margin; }
|
double margin() { return m_margin; }
|
||||||
void set_margin(double margin) { m_margin = margin; run(); }
|
void set_margin(double margin) { m_margin = margin; run(); }
|
||||||
|
@ -22,6 +22,8 @@ public:
|
||||||
|
|
||||||
bool inherit_secondary_dimension() { return m_inherit_secondary_dimension; }
|
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; }
|
void set_inherit_secondary_dimension(bool inherit_secondary_dimension) { m_inherit_secondary_dimension = inherit_secondary_dimension; }
|
||||||
|
|
||||||
|
bool dynamically_sizes_target() override { return true; }
|
||||||
private:
|
private:
|
||||||
double m_margin { 0.0 };
|
double m_margin { 0.0 };
|
||||||
double m_spacing { 0.0 };
|
double m_spacing { 0.0 };
|
||||||
|
|
Loading…
Reference in a new issue