Changeset 48018aedd562fa8751c620583e1e09852c79e1be
- Timestamp:
- 24/08/08 08:30:51
(3 months ago)
- Author:
- Jean-Baptiste Kempf <jb@videolan.org>
- git-committer:
- Jean-Baptiste Kempf <jb@videolan.org> 1219559451 -0700
- git-parent:
[ac495caa3816336ac9a2cece655cd69aa149fcbc]
- git-author:
- Jean-Baptiste Kempf <jb@videolan.org> 1219559363 -0700
- Message:
Video Widget cleaning. Corrections of previous commits.
zoom and resize when stop should be fixed. #1652 and #1716
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra0841e0 |
r48018ae |
|
| 68 | 68 | /* Init */ |
|---|
| 69 | 69 | i_vout = 0; |
|---|
| 70 | | hide(); setMinimumSize( 16, 16 ); |
|---|
| 71 | 70 | videoSize.rwidth() = -1; |
|---|
| 72 | 71 | videoSize.rheight() = -1; |
|---|
| | 72 | |
|---|
| | 73 | hide(); |
|---|
| | 74 | |
|---|
| | 75 | /* Set the policy to expand in both directions */ |
|---|
| 73 | 76 | setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
|---|
| 74 | 77 | |
|---|
| 75 | | /* Black background is more coherent for a Video Widget IMVHO */ |
|---|
| | 78 | /* Black background is more coherent for a Video Widget */ |
|---|
| 76 | 79 | QPalette plt = palette(); |
|---|
| 77 | | plt.setColor( QPalette::Active, QPalette::Window , Qt::black ); |
|---|
| 78 | | plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black ); |
|---|
| | 80 | plt.setColor( QPalette::Window, Qt::black ); |
|---|
| 79 | 81 | setPalette( plt ); |
|---|
| | 82 | setAutoFillBackground(true); |
|---|
| | 83 | |
|---|
| | 84 | /* Indicates that the widget wants to draw directly onto the screen. |
|---|
| | 85 | Widgets with this attribute set do not participate in composition |
|---|
| | 86 | management */ |
|---|
| 80 | 87 | setAttribute( Qt::WA_PaintOnScreen, true ); |
|---|
| 81 | 88 | |
|---|
| … | … | |
| 86 | 93 | Qt::BlockingQueuedConnection ); |
|---|
| 87 | 94 | #else |
|---|
| 88 | | #error This is broken. Fix it with a QEventLoop with a processEvents () |
|---|
| | 95 | #warning This is broken. Fix it with a QEventLoop with a processEvents () |
|---|
| 89 | 96 | connect( this, SIGNAL(askVideoWidgetToShow( unsigned int, unsigned int)), |
|---|
| 90 | 97 | this, SLOT(SetSizing(unsigned int, unsigned int )) ); |
|---|
| … | … | |
| 100 | 107 | } |
|---|
| 101 | 108 | |
|---|
| | 109 | /* Kill the vout at Destruction */ |
|---|
| 102 | 110 | VideoWidget::~VideoWidget() |
|---|
| 103 | 111 | { |
|---|
| 104 | | vout_thread_t *p_vout = i_vout |
|---|
| 105 | | ? (vout_thread_t *)vlc_object_get( i_vout ) : NULL; |
|---|
| | 112 | vout_thread_t *p_vout = i_vout ? |
|---|
| | 113 | (vout_thread_t *)vlc_object_get( i_vout ) : NULL; |
|---|
| 106 | 114 | |
|---|
| 107 | 115 | if( p_vout ) |
|---|
| … | … | |
| 135 | 143 | } |
|---|
| 136 | 144 | i_vout = p_nvout->i_object_id; |
|---|
| | 145 | #ifndef NDEBUG |
|---|
| 137 | 146 | msg_Dbg( p_intf, "embedded video ready (handle %p)", winId() ); |
|---|
| | 147 | #endif |
|---|
| 138 | 148 | return ( void* )winId(); |
|---|
| 139 | 149 | } |
|---|
| … | … | |
| 157 | 167 | videoSize.rwidth() = 0; |
|---|
| 158 | 168 | videoSize.rheight() = 0; |
|---|
| | 169 | updateGeometry(); |
|---|
| 159 | 170 | hide(); |
|---|
| 160 | | updateGeometry(); // Needed for deinterlace |
|---|
| 161 | 171 | } |
|---|
| 162 | 172 | |
|---|
| r76dfb93 |
r48018ae |
|
| 42 | 42 | #include <QFrame> |
|---|
| 43 | 43 | |
|---|
| 44 | | #define VOLUME_MAX 200 |
|---|
| 45 | | |
|---|
| 46 | | /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be |
|---|
| 47 | | done by trick with setting the opacity of window */ |
|---|
| 48 | | #ifdef WIN32 |
|---|
| 49 | | #define WIN32TRICK |
|---|
| 50 | | #endif |
|---|
| 51 | | |
|---|
| 52 | | /* to trying transparency with fullscreen controller on windows enable that */ |
|---|
| 53 | | /* it can be enabled on-non windows systems, |
|---|
| 54 | | but it will be transparent only with composite manager */ |
|---|
| 55 | | #ifndef WIN32 |
|---|
| 56 | | #define HAVE_TRANSPARENCY 1 |
|---|
| 57 | | #else |
|---|
| 58 | | #define HAVE_TRANSPARENCY 0 |
|---|
| 59 | | #endif |
|---|
| 60 | | |
|---|
| 61 | | /* Default value of opacity for FS controller */ |
|---|
| 62 | | #define DEFAULT_OPACITY 0.75 |
|---|
| 63 | | |
|---|
| 64 | 44 | class ResizeEvent; |
|---|
| 65 | 45 | class QPalette; |
|---|
| … | … | |
| 241 | 221 | }; |
|---|
| 242 | 222 | |
|---|
| | 223 | /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be |
|---|
| | 224 | done by trick with setting the opacity of window */ |
|---|
| | 225 | #ifdef WIN32 |
|---|
| | 226 | #define WIN32TRICK |
|---|
| | 227 | #endif |
|---|
| | 228 | |
|---|
| | 229 | /* to trying transparency with fullscreen controller on windows enable that */ |
|---|
| | 230 | /* it can be enabled on-non windows systems, |
|---|
| | 231 | but it will be transparent only with composite manager */ |
|---|
| | 232 | #ifndef WIN32 |
|---|
| | 233 | #define HAVE_TRANSPARENCY 1 |
|---|
| | 234 | #else |
|---|
| | 235 | #define HAVE_TRANSPARENCY 0 |
|---|
| | 236 | #endif |
|---|
| | 237 | |
|---|
| | 238 | /* Default value of opacity for FS controller */ |
|---|
| | 239 | #define DEFAULT_OPACITY 0.75 |
|---|
| | 240 | |
|---|
| 243 | 241 | /*********************************** |
|---|
| 244 | 242 | * Fullscreen controller |
|---|
| … | … | |
| 303 | 301 | |
|---|
| 304 | 302 | |
|---|
| 305 | | |
|---|
| | 303 | #define VOLUME_MAX 200 |
|---|
| 306 | 304 | class VolumeClickHandler : public QObject |
|---|
| 307 | 305 | { |
|---|
| rda38842 |
r48018ae |
|
| 2 | 2 | * main_interface.cpp : Main interface |
|---|
| 3 | 3 | **************************************************************************** |
|---|
| 4 | | * Copyright (C) 2006-2007 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2006-2008 the VideoLAN team |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 52 | 52 | #include <QSlider> |
|---|
| 53 | 53 | #include <QWidgetAction> |
|---|
| 54 | | #if 0 |
|---|
| 55 | | #include <QDockWidget> |
|---|
| 56 | | #endif |
|---|
| 57 | 54 | #include <QToolBar> |
|---|
| 58 | 55 | #include <QGroupBox> |
|---|
| … | … | |
| 62 | 59 | #include <vlc_keys.h> |
|---|
| 63 | 60 | #include <vlc_vout.h> |
|---|
| 64 | | |
|---|
| 65 | | #define SET_WIDTH(i,j) i->widgetSize.setWidth(j) |
|---|
| 66 | | #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j) |
|---|
| 67 | | #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k); |
|---|
| 68 | | |
|---|
| 69 | | #define DS(i) i.width(),i.height() |
|---|
| 70 | 61 | |
|---|
| 71 | 62 | /* Callback prototypes */ |
|---|
| … | … | |
| 113 | 104 | settings->beginGroup( "MainWindow" ); |
|---|
| 114 | 105 | |
|---|
| 115 | | //TODO: I don't like that code |
|---|
| 116 | | visualSelectorEnabled = settings->value( "visual-selector", false ).toBool(); |
|---|
| | 106 | /* Visualisation, not really used yet */ |
|---|
| | 107 | visualSelectorEnabled = settings->value( "visual-selector", false).toBool(); |
|---|
| | 108 | |
|---|
| | 109 | /* Do we want anoying popups or not */ |
|---|
| 117 | 110 | notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" ); |
|---|
| 118 | 111 | |
|---|
| … | … | |
| 135 | 128 | #endif |
|---|
| 136 | 129 | |
|---|
| 137 | | /************ |
|---|
| 138 | | * Menu Bar |
|---|
| 139 | | ************/ |
|---|
| | 130 | /************************** |
|---|
| | 131 | * Menu Bar and Status Bar |
|---|
| | 132 | **************************/ |
|---|
| 140 | 133 | QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled ); |
|---|
| 141 | | |
|---|
| 142 | 134 | /* StatusBar Creation */ |
|---|
| 143 | 135 | createStatusBar(); |
|---|
| … | … | |
| 198 | 190 | /** OnTimeOut **/ |
|---|
| 199 | 191 | /* TODO Remove this function, but so far, there is no choice because there |
|---|
| 200 | | is no intf-should-die variable */ |
|---|
| | 192 | is no intf-should-die variable #1365 */ |
|---|
| 201 | 193 | ON_TIMEOUT( updateOnTimer() ); |
|---|
| 202 | | //ON_TIMEOUT( debug() ); |
|---|
| 203 | | |
|---|
| 204 | | /** |
|---|
| | 194 | |
|---|
| | 195 | /************ |
|---|
| 205 | 196 | * Callbacks |
|---|
| 206 | | **/ |
|---|
| | 197 | ************/ |
|---|
| 207 | 198 | var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); |
|---|
| 208 | 199 | var_AddCallback( p_intf, "interaction", InteractCallback, this ); |
|---|
| … | … | |
| 214 | 205 | var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); |
|---|
| 215 | 206 | |
|---|
| 216 | | /* VideoWidget connect mess to avoid different threads speaking to each other */ |
|---|
| | 207 | |
|---|
| | 208 | /* VideoWidget connects to avoid different threads speaking to each other */ |
|---|
| 217 | 209 | CONNECT( this, askReleaseVideo( void * ), |
|---|
| 218 | 210 | this, releaseVideoSlot( void * ) ); |
|---|
| … | … | |
| 231 | 223 | settings->endGroup(); |
|---|
| 232 | 224 | |
|---|
| | 225 | |
|---|
| | 226 | /* Final sizing and showing */ |
|---|
| | 227 | setMinimumWidth( __MAX( controls->sizeHint().width(), |
|---|
| | 228 | menuBar()->sizeHint().width() ) ); |
|---|
| 233 | 229 | show(); |
|---|
| 234 | 230 | |
|---|
| | 231 | /* And switch to minimal view if needed |
|---|
| | 232 | Must be called after the show() */ |
|---|
| 235 | 233 | if( i_visualmode == QT_MINIMAL_MODE ) |
|---|
| 236 | 234 | toggleMinimalView(); |
|---|
| … | … | |
| 238 | 236 | /* Update the geometry TODO: is it useful ?*/ |
|---|
| 239 | 237 | updateGeometry(); |
|---|
| 240 | | resize( sizeHint() ); |
|---|
| | 238 | // resize( sizeHint() ); |
|---|
| 241 | 239 | |
|---|
| 242 | 240 | /***************************************************** |
|---|
| … | … | |
| 307 | 305 | nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel); |
|---|
| 308 | 306 | |
|---|
| 309 | | |
|---|
| 310 | 307 | /* and adding those */ |
|---|
| 311 | 308 | statusBar()->addWidget( nameLabel, 8 ); |
|---|
| … | … | |
| 545 | 542 | QSize MainInterface::sizeHint() const |
|---|
| 546 | 543 | { |
|---|
| 547 | | int nwidth = __MAX( controls->sizeHint().width(), |
|---|
| 548 | | menuBar()->sizeHint().width() ); |
|---|
| | 544 | int nwidth = controls->sizeHint().width(); |
|---|
| 549 | 545 | int nheight = controls->isVisible() ? |
|---|
| 550 | 546 | controls->size().height() |
|---|
| … | … | |
| 553 | 549 | : 0 ; |
|---|
| 554 | 550 | |
|---|
| 555 | | msg_Dbg( p_intf, "1 %i %i", nheight, nwidth ); |
|---|
| 556 | 551 | if( VISIBLE( bgWidget ) ) |
|---|
| 557 | 552 | { |
|---|
| 558 | 553 | nheight += bgWidget->size().height(); |
|---|
| 559 | 554 | nwidth = bgWidget->size().width(); |
|---|
| 560 | | msg_Dbg( p_intf, "1b %i %i", nheight, nwidth ); |
|---|
| 561 | | } |
|---|
| 562 | | else if( videoIsActive ) |
|---|
| | 555 | } |
|---|
| | 556 | else if( videoIsActive && videoWidget->isVisible() ) |
|---|
| 563 | 557 | { |
|---|
| 564 | 558 | nheight += videoWidget->sizeHint().height(); |
|---|
| 565 | 559 | nwidth = videoWidget->sizeHint().width(); |
|---|
| 566 | | msg_Dbg( p_intf, "2 %i %i", nheight, nwidth ); |
|---|
| 567 | 560 | } |
|---|
| 568 | 561 | #if 0 |
|---|
| … | … | |
| 571 | 564 | nheight += dockPL->size().height(); |
|---|
| 572 | 565 | nwidth = __MAX( nwidth, dockPL->size().width() ); |
|---|
| 573 | | msg_Dbg( p_intf, "3 %i %i", nheight, nwidth ); |
|---|
| | 566 | msg_Warn( p_intf, "3 %i %i", nheight, nwidth ); |
|---|
| 574 | 567 | } |
|---|
| 575 | 568 | #endif |
|---|
| 576 | | msg_Dbg( p_intf, "4 %i %i", nheight, nwidth ); |
|---|
| 577 | 569 | return QSize( nwidth, nheight ); |
|---|
| 578 | 570 | } |
|---|
| 579 | | |
|---|
| 580 | | #if 0 |
|---|
| 581 | | /* FIXME This is dead code and need to be removed AT THE END */ |
|---|
| 582 | | void MainInterface::resizeEvent( QResizeEvent *e ) |
|---|
| 583 | | { |
|---|
| 584 | | if( videoWidget ) |
|---|
| 585 | | videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() ); |
|---|
| 586 | | if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 ) |
|---|
| 587 | | { |
|---|
| 588 | | SET_WH( videoWidget, e->size().width() - addSize.width(), |
|---|
| 589 | | e->size().height() - addSize.height() ); |
|---|
| 590 | | videoWidget->updateGeometry(); |
|---|
| 591 | | } |
|---|
| 592 | | if( VISIBLE( playlistWidget ) ) |
|---|
| 593 | | { |
|---|
| 594 | | // SET_WH( playlistWidget , e->size().width() - addSize.width(), |
|---|
| 595 | | // e->size().height() - addSize.height() ); |
|---|
| 596 | | playlistWidget->updateGeometry(); |
|---|
| 597 | | } |
|---|
| 598 | | } |
|---|
| 599 | | #endif |
|---|
| 600 | 571 | |
|---|
| 601 | 572 | void MainInterface::toggleFSC() |
|---|
| … | … | |
| 606 | 577 | QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) ); |
|---|
| 607 | 578 | } |
|---|
| 608 | | #if 0 |
|---|
| 609 | | void MainInterface::requestLayoutUpdate() |
|---|
| 610 | | { |
|---|
| 611 | | emit askUpdate(); |
|---|
| 612 | | } |
|---|
| 613 | | #endif |
|---|
| | 579 | |
|---|
| 614 | 580 | |
|---|
| 615 | 581 | //FIXME remove me at the end... |
|---|
| 616 | 582 | void MainInterface::debug() |
|---|
| 617 | 583 | { |
|---|
| | 584 | #ifndef NDEBUG |
|---|
| 618 | 585 | msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); |
|---|
| 619 | 586 | msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); |
|---|
| 620 | 587 | if( videoWidget && videoWidget->isVisible() ) |
|---|
| 621 | 588 | { |
|---|
| 622 | | // sleep( 10 ); |
|---|
| 623 | | msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); |
|---|
| 624 | | msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); |
|---|
| | 589 | // sleep( 10 ); |
|---|
| | 590 | msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); |
|---|
| | 591 | msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); |
|---|
| 625 | 592 | } |
|---|
| 626 | 593 | adjustSize(); |
|---|
| | 594 | #endif |
|---|
| 627 | 595 | } |
|---|
| 628 | 596 | |
|---|
| … | … | |
| 639 | 607 | * Video Handling |
|---|
| 640 | 608 | ****************************************************************************/ |
|---|
| | 609 | |
|---|
| | 610 | /* This event is used to deal with the fullscreen and always on top |
|---|
| | 611 | issue conflict (bug in wx) */ |
|---|
| 641 | 612 | class SetVideoOnTopQtEvent : public QEvent |
|---|
| 642 | 613 | { |
|---|
| … | … | |
| 646 | 617 | {} |
|---|
| 647 | 618 | |
|---|
| 648 | | bool OnTop() const |
|---|
| 649 | | { |
|---|
| 650 | | return onTop; |
|---|
| 651 | | } |
|---|
| | 619 | bool OnTop() const { return onTop; } |
|---|
| 652 | 620 | |
|---|
| 653 | 621 | private: |
|---|
| … | … | |
| 656 | 624 | |
|---|
| 657 | 625 | /** |
|---|
| 658 | | * README |
|---|
| 659 | 626 | * README |
|---|
| 660 | 627 | * Thou shall not call/resize/hide widgets from on another thread. |
|---|
| … | … | |
| 665 | 632 | unsigned int *pi_height ) |
|---|
| 666 | 633 | { |
|---|
| 667 | | bgWasVisible = false; |
|---|
| 668 | | |
|---|
| 669 | 634 | /* Request the videoWidget */ |
|---|
| 670 | 635 | void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height ); |
|---|
| … | … | |
| 677 | 642 | emit askBgWidgetToToggle(); |
|---|
| 678 | 643 | } |
|---|
| 679 | | #if 0 |
|---|
| 680 | | if( THEMIM->getIM()->hasVideo() || !bgWasVisible ) |
|---|
| 681 | | { |
|---|
| 682 | | videoWidget->widgetSize = QSize( *pi_width, *pi_height ); |
|---|
| 683 | | } |
|---|
| 684 | | else /* Background widget available, use its size */ |
|---|
| 685 | | { |
|---|
| 686 | | /* Ok, our visualizations are bad, so don't do this for the moment |
|---|
| 687 | | * use the requested size anyway */ |
|---|
| 688 | | // videoWidget->widgetSize = bgWidget->widgeTSize; |
|---|
| 689 | | videoWidget->widgetSize = QSize( *pi_width, *pi_height ); |
|---|
| 690 | | } |
|---|
| 691 | | #endif |
|---|
| | 644 | else |
|---|
| | 645 | bgWasVisible = false; |
|---|
| | 646 | |
|---|
| | 647 | /* Consider the video active now */ |
|---|
| 692 | 648 | videoIsActive = true; |
|---|
| 693 | 649 | |
|---|
| 694 | | // emit askVideoToResize( *pi_width, *pi_height ); |
|---|
| 695 | 650 | emit askUpdate(); |
|---|
| 696 | 651 | |
|---|
| … | … | |
| 700 | 655 | } |
|---|
| 701 | 656 | |
|---|
| | 657 | /* Call from the WindowClose function */ |
|---|
| 702 | 658 | void MainInterface::releaseVideo( void *p_win ) |
|---|
| 703 | 659 | { |
|---|
| … | … | |
| 707 | 663 | } |
|---|
| 708 | 664 | |
|---|
| | 665 | /* Function that is CONNECTED to the previous emit */ |
|---|
| 709 | 666 | void MainInterface::releaseVideoSlot( void *p_win ) |
|---|
| 710 | 667 | { |
|---|
| 711 | 668 | videoWidget->release( p_win ); |
|---|
| 712 | | videoWidget->hide(); |
|---|
| 713 | 669 | |
|---|
| 714 | 670 | if( bgWasVisible ) |
|---|
| 715 | 671 | { |
|---|
| | 672 | /* Reset the bg state */ |
|---|
| 716 | 673 | bgWasVisible = false; |
|---|
| 717 | 674 | bgWidget->show(); |
|---|
| 718 | 675 | } |
|---|
| 719 | 676 | |
|---|
| 720 | | videoIsActive = false; |
|---|
| 721 | | if( !isFullScreen() ) adjustSize(); |
|---|
| 722 | | } |
|---|
| 723 | | |
|---|
| | 677 | /* Try to resize, except when you are in Fullscreen mode */ |
|---|
| | 678 | if( !isFullScreen() ) doComponentsUpdate(); |
|---|
| | 679 | } |
|---|
| | 680 | |
|---|
| | 681 | /* Call from WindowControl function */ |
|---|
| 724 | 682 | int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) |
|---|
| 725 | 683 | { |
|---|
| … | … | |
| 826 | 784 | { |
|---|
| 827 | 785 | /* If video is visible, then toggle the status of bgWidget */ |
|---|
| 828 | | bgWasVisible = !bgWasVisible; |
|---|
| | 786 | bgWasVisible = !bgWasVisible; |
|---|
| 829 | 787 | } |
|---|
| 830 | 788 | } |
|---|
| … | … | |
| 841 | 799 | { |
|---|
| 842 | 800 | msg_Dbg( p_intf, "Updating the geometry" ); |
|---|
| 843 | | // resize( sizeHint() ); |
|---|
| 844 | | debug(); |
|---|
| | 801 | // resize( sizeHint() ); |
|---|
| | 802 | adjustSize(); |
|---|
| 845 | 803 | } |
|---|
| 846 | 804 | |
|---|
| rd197ab1 |
r48018ae |
|
| 76 | 76 | int controlVideo( void *p_window, int i_query, va_list args ); |
|---|
| 77 | 77 | |
|---|
| 78 | | #if 0 |
|---|
| 79 | | void requestLayoutUpdate(); |
|---|
| 80 | | #endif |
|---|
| 81 | 78 | /* Getters */ |
|---|
| 82 | 79 | QSystemTrayIcon *getSysTray() { return sysTray; }; |
|---|