aboutsummaryrefslogtreecommitdiff
path: root/symbol.cpp
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-26 22:33:42 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-26 22:33:42 +0200
commite1b36719796209bfe47320c493b708d27dab3f25 (patch)
treef4eacb22a521126c4faa6e6d5940e4aa94591e14 /symbol.cpp
parentde0acfd2b1e83c58659f9293e1b23f196a14ef9e (diff)
downloadsymedit-e1b36719796209bfe47320c493b708d27dab3f25.tar.gz
symedit-e1b36719796209bfe47320c493b708d27dab3f25.zip
Implemented raise and lower.
Diffstat (limited to 'symbol.cpp')
-rw-r--r--symbol.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/symbol.cpp b/symbol.cpp
index ea24933..32dd7d0 100644
--- a/symbol.cpp
+++ b/symbol.cpp
@@ -291,3 +291,29 @@ void SymEditSymbol::RotateSymbol(int dir)
rotate(item.Value, dir);
}
}
+
+//! Raise or lower item.
+/*!
+ \param dir Positive value raises, negative lowers.
+ \return True for success.
+*/
+bool SymEditSymbol::RaiseItem(int dir)
+{
+ if ( !Items.empty() )
+ {
+ size_t index = static_cast<size_t>(ActiveIndex);
+ if ( dir > 0 && index < Items.size() - 1 ) // raise
+ {
+ std::swap(Items[index], Items[index + 1]);
+ ++ActiveIndex;
+ return true;
+ }
+ if ( dir < 0 && index > 0 ) // lower
+ {
+ std::swap(Items[index - 1], Items[index]);
+ --ActiveIndex;
+ return true;
+ }
+ }
+ return false;
+}