Skip to content

Commit

Permalink
further changes to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyarndley committed Jun 5, 2021
1 parent 02996da commit 683eea4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn window_main(renderer: Arc<Mutex<FractalRenderer>>) -> impl Widget<Fractal
.with_child(Flex::row()
.with_child(Label::new("Pattern Zoom: ").with_text_size(14.0))
.with_flex_child(Slider::new()
.with_range(-1.0,4.0).expand_width()
.with_range(0.0,4.0).expand_width()
.lens(FractalData::root_zoom_factor.map(
|val| (1.0 / (1.0 - val)).log2(),
|val, new| *val = 1.0 - (1.0 / 2.0_f64.powf(new.round())))), 1.0)
Expand Down Expand Up @@ -217,12 +217,12 @@ pub fn window_main(renderer: Arc<Mutex<FractalRenderer>>) -> impl Widget<Fractal
};
}).lens(FractalData::mouse_mode).expand_width().fix_height(24.0), 1.0)
.with_spacer(4.0)
.with_flex_child(Button::new("CENTRAL OUT").on_click(|ctx, _data: &mut FractalData, _env| {
ctx.submit_command(MULTIPLY_PATTERN.with(-1.0));
.with_flex_child(Button::new("CENTRAL OUT").on_click(|ctx, data: &mut FractalData, _env| {
ctx.submit_command(MULTIPLY_PATTERN.with(1.0 - 1.0 / (1.0 - data.root_zoom_factor)));
}).expand_width().fix_height(24.0), 1.0)
.with_spacer(4.0)
.with_flex_child(Button::new("CENTRAL IN").on_click(|ctx, _data: &mut FractalData, _env| {
ctx.submit_command(MULTIPLY_PATTERN.with(0.5));
.with_flex_child(Button::new("CENTRAL IN").on_click(|ctx, data: &mut FractalData, _env| {
ctx.submit_command(MULTIPLY_PATTERN.with(data.root_zoom_factor));
}).expand_width().fix_height(24.0), 1.0));

let group_palette = Flex::column()
Expand Down
19 changes: 11 additions & 8 deletions src/widgets/fractal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl<'a> Widget<FractalData> for FractalWidget<'a> {

if let Some(root_zoom) = command.get(ROOT_FINDING_COMPLETE) {
self.mouse_mode = MouseMode::None;
self.pos1 = self.pos2;

data.root_progress = 1.0;
data.root_iteration = 64;
Expand Down Expand Up @@ -756,16 +757,18 @@ impl<'a> Widget<FractalData> for FractalWidget<'a> {
if let Some(factor) = command.get(MULTIPLY_PATTERN) {
let new_zoom = linear_interpolation_between_zoom(renderer.zoom, string_to_extended(&data.root_zoom), *factor);

renderer.zoom = new_zoom;
if new_zoom.exponent > -1 {
renderer.zoom = new_zoom;

data.zoom = extended_to_string_long(renderer.zoom);
settings.set("zoom", data.zoom.clone()).unwrap();

if string_to_extended(&data.zoom) > string_to_extended(&data.center_reference_zoom) {
data.need_full_rerender = true;
};
data.zoom = extended_to_string_long(renderer.zoom);
settings.set("zoom", data.zoom.clone()).unwrap();

ctx.submit_command(RESET_RENDERER_FAST);
if string_to_extended(&data.zoom) > string_to_extended(&data.center_reference_zoom) {
data.need_full_rerender = true;
};

ctx.submit_command(RESET_RENDERER_FAST);
}

return;
}
Expand Down

0 comments on commit 683eea4

Please sign in to comment.