📄 window_manager.cpp
字号:
// Save the current position/size of the window, to be able to restore it m_maximizeRect = SkinsRect( rWindow.getLeft(), rWindow.getTop(), rWindow.getLeft() + rWindow.getWidth(), rWindow.getTop() + rWindow.getHeight() ); SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea(); // Move the window startMove( rWindow ); move( rWindow, workArea.getLeft(), workArea.getTop() ); stopMove(); // Now resize it // FIXME: Ugly const_cast GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); startResize( rLayout, kResizeSE ); resize( rLayout, workArea.getWidth(), workArea.getHeight() ); stopResize(); rWindow.m_pVarMaximized->set( true ); // Make the window unmovable by unregistering it// unregisterWindow( rWindow );}void WindowManager::unmaximize( TopWindow &rWindow ){ // Register the window to allow moving it// registerWindow( rWindow ); // Resize the window // FIXME: Ugly const_cast GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); startResize( rLayout, kResizeSE ); resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() ); stopResize(); // Now move it startMove( rWindow ); move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() ); stopMove(); rWindow.m_pVarMaximized->set( false );}void WindowManager::synchVisibility() const{ WinSet_t::const_iterator it; for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { // Show the window if it has to be visible if( (*it)->getVisibleVar().get() ) { (*it)->innerShow(); } }}void WindowManager::saveVisibility(){ WinSet_t::const_iterator it; m_savedWindows.clear(); for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { // Remember the window if it is visible if( (*it)->getVisibleVar().get() ) { m_savedWindows.insert( *it ); } }}void WindowManager::restoreVisibility() const{ // Warning in case we never called saveVisibility() if( m_savedWindows.size() == 0 ) { msg_Warn( getIntf(), "restoring visibility for no window" ); } WinSet_t::const_iterator it; for( it = m_savedWindows.begin(); it != m_savedWindows.end(); it++) { (*it)->show(); }}void WindowManager::raiseAll() const{ // Raise all the windows WinSet_t::const_iterator it; for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { (*it)->raise(); }}void WindowManager::showAll( bool firstTime ) const{ // Show all the windows WinSet_t::const_iterator it; for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { // When the theme is opened for the first time, // only show the window if set as visible in the XML if( (*it)->isVisible() || !firstTime ) { (*it)->show(); } (*it)->setOpacity( m_alpha ); }}void WindowManager::hideAll() const{ WinSet_t::const_iterator it; for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { (*it)->hide(); }}void WindowManager::toggleOnTop(){ // Update the boolean variable VarBoolImpl *pVarOnTop = (VarBoolImpl*)m_cVarOnTop.get(); pVarOnTop->set( !pVarOnTop->get() ); // Toggle the "on top" status WinSet_t::const_iterator it; for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ ) { (*it)->toggleOnTop( pVarOnTop->get() ); }}void WindowManager::buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow ){ // pWindow is in the set rWinSet.insert( pWindow ); // Iterate through the anchored windows const WinSet_t &anchored = m_dependencies[pWindow]; WinSet_t::const_iterator iter; for( iter = anchored.begin(); iter != anchored.end(); iter++ ) { // Check that the window isn't already in the set before adding it if( rWinSet.find( *iter ) == rWinSet.end() ) { buildDependSet( rWinSet, *iter ); } }}void WindowManager::checkAnchors( TopWindow *pWindow, int &xOffset, int &yOffset ) const{ WinSet_t::const_iterator itMov, itSta; AncList_t::const_iterator itAncMov, itAncSta; // Check magnetism with screen edges first (actually it is the work area) SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea(); // Iterate through the moving windows for( itMov = m_movingWindows.begin(); itMov != m_movingWindows.end(); itMov++ ) { // Skip the invisible windows if( ! (*itMov)->getVisibleVar().get() ) { continue; } int newLeft = (*itMov)->getLeft() + xOffset; int newTop = (*itMov)->getTop() + yOffset; if( newLeft > workArea.getLeft() - m_magnet && newLeft < workArea.getLeft() + m_magnet ) { xOffset = workArea.getLeft() - (*itMov)->getLeft(); } if( newTop > workArea.getTop() - m_magnet && newTop < workArea.getTop() + m_magnet ) { yOffset = workArea.getTop() - (*itMov)->getTop(); } int right = workArea.getLeft() + workArea.getWidth(); if( newLeft + (*itMov)->getWidth() > right - m_magnet && newLeft + (*itMov)->getWidth() < right + m_magnet ) { xOffset = right - (*itMov)->getLeft() - (*itMov)->getWidth(); } int bottom = workArea.getTop() + workArea.getHeight(); if( newTop + (*itMov)->getHeight() > bottom - m_magnet && newTop + (*itMov)->getHeight() < bottom + m_magnet ) { yOffset = bottom - (*itMov)->getTop() - (*itMov)->getHeight(); } } // Iterate through the moving windows for( itMov = m_movingWindows.begin(); itMov != m_movingWindows.end(); itMov++ ) { // Skip the invisible windows if( ! (*itMov)->getVisibleVar().get() ) { continue; } // Get the anchors in the main layout of this moving window const AncList_t &movAnchors = (*itMov)->getActiveLayout().getAnchorList(); // Iterate through the static windows for( itSta = m_allWindows.begin(); itSta != m_allWindows.end(); itSta++ ) { // Skip the moving windows and the invisible ones if( m_movingWindows.find( (*itSta) ) != m_movingWindows.end() || ! (*itSta)->getVisibleVar().get() ) { continue; } // Get the anchors in the main layout of this static window const AncList_t &staAnchors = (*itSta)->getActiveLayout().getAnchorList(); // Check if there is an anchoring between one of the movAnchors // and one of the staAnchors for( itAncMov = movAnchors.begin(); itAncMov != movAnchors.end(); itAncMov++ ) { for( itAncSta = staAnchors.begin(); itAncSta != staAnchors.end(); itAncSta++ ) { if( (*itAncSta)->canHang( **itAncMov, xOffset, yOffset ) ) { // We have found an anchoring! // There is nothing to do here, since xOffset and // yOffset are automatically modified by canHang() // Don't check the other anchors, one is enough... return; } else { // Temporary variables int xOffsetTemp = -xOffset; int yOffsetTemp = -yOffset; if( (*itAncMov)->canHang( **itAncSta, xOffsetTemp, yOffsetTemp ) ) { // We have found an anchoring! // xOffsetTemp and yOffsetTemp have been updated, // we just need to change xOffset and yOffset xOffset = -xOffsetTemp; yOffset = -yOffsetTemp; // Don't check the other anchors, one is enough... return; } } } } } }}void WindowManager::createTooltip( const GenericFont &rTipFont ){ // Create the tooltip window if( !m_pTooltip ) { m_pTooltip = new Tooltip( getIntf(), rTipFont, 500 ); } else { msg_Warn( getIntf(), "tooltip already created!" ); }}void WindowManager::showTooltip(){ if( m_pTooltip ) { m_pTooltip->show(); }}void WindowManager::hideTooltip(){ if( m_pTooltip ) { m_pTooltip->hide(); }}void WindowManager::addLayout( TopWindow &rWindow, GenericLayout &rLayout ){ rWindow.setActiveLayout( &rLayout );}void WindowManager::setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout ){ rWindow.setActiveLayout( &rLayout ); // Rebuild the dependencies stopMove();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -