diff --git a/meson.build b/meson.build index 073ba8d..a9e51f9 100644 --- a/meson.build +++ b/meson.build @@ -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', ] diff --git a/src/BoxLayout.cpp b/src/BoxLayout.cpp index a3b1e9c..1a55086 100644 --- a/src/BoxLayout.cpp +++ b/src/BoxLayout.cpp @@ -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 diff --git a/src/DocumentLayout.hpp b/src/DocumentLayout.hpp index 5a03a23..93f464c 100644 --- a/src/DocumentLayout.hpp +++ b/src/DocumentLayout.hpp @@ -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; } }; } diff --git a/src/Layout.hpp b/src/Layout.hpp index 2c10d40..8378caf 100644 --- a/src/Layout.hpp +++ b/src/Layout.hpp @@ -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() {} }; diff --git a/src/ListLayout.hpp b/src/ListLayout.hpp index e7f0988..c1258ad 100644 --- a/src/ListLayout.hpp +++ b/src/ListLayout.hpp @@ -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 };