Commit 09539802 authored by Olivier Teulière's avatar Olivier Teulière

* skins2:

    - new WindowID.maximize() and WindowID.unmaximize() actions
    - new WindowID.isMaximized boolean variable
    - doc updated
parent 618352d2
......@@ -995,6 +995,12 @@ difficulty to understand how VLC skins work.</para>
<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>
......@@ -1097,6 +1103,9 @@ difficulty to understand how VLC skins work.</para>
<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>
......
......@@ -5,6 +5,7 @@
* $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
......@@ -22,6 +23,7 @@
*****************************************************************************/
#include "cmd_minimize.hpp"
#include "../src/window_manager.hpp"
#include "../src/os_factory.hpp"
......@@ -41,6 +43,38 @@ void CmdRestore::execute()
}
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
......
......@@ -26,9 +26,55 @@
#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" )
......
......@@ -225,6 +225,40 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
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()" );
......@@ -420,7 +454,25 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
}
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;
}
}
......@@ -436,7 +488,8 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
}
else
{
msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() );
msg_Err( getIntf(), "unknown layout (%s)",
layoutId.c_str() );
return NULL;
}
}
......
......@@ -129,13 +129,16 @@ void GenericWindow::toggleOnTop( bool onTop ) const
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();
}
}
}
......
......@@ -58,6 +58,10 @@ TopWindow::TopWindow( intf_thread_t *pIntf, int left, int top,
{
// 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 ) );
}
......
......@@ -78,6 +78,9 @@ class TopWindow: public GenericWindow
/// 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; }
......@@ -89,8 +92,13 @@ class TopWindow: public GenericWindow
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;
......@@ -107,12 +115,19 @@ class TopWindow: public GenericWindow
/// 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 );
};
......
......@@ -29,11 +29,11 @@
#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
......@@ -317,6 +317,50 @@ void WindowManager::resize( GenericLayout &rLayout,
}
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;
......
......@@ -27,6 +27,7 @@
#include "skin_common.hpp"
#include "top_window.hpp"
#include "../utils/position.hpp"
#include <list>
#include <map>
#include <set>
......@@ -88,13 +89,19 @@ class WindowManager: public SkinObject
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;
......@@ -201,6 +208,8 @@ class WindowManager: public SkinObject
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
......
......@@ -59,6 +59,8 @@ class Rect: public GenericRect
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; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment