PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 298 forks source link

Make `Theme` an optional builder method for `Ui` (using `Theme::default` if none is specified`). #689

Closed mitchmindtree closed 6 years ago

mitchmindtree commented 8 years ago

This will make it one step easier by not having to import or construct a Theme for users who just want to get up and running.

lllShamanlll commented 8 years ago

Only optional builder method should be added, or Ui've to be redesigned to be build from something like UiSettings? Should alternative constructors be removed in favor of builder?

mitchmindtree commented 8 years ago

@lllShamanlll hmmm I've been thinking about this and I'm a little unsure.

Currently, our optional parameters only include:

So at first, the builder constructor as you mention seemed a little like overkill to me. However I think you're right: I think it might still be the best option as it will allow us to add further optional arguments in the future without breaking the API :+1:

Something like this would be great:

let ui = conrod::UiBuilder::new()
    .theme(my_theme)
    .widget_capacity(2048)
    .build();
lllShamanlll commented 8 years ago

The problme here i've got, we've to pass theme somehow to Ui while building. so it've to be Cloneable, or user've to be pushed to use Rc. Mb there's other aproach to do that? The problem with Cloned is: 'WidgetDefaults' can't be Cloned due to 'style' field, wich is Box. Patch

mitchmindtree commented 6 years ago

Closing as this has been implemented for a while.