Skip to content

Commit 110bb32

Browse files
Merge pull request #76 from iShape-Rust/feature/int_api
Feature/int api
2 parents 3f6066c + 3d1997a commit 110bb32

158 files changed

Lines changed: 6999 additions & 2880 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/overlay_editor/src/app/boolean/content.rs

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
use std::collections::HashMap;
2-
use i_triangle::i_overlay::core::overlay::Overlay;
3-
use i_triangle::i_overlay::i_shape::int::count::PointsCount;
4-
use i_triangle::i_overlay::i_float::int::rect::IntRect;
5-
use iced::widget::scrollable;
6-
use iced::{Alignment, Length, Padding, Size, Vector};
7-
use iced::widget::{Button, Column, Container, Row, Space, Text};
8-
use crate::app::design;
91
use crate::app::boolean::control::ModeOption;
102
use crate::app::boolean::workspace::WorkspaceState;
3+
use crate::app::design;
114
use crate::app::fill_option::FillOption;
12-
use crate::app::main::{EditorApp, AppMessage};
5+
use crate::app::main::{AppMessage, EditorApp};
136
use crate::app::solver_option::SolverOption;
14-
use crate::geom::camera::Camera;
157
use crate::data::boolean::BooleanResource;
8+
use crate::geom::camera::Camera;
169
use crate::point_editor::point::PathsToEditorPoints;
1710
use crate::point_editor::widget::PointEditUpdate;
11+
use i_triangle::i_overlay::core::overlay::Overlay;
12+
use i_triangle::i_overlay::i_float::int::rect::IntRect;
13+
use i_triangle::i_overlay::i_shape::int::count::PointsCount;
14+
use iced::widget::scrollable;
15+
use iced::widget::{Button, Column, Container, Row, Space, Text};
16+
use iced::{Alignment, Length, Padding, Size, Vector};
17+
use std::collections::HashMap;
1818

1919
pub(crate) struct BooleanState {
2020
pub(crate) test: usize,
@@ -41,25 +41,31 @@ pub(crate) enum BooleanMessage {
4141
impl EditorApp {
4242
fn boolean_sidebar(&self) -> Column<'_, AppMessage> {
4343
let count = self.app_resource.boolean.count;
44-
let mut column = Column::new().push(
45-
Space::new()
46-
.width(Length::Fill)
47-
.height(Length::Fixed(2.0)),
48-
);
44+
let mut column =
45+
Column::new().push(Space::new().width(Length::Fill).height(Length::Fixed(2.0)));
4946
for index in 0..count {
5047
let is_selected = self.state.boolean.test == index;
5148

5249
column = column.push(
5350
Container::new(
5451
Button::new(
5552
Text::new(format!("test_{}", index))
56-
.style(if is_selected { design::style_sidebar_text_selected } else { design::style_sidebar_text })
57-
.size(14)
53+
.style(if is_selected {
54+
design::style_sidebar_text_selected
55+
} else {
56+
design::style_sidebar_text
57+
})
58+
.size(14),
5859
)
59-
.width(Length::Fill)
60-
.on_press(AppMessage::Bool(BooleanMessage::TestSelected(index)))
61-
.style(if is_selected { design::style_sidebar_button_selected } else { design::style_sidebar_button })
62-
).padding(self.design.action_padding())
60+
.width(Length::Fill)
61+
.on_press(AppMessage::Bool(BooleanMessage::TestSelected(index)))
62+
.style(if is_selected {
63+
design::style_sidebar_button_selected
64+
} else {
65+
design::style_sidebar_button
66+
}),
67+
)
68+
.padding(self.design.action_padding()),
6369
);
6470
}
6571

@@ -75,14 +81,15 @@ impl EditorApp {
7581
.height(Length::Shrink)
7682
.align_x(Alignment::Start)
7783
.padding(Padding::new(0.0).right(8))
78-
.style(design::style_sidebar_background)
79-
).direction(scrollable::Direction::Vertical(
84+
.style(design::style_sidebar_background),
85+
)
86+
.direction(scrollable::Direction::Vertical(
8087
scrollable::Scrollbar::new()
8188
.width(4)
8289
.margin(0)
8390
.scroller_width(4)
8491
.anchor(scrollable::Anchor::Start),
85-
))
92+
)),
8693
)
8794
.push(self.boolean_workspace())
8895
}
@@ -101,7 +108,9 @@ impl EditorApp {
101108
}
102109

103110
fn boolean_set_test(&mut self, index: usize) {
104-
self.state.boolean.load_test(index, &mut self.app_resource.boolean);
111+
self.state
112+
.boolean
113+
.load_test(index, &mut self.app_resource.boolean);
105114
self.state.boolean.update_solution();
106115
}
107116

