<listitem><para>
<emphasis>WindowID.hide()</emphasis>: Hide the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'.
</para></listitem>
+ <listitem><para>
+ <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.
+ </para></listitem>
+ <listitem><para>
+ <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.
+ </para></listitem>
<listitem><para>
<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'.
</para></listitem>
<listitem><para>
<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).
</para></listitem>
+ <listitem><para>
+ <emphasis>WindowID.isMaximized</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is maximized, false otherwise.
+ </para></listitem>
<listitem><para>
<emphasis>WindowID.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is visible, false otherwise.
</para></listitem>
* $Id$
*
* Authors: Mohammed Adnène Trojette <adn@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*****************************************************************************/
#include "cmd_minimize.hpp"
+#include "../src/window_manager.hpp"
#include "../src/os_factory.hpp"
}
+CmdMaximize::CmdMaximize( intf_thread_t *pIntf,
+ WindowManager &rWindowManager,
+ TopWindow &rWindow ):
+ CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ),
+ m_rWindow( rWindow )
+{
+}
+
+
+void CmdMaximize::execute()
+{
+ // Simply delegate the job to the WindowManager
+ m_rWindowManager.maximize( m_rWindow );
+}
+
+
+CmdUnmaximize::CmdUnmaximize( intf_thread_t *pIntf,
+ WindowManager &rWindowManager,
+ TopWindow &rWindow ):
+ CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ),
+ m_rWindow( rWindow )
+{
+}
+
+
+void CmdUnmaximize::execute()
+{
+ // Simply delegate the job to the WindowManager
+ m_rWindowManager.unmaximize( m_rWindow );
+}
+
+
void CmdAddInTray::execute()
{
// Get the instance of OSFactory
#include "cmd_generic.hpp"
+class WindowManager;
+class TopWindow;
+
DEFINE_COMMAND(Minimize, "minimize" )
DEFINE_COMMAND(Restore, "restore" )
+
+/// Command to maximize a window
+class CmdMaximize: public CmdGeneric
+{
+ public:
+ /// Maximize the given layout
+ CmdMaximize( intf_thread_t *pIntf, WindowManager &rWindowManager,
+ TopWindow &rWindow );
+ virtual ~CmdMaximize() {}
+
+ /// This method does the real job of the command
+ virtual void execute();
+
+ /// Return the type of the command
+ virtual string getType() const { return "maximize"; }
+
+ private:
+ WindowManager &m_rWindowManager;
+ TopWindow &m_rWindow;
+};
+
+
+/// Command to unmaximize a window
+class CmdUnmaximize: public CmdGeneric
+{
+ public:
+ /// Unmaximize the given layout
+ CmdUnmaximize( intf_thread_t *pIntf, WindowManager &rWindowManager,
+ TopWindow &rWindow );
+ virtual ~CmdUnmaximize() {}
+
+ /// This method does the real job of the command
+ virtual void execute();
+
+ /// Return the type of the command
+ virtual string getType() const { return "unmaximize"; }
+
+ private:
+ WindowManager &m_rWindowManager;
+ TopWindow &m_rWindow;
+};
+
+
DEFINE_COMMAND(AddInTray, "add in tray" )
DEFINE_COMMAND(RemoveFromTray, "remove from tray" )
DEFINE_COMMAND(AddInTaskBar, "add in taskbar" )
pCommand = new CmdLayout( getIntf(), *pWin, *pLayout );
}
}
+ else if( rAction.find( ".maximize()" ) != string::npos )
+ {
+ int leftPos = rAction.find( ".maximize()" );
+ string windowId = rAction.substr( 0, leftPos );
+
+ TopWindow *pWin = pTheme->getWindowById( windowId );
+ if( !pWin )
+ {
+ msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+ }
+ else
+ {
+ pCommand = new CmdMaximize( getIntf(),
+ pTheme->getWindowManager(),
+ *pWin );
+ }
+ }
+ else if( rAction.find( ".unmaximize()" ) != string::npos )
+ {
+ int leftPos = rAction.find( ".unmaximize()" );
+ string windowId = rAction.substr( 0, leftPos );
+
+ TopWindow *pWin = pTheme->getWindowById( windowId );
+ if( !pWin )
+ {
+ msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+ }
+ else
+ {
+ pCommand = new CmdUnmaximize( getIntf(),
+ pTheme->getWindowManager(),
+ *pWin );
+ }
+ }
else if( rAction.find( ".show()" ) != string::npos )
{
int leftPos = rAction.find( ".show()" );
}
else
{
- msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+ msg_Err( getIntf(), "unknown window (%s)",
+ windowId.c_str() );
+ return NULL;
+ }
+ }
+ else if( token.find( ".isMaximized" ) != string::npos )
+ {
+ int leftPos = token.find( ".isMaximized" );
+ string windowId = token.substr( 0, leftPos );
+ TopWindow *pWin = pTheme->getWindowById( windowId );
+ if( pWin )
+ {
+ // Push the "maximized" variable onto the stack
+ varStack.push_back( &pWin->getMaximizedVar() );
+ }
+ else
+ {
+ msg_Err( getIntf(), "unknown window (%s)",
+ windowId.c_str() );
return NULL;
}
}
}
else
{
- msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() );
+ msg_Err( getIntf(), "unknown layout (%s)",
+ layoutId.c_str() );
return NULL;
}
}
void GenericWindow::onUpdate( Subject<VarBool> &rVariable, void*arg )
{
- if( m_pVarVisible->get() )
+ if (&rVariable == m_pVarVisible )
{
- innerShow();
- }
- else
- {
- innerHide();
+ if( m_pVarVisible->get() )
+ {
+ innerShow();
+ }
+ else
+ {
+ innerHide();
+ }
}
}
{
// Register as a moving window
m_rWindowManager.registerWindow( *this );
+
+ // Create the "maximized" variable and register it in the manager
+ m_pVarMaximized = new VarBoolImpl( pIntf );
+ VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarMaximized ) );
}
/// Called by a control when its tooltip changed
virtual void onTooltipChange( const CtrlGeneric &rCtrl );
+ /// Get the "maximized" variable
+ VarBool &getMaximizedVar() { return *m_pVarMaximized; }
+
/// Get the initial visibility status
bool isVisible() const { return m_visible; }
virtual void innerHide();
private:
+ /**
+ * These methods are only used by the window manager
+ */
+ //@{
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
+ //@}
/// Initial visibility status
bool m_visible;
/// Current key modifier (also used for mouse)
int m_currModifier;
- /// Find the uppest control in the layout hit by the mouse, and send
- /// it an enter event if needed
+ /// Variable for the visibility of the window
+ VarBoolImpl *m_pVarMaximized;
+
+ /**
+ * Find the uppest control in the layout hit by the mouse, and send
+ * it an enter event if needed
+ */
CtrlGeneric *findHitControl( int xPos, int yPos );
- /// Update the lastHitControl pointer and send a leave event to the
- /// right control
+ /**
+ * Update the lastHitControl pointer and send a leave event to the
+ * right control
+ */
void setLastHit( CtrlGeneric *pNewHitControl );
};
#include "anchor.hpp"
#include "tooltip.hpp"
#include "var_manager.hpp"
-#include "../utils/position.hpp"
WindowManager::WindowManager( intf_thread_t *pIntf ):
SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ),
+ m_maximizeRect(0, 0, 50, 50),
m_pTooltip( NULL ), m_pPopup( NULL )
{
// Create and register a variable for the "on top" status
}
+void WindowManager::maximize( TopWindow &rWindow )
+{
+ // Save the current position/size of the window, to be able to restore it
+ m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(),
+ rWindow.getLeft() + rWindow.getWidth(),
+ rWindow.getTop() + rWindow.getHeight() );
+
+ Rect 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;
#include "skin_common.hpp"
#include "top_window.hpp"
+#include "../utils/position.hpp"
#include <list>
#include <map>
#include <set>
void stopResize();
/**
- * Resize the rWindow window to (width, height), and move all its
+ * Resize the rLayout layout to (width, height), and move all its
* anchored windows, if some anchors are moved during the resizing.
* If a new anchoring is detected, the windows will move (or resize)
* accordingly.
*/
void resize( GenericLayout &rLayout, int width, int height ) const;
+ /// Maximize the given window
+ void maximize( TopWindow &rWindow );
+
+ /// Unmaximize the given window
+ void unmaximize( TopWindow &rWindow );
+
/// Raise all the registered windows
void raiseAll() const;
int m_moveAlpha;
/// Direction of the current resizing
Direction_t m_direction;
+ /// Rect of the last maximized window
+ Rect m_maximizeRect;
/// Tooltip
Tooltip *m_pTooltip;
/// Active popup, if any
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
+ virtual int getRight() const { return m_right; }
+ virtual int getBottom() const { return m_bottom; }
virtual int getWidth() const { return m_right - m_left; }
virtual int getHeight() const { return m_bottom - m_top; }