Changeset 09539802dc311c3fc03d551f14627a25f8066359
- Timestamp:
- 28/01/07 21:37:21 (2 years ago)
- git-parent:
- Files:
-
- doc/skins/skins2-howto.xml (modified) (2 diffs)
- modules/gui/skins2/commands/cmd_minimize.cpp (modified) (3 diffs)
- modules/gui/skins2/commands/cmd_minimize.hpp (modified) (1 diff)
- modules/gui/skins2/parser/interpreter.cpp (modified) (3 diffs)
- modules/gui/skins2/src/generic_window.cpp (modified) (1 diff)
- modules/gui/skins2/src/top_window.cpp (modified) (1 diff)
- modules/gui/skins2/src/top_window.hpp (modified) (3 diffs)
- modules/gui/skins2/src/window_manager.cpp (modified) (2 diffs)
- modules/gui/skins2/src/window_manager.hpp (modified) (4 diffs)
- modules/gui/skins2/utils/position.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/skins/skins2-howto.xml
r8086b07 r0953980 997 997 </para></listitem> 998 998 <listitem><para> 999 <emphasis>WindowID.maximize()</emphasis>: Maximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0. 1000 </para></listitem> 1001 <listitem><para> 1002 <emphasis>WindowID.unmaximize()</emphasis>: Unmaximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0. 1003 </para></listitem> 1004 <listitem><para> 999 1005 <emphasis>WindowID.setLayout(LayoutID)</emphasis>: Change the layout of the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID', using the <link linkend="Layout">Layout</link> whose <link linkend="layoutid">id</link> attribute is 'LayoutID'. 1000 1006 </para></listitem> … … 1097 1103 <listitem><para> 1098 1104 <emphasis>dvd.isActive</emphasis>: True when a DVD is currently playing. This variable can be used to display buttons associated to the <link linkend="dvdactions">dvd.* actions</link> only when needed (since VLC 0.8.5). 1105 </para></listitem> 1106 <listitem><para> 1107 <emphasis>WindowID.isMaximized</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is maximized, false otherwise. 1099 1108 </para></listitem> 1100 1109 <listitem><para> modules/gui/skins2/commands/cmd_minimize.cpp
r1cf7350 r0953980 6 6 * 7 7 * Authors: Mohammed Adnène Trojette <adn@via.ecp.fr> 8 * Olivier Teulière <ipkiss@via.ecp.fr> 8 9 * 9 10 * This program is free software; you can redistribute it and/or modify … … 23 24 24 25 #include "cmd_minimize.hpp" 26 #include "../src/window_manager.hpp" 25 27 #include "../src/os_factory.hpp" 26 28 … … 39 41 OSFactory *pOsFactory = OSFactory::instance( getIntf() ); 40 42 pOsFactory->restore(); 43 } 44 45 46 CmdMaximize::CmdMaximize( intf_thread_t *pIntf, 47 WindowManager &rWindowManager, 48 TopWindow &rWindow ): 49 CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ), 50 m_rWindow( rWindow ) 51 { 52 } 53 54 55 void CmdMaximize::execute() 56 { 57 // Simply delegate the job to the WindowManager 58 m_rWindowManager.maximize( m_rWindow ); 59 } 60 61 62 CmdUnmaximize::CmdUnmaximize( intf_thread_t *pIntf, 63 WindowManager &rWindowManager, 64 TopWindow &rWindow ): 65 CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ), 66 m_rWindow( rWindow ) 67 { 68 } 69 70 71 void CmdUnmaximize::execute() 72 { 73 // Simply delegate the job to the WindowManager 74 m_rWindowManager.unmaximize( m_rWindow ); 41 75 } 42 76 modules/gui/skins2/commands/cmd_minimize.hpp
r1cf7350 r0953980 27 27 #include "cmd_generic.hpp" 28 28 29 class WindowManager; 30 class TopWindow; 31 29 32 30 33 DEFINE_COMMAND(Minimize, "minimize" ) 31 34 DEFINE_COMMAND(Restore, "restore" ) 35 36 /// Command to maximize a window 37 class CmdMaximize: public CmdGeneric 38 { 39 public: 40 /// Maximize the given layout 41 CmdMaximize( intf_thread_t *pIntf, WindowManager &rWindowManager, 42 TopWindow &rWindow ); 43 virtual ~CmdMaximize() {} 44 45 /// This method does the real job of the command 46 virtual void execute(); 47 48 /// Return the type of the command 49 virtual string getType() const { return "maximize"; } 50 51 private: 52 WindowManager &m_rWindowManager; 53 TopWindow &m_rWindow; 54 }; 55 56 57 /// Command to unmaximize a window 58 class CmdUnmaximize: public CmdGeneric 59 { 60 public: 61 /// Unmaximize the given layout 62 CmdUnmaximize( intf_thread_t *pIntf, WindowManager &rWindowManager, 63 TopWindow &rWindow ); 64 virtual ~CmdUnmaximize() {} 65 66 /// This method does the real job of the command 67 virtual void execute(); 68 69 /// Return the type of the command 70 virtual string getType() const { return "unmaximize"; } 71 72 private: 73 WindowManager &m_rWindowManager; 74 TopWindow &m_rWindow; 75 }; 76 77 32 78 DEFINE_COMMAND(AddInTray, "add in tray" ) 33 79 DEFINE_COMMAND(RemoveFromTray, "remove from tray" ) modules/gui/skins2/parser/interpreter.cpp
r95ff93b r0953980 226 226 } 227 227 } 228 else if( rAction.find( ".maximize()" ) != string::npos ) 229 { 230 int leftPos = rAction.find( ".maximize()" ); 231 string windowId = rAction.substr( 0, leftPos ); 232 233 TopWindow *pWin = pTheme->getWindowById( windowId ); 234 if( !pWin ) 235 { 236 msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 237 } 238 else 239 { 240 pCommand = new CmdMaximize( getIntf(), 241 pTheme->getWindowManager(), 242 *pWin ); 243 } 244 } 245 else if( rAction.find( ".unmaximize()" ) != string::npos ) 246 { 247 int leftPos = rAction.find( ".unmaximize()" ); 248 string windowId = rAction.substr( 0, leftPos ); 249 250 TopWindow *pWin = pTheme->getWindowById( windowId ); 251 if( !pWin ) 252 { 253 msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 254 } 255 else 256 { 257 pCommand = new CmdUnmaximize( getIntf(), 258 pTheme->getWindowManager(), 259 *pWin ); 260 } 261 } 228 262 else if( rAction.find( ".show()" ) != string::npos ) 229 263 { … … 421 455 else 422 456 { 423 msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() ); 457 msg_Err( getIntf(), "unknown window (%s)", 458 windowId.c_str() ); 459 return NULL; 460 } 461 } 462 else if( token.find( ".isMaximized" ) != string::npos ) 463 { 464 int leftPos = token.find( ".isMaximized" ); 465 string windowId = token.substr( 0, leftPos ); 466 TopWindow *pWin = pTheme->getWindowById( windowId ); 467 if( pWin ) 468 { 469 // Push the "maximized" variable onto the stack 470 varStack.push_back( &pWin->getMaximizedVar() ); 471 } 472 else 473 { 474 msg_Err( getIntf(), "unknown window (%s)", 475 windowId.c_str() ); 424 476 return NULL; 425 477 } … … 437 489 else 438 490 { 439 msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() ); 491 msg_Err( getIntf(), "unknown layout (%s)", 492 layoutId.c_str() ); 440 493 return NULL; 441 494 } modules/gui/skins2/src/generic_window.cpp
re1670ac r0953980 130 130 void GenericWindow::onUpdate( Subject<VarBool> &rVariable, void*arg ) 131 131 { 132 if ( m_pVarVisible->get())132 if (&rVariable == m_pVarVisible ) 133 133 { 134 innerShow(); 135 } 136 else 137 { 138 innerHide(); 134 if( m_pVarVisible->get() ) 135 { 136 innerShow(); 137 } 138 else 139 { 140 innerHide(); 141 } 139 142 } 140 143 } modules/gui/skins2/src/top_window.cpp
rf485214 r0953980 59 59 // Register as a moving window 60 60 m_rWindowManager.registerWindow( *this ); 61 62 // Create the "maximized" variable and register it in the manager 63 m_pVarMaximized = new VarBoolImpl( pIntf ); 64 VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarMaximized ) ); 61 65 } 62 66 modules/gui/skins2/src/top_window.hpp
r91e5a90 r0953980 79 79 virtual void onTooltipChange( const CtrlGeneric &rCtrl ); 80 80 81 /// Get the "maximized" variable 82 VarBool &getMaximizedVar() { return *m_pVarMaximized; } 83 81 84 /// Get the initial visibility status 82 85 bool isVisible() const { return m_visible; } … … 90 93 91 94 private: 95 /** 96 * These methods are only used by the window manager 97 */ 98 //@{ 92 99 /// Change the active layout 93 100 virtual void setActiveLayout( GenericLayout *pLayout ); 101 //@} 94 102 95 103 /// Initial visibility status … … 108 116 int m_currModifier; 109 117 110 /// Find the uppest control in the layout hit by the mouse, and send 111 /// it an enter event if needed 118 /// Variable for the visibility of the window 119 VarBoolImpl *m_pVarMaximized; 120 121 /** 122 * Find the uppest control in the layout hit by the mouse, and send 123 * it an enter event if needed 124 */ 112 125 CtrlGeneric *findHitControl( int xPos, int yPos ); 113 126 114 /// Update the lastHitControl pointer and send a leave event to the 115 /// right control 127 /** 128 * Update the lastHitControl pointer and send a leave event to the 129 * right control 130 */ 116 131 void setLastHit( CtrlGeneric *pNewHitControl ); 117 132 }; modules/gui/skins2/src/window_manager.cpp
r8086b07 r0953980 30 30 #include "tooltip.hpp" 31 31 #include "var_manager.hpp" 32 #include "../utils/position.hpp"33 32 34 33 35 34 WindowManager::WindowManager( intf_thread_t *pIntf ): 36 35 SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ), 36 m_maximizeRect(0, 0, 50, 50), 37 37 m_pTooltip( NULL ), m_pPopup( NULL ) 38 38 { … … 318 318 319 319 320 void WindowManager::maximize( TopWindow &rWindow ) 321 { 322 // Save the current position/size of the window, to be able to restore it 323 m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(), 324 rWindow.getLeft() + rWindow.getWidth(), 325 rWindow.getTop() + rWindow.getHeight() ); 326 327 Rect workArea = OSFactory::instance( getIntf() )->getWorkArea(); 328 // Move the window 329 startMove( rWindow ); 330 move( rWindow, workArea.getLeft(), workArea.getTop() ); 331 stopMove(); 332 // Now resize it 333 // FIXME: Ugly const_cast 334 GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); 335 startResize( rLayout, kResizeSE ); 336 resize( rLayout, workArea.getWidth(), workArea.getHeight() ); 337 stopResize(); 338 rWindow.m_pVarMaximized->set( true ); 339 340 // Make the window unmovable by unregistering it 341 // unregisterWindow( rWindow ); 342 } 343 344 345 void WindowManager::unmaximize( TopWindow &rWindow ) 346 { 347 // Register the window to allow moving it 348 // registerWindow( rWindow ); 349 350 // Resize the window 351 // FIXME: Ugly const_cast 352 GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); 353 startResize( rLayout, kResizeSE ); 354 resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() ); 355 stopResize(); 356 // Now move it 357 startMove( rWindow ); 358 move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() ); 359 stopMove(); 360 rWindow.m_pVarMaximized->set( false ); 361 } 362 363 320 364 void WindowManager::synchVisibility() const 321 365 { modules/gui/skins2/src/window_manager.hpp
r8086b07 r0953980 28 28 #include "skin_common.hpp" 29 29 #include "top_window.hpp" 30 #include "../utils/position.hpp" 30 31 #include <list> 31 32 #include <map> … … 89 90 90 91 /** 91 * Resize the r Window windowto (width, height), and move all its92 * Resize the rLayout layout to (width, height), and move all its 92 93 * anchored windows, if some anchors are moved during the resizing. 93 94 * If a new anchoring is detected, the windows will move (or resize) … … 95 96 */ 96 97 void resize( GenericLayout &rLayout, int width, int height ) const; 98 99 /// Maximize the given window 100 void maximize( TopWindow &rWindow ); 101 102 /// Unmaximize the given window 103 void unmaximize( TopWindow &rWindow ); 97 104 98 105 /// Raise all the registered windows … … 202 209 /// Direction of the current resizing 203 210 Direction_t m_direction; 211 /// Rect of the last maximized window 212 Rect m_maximizeRect; 204 213 /// Tooltip 205 214 Tooltip *m_pTooltip; modules/gui/skins2/utils/position.hpp
r8086b07 r0953980 60 60 virtual int getLeft() const { return m_left; } 61 61 virtual int getTop() const { return m_top; } 62 virtual int getRight() const { return m_right; } 63 virtual int getBottom() const { return m_bottom; } 62 64 virtual int getWidth() const { return m_right - m_left; } 63 65 virtual int getHeight() const { return m_bottom - m_top; }
