Changeset 104

Show
Ignore:
Timestamp:
04/21/06 05:47:55 (2 years ago)
Author:
jordi
Message:

Rotation the page also keeps the zoom to fit and zoom to width options.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/MainPter.cxx

    r103 r104  
    362362 
    363363    m_Document->rotateLeft (); 
     364 
     365    Config &config = Config::getConfig (); 
     366    if ( config.zoomToWidth () ) 
     367    { 
     368        zoomWidth (); 
     369    } 
     370    else if ( config.zoomToFit () ) 
     371    { 
     372        zoomFit (); 
     373    } 
    364374    showPage (); 
    365375} 
     
    374384 
    375385    m_Document->rotateRight (); 
     386 
     387    Config &config = Config::getConfig (); 
     388    if ( config.zoomToWidth () ) 
     389    { 
     390        zoomWidth (); 
     391    } 
     392    else if ( config.zoomToFit () ) 
     393    { 
     394        zoomFit (); 
     395    } 
    376396    showPage (); 
    377397} 
     
    410430    Config::getConfig().setShowToolbar (show); 
    411431    getView ().showToolbar (show); 
     432} 
     433 
     434/// 
     435/// @brief Performs the "Zoom Fit Best". 
     436/// 
     437/// Gets the width of the current page view and then calls the zoom to fit 
     438/// function from document. 
     439/// 
     440void 
     441MainPter::zoomFit () 
     442{ 
     443    gint width; 
     444    gint height; 
     445    getView ().getPageViewSize (&width, &height); 
     446    m_Document->zoomToFit (width, height); 
    412447} 
    413448 
     
    429464    if ( active ) 
    430465    { 
    431         gint width; 
    432         gint height; 
    433         view.getPageViewSize (&width, &height); 
    434         m_Document->zoomToFit (width, height); 
     466        zoomFit (); 
    435467        showPage (); 
    436468    } 
     
    475507    m_Document->zoomOut (); 
    476508    showPage (); 
     509} 
     510 
     511/// 
     512/// @brief Performs the "Zoom Fit Width". 
     513/// 
     514/// Gets the width of the current page view and then calls the zoom to width 
     515/// function from document. 
     516/// 
     517void 
     518MainPter::zoomWidth () 
     519{ 
     520    gint width; 
     521    gint height; 
     522    getView ().getPageViewSize (&width, &height); 
     523    m_Document->zoomToWidth (width); 
    477524} 
    478525 
     
    494541    if ( active ) 
    495542    { 
    496         gint width; 
    497         gint height; 
    498         view.getPageViewSize (&width, &height); 
    499         m_Document->zoomToWidth (width); 
     543        zoomWidth (); 
    500544        showPage (); 
    501545    } 
  • trunk/src/MainPter.h

    r103 r104  
    7272            DocumentPage *m_DocumentPage; 
    7373            IMainView *m_View; 
     74 
     75            void zoomFit (void); 
     76            void zoomWidth (void); 
    7477    }; 
    7578} 
  • trunk/tests/DumbDocument.cxx

    r66 r104  
    7777DumbDocument::getPageSize (gdouble *width, gdouble *height) 
    7878{ 
    79     if ( 0 == getRotation () || 270 == getRotation () ) 
     79    if ( 90 == getRotation () || 270 == getRotation () ) 
     80    { 
     81        *width = 250; 
     82        *height = 100; 
     83    } 
     84    else 
    8085    { 
    8186        *width = 100; 
    8287        *height = 250; 
    83     } 
    84     else 
    85     { 
    86         *width = 250; 
    87         *height = 100; 
    8888    } 
    8989} 
  • trunk/tests/MainPterTest.cxx

    r103 r104  
    676676} 
    677677 
     678/// 
     679/// @brief Checks rotation and zoom. 
     680/// 
     681/// This tests that rotation while the zoom to width or zoom to 
     682/// fit are activated also changed the zoom level. 
     683/// 
     684void 
     685MainPterTest::pageZoomAndRotate () 
     686{ 
     687    m_View->setOpenFileName ("/tmp/test.pdf"); 
     688    m_MainPter->openFileActivated (); 
     689    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     690    CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); 
     691 
     692    // The document is 100x250 and the page view 75x50. 
     693    // ZoomToWidth 75/100 = 0.75 
     694    m_MainPter->zoomWidthActivated (TRUE); 
     695    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 
     696    // Rotate left. 75/250 = 0.3 
     697    m_MainPter->rotateLeftActivated (); 
     698    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
     699    m_MainPter->rotateRightActivated ();     
     700    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 
     701    m_MainPter->rotateRightActivated ();     
     702    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
     703    m_MainPter->rotateLeftActivated (); 
     704    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 
     705 
     706    // Now try the same with zoom to fit. 
     707    // 50/250 = 0.2 
     708    m_MainPter->zoomFitActivated (TRUE); 
     709    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 
     710    // Rotate left, 75/250 = 0.3 
     711    m_MainPter->rotateLeftActivated (); 
     712    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
     713    m_MainPter->rotateRightActivated ();     
     714    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 
     715    m_MainPter->rotateRightActivated ();     
     716    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
     717    m_MainPter->rotateLeftActivated (); 
     718    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 
     719} 
    678720 
    679721/// 
  • trunk/tests/MainPterTest.h

    r102 r104  
    4040        CPPUNIT_TEST (pageZoomWidth); 
    4141        CPPUNIT_TEST (pageZoomFit); 
     42        CPPUNIT_TEST (pageZoomAndRotate); 
    4243        CPPUNIT_TEST (reloadNormal); 
    4344        CPPUNIT_TEST (reloadEncrypted); 
     
    6566            void pageZoomWidth (void); 
    6667            void pageZoomFit (void); 
     68            void pageZoomAndRotate (void); 
    6769            void reloadNormal (void); 
    6870            void reloadEncrypted (void);