refactoring: application mode code split

This commit is contained in:
tmj-fstate
2018-08-02 20:39:19 +02:00
parent 460bf6d382
commit ff6bed67a9
74 changed files with 5375 additions and 2921 deletions

View File

@@ -13,44 +13,29 @@ http://mozilla.org/MPL/2.0/.
namespace scene {
// TODO: move the snapshot to history stack
struct node_snapshot {
scene::basic_node *node;
std::string data;
node_snapshot( scene::basic_node *Node ) :
node( Node ) {
if( Node != nullptr ) {
Node->export_as_text( data ); } };
};
inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); }
inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return ( !( Left == Right ) ); }
class basic_editor {
public:
// methods
bool
on_key( int const Key, int const Action );
bool
on_mouse_button( int const Button, int const Action );
bool
on_mouse_move( double const Mousex, double const Mousey );
scene::basic_node const *
node() const {
return m_node; }
private:
// types
struct node_snapshot {
scene::basic_node *node;
std::string data;
node_snapshot( scene::basic_node *Node ) :
node( Node ) {
if( Node != nullptr ) {
Node->export_as_text( data ); } };
};
friend bool operator==( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right );
friend bool operator!=( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right );
// methods
bool
mode_translation() const;
bool
mode_translation_vertical() const;
bool
mode_snap() const;
void
translate( glm::dvec3 const &Location );
translate( scene::basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground );
void
translate( float const Offset );
translate( scene::basic_node *Node, float const Offset );
void
translate_instance( TAnimModel *Instance, glm::dvec3 const &Location );
void
@@ -60,22 +45,11 @@ private:
void
translate_memorycell( TMemCell *Memorycell, float const Offset );
void
rotate( glm::vec3 const &Angle );
rotate( scene::basic_node *Node, glm::vec3 const &Angle, float const Quantization );
void
rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle );
// members
scene::basic_node *m_node; // temporary helper, currently selected scene node
node_snapshot m_nodesnapshot { nullptr }; // currently selected scene node in its pre-modified state
glm::dvec2 m_mouseposition { 0.0 };
bool m_mouseleftbuttondown { false };
rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle, float const Quantization );
};
inline bool operator==( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); }
inline bool operator!=( basic_editor::node_snapshot const &Left, basic_editor::node_snapshot const &Right ) { return ( !( Left == Right ) ); }
extern basic_editor Editor;
} // scene
//---------------------------------------------------------------------------