diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-11-24 17:01:04 -0200 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-11-24 17:01:04 -0200 |
commit | 22f71caae9771b8279dcfdbd3842b45c4520b782 (patch) | |
tree | 51925aae4d9c1bad0cd60899e9139bdf089df0c0 /Project/Workspace.cpp | |
parent | 8e79aff80e56adbdcfd6a9be5a873c6bb4b1020a (diff) | |
download | PSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.tar.gz PSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.tar.xz PSP.git-22f71caae9771b8279dcfdbd3842b45c4520b782.zip |
Text under implementation [2]
Diffstat (limited to 'Project/Workspace.cpp')
-rw-r--r-- | Project/Workspace.cpp | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 029737c..1a91bb0 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -101,7 +101,7 @@ void Workspace::OnPaint(wxPaintEvent& event) // Texts for(auto it = m_textList.begin(); it != m_textList.end(); ++it) { Text* text = *it; - text->Draw(m_camera->GetTranslation(), m_camera->GetScale(), dc); + text->Draw(m_camera->GetTranslation(), m_camera->GetScale()); } // Selection rectangle @@ -156,8 +156,7 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) bool foundElement = false; if(m_mode == MODE_INSERT_TEXT) { m_mode = MODE_EDIT; - } - else if(m_mode == MODE_INSERT || m_mode == MODE_DRAG_INSERT) { + } else if(m_mode == MODE_INSERT || m_mode == MODE_DRAG_INSERT) { // Get the last element inserted on the list. Element* newElement = *(m_elementList.end() - 1); for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { @@ -224,6 +223,21 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) element->SetOnline(element->IsOnline() ? false : true); } } + + // Text element + for(auto it = m_textList.begin(); it != m_textList.end(); it++) { + Text* text = *it; + + text->StartMove(m_camera->ScreenToWorld(event.GetPosition())); + + if(text->Contains(m_camera->ScreenToWorld(event.GetPosition()))) { + if(!foundElement) { + text->SetSelected(); + m_mode = MODE_MOVE_ELEMENT; + foundElement = true; + } + } + } } if(!foundElement) { @@ -391,6 +405,23 @@ void Workspace::OnLeftClickUp(wxMouseEvent& event) } } } + + // Text element + for(auto it = m_textList.begin(); it != m_textList.end(); it++) { + Text* text = *it; + if(m_mode == MODE_SELECTION_RECT) { + if(text->Intersects(m_selectionRect)) { + text->SetSelected(); + } else { + text->SetSelected(false); + } + } else if(!event.ControlDown()) { + if(!text->Contains(m_camera->ScreenToWorld(event.GetPosition()))) { + text->SetSelected(false); + } + } + } + if(findNewParent) { std::rotate(itnp, itnp + 1, m_elementList.end()); updateVoltages = true; @@ -499,6 +530,14 @@ void Workspace::OnMouseMotion(wxMouseEvent& event) redraw = true; } } + // Text element motion + for(auto it = m_textList.begin(); it != m_textList.end(); it++) { + Text* text = *it; + if(text->IsSelected()) { + text->Move(m_camera->ScreenToWorld(event.GetPosition())); + redraw = true; + } + } } break; case MODE_SELECTION_RECT: { @@ -574,6 +613,11 @@ void Workspace::OnKeyDown(wxKeyEvent& event) m_mode = MODE_EDIT; Redraw(); } + else if(m_mode == MODE_INSERT_TEXT) { + m_textList.pop_back(); + m_mode = MODE_EDIT; + Redraw(); + } } break; case WXK_DELETE: // Delete selected elements { @@ -828,6 +872,15 @@ void Workspace::RotateSelectedElements(bool clockwise) element->StartMove(m_camera->GetMousePosition()); } } + + //Rotate text element + for(auto it = m_textList.begin(); it != m_textList.end(); it++) { + Text* text = *it; + if(text->IsSelected()) { + text->Rotate(clockwise); + text->StartMove(m_camera->GetMousePosition()); + } + } Redraw(); } |