Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardized layout definition system #147

Closed
Keavon opened this issue May 23, 2021 · 4 comments · Fixed by #499
Closed

Standardized layout definition system #147

Keavon opened this issue May 23, 2021 · 4 comments · Fixed by #499
Assignees
Labels
Feature New feature or request Rust Involves Rust programming for the backend Web Involves web programming (TypeScript, Vue, CSS)
Milestone

Comments

@Keavon
Copy link
Member

Keavon commented May 23, 2021

We need to create a reusable system for defining input widgets for the frontend to render and communicate changes back to Rust. This will be used in the Document Panel's options bar for tools (#114) in one row but grouped into sections, as well as the Properties Panel for a multi-row and column-based layout likely broken into sections and possibly tabs (#146), plus other future uses. This will involve defining a flexible API spec (likely JSON) for interface elements and their layout, and creating a modular, reusable system.

@TrueDoctor TrueDoctor self-assigned this May 23, 2021
@TrueDoctor TrueDoctor added Feature New feature or request Architecture Involves architecture or engineering work or discussion labels May 23, 2021
@TrueDoctor TrueDoctor added this to the Sprint 4 (current) milestone May 23, 2021
@Keavon
Copy link
Member Author

Keavon commented May 23, 2021

Some examples of needed layout capabilities:

Properties panel

Options bar

@TrueDoctor TrueDoctor removed their assignment May 28, 2021
@Keavon Keavon added Rust Involves Rust programming for the backend Web Involves web programming (TypeScript, Vue, CSS) labels Jun 10, 2021
@Keavon
Copy link
Member Author

Keavon commented Jun 12, 2021

Notes on this:

Layout system depends on a lot of things. We need to define some layout API approach that can properly encode all the designs and layouts we need throughout Graphite. This requires some additional design work to fully understand the needs. This also touches upon the extension system, since extensions should be able to add layouts. It also gets into the question of how far we want to go with this because it leans into the territory of the original XML-based layout system. That system was meant for defining composable components (much like Vue is used now for) and could be resurrected with the web and Vue as UI renderers, until we port that system over to a custom WGPU-based render backend. This could be a path towards gently transitioning to the native editor client.

@TrueDoctor
Copy link
Member

some pseudocode:

trait Component {
	fn render(&self) -> HTML;
}

struct Checkbox {
	bool: checked,
}

impl Component for Checkbox {
	fn render(&self) -> HTML {
		html!("<box>{}</box>", self.checked)
	}
}
struct BarSeparator;
impl Component for BarSeparator {
	fn render(&self) -> HTML {
		html!("|", self.checked)
	}
}

type Icon = String;
const LEFT_ALIGN: Icon = "left_align";

struct AlignButton {
    icon: Icon,
    tooltip: Option<String>,
	callback: String,
}

fn callback(m: Message) -> HTML {
	html!("<div onclick=dispatch_message({})>", serde_json::to_string(m))
}

let shape_options = …;
shape_options.render()

const LEFT_ALIGN_BUTTON: AlignButton = AlignButton{icon: LEFT_ALIGN, tooltip:"left_align"};

#[derive(Component)]
#[Component(direction:horizontal)]
struct ShapeOptions { // 3c | 3b | 3c
    stroke_bitmask: Row<Checkbox>,
    #[separator(4px)]
    clicky_stuff: Row<Button>,
    other_stuff: Row<Checkbox>,
}

render() {
    match self.sides {
        1 => foo!,
        2..5 => bar!,
        _ => panic!,
    }
}

struct RowWithSeparator<U:Component, T: Component> {
    elements: Vec<U>
}

impl Component for RowWithSeparator<…> {
	fn render(&self) -> HTML {
        self.iter().map(|x|html!(x)).join(T::default().render())
	}
}

struct Row {
	elements: Vec<Box<Component>>,
}

impl Component for Vec<Box<Component>> {
	fn render(&self) -> HTML {
        self.iter().map(|x|html!(x)).join()
	}
}

impl Component for Checkbox {
	fn render(&self) -> HTML {
		html!("<row>{}</row>", self.checked)
	}
}

@Keavon Keavon added P-High and removed In-Progress labels Jul 21, 2021
@Keavon Keavon changed the title Design the layout definition system Standardized layout definition system Aug 12, 2021
@Keavon Keavon added P-Critical and removed P-High labels Aug 12, 2021
@henryksloan henryksloan removed their assignment Aug 23, 2021
@Keavon
Copy link
Member Author

Keavon commented Jan 31, 2022

Closed by PR #499.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request Rust Involves Rust programming for the backend Web Involves web programming (TypeScript, Vue, CSS)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants