Compare commits
9 commits
711c244ef2
...
112a3b83d3
Author | SHA1 | Date | |
---|---|---|---|
|
112a3b83d3 | ||
|
cbbe90f57d | ||
|
32524f01e2 | ||
|
533b6ebe91 | ||
|
801482efbf | ||
|
6dd0a1338f | ||
|
59e8806c9e | ||
|
3139582373 | ||
|
c63d94a651 |
15 changed files with 42 additions and 22 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
build/
|
||||
builddir/
|
||||
buildclang/
|
||||
releaseclang/
|
||||
|
|
|
@ -74,7 +74,7 @@ pkg_mod.generate(
|
|||
filebase : meson.project_name(),
|
||||
description : project_description,
|
||||
subdirs : meson.project_name(),
|
||||
libraries : raven_lib
|
||||
libraries : [raven_dependencies, raven_lib]
|
||||
)
|
||||
|
||||
executable(
|
||||
|
|
13
pkg/install.sh
Executable file
13
pkg/install.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! command -v arch-meson &> /dev/null
|
||||
then
|
||||
echo "arch-meson not found, using meson"
|
||||
meson build
|
||||
else
|
||||
echo "found arch-meson"
|
||||
arch-meson . build
|
||||
fi
|
||||
|
||||
meson compile -C build
|
||||
meson install -C build --destdir "$DEST"
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "src/Layout.hpp"
|
||||
#include "src/Widget.hpp"
|
||||
#include "src/Box.hpp"
|
||||
#include "Layout.hpp"
|
||||
#include "Widget.hpp"
|
||||
#include "Box.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ void Button::on_paint() {
|
|||
auto painter = window()->painter();
|
||||
|
||||
painter.source_rgb(style()->foreground());
|
||||
// todo: do we use the max geometry like in Label?
|
||||
painter.text(rect(), m_text, PaintTextAlign::Center, PANGO_ELLIPSIZE_END, style()->font_description());
|
||||
painter.fill();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ void DocumentLayout::run() {
|
|||
if (!m_target)
|
||||
return;
|
||||
|
||||
Point bound { m_margin, m_margin };
|
||||
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;
|
||||
|
||||
|
@ -36,10 +36,12 @@ void DocumentLayout::run() {
|
|||
|
||||
if (!new_row_because_of_control_widget) {
|
||||
current_position.add(child->rect().width() + m_margin, 0);
|
||||
bound.add(child->rect().width() + m_margin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* account for the first row */
|
||||
bound.add(0, largest_height_so_far);
|
||||
|
||||
m_target->rect().set_width(bound.x());
|
||||
m_target->rect().set_height(bound.y());
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ void Label::on_init() {
|
|||
|
||||
void Label::on_paint() {
|
||||
auto painter = window()->painter();
|
||||
auto geometry = rect().max_geometry();
|
||||
|
||||
painter.source_rgb(style()->foreground());
|
||||
painter.text(rect(), m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_NONE, style()->font_description());
|
||||
painter.text(geometry, m_text, PaintTextAlign::Left, PANGO_ELLIPSIZE_END, style()->font_description());
|
||||
painter.fill();
|
||||
}
|
||||
|
||||
|
|
|
@ -102,11 +102,4 @@ void Painter::flush_paint_group() {
|
|||
m_cairo->get_target()->flush();
|
||||
}
|
||||
|
||||
Point Painter::png(std::string path) {
|
||||
auto image = Cairo::ImageSurface::create_from_png(path.c_str());
|
||||
m_cairo->set_source(image, 0, 0);
|
||||
|
||||
return Point(image->get_width(), image->get_height());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ public:
|
|||
bool can_paint() { if (m_cairo) return true; else return false; }
|
||||
|
||||
void source_rgb(RGB source_rgb);
|
||||
Point png(std::string path);
|
||||
void fill();
|
||||
|
||||
void begin_paint_group();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "ScrollContainer.hpp"
|
||||
#include "src/Styles.hpp"
|
||||
#include "Styles.hpp"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
|
@ -11,6 +11,9 @@ void ScrollContainer::on_layout() {
|
|||
|
||||
m_target->rect().set_x(-m_scroll.x());
|
||||
m_target->rect().set_y(-m_scroll.y());
|
||||
// todo: doesn't work with horizontal scrolling
|
||||
m_target->rect().set_min_width(rect().width());
|
||||
m_target->rect().set_max_width(rect().width());
|
||||
}
|
||||
|
||||
std::shared_ptr<Widget> ScrollContainer::make_target() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.hpp"
|
||||
#include "src/Point.hpp"
|
||||
#include "Point.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace Raven {
|
||||
|
|
|
@ -106,6 +106,11 @@ void Widget::remove_child(std::shared_ptr<Widget> child) {
|
|||
reflow();
|
||||
}
|
||||
|
||||
void Widget::clear_children() {
|
||||
m_children.clear();
|
||||
reflow();
|
||||
}
|
||||
|
||||
void Widget::repaint() {
|
||||
if (m_window)
|
||||
m_window->repaint(this);
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
std::vector<std::shared_ptr<Widget>> &children() { return m_children; }
|
||||
bool add_child(std::shared_ptr<Widget> child);
|
||||
void remove_child(std::shared_ptr<Widget> child);
|
||||
void clear_children();
|
||||
|
||||
Box &rect() { return m_rect; }
|
||||
void set_rect(Box rect) { m_rect = rect; reflow(); }
|
||||
|
|
|
@ -21,6 +21,7 @@ void Window::set_main_widget(std::shared_ptr<Widget> main_widget) {
|
|||
|
||||
bool Window::spawn_window() {
|
||||
Display *dsp = XOpenDisplay(NULL);
|
||||
XSynchronize(dsp, False);
|
||||
if (dsp == NULL) {
|
||||
std::cerr << "error: XOpenDisplay(NULL)" << "\n";
|
||||
return false;
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -8,10 +8,10 @@
|
|||
#include "RGB.hpp"
|
||||
#include "DocumentLayout.hpp"
|
||||
#include "Events.hpp"
|
||||
#include "src/BoxLayout.hpp"
|
||||
#include "src/Box.hpp"
|
||||
#include "src/ScrollContainer.hpp"
|
||||
#include "src/Styles.hpp"
|
||||
#include "BoxLayout.hpp"
|
||||
#include "Box.hpp"
|
||||
#include "ScrollContainer.hpp"
|
||||
#include "Styles.hpp"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -24,7 +24,7 @@ protected:
|
|||
void on_paint() {
|
||||
if (!painter()) return;
|
||||
|
||||
painter()->png("tuna.png");
|
||||
//painter()->png("tuna.png");
|
||||
painter()->cairo()->paint();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue