void CMyPicture::OnMoveToBack() { //Se selecciona un elemento std::string name_window = CORE->GetGUIManager()->GetCurrentWindow(); CGUIWindow *window = CORE->GetGUIManager()->GetWindow(name_window); CGuiElement *element = NULL; //Mira sobre qué elemento está el mouse uint16 count = window->GetNumElements(); for( uint16 i = count; i > 0; --i) { element = window->GetElementById(i-1); Vect2i mousePosition; CORE->GetInputManager()->GetPosition(IDV_MOUSE, mousePosition); element->CalculatePosMouse(mousePosition); if( element->IsInside() ) { //Está adentro window->MoveElementToBack(element); break; } } }
void CMyPicture::OnLButtonUp(UINT nFlags, CPoint point) { if( m_bIsLMouseDown ) { //Se selecciona un elemento std::string name_window = CORE->GetGUIManager()->GetCurrentWindow(); CGUIWindow *window = CORE->GetGUIManager()->GetWindow(name_window); CGuiElement *element = NULL; //hace reset de todos los controles uint32 count = window->GetNumElements(); for( uint32 i = 0; i < count; ++i) { element = window->GetElementById(i); element->SetIsSelected(false); } bool isElementSelected = false; //Mira sobre qué elemento está el mouse for( uint32 i = count; i > 0; --i) { element = window->GetElementById(i-1); Vect2i mousePosition; CORE->GetInputManager()->GetPosition(IDV_MOUSE, mousePosition); element->CalculatePosMouse(mousePosition); if( element->IsInside() ) { element->SetIsSelected(true); CElementProperties::ElementProperties(element); isElementSelected = true; break; } } //No hay nada seleccionado y ponemos las propiedades de la window if( !isElementSelected ) { CElementProperties::WindowProperties(window); } } else { //Se hace Drag & drop CElementManager *l_pElementManager = CElementManager::GetInstance(); TElement element = l_pElementManager->GetElementToAdd(); std::string window = l_pElementManager->GetWindowToAdd(); if( element != NONE ) { l_pElementManager->SetElementToAdd(NONE); AddElementToActiveWindow(element); } else if( window != "" ) { std::string current_window = CORE->GetGUIManager()->GetCurrentWindow(); current_window = current_window; CGUIWindow *windowcurrent = CORE->GetGUIManager()->GetWindow( current_window ); windowcurrent->ClearSelectElements(); window = window; CORE->GetGUIManager()->ActiveWindows( window ); CORE->GetGUIManager()->GetWindow( window )->ClearSelectElements(); CElementProperties::WindowProperties( CORE->GetGUIManager()->GetWindow( window ) ); } } m_bIsLMouseDown = false; CStatic::OnLButtonUp(nFlags, point); }