Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog {#Changelog}

# git master (1.1.0)

* [30](https://github.com/BlueBrain/Tide/pull/30):
The contents can now be shown in fullscreen mode
* [28](https://github.com/BlueBrain/Tide/pull/28):
Simplify window interaction [DISCL-320].
This change makes interacting with contents more natural and intuitive:
Expand Down
6 changes: 5 additions & 1 deletion tests/cpp/core/ContentWindowControllerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,23 @@ BOOST_AUTO_TEST_CASE( testFullScreenSize )
{
ContentPtr content( new DummyContent );
content->setDimensions( CONTENT_SIZE );
content->setZoomRect( QRectF( 0.25, 0.25, 0.5, 0.5 ));
ContentWindow window( content );

DisplayGroupPtr displayGroup( new DisplayGroup( wallSize ));
ContentWindowController controller( window, *displayGroup );

controller.adjustSize( SIZE_FULLSCREEN );
const QRectF& coords = window.getCoordinates();
const QRectF& coords = window.getFullscreenCoordinates();

// full screen, center on wall
BOOST_CHECK_EQUAL( coords.x(), 0.0 );
BOOST_CHECK_EQUAL( coords.y(), 125 );
BOOST_CHECK_EQUAL( coords.width(), wallSize.width( ));
BOOST_CHECK_EQUAL( coords.height(), wallSize.width() / CONTENT_AR );

// zoom reset
BOOST_CHECK_EQUAL( content->getZoomRect(), UNIT_RECTF );
}

BOOST_AUTO_TEST_CASE( testResizeRelativeToBorder )
Expand Down
28 changes: 26 additions & 2 deletions tests/cpp/core/VisibilityHelperTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ BOOST_FIXTURE_TEST_CASE( testOverlappingWindow, Fixture )

// Focused
window->setFocusedCoordinates( coord );
window->setFocused( true );
window->setMode( ContentWindow::WindowMode::FOCUSED );
BOOST_CHECK_EQUAL( helper.getVisibleArea( *window ), coord );
window->setFocused( false );
window->setMode( ContentWindow::WindowMode::STANDARD );

// Half-above horizonally
otherWindow->setCoordinates( QRectF( QPointF( 100, 0 ), size ));
Expand Down Expand Up @@ -191,3 +191,27 @@ BOOST_FIXTURE_TEST_CASE( testViewCutCombinedWithOverlappingWindow, Fixture )
otherWindow->setCoordinates( QRectF( QPointF( 200, 400 ), size ));
BOOST_CHECK_EQUAL( helper.getVisibleArea( *window ), QRectF( ));
}

BOOST_FIXTURE_TEST_CASE( testFullscreenWindowOverlapEverything, Fixture )
{
const QRectF& coord = window->getCoordinates();

ContentWindowPtr otherWindow = boost::make_shared<ContentWindow>( content );
group->addContentWindow( otherWindow );
BOOST_REQUIRE_EQUAL( helper.getVisibleArea( *window ), QRectF( ));
BOOST_REQUIRE_EQUAL( helper.getVisibleArea( *otherWindow ), coord );

// Even a "small" fullscreen window should overlap everything...
group->showFullscreen( window->getID( ));
const QRectF fullscreen( QPointF(), window->getCoordinates().size() / 2 );
window->setFullscreenCoordinates( fullscreen );
BOOST_CHECK_EQUAL( helper.getVisibleArea( *otherWindow ), QRectF( ));
BOOST_CHECK_EQUAL( helper.getVisibleArea( *window ), fullscreen );

// ...including focused windows
ContentWindowPtr focusWindow = boost::make_shared<ContentWindow>( content );
group->addContentWindow( focusWindow );
group->focus( focusWindow->getID( ));
BOOST_CHECK_EQUAL( helper.getVisibleArea( *focusWindow ), QRectF( ));
BOOST_CHECK_EQUAL( helper.getVisibleArea( *window ), fullscreen );
}
56 changes: 44 additions & 12 deletions tide/core/ContentWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ContentWindow::ContentWindow( ContentPtr content, const WindowType type )
, _controller( nullptr )
, _activeHandle( NOHANDLE )
, _resizePolicy( KEEP_ASPECT_RATIO )
, _focused( false )
, _mode( WindowMode::STANDARD )
, _windowState( NONE )
, _controlsVisible( false )
{
Expand All @@ -76,14 +76,12 @@ ContentWindow::ContentWindow()
, _controller( nullptr )
, _activeHandle( NOHANDLE )
, _resizePolicy( KEEP_ASPECT_RATIO )
, _focused( false )
, _mode( WindowMode::STANDARD )
, _windowState( NONE )
, _controlsVisible( false )
{}

ContentWindow::~ContentWindow()
{
}
ContentWindow::~ContentWindow() {}

const QUuid& ContentWindow::getID() const
{
Expand Down Expand Up @@ -192,9 +190,29 @@ ContentWindow::WindowState ContentWindow::getState() const
return _windowState;
}

ContentWindow::WindowMode ContentWindow::getMode() const
{
return _mode;
}

void ContentWindow::setMode( const ContentWindow::WindowMode mode )
{
if( mode == _mode )
return;

_mode = mode;
emit modeChanged();
emit modified();
}

bool ContentWindow::isFocused() const
{
return _focused;
return _mode == WindowMode::FOCUSED;
}

bool ContentWindow::isFullscreen() const
{
return _mode == WindowMode::FULLSCREEN;
}

const QRectF& ContentWindow::getFocusedCoordinates() const
Expand All @@ -211,18 +229,32 @@ void ContentWindow::setFocusedCoordinates( const QRectF& coordinates )
emit focusedCoordinatesChanged();
}

const QRectF& ContentWindow::getDisplayCoordinates() const
const QRectF& ContentWindow::getFullscreenCoordinates() const
{
return isFocused() ? getFocusedCoordinates() : getCoordinates();
return _fullscreenCoordinates;
}

void ContentWindow::setFocused( const bool value )
void ContentWindow::setFullscreenCoordinates( const QRectF& coordinates )
{
if( _focused == value )
if( coordinates == _fullscreenCoordinates )
return;

_focused = value;
emit focusedChanged();
_fullscreenCoordinates = coordinates;
emit fullscreenCoordinatesChanged();
}

const QRectF& ContentWindow::getDisplayCoordinates() const
{
switch( getMode( ))
{
case WindowMode::FULLSCREEN:
return getFullscreenCoordinates();
case WindowMode::FOCUSED:
return getFocusedCoordinates();
case WindowMode::STANDARD:
default:
return getCoordinates();
}
}

bool ContentWindow::setState( const ContentWindow::WindowState state )
Expand Down
72 changes: 53 additions & 19 deletions tide/core/ContentWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,30 @@
class ContentWindow : public Coordinates
{
Q_OBJECT
Q_PROPERTY( QUuid id READ getID )
Q_PROPERTY( QUuid id READ getID CONSTANT )
Q_PROPERTY( bool isPanel READ isPanel CONSTANT )
Q_PROPERTY( Content* content READ getContentPtr CONSTANT )
Q_PROPERTY( ContentInteractionDelegate* delegate READ getInteractionDelegate
CONSTANT )
Q_PROPERTY( ContentWindowController* controller READ getController
CONSTANT )
Q_PROPERTY( WindowMode mode READ getMode WRITE setMode
NOTIFY modeChanged )
Q_PROPERTY( bool focused READ isFocused NOTIFY modeChanged )
Q_PROPERTY( QRectF focusedCoordinates READ getFocusedCoordinates
NOTIFY focusedCoordinatesChanged )
Q_PROPERTY( bool fullscreen READ isFullscreen NOTIFY modeChanged )
Q_PROPERTY( QRectF fullscreenCoordinates READ getFullscreenCoordinates
NOTIFY fullscreenCoordinatesChanged )
Q_PROPERTY( WindowState state READ getState WRITE setState
NOTIFY stateChanged )
Q_PROPERTY( ResizeHandle activeHandle READ getActiveHandle
WRITE setActiveHandle NOTIFY activeHandleChanged )
Q_PROPERTY( ResizePolicy resizePolicy READ getResizePolicy
WRITE setResizePolicy NOTIFY resizePolicyChanged )
Q_PROPERTY( bool focused READ isFocused WRITE setFocused
NOTIFY focusedChanged )
Q_PROPERTY( QString label READ getLabel NOTIFY labelChanged )
Q_PROPERTY( bool controlsVisible READ getControlsVisible
WRITE setControlsVisible NOTIFY controlsVisibleChanged )
Q_PROPERTY( ContentInteractionDelegate* delegate READ getInteractionDelegate
CONSTANT )
Q_PROPERTY( ContentWindowController* controller READ getController
CONSTANT )
Q_PROPERTY( QRectF focusedCoordinates READ getFocusedCoordinates
WRITE setFocusedCoordinates NOTIFY focusedCoordinatesChanged )

public:
/** The current active resize handle. */
Expand All @@ -113,6 +117,15 @@ class ContentWindow : public Coordinates
};
Q_ENUMS( ResizePolicy )

/** The possible rendering modes of a window. */
enum WindowMode
{
STANDARD, // standard window mode on the desktop
FOCUSED, // window focused for presentation
FULLSCREEN // fullscreen
};
Q_ENUMS( WindowMode )

/** The possible states of a window. */
enum WindowState
{
Expand Down Expand Up @@ -182,28 +195,35 @@ class ContentWindow : public Coordinates
/** Get the current resize policy. */
ContentWindow::ResizePolicy getResizePolicy() const;


/** Get the current state. */
ContentWindow::WindowState getState() const;
ContentWindow::WindowMode getMode() const;

/** Is the window focused. */
bool isFocused() const;

/** Set the window in focused mode. */
void setFocused( bool value );
/** Is the window fullscreen. */
bool isFullscreen() const;


/** @return the focused coordinates of this window. */
const QRectF& getFocusedCoordinates() const;

/** Set the focused coordinates of this window. */
void setFocusedCoordinates( const QRectF& coordinates );

/** @return the fullscreen coordinates of this window. */
const QRectF& getFullscreenCoordinates() const;

/** @return the actual coordinates of this window (normal or focused). */
/** Set the fullscreen coordinates of this window. */
void setFullscreenCoordinates( const QRectF& coordinates );

/** @return the actual display coordinates of (depending on the mode). */
const QRectF& getDisplayCoordinates() const;


/** Set the current state. */
bool setState( const ContentWindow::WindowState state );
/** Get the current state. */
ContentWindow::WindowState getState() const;

/** Check if moving. */
bool isMoving() const;
Expand Down Expand Up @@ -231,12 +251,18 @@ class ContentWindow : public Coordinates
void setControlsVisible( bool value );

public slots:
/** Set the current state. */
void setMode( const ContentWindow::WindowMode mode );

/** Set the current active resize handle. */
void setActiveHandle( ContentWindow::ResizeHandle handle );

/** Set the resize policy. */
bool setResizePolicy( ContentWindow::ResizePolicy policy );

/** Set the current state. */
bool setState( const ContentWindow::WindowState state );

signals:
/** Emitted when the Content signals that it has been modified. */
void contentModified();
Expand All @@ -254,8 +280,9 @@ public slots:
//@{
void activeHandleChanged();
void resizePolicyChanged();
void focusedChanged();
void modeChanged();
void focusedCoordinatesChanged();
void fullscreenCoordinatesChanged();
void stateChanged();
void labelChanged();
void controlsVisibleChanged();
Expand All @@ -278,8 +305,9 @@ public slots:
ar & _controller;
ar & _activeHandle;
ar & _resizePolicy;
ar & _focused;
ar & _mode;
ar & _focusedCoordinates;
ar & _fullscreenCoordinates;
ar & _windowState;
ar & _controlsVisible;
}
Expand Down Expand Up @@ -307,7 +335,12 @@ public slots:
ar & boost::serialization::make_nvp( "centerY", zoomCenter.ry( ));
ar & boost::serialization::make_nvp( "zoom", zoom );
if( version >= 3 )
ar & boost::serialization::make_nvp( "focused", _focused );
{
bool focused = isFocused();
ar & boost::serialization::make_nvp( "focused", focused );
if( focused )
setMode( WindowMode::FOCUSED );
}
QRectF zoomRect;
zoomRect.setSize( QSizeF( 1.0/zoom, 1.0/zoom ));
zoomRect.moveCenter( zoomCenter );
Expand Down Expand Up @@ -344,8 +377,9 @@ public slots:
ContentWindowController* _controller; // child QObject, don't delete
ContentWindow::ResizeHandle _activeHandle;
ContentWindow::ResizePolicy _resizePolicy;
bool _focused;
ContentWindow::WindowMode _mode;
QRectF _focusedCoordinates;
QRectF _fullscreenCoordinates;
ContentWindow::WindowState _windowState;
bool _controlsVisible;

Expand Down
4 changes: 3 additions & 1 deletion tide/core/ContentWindowController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,13 @@ void ContentWindowController::adjustSize( const SizeState state )

case SIZE_FULLSCREEN:
{
_contentWindow->getContent()->resetZoom();
QSizeF size = _contentWindow->getContent()->getDimensions();
size.scale( _displayGroup->getCoordinates().size(),
Qt::KeepAspectRatio );
constrainSize( size );
_contentWindow->setCoordinates( _getCenteredCoordinates( size ));
const auto fullscreenCoordinates = _getCenteredCoordinates( size );
_contentWindow->setFullscreenCoordinates( fullscreenCoordinates );
} break;

default:
Expand Down
Loading