Skip to content

Commit

Permalink
Restructure element modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed Aug 7, 2024
1 parent 0ebfb4f commit d2b4a36
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 93 deletions.
3 changes: 1 addition & 2 deletions src/action/mod.rs
Original file line number Diff line number Diff line change
@@ -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?

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/elements/align.rs → src/elements/align/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mod horizontal;

pub use self::horizontal::*;

use serde::{Deserialize, Serialize};
use strum::{AsRefStr, EnumIter, VariantArray};

Expand Down
7 changes: 6 additions & 1 deletion src/elements/bar.rs → src/elements/bar/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/elements/bar_props.rs → src/elements/bar/props.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/elements/direction.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions src/elements/element.rs → src/elements/element/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)]
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 7 additions & 1 deletion src/elements/icon.rs → src/elements/icon/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/elements/icon_props.rs → src/elements/icon/props.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::PartialProps;
use crate::{
colors,
context::EditState,
elements::PartialProps,
render_util::{input_color_alpha, input_optional},
traits::RenderOptions,
};
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/action/icon.rs → src/elements/list/action.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/elements/list_icon.rs → src/elements/list/icon.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
File renamed without changes.
9 changes: 7 additions & 2 deletions src/elements/list.rs → src/elements/list/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
55 changes: 0 additions & 55 deletions src/elements/list_action.rs

This file was deleted.

41 changes: 21 additions & 20 deletions src/elements/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*,
};
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion src/elements/text.rs → src/elements/text/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/elements/text_props.rs → src/elements/text/props.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion src/settings/icon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
colors::{self, with_alpha},
elements::TextDecoration,
elements::text::TextDecoration,
};
use serde::{Deserialize, Serialize};

Expand Down
2 changes: 1 addition & 1 deletion src/texture_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
addon::Addon,
assets::{MONSTER_ICON, TEMP_ICON},
elements::IconSource,
elements::icon::IconSource,
};
use nexus::{
imgui::TextureId,
Expand Down

0 comments on commit d2b4a36

Please sign in to comment.