diff --git a/src/action/mod.rs b/src/action/mod.rs index dc4e200..3493b08 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -1,10 +1,9 @@ mod element; -mod icon; use crate::render_util::{button_size_with_spacing, close_button}; use nexus::imgui::{Direction, Ui}; -pub use self::{element::*, icon::*}; +pub use self::element::*; // TODO: action clear entire vec? diff --git a/src/elements/align_horizontal.rs b/src/elements/align/horizontal.rs similarity index 100% rename from src/elements/align_horizontal.rs rename to src/elements/align/horizontal.rs diff --git a/src/elements/align.rs b/src/elements/align/mod.rs similarity index 94% rename from src/elements/align.rs rename to src/elements/align/mod.rs index 3cc11f3..de2259c 100644 --- a/src/elements/align.rs +++ b/src/elements/align/mod.rs @@ -1,3 +1,7 @@ +mod horizontal; + +pub use self::horizontal::*; + use serde::{Deserialize, Serialize}; use strum::{AsRefStr, EnumIter, VariantArray}; diff --git a/src/elements/bar.rs b/src/elements/bar/mod.rs similarity index 98% rename from src/elements/bar.rs rename to src/elements/bar/mod.rs index 707b7ef..1d6cd75 100644 --- a/src/elements/bar.rs +++ b/src/elements/bar/mod.rs @@ -1,4 +1,9 @@ -use super::{Align, BarProps, Direction, Progress, Props, RenderState, Unit}; +mod progress; +mod props; + +pub use self::{progress::*, props::*}; + +use super::{align::Align, Direction, Props, RenderState, Unit}; use crate::{ action::Action, bounds::Bounds, diff --git a/src/elements/progress.rs b/src/elements/bar/progress.rs similarity index 100% rename from src/elements/progress.rs rename to src/elements/bar/progress.rs diff --git a/src/elements/bar_props.rs b/src/elements/bar/props.rs similarity index 99% rename from src/elements/bar_props.rs rename to src/elements/bar/props.rs index 173190a..f9e0f6e 100644 --- a/src/elements/bar_props.rs +++ b/src/elements/bar/props.rs @@ -1,7 +1,7 @@ -use super::PartialProps; use crate::{ colors, context::EditState, + elements::PartialProps, render_util::{ input_color_alpha, input_optional, input_percent, input_percent_inverse, input_positive_with_format, diff --git a/src/elements/direction.rs b/src/elements/direction.rs index ed8c4e0..5466db6 100644 --- a/src/elements/direction.rs +++ b/src/elements/direction.rs @@ -1,4 +1,4 @@ -use super::{Align, Icon}; +use super::{align::Align, Icon}; use crate::render_util::Rect; use serde::{Deserialize, Serialize}; use strum::{AsRefStr, EnumIter, VariantArray}; diff --git a/src/elements/element_type.rs b/src/elements/element/kind.rs similarity index 97% rename from src/elements/element_type.rs rename to src/elements/element/kind.rs index 9608fd8..67c2fae 100644 --- a/src/elements/element_type.rs +++ b/src/elements/element/kind.rs @@ -1,7 +1,7 @@ -use super::{Bar, Element, Group, IconElement, IconList, RenderState, Text}; use crate::{ bounds::Bounds, context::{Context, EditState}, + elements::{Bar, Group, IconElement, IconList, RenderState, Text}, render_util::{impl_static_variants, Rect}, traits::{Render, RenderDebug, RenderOptions}, tree::TreeNode, @@ -10,6 +10,8 @@ use nexus::imgui::Ui; use serde::{Deserialize, Serialize}; use strum::{AsRefStr, EnumIter, IntoStaticStr}; +use super::Element; + #[derive(Debug, Clone, EnumIter, AsRefStr, IntoStaticStr, Serialize, Deserialize)] #[serde(tag = "type")] pub enum ElementType { diff --git a/src/elements/element.rs b/src/elements/element/mod.rs similarity index 97% rename from src/elements/element.rs rename to src/elements/element/mod.rs index 53e7581..2fed1c1 100644 --- a/src/elements/element.rs +++ b/src/elements/element/mod.rs @@ -1,4 +1,8 @@ -use super::{Animation, Common, ElementType, RenderState}; +mod kind; + +pub use self::kind::*; + +use super::{Animation, Common, RenderState}; use crate::{ action::ElementAction, bounds::Bounds, @@ -14,7 +18,6 @@ use crate::{ use nexus::imgui::{MenuItem, Ui}; use serde::{Deserialize, Serialize}; -// TODO: conditions, e.g. lower opacity out of combat, color change based on stack threshold // TODO: anchor to parent vs screen #[derive(Debug, Default, Clone, Serialize, Deserialize)] diff --git a/src/elements/group.rs b/src/elements/group/mod.rs similarity index 100% rename from src/elements/group.rs rename to src/elements/group/mod.rs diff --git a/src/elements/icon_element.rs b/src/elements/icon/element.rs similarity index 100% rename from src/elements/icon_element.rs rename to src/elements/icon/element.rs diff --git a/src/elements/icon.rs b/src/elements/icon/mod.rs similarity index 98% rename from src/elements/icon.rs rename to src/elements/icon/mod.rs index ff202e5..9038de3 100644 --- a/src/elements/icon.rs +++ b/src/elements/icon/mod.rs @@ -1,4 +1,10 @@ -use super::{AlignHorizontal, IconProps, IconSource, Props, RenderState}; +mod element; +mod props; +mod source; + +pub use self::{element::*, props::*, source::*}; + +use super::{align::AlignHorizontal, Props, RenderState}; use crate::{ colors::{self, with_alpha, with_alpha_factor}, component_wise::ComponentWise, diff --git a/src/elements/icon_props.rs b/src/elements/icon/props.rs similarity index 97% rename from src/elements/icon_props.rs rename to src/elements/icon/props.rs index 222de8c..8e1c4c1 100644 --- a/src/elements/icon_props.rs +++ b/src/elements/icon/props.rs @@ -1,7 +1,7 @@ -use super::PartialProps; use crate::{ colors, context::EditState, + elements::PartialProps, render_util::{input_color_alpha, input_optional}, traits::RenderOptions, }; diff --git a/src/elements/icon_source.rs b/src/elements/icon/source.rs similarity index 100% rename from src/elements/icon_source.rs rename to src/elements/icon/source.rs diff --git a/src/action/icon.rs b/src/elements/list/action.rs similarity index 97% rename from src/action/icon.rs rename to src/elements/list/action.rs index c2d241e..3e7e534 100644 --- a/src/action/icon.rs +++ b/src/elements/list/action.rs @@ -1,6 +1,7 @@ +use super::ListIcon; use crate::{ context::EditState, - elements::{Element, ElementType, ListIcon}, + elements::{Element, ElementType}, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/src/elements/list_icon.rs b/src/elements/list/icon.rs similarity index 96% rename from src/elements/list_icon.rs rename to src/elements/list/icon.rs index 4c9a3a8..fd186e5 100644 --- a/src/elements/list_icon.rs +++ b/src/elements/list/icon.rs @@ -1,6 +1,6 @@ -use super::{Common, Element, ElementType, Icon, IconElement, RenderState}; use crate::{ context::{Context, EditState}, + elements::{Common, Element, ElementType, Icon, IconElement, RenderState}, render_util::Rect, traits::{RenderDebug, RenderOptions}, trigger::ProgressTrigger, diff --git a/src/elements/layout.rs b/src/elements/list/layout.rs similarity index 100% rename from src/elements/layout.rs rename to src/elements/list/layout.rs diff --git a/src/elements/list.rs b/src/elements/list/mod.rs similarity index 98% rename from src/elements/list.rs rename to src/elements/list/mod.rs index 9d21229..072194e 100644 --- a/src/elements/list.rs +++ b/src/elements/list/mod.rs @@ -1,6 +1,11 @@ -use super::{Direction, Layout, ListIcon, RenderState}; +mod action; +mod icon; +mod layout; + +pub use self::{action::*, icon::*, layout::*}; + +use super::{Direction, RenderState}; use crate::{ - action::IconAction, bounds::Bounds, colors, component_wise::ComponentWise, diff --git a/src/elements/list_action.rs b/src/elements/list_action.rs deleted file mode 100644 index 6808b11..0000000 --- a/src/elements/list_action.rs +++ /dev/null @@ -1,55 +0,0 @@ -use super::ListIcon; - -#[derive(Debug, Clone)] -#[must_use] -pub enum ListAction { - None, - Up(usize), - Down(usize), - Delete(usize), - Paste(usize, ListIcon), -} - -impl ListAction { - pub const fn new() -> Self { - Self::None - } - - pub fn perform(self, children: &mut Vec) -> bool { - match self { - Self::None => false, - Self::Up(index) => { - if index == 0 { - let first = children.remove(0); - children.push(first); - } else { - children.swap(index, index - 1); - } - true - } - Self::Down(index) => { - if index == children.len() - 1 { - let last = children.pop().expect("action down with empty vec"); - children.insert(0, last); - } else { - children.swap(index, index + 1); - }; - true - } - Self::Delete(index) => { - children.remove(index); - true - } - Self::Paste(index, element) => { - children.insert(index, element); - true - } - } - } -} - -impl Default for ListAction { - fn default() -> Self { - Self::new() - } -} diff --git a/src/elements/mod.rs b/src/elements/mod.rs index f8ba66d..e7c56b6 100644 --- a/src/elements/mod.rs +++ b/src/elements/mod.rs @@ -1,34 +1,35 @@ -mod align; -mod align_horizontal; +pub mod align; +pub mod bar; +pub mod icon; +pub mod list; +pub mod text; + mod animation; -mod bar; -mod bar_props; mod common; mod direction; mod dnd; mod element; -mod element_type; mod group; -mod icon; -mod icon_element; -mod icon_props; -mod icon_source; -mod layout; -mod list; -mod list_icon; mod pack; -mod progress; mod props; mod render_state; mod screen_anchor; -mod text; -mod text_decoration; -mod text_props; mod unit; pub use self::{ - align::*, align_horizontal::*, animation::*, bar::*, bar_props::*, common::*, direction::*, - dnd::*, element::*, element_type::*, group::*, icon::*, icon_element::*, icon_props::*, - icon_source::*, layout::*, list::*, list_icon::*, pack::*, progress::*, props::*, - render_state::*, screen_anchor::*, text::*, text_decoration::*, text_props::*, unit::*, + animation::*, + bar::Bar, + common::*, + direction::*, + dnd::*, + element::*, + group::*, + icon::{Icon, IconElement}, + list::IconList, + pack::*, + props::*, + render_state::*, + screen_anchor::*, + text::Text, + unit::*, }; diff --git a/src/elements/pack.rs b/src/elements/pack/mod.rs similarity index 100% rename from src/elements/pack.rs rename to src/elements/pack/mod.rs diff --git a/src/elements/text_decoration.rs b/src/elements/text/decoration.rs similarity index 100% rename from src/elements/text_decoration.rs rename to src/elements/text/decoration.rs diff --git a/src/elements/text.rs b/src/elements/text/mod.rs similarity index 98% rename from src/elements/text.rs rename to src/elements/text/mod.rs index 6a50853..3fab488 100644 --- a/src/elements/text.rs +++ b/src/elements/text/mod.rs @@ -1,4 +1,9 @@ -use super::{AlignHorizontal, Props, RenderState, TextProps}; +mod decoration; +mod props; + +pub use self::{decoration::*, props::*}; + +use super::{align::AlignHorizontal, Props, RenderState}; use crate::{ bounds::Bounds, component_wise::ComponentWise, diff --git a/src/elements/text_props.rs b/src/elements/text/props.rs similarity index 97% rename from src/elements/text_props.rs rename to src/elements/text/props.rs index 8e4c9e8..d1b4420 100644 --- a/src/elements/text_props.rs +++ b/src/elements/text/props.rs @@ -1,7 +1,8 @@ -use super::{PartialProps, TextDecoration}; +use super::TextDecoration; use crate::{ colors, context::EditState, + elements::PartialProps, render_util::{input_color_alpha, input_optional, input_percent}, traits::RenderOptions, }; diff --git a/src/settings/icon.rs b/src/settings/icon.rs index 2cc3184..b4e1421 100644 --- a/src/settings/icon.rs +++ b/src/settings/icon.rs @@ -1,6 +1,6 @@ use crate::{ colors::{self, with_alpha}, - elements::TextDecoration, + elements::text::TextDecoration, }; use serde::{Deserialize, Serialize}; diff --git a/src/texture_manager.rs b/src/texture_manager.rs index 4bb4bc1..d42cfdb 100644 --- a/src/texture_manager.rs +++ b/src/texture_manager.rs @@ -1,7 +1,7 @@ use crate::{ addon::Addon, assets::{MONSTER_ICON, TEMP_ICON}, - elements::IconSource, + elements::icon::IconSource, }; use nexus::{ imgui::TextureId,