* Option to enable and disable line spacing
* Version upgrade
This commit is contained in:
parent
90d72f9d4e
commit
c6763fca4b
|
|
@ -905,7 +905,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "post_maker"
|
||||
version = "0.6.0-alpha.1"
|
||||
version = "0.6.0-alpha.2"
|
||||
dependencies = [
|
||||
"bichannel",
|
||||
"clap",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "post_maker"
|
||||
version = "0.6.0-alpha.1"
|
||||
version = "0.6.0-alpha.2"
|
||||
edition = "2021"
|
||||
description = "Post Maker helps you to make post for Instagram and other Social Media apps easily."
|
||||
authors = ["PiyushXCoder <https://piyushxcoder.in>"]
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ pub(crate) struct ConfigFile {
|
|||
pub(crate) minimum_width_limit: f64, // for export of image
|
||||
pub(crate) maximum_width_limit: f64, // for export of image
|
||||
pub(crate) draw_box_around_quote: bool,
|
||||
pub(crate) line_spacing: bool,
|
||||
pub(crate) image_format: ImageType,
|
||||
}
|
||||
|
||||
|
|
@ -156,10 +157,11 @@ impl Default for ConfigFile {
|
|||
tag_y_position_ratio: 0.5,
|
||||
tag2_position_ratio: 0.95,
|
||||
image_ratio: (4.0, 5.0),
|
||||
color_layer: [20, 22, 25, 80],
|
||||
color_layer: [20, 22, 25, 0],
|
||||
minimum_width_limit: 650.0,
|
||||
maximum_width_limit: 1080.0,
|
||||
draw_box_around_quote: true,
|
||||
line_spacing: true,
|
||||
image_format: ImageType::Jpeg,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ pub(crate) struct ConfigWindow {
|
|||
pub(crate) image_ratio_width: ValueInput,
|
||||
pub(crate) image_ratio_height: ValueInput,
|
||||
pub(crate) draw_box_around_quote: CheckButton,
|
||||
pub(crate) line_spacing: CheckButton,
|
||||
pub(crate) minimum_width_limit: ValueInput,
|
||||
pub(crate) maximum_width_limit: ValueInput,
|
||||
/// RGB value of top translucent layer
|
||||
|
|
@ -391,16 +392,18 @@ impl ConfigWindow {
|
|||
col.set_size(&image_ratio_grp, 30);
|
||||
|
||||
// Draw box around Quote
|
||||
let mut label = Frame::default().with_label("Draw Box:");
|
||||
let mut label = Frame::default().with_label("Quote Special:");
|
||||
label.set_label_font(enums::Font::HelveticaBold);
|
||||
col.set_size(&label, 15);
|
||||
|
||||
let mut draw_box_around_quote_flex = Flex::default().row();
|
||||
draw_box_around_quote_flex.set_size(&Frame::default(), 20);
|
||||
let mut quote_special_flex = Flex::default().row();
|
||||
quote_special_flex.set_size(&Frame::default(), 20);
|
||||
let mut draw_box_around_quote = CheckButton::default().with_label("Draw box around text");
|
||||
draw_box_around_quote.set_value(true);
|
||||
draw_box_around_quote_flex.end();
|
||||
col.set_size(&draw_box_around_quote_flex, 30);
|
||||
let mut line_spacing = CheckButton::default().with_label("Line spacing in quotes");
|
||||
line_spacing.set_value(true);
|
||||
quote_special_flex.end();
|
||||
col.set_size("e_special_flex, 30);
|
||||
|
||||
let mut label = Frame::default().with_label("Image with limits:");
|
||||
label.set_label_font(enums::Font::HelveticaBold);
|
||||
|
|
@ -519,6 +522,7 @@ impl ConfigWindow {
|
|||
image_ratio_width,
|
||||
image_ratio_height,
|
||||
draw_box_around_quote,
|
||||
line_spacing,
|
||||
minimum_width_limit,
|
||||
maximum_width_limit,
|
||||
translucent_layer_rgb,
|
||||
|
|
@ -577,6 +581,7 @@ impl ConfigWindow {
|
|||
self.image_ratio_height.set_value(config.image_ratio.1);
|
||||
self.draw_box_around_quote
|
||||
.set_checked(config.draw_box_around_quote);
|
||||
self.line_spacing.set_checked(config.line_spacing);
|
||||
self.minimum_width_limit
|
||||
.set_value(config.minimum_width_limit);
|
||||
self.maximum_width_limit
|
||||
|
|
@ -628,6 +633,7 @@ impl ConfigWindow {
|
|||
let mut image_ratio_width = self.image_ratio_width.clone();
|
||||
let mut image_ratio_height = self.image_ratio_height.clone();
|
||||
let draw_box_around_quote = self.draw_box_around_quote.clone();
|
||||
let line_spacing = self.line_spacing.clone();
|
||||
let mut minimum_width_limit = self.minimum_width_limit.clone();
|
||||
let mut maximum_width_limit = self.maximum_width_limit.clone();
|
||||
let mut layer_rgb = self.translucent_layer_rgb.clone();
|
||||
|
|
@ -675,6 +681,7 @@ impl ConfigWindow {
|
|||
image_ratio_width.set_value(conf.image_ratio.0);
|
||||
image_ratio_height.set_value(conf.image_ratio.1);
|
||||
draw_box_around_quote.set_checked(conf.draw_box_around_quote);
|
||||
line_spacing.set_checked(conf.line_spacing);
|
||||
minimum_width_limit.set_value(conf.minimum_width_limit);
|
||||
maximum_width_limit.set_value(conf.maximum_width_limit);
|
||||
utils::set_color_btn_rgba(conf.color_layer, &mut layer_rgb);
|
||||
|
|
@ -706,6 +713,7 @@ impl ConfigWindow {
|
|||
let mut image_ratio_width = self.image_ratio_width.clone();
|
||||
let mut image_ratio_height = self.image_ratio_height.clone();
|
||||
let draw_box_around_quote = self.draw_box_around_quote.clone();
|
||||
let line_spacing = self.line_spacing.clone();
|
||||
let mut minimum_width_limit = self.minimum_width_limit.clone();
|
||||
let mut maximum_width_limit = self.maximum_width_limit.clone();
|
||||
let mut layer_rgb = self.translucent_layer_rgb.clone();
|
||||
|
|
@ -752,6 +760,7 @@ impl ConfigWindow {
|
|||
image_ratio_width.set_value(conf.image_ratio.0);
|
||||
image_ratio_height.set_value(conf.image_ratio.1);
|
||||
draw_box_around_quote.set_checked(conf.draw_box_around_quote);
|
||||
line_spacing.set_checked(conf.line_spacing);
|
||||
minimum_width_limit.set_value(conf.minimum_width_limit);
|
||||
maximum_width_limit.set_value(conf.maximum_width_limit);
|
||||
utils::set_color_btn_rgba(conf.color_layer, &mut layer_rgb);
|
||||
|
|
@ -780,6 +789,7 @@ impl ConfigWindow {
|
|||
let mut image_ratio_width = self.image_ratio_width.clone();
|
||||
let mut image_ratio_height = self.image_ratio_height.clone();
|
||||
let draw_box_around_quote = self.draw_box_around_quote.clone();
|
||||
let line_spacing = self.line_spacing.clone();
|
||||
let mut minimum_width_limit = self.minimum_width_limit.clone();
|
||||
let mut maximum_width_limit = self.maximum_width_limit.clone();
|
||||
let mut layer_rgb = self.translucent_layer_rgb.clone();
|
||||
|
|
@ -816,6 +826,7 @@ impl ConfigWindow {
|
|||
image_ratio_width.set_value(conf.image_ratio.0);
|
||||
image_ratio_height.set_value(conf.image_ratio.1);
|
||||
draw_box_around_quote.set_checked(conf.draw_box_around_quote);
|
||||
line_spacing.set_checked(conf.line_spacing);
|
||||
minimum_width_limit.set_value(conf.minimum_width_limit);
|
||||
maximum_width_limit.set_value(conf.maximum_width_limit);
|
||||
utils::set_color_btn_rgba(conf.color_layer, &mut layer_rgb);
|
||||
|
|
@ -1130,6 +1141,7 @@ impl ConfigWindow {
|
|||
true
|
||||
});
|
||||
|
||||
// Draw box around quote
|
||||
let browse = self.browse.clone();
|
||||
let configs = Rc::clone(&self.configs);
|
||||
self.draw_box_around_quote.handle(move |f, _| {
|
||||
|
|
@ -1142,6 +1154,19 @@ impl ConfigWindow {
|
|||
true
|
||||
});
|
||||
|
||||
// line spacing
|
||||
let browse = self.browse.clone();
|
||||
let configs = Rc::clone(&self.configs);
|
||||
self.line_spacing.handle(move |f, _| {
|
||||
if let Some(conf) = configs
|
||||
.borrow_mut()
|
||||
.get_mut(&browse.selected_text().unwrap())
|
||||
{
|
||||
conf.line_spacing = f.value();
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
// Minimum Width Limit
|
||||
let browse = self.browse.clone();
|
||||
let configs = Rc::clone(&self.configs);
|
||||
|
|
@ -1260,6 +1285,7 @@ impl ConfigWindow {
|
|||
let mut image_ratio_width = self.image_ratio_width.clone();
|
||||
let mut image_ratio_height = self.image_ratio_height.clone();
|
||||
let draw_box_around_quote = self.draw_box_around_quote.clone();
|
||||
let line_spacing = self.line_spacing.clone();
|
||||
let mut minimum_width_limit = self.minimum_width_limit.clone();
|
||||
let mut maximum_width_limit = self.maximum_width_limit.clone();
|
||||
let mut layer_rgb = self.translucent_layer_rgb.clone();
|
||||
|
|
@ -1289,6 +1315,7 @@ impl ConfigWindow {
|
|||
image_ratio_width.set_value(conf.image_ratio.0);
|
||||
image_ratio_height.set_value(conf.image_ratio.1);
|
||||
draw_box_around_quote.set_checked(conf.draw_box_around_quote);
|
||||
line_spacing.set_checked(conf.line_spacing);
|
||||
minimum_width_limit.set_value(conf.minimum_width_limit);
|
||||
maximum_width_limit.set_value(conf.maximum_width_limit);
|
||||
utils::set_color_btn_rgba(conf.color_layer, &mut layer_rgb);
|
||||
|
|
|
|||
12
src/utils.rs
12
src/utils.rs
|
|
@ -666,6 +666,7 @@ pub(crate) fn draw_multiline_mid_string(
|
|||
let (mut box_width, mut box_height) = (0.0, 0.0);
|
||||
|
||||
let (width, height): (f64, f64) = Coord::from(tmp.dimensions()).into();
|
||||
let has_line_spacing = rw_read!(globals::CONFIG).line_spacing;
|
||||
for (index, line) in text.lines().enumerate() {
|
||||
let (text_width, text_height) =
|
||||
measure_line(font, line, rusttype::Scale::uniform(size as f32));
|
||||
|
|
@ -673,11 +674,16 @@ pub(crate) fn draw_multiline_mid_string(
|
|||
if text_width > box_width {
|
||||
box_width = text_width;
|
||||
}
|
||||
box_height += text_height * 1.15;
|
||||
box_height += text_height
|
||||
* if index == 0 || !has_line_spacing {
|
||||
1.0
|
||||
} else {
|
||||
1.12
|
||||
};
|
||||
|
||||
let (x, y) = (
|
||||
(width - text_width) / 2.0,
|
||||
(position * height) / original_height + index as f64 * (text_height * 1.15),
|
||||
(position * height) / original_height + index as f64 * (text_height * 1.12),
|
||||
);
|
||||
|
||||
if !boxed || !rw_read!(globals::CONFIG).draw_box_around_quote {
|
||||
|
|
@ -733,7 +739,7 @@ fn draw_box(
|
|||
let (width, height): (f64, f64) = Coord::from(tmp.dimensions()).into();
|
||||
let (delta_x, delta_y) = (width / original_width, height / original_height);
|
||||
|
||||
let (x_gap, y_gap) = (8.0 * delta_x, 5.0 * delta_y);
|
||||
let (x_gap, y_gap) = (30.0 * delta_x, 10.0 * delta_y);
|
||||
let (x, y) = (
|
||||
((width - box_width) / 2.0 - x_gap) as u32,
|
||||
((position * height) / original_height - y_gap) as u32,
|
||||
|
|
|
|||
Loading…
Reference in New Issue