@@ -174,7 +183,8 @@ impl BooleanState {
174183
let editor_points = &mut self.workspace.points;
175184

176185
if editor_points.is_empty() {
177-
editor_points.reserve(test.clip_paths.points_count() + test.subj_paths.points_count())
186+
editor_points
187+
.reserve(test.clip_paths.points_count() + test.subj_paths.points_count())
178188
} else {
179189
editor_points.clear();
180190
}
@@ -204,10 +214,11 @@ impl BooleanState {
204214
let clip = &self.workspace.clip;
205215
let fill_rule = self.fill.fill_rule();
206216
match self.mode {
207-
ModeOption::Edit => {},
217+
ModeOption::Edit => {}
208218
ModeOption::Debug => {
209-
self.workspace.vectors = Overlay::with_contours(subj, clip).build_separate_vectors(fill_rule);
210-
},
219+
self.workspace.vectors =
220+
Overlay::with_contours(subj, clip).build_separate_vectors(fill_rule);
221+
}
211222
_ => {
212223
let overlay_rule = self.mode.overlay_rule().unwrap();
213224
let solution = Overlay::with_contours(subj, clip).overlay(overlay_rule, fill_rule);

examples/overlay_editor/src/app/boolean/control.rs

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,75 @@
1-
use i_triangle::i_overlay::core::overlay_rule::OverlayRule;
21
use crate::app::boolean::content::BooleanMessage;
32
use crate::app::fill_option::FillOption;
4-
use crate::app::main::{EditorApp, AppMessage};
3+
use crate::app::main::{AppMessage, EditorApp};
54
use crate::app::solver_option::SolverOption;
5+
use i_triangle::i_overlay::core::overlay_rule::OverlayRule;
6+
use iced::widget::{pick_list, Column, Container, Row, Space, Text};
67
use iced::{Alignment, Length};
7-
use iced::widget::{Column, Container, pick_list, Row, Space, Text};
88

99
impl EditorApp {
1010
pub(crate) fn boolean_control(&self) -> Column<'_, AppMessage> {
11-
let solver_pick_list =
12-
Row::new()
13-
.push(Text::new("Solver:")
11+
let solver_pick_list = Row::new()
12+
.push(
13+
Text::new("Solver:")
1414
.width(Length::Fixed(90.0))
1515
.height(Length::Fill)
16-
.align_y(Alignment::Center))
17-
.push(
18-
Container::new(
19-
pick_list(
20-
&SolverOption::ALL[..],
21-
Some(self.state.boolean.solver),
22-
on_select_solver,
23-
).width(Length::Fixed(160.0))
16+
.align_y(Alignment::Center),
17+
)
18+
.push(
19+
Container::new(
20+
pick_list(
21+
&SolverOption::ALL[..],
22+
Some(self.state.boolean.solver),
23+
on_select_solver,
2424
)
25-
.height(Length::Fill)
26-
.align_y(Alignment::Center)
27-
).height(Length::Fixed(40.0));
25+
.width(Length::Fixed(160.0)),
26+
)
27+
.height(Length::Fill)
28+
.align_y(Alignment::Center),
29+
)
30+
.height(Length::Fixed(40.0));
2831

29-
let fill_pick_list =
30-
Row::new()
31-
.push(Text::new("Fill Rule:")
32+
let fill_pick_list = Row::new()
33+
.push(
34+
Text::new("Fill Rule:")
3235
.width(Length::Fixed(90.0))
3336
.height(Length::Fill)
34-
.align_y(Alignment::Center))
35-
.push(
36-
Container::new(
37-
pick_list(
38-
&FillOption::ALL[..],
39-
Some(self.state.boolean.fill),
40-
on_select_fill,
41-
).width(Length::Fixed(160.0))
37+
.align_y(Alignment::Center),
38+
)
39+
.push(
40+
Container::new(
41+
pick_list(
42+
&FillOption::ALL[..],
43+
Some(self.state.boolean.fill),
44+
on_select_fill,
4245
)
43-
.height(Length::Fill)
44-
.align_y(Alignment::Center)
45-
).height(Length::Fixed(40.0));
46+
.width(Length::Fixed(160.0)),
47+
)
48+
.height(Length::Fill)
49+
.align_y(Alignment::Center),
50+
)
51+
.height(Length::Fixed(40.0));
4652

47-
let mode_pick_list =
48-
Row::new()
49-
.push(Text::new("Mode:")
53+
let mode_pick_list = Row::new()
54+
.push(
55+
Text::new("Mode:")
5056
.width(Length::Fixed(90.0))
5157
.height(Length::Fill)
52-
.align_y(Alignment::Center))
53-
.push(
54-
Container::new(
55-
pick_list(
56-
&ModeOption::ALL[..],
57-
Some(self.state.boolean.mode),
58-
on_select_mode,
59-
).width(Length::Fixed(160.0))
58+
.align_y(Alignment::Center),
59+
)
60+
.push(
61+
Container::new(
62+
pick_list(
63+
&ModeOption::ALL[..],
64+
Some(self.state.boolean.mode),
65+
on_select_mode,
6066
)
61-
.height(Length::Fill)
62-
.align_y(Alignment::Center)
63-
).height(Length::Fixed(40.0));
67+
.width(Length::Fixed(160.0)),
68+
)
69+
.height(Length::Fill)
70+
.align_y(Alignment::Center),
71+
)
72+
.height(Length::Fixed(40.0));
6473

6574
Column::new()
6675
.push(solver_pick_list)
@@ -127,7 +136,7 @@ impl ModeOption {
127136
ModeOption::Difference => Some(OverlayRule::Difference),
128137
ModeOption::InverseDifference => Some(OverlayRule::InverseDifference),
129138
ModeOption::Xor => Some(OverlayRule::Xor),
130-
_ => None
139+
_ => None,
131140
}
132141
}
133142
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub(crate) mod content;
2+
mod control;
23
mod workspace;
3-
mod control;

0 commit comments

Comments
 (0)