summaryrefslogtreecommitdiff
path: root/src/layout/actions.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-07-29 18:09:51 +0200
committerLaurenz <laurmaedje@gmail.com>2020-07-29 18:09:51 +0200
commitbbcdeb128cce04cd95714b7bc7af5a23a7e38bd2 (patch)
treee0a1620d335982669cd7671cbd71df46d100e9ea /src/layout/actions.rs
parentf34ba3dcda182d9b9c14cc94fdb48810bf18bef0 (diff)
Move, rename and switch some things (boring) 🚚
- Problems -> Diagnostics - Position -> Pos - offset_spans -> Offset trait - Size -> Length (and some more size types renamed) - Paper into its own module - scope::Parser -> parsing::CallParser - Create `Decorations` alias - Remove lots of double newlines - Switch from f32 to f64
Diffstat (limited to 'src/layout/actions.rs')
-rw-r--r--src/layout/actions.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/layout/actions.rs b/src/layout/actions.rs
index 8b50edfa..317cff25 100644
--- a/src/layout/actions.rs
+++ b/src/layout/actions.rs
@@ -4,23 +4,22 @@ use std::fmt::{self, Debug, Formatter};
use serde::ser::{Serialize, Serializer, SerializeTuple};
use toddle::query::FontIndex;
-use crate::size::{Size, Size2D};
+use crate::length::{Length, Size};
use super::Layout;
use self::LayoutAction::*;
-
/// A layouting action, which is the basic building block layouts are composed
/// of.
#[derive(Clone, PartialEq)]
pub enum LayoutAction {
/// Move to an absolute position.
- MoveAbsolute(Size2D),
+ MoveAbsolute(Size),
/// Set the font given the index from the font loader and font size.
- SetFont(FontIndex, Size),
+ SetFont(FontIndex, Length),
/// Write text at the current position.
WriteText(String),
/// Visualize a box for debugging purposes.
- DebugBox(Size2D),
+ DebugBox(Size),
}
impl Serialize for LayoutAction {
@@ -81,11 +80,11 @@ impl Debug for LayoutAction {
/// position.
#[derive(Debug, Clone, PartialEq)]
pub struct LayoutActions {
- origin: Size2D,
+ origin: Size,
actions: Vec<LayoutAction>,
- active_font: (FontIndex, Size),
- next_pos: Option<Size2D>,
- next_font: Option<(FontIndex, Size)>,
+ active_font: (FontIndex, Length),
+ next_pos: Option<Size>,
+ next_font: Option<(FontIndex, Length)>,
}
impl LayoutActions {
@@ -93,8 +92,8 @@ impl LayoutActions {
pub fn new() -> LayoutActions {
LayoutActions {
actions: vec![],
- origin: Size2D::ZERO,
- active_font: (FontIndex::MAX, Size::ZERO),
+ origin: Size::ZERO,
+ active_font: (FontIndex::MAX, Length::ZERO),
next_pos: None,
next_font: None,
}
@@ -126,7 +125,7 @@ impl LayoutActions {
/// Add a layout at a position. All move actions inside the layout are
/// translated by the position.
- pub fn add_layout(&mut self, position: Size2D, layout: Layout) {
+ pub fn add_layout(&mut self, position: Size, layout: Layout) {
self.flush_position();
self.origin = position;