Compare commits

..

No commits in common. "e76e2b43a1c8f2749bb549073303f9650c750ff9" and "fc59ad6e105f2a6b7cdbd670baf305f128f0ea76" have entirely different histories.

14 changed files with 23 additions and 48 deletions

View file

@ -61,8 +61,7 @@ raven_header_files = [
'./src/Widget.hpp',
'./src/SvgWidget.hpp',
'./src/Application.hpp',
'./src/Window.hpp',
'./src/TextInput.hpp',
'./src/Window.hpp'
]

View file

@ -17,9 +17,9 @@ public:
int turn();
int run();
template<typename T, class... Args>
std::shared_ptr<T> add_window(Args&&... args) {
std::shared_ptr<T> child = std::make_shared<T>(std::forward<Args>(args)...);
template<class... Args>
std::shared_ptr<Window> add_window(Args&&... args) {
std::shared_ptr<Window> child = std::make_shared<Window>(std::forward<Args>(args)...);
add_window(child);
return child;
}

View file

@ -1,7 +1,7 @@
#include "BoxLayout.hpp"
#include "Box.hpp"
#include "Widget.hpp"
#include "Events.hpp"
#include "src/Events.hpp"
#include <cmath>
#include <vector>
#include <algorithm>
@ -25,11 +25,6 @@ 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);
@ -94,13 +89,8 @@ 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

View file

@ -1,7 +1,6 @@
#include "DocumentLayout.hpp"
#include "Point.hpp"
#include "Widget.hpp"
#include "Events.hpp"
#include <iostream>
namespace Raven {
@ -10,20 +9,15 @@ bool DocumentLayout::run() {
if (!m_target)
return false;
Point bound { m_margin + m_target->rect().max_geometry().width(), m_margin };
Point current_position { m_margin, m_margin };
double largest_height_so_far = -1.0;
double desired_height = m_margin * 2;
auto& children = m_target->children();
for (auto child : children) {
if (child->absolute())
continue;
if (child->layout() && child->layout()->dynamically_sizes_target()) {
auto event = RelayoutSubtreeEvent();
child->dispatch_event(event);
}
if (child->rect().height() > largest_height_so_far) {
largest_height_so_far = child->rect().height();
}
@ -33,7 +27,7 @@ bool DocumentLayout::run() {
bool should_do_new_row = new_row_because_of_control_widget || new_row_because_of_justification;
if (should_do_new_row) {
current_position.add(0, largest_height_so_far + m_margin);
desired_height += largest_height_so_far + m_margin;
bound.add(0, largest_height_so_far + m_margin);
current_position.set_x(m_margin);
}
@ -45,17 +39,13 @@ bool DocumentLayout::run() {
}
}
for (auto &child : m_target->children()) {
auto event = RelayoutSubtreeEvent();
child->dispatch_event(event);
}
/* account for the first row */
desired_height += largest_height_so_far;
bound.add(0, largest_height_so_far);
m_target->rect().set_height(desired_height);
m_target->rect().set_width(bound.x());
m_target->rect().set_height(bound.y());
return true;
return false;
}
}

View file

@ -15,13 +15,10 @@ public:
: Layout()
, m_margin(margin) {}
bool run() override;
bool run();
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; }
};
}

View file

@ -1,6 +1,6 @@
#pragma once
#include <pango/pango-font.h>
#include "pango/pango-font.h"
#include "RGB.hpp"
#define __RAVEN_STYLE_PROP(name, type, ...) \

View file

@ -16,7 +16,6 @@ public:
Widget *target() { return m_target; }
virtual bool dynamically_sizes_target() { return false; }
virtual bool depends_on_width() { return false; }
virtual ~Layout() {}
};

View file

@ -1,7 +1,7 @@
#include "ListLayout.hpp"
#include "Widget.hpp"
#include "Box.hpp"
#include "Events.hpp"
#include "src/Events.hpp"
namespace Raven {

View file

@ -12,7 +12,7 @@ public:
: Layout()
, m_direction(direction) {}
bool run() override;
bool run();
double margin() { return m_margin; }
void set_margin(double margin) { m_margin = margin; run(); }
@ -22,8 +22,6 @@ 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 };

View file

@ -1,6 +1,6 @@
#include "ListView.hpp"
#include "pango/pango-layout.h"
#include "Painter.hpp"
#include "src/Painter.hpp"
namespace Raven {

View file

@ -1,6 +1,6 @@
#pragma once
#include "Widget.hpp"
#include "src/Widget.hpp"
namespace Raven {

View file

@ -2,7 +2,7 @@
#include "Events.hpp"
#include "Logging.hpp"
#include "Painter.hpp"
#include "Styles.hpp"
#include "src/Styles.hpp"
#include <cctype>
#include <string>
#include <locale>

View file

@ -202,7 +202,9 @@ void Widget::handle_relayout_subtree(RelayoutSubtreeEvent &event) {
m_window_relative = compute_window_relative();
if (!m_layout || !m_layout->run()) {
if (m_layout) {
m_layout->run();
} else {
for (auto child : m_children) {
child->dispatch_event(event);
}

View file

@ -23,8 +23,8 @@
int main() {
Raven::Application application {};
auto window = application.add_window<Raven::Window>();
auto test_window = application.add_window<Raven::Window>();
auto window = application.add_window();
auto test_window = application.add_window();
window->spawn_window();
test_window->spawn_window();