From 1fcca9b3a9570803ff0b5f19dcfe527e02009505 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 18 May 2015 11:51:30 -0700 Subject: [PATCH] Rename module vec2 -> vec Margins may be moved to vec::Vec4 some day --- src/lib.rs | 4 ++-- src/margins.rs | 14 ++++++++++++++ src/printer.rs | 2 +- src/{vec2.rs => vec.rs} | 0 src/view/box_view.rs | 2 +- src/view/dialog.rs | 2 +- src/view/key_event_view.rs | 2 +- src/view/mod.rs | 2 +- src/view/stack_view.rs | 2 +- src/view/text_view.rs | 2 +- 10 files changed, 23 insertions(+), 9 deletions(-) rename src/{vec2.rs => vec.rs} (100%) diff --git a/src/lib.rs b/src/lib.rs index 8c11e5e..fdab802 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ extern crate ncurses; pub mod event; pub mod view; pub mod printer; -pub mod vec2; +pub mod vec; mod div; mod margins; @@ -36,7 +36,7 @@ use std::any::Any; use std::rc::Rc; use std::collections::HashMap; -use vec2::Vec2; +use vec::Vec2; use view::View; use printer::Printer; use view::{StackView,ViewPath}; diff --git a/src/margins.rs b/src/margins.rs index bd9cccc..4dd524e 100644 --- a/src/margins.rs +++ b/src/margins.rs @@ -1,3 +1,5 @@ +use vec::Vec2; + /// Fixed margins around a rectangular view. pub struct Margins { /// Left margin @@ -20,4 +22,16 @@ impl Margins { bottom: bottom, } } + + pub fn horizontal(&self) -> u32 { + self.left + self.right + } + + pub fn vertical(&self) -> u32 { + self.top + self.bottom + } + + pub fn combined(&self) -> Vec2 { + Vec2::new(self.horizontal(), self.vertical()) + } } diff --git a/src/printer.rs b/src/printer.rs index 1fb7257..259d87d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -1,7 +1,7 @@ //! Makes drawing on ncurses windows easier. use ncurses; -use vec2::{Vec2,ToVec2}; +use vec::{Vec2,ToVec2}; /// Wrapper around a subset of a ncurses window. pub struct Printer { diff --git a/src/vec2.rs b/src/vec.rs similarity index 100% rename from src/vec2.rs rename to src/vec.rs diff --git a/src/view/box_view.rs b/src/view/box_view.rs index a7e834d..d6ba4d4 100644 --- a/src/view/box_view.rs +++ b/src/view/box_view.rs @@ -1,5 +1,5 @@ use event::EventResult; -use vec2::{Vec2,ToVec2}; +use vec::{Vec2,ToVec2}; use super::{View,SizeRequest}; use printer::Printer; diff --git a/src/view/dialog.rs b/src/view/dialog.rs index ab96a17..81ea66b 100644 --- a/src/view/dialog.rs +++ b/src/view/dialog.rs @@ -1,6 +1,6 @@ use ::Cursive; use view::{View,ViewPath,SizeRequest,DimensionRequest}; -use vec2::{Vec2}; +use vec::{Vec2}; use printer::Printer; enum Focus { diff --git a/src/view/key_event_view.rs b/src/view/key_event_view.rs index e2b38d7..83600eb 100644 --- a/src/view/key_event_view.rs +++ b/src/view/key_event_view.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use ::Cursive; use event::{EventResult,Callback}; -use vec2::{Vec2}; +use vec::{Vec2}; use super::{View,SizeRequest,ViewPath}; use printer::Printer; diff --git a/src/view/mod.rs b/src/view/mod.rs index 4f7e0e9..80ddfee 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -17,7 +17,7 @@ pub use self::text_view::TextView; pub use self::dialog::Dialog; use event::EventResult; -use vec2::Vec2; +use vec::Vec2; use printer::Printer; /// Describe constraints on a view layout in one dimension. diff --git a/src/view/stack_view.rs b/src/view/stack_view.rs index 0d2d875..8db29da 100644 --- a/src/view/stack_view.rs +++ b/src/view/stack_view.rs @@ -1,6 +1,6 @@ use std::cmp::max; -use vec2::Vec2; +use vec::Vec2; use view::{View,SizeRequest,DimensionRequest}; use event::EventResult; use printer::Printer; diff --git a/src/view/text_view.rs b/src/view/text_view.rs index 7f98dae..45656aa 100644 --- a/src/view/text_view.rs +++ b/src/view/text_view.rs @@ -1,6 +1,6 @@ use std::cmp; -use vec2::Vec2; +use vec::Vec2; use view::{View,DimensionRequest,SizeRequest}; use div::*; use printer::Printer;