Struct thyme::AppBuilder
source · pub struct AppBuilder { /* private fields */ }
Expand description
An easy to use but still fairly configurable builder, allowing you to get
a Thyme app up in just a few lines of code. It is designed to cover the
majority of cases and handles display creation, asset loading, and
initial Thyme setup. If your use case isn’t covered here, you’ll need to
manually create your ContextBuilder
, and
associated structs. See the examples.
Implementations§
source§impl AppBuilder
impl AppBuilder
sourcepub fn new() -> AppBuilder
pub fn new() -> AppBuilder
Creates a new empty App builder. Use with the builder pattern.
Example
// Assuming you have a theme definition in theme.yml, fonts in the fonts
// directory and images in the images
directory:
let app = AppBuilder::new()
.with_title(“My App”)
.with_window_size(1600.0, 900.0)
.with_theme_file(“theme.yml”)
.with_font_dir(“fonts”)
.with_image_dir(“images”)
.build_glium();
*
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_tooltip_time(self, time_millis: u32) -> AppBuilder
pub fn with_tooltip_time(self, time_millis: u32) -> AppBuilder
Set the time in milliseconds for tooltips to show.
See BuildOptions
sourcepub fn with_line_scroll(self, line_scroll: f32) -> AppBuilder
pub fn with_line_scroll(self, line_scroll: f32) -> AppBuilder
Set the number of lines that scrollbars will scroll per mouse scroll.
See BuildOptions
sourcepub fn with_logger(self) -> AppBuilder
pub fn with_logger(self) -> AppBuilder
If called, this App Builder will setup a default Thyme logger
at the warn level. See SimpleLogger
.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_title<T: Into<String>>(self, title: T) -> AppBuilder
pub fn with_title<T: Into<String>>(self, title: T) -> AppBuilder
Specifies the window title for this app.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_window_size(self, x: f32, y: f32) -> AppBuilder
pub fn with_window_size(self, x: f32, y: f32) -> AppBuilder
Specifies the window size, in logical pixels, for this app.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_base_dir(self, dir: &str) -> AppBuilder
pub fn with_base_dir(self, dir: &str) -> AppBuilder
Specifies a top level base directory, that all other assets will be read as subdirectories of. By default, this will just be the current working directory
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_theme_files(self, files: &[&str]) -> AppBuilder
pub fn with_theme_files(self, files: &[&str]) -> AppBuilder
Specifies the set of YAML theme files to read in as your theme
definition. The filename
is relative to the base directory
. Only the last of
with_theme_files
, with_theme_file
, or
with_theme_dir
will take effect.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_theme_file(self, file: &str) -> AppBuilder
pub fn with_theme_file(self, file: &str) -> AppBuilder
Specifies a single YAML theme file to read in as your theme
definition. The filename
is relative to the base directory
. Only the last of
with_theme_files
, with_theme_file
, or
with_theme_dir
will take effect.
sourcepub fn with_theme_dir(self, dir: &str) -> AppBuilder
pub fn with_theme_dir(self, dir: &str) -> AppBuilder
Specifies to read all YAML files inside the specified directory and parse them to create your
theme
definition. The dir
path is relative to the
base directory
. Only the last of
with_theme_files
, with_theme_file
, or
with_theme_dir
will take effect.
sourcepub fn with_font_files(self, files: &[&str]) -> AppBuilder
pub fn with_font_files(self, files: &[&str]) -> AppBuilder
Specifies to read the specified TTF files as fonts for use in your theme
. The fonts
will be registered with an ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_font_from_file
The paths are relative to the base directory
. Only the last of
with_font_files
, with_font_file
, or
with_font_dir
will take effect.
sourcepub fn with_font_file(self, file: &str) -> AppBuilder
pub fn with_font_file(self, file: &str) -> AppBuilder
Specifies to read the specified single TTF file as a font for use in your theme
. The font
will be registered with an ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_font_from_file
The paths are relative to the base directory
. Only the last of
with_font_files
, with_font_file
, or
with_font_dir
will take effect.
sourcepub fn with_font_dir(self, dir: &str) -> AppBuilder
pub fn with_font_dir(self, dir: &str) -> AppBuilder
Specifies to read all TTF files in the directory as fonts for use in your theme
. The fonts
will be registered with an ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_font_from_file
The paths are relative to the base directory
. Only the last of
with_font_files
, with_font_file
, or
with_font_dir
will take effect.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn with_image_files(self, files: &[&str]) -> AppBuilder
pub fn with_image_files(self, files: &[&str]) -> AppBuilder
Specifies to read the files
as images for use in your theme
. The images
will be registered with ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_texture_from_file
The paths are relative to the base directory
. Only the last of
with_image_files
, with_image_file
, or
with_image_dir
will take effect.
sourcepub fn with_image_file(self, file: &str) -> AppBuilder
pub fn with_image_file(self, file: &str) -> AppBuilder
Specifies to read the file as a single image for use in your theme
. The image
will be registered with ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_texture_from_file
The path is relative to the base directory
. Only the last of
with_image_files
, with_image_file
, or
with_image_dir
will take effect.
sourcepub fn with_image_dir(self, dir: &str) -> AppBuilder
pub fn with_image_dir(self, dir: &str) -> AppBuilder
Specifies to read all png and jpg files in the specified directory as images for use in yourtheme
.
The images will be registered with ID of the filestem (filename without extensions) to the Context,
see ContextBuilder.register_texture_from_file
The paths are relative to the base directory
. Only the last of
with_image_files
, with_image_file
, or
with_image_dir
will take effect.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
More examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn build_gl(self) -> Result<GlApp, Error>
pub fn build_gl(self) -> Result<GlApp, Error>
Creates a GlApp
object, setting up Thyme as specified in this
builder and using the GlRenderer
.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Gl Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_gl()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn build_glium(self) -> Result<GliumApp, Error>
pub fn build_glium(self) -> Result<GliumApp, Error>
Creates a GliumApp
object, setting up Thyme as specified
in this Builder and using the GliumRenderer
.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme Glium Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_glium()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}
sourcepub fn build_wgpu(self) -> Result<WgpuApp, Error>
pub fn build_wgpu(self) -> Result<WgpuApp, Error>
Creates a WgpuApp
object, setting up Thyme as specified
in this Builder and using the WgpuRenderer
.
Examples found in repository?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = thyme::AppBuilder::new()
.with_logger()
.with_title("Thyme wgpu Demo")
.with_window_size(1280.0, 720.0)
.with_base_dir("examples/data")
.with_theme_files(&["themes/base.yml", "themes/pixel.yml"])
.with_font_dir("fonts")
.with_image_dir("images")
.build_wgpu()?;
app.main_loop(|ui| {
ui.window("window", |ui| {
ui.gap(20.0);
ui.button("label", "Hello, World!");
});
});
}