Esempio n. 1
0
//---------------------------------------------------------------------------------------
void ScoreCaretPositioner::set_caret_y_pos_and_height(URect* pBounds, ImoId id,
                                                      int iStaff)
{
    URect staffBounds;

    if (id >= 0)
    {
        GmoShape* pShape = get_shape_for_imo(id, iStaff);
        GmoBox* pBox = pShape->get_owner_box();
        while (pBox && !pBox->is_box_system())
            pBox = pBox->get_owner_box();
        if (!pBox)
        {
            LOMSE_LOG_ERROR("[ScoreCaretPositioner::set_caret_y_pos_and_height] Invalid boxes structure");
            throw runtime_error("[ScoreCaretPositioner::set_caret_y_pos_and_height] Invalid boxes structure");
        }
        m_pBoxSystem = static_cast<GmoBoxSystem*>(pBox);

        int staff = m_spState->staff();
        int instr = m_spState->instrument();
        GmoShapeStaff* pStaff = m_pBoxSystem->get_staff_shape(instr, staff);
        staffBounds = pStaff->get_bounds();
    }
    else
    {
        //score is empty
        staffBounds = *pBounds;
    }

    //set position and size
    pBounds->y = staffBounds.y - tenths_to_logical(10);
    pBounds->height = staffBounds.height + tenths_to_logical(20);
}
    TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_BoxScoreHasBoxSystem)
    {
        Document doc(m_libraryScope);
        doc.from_string("(lenmusdoc (vers 0.0) "
            "(pageLayout (pageSize 24000 35700)(pageMargins 1000 1500 3000 2500 4000) landscape) "
            "(content (score (vers 1.6) "
            "(instrument (musicData (clef G)(key e)(n c4 q)(r q)(barline simple))))))" );
        DocLayouter dl( doc.get_im_model(), m_libraryScope);
        dl.layout_document();
        GraphicModel* pGModel = dl.get_graphic_model();
//        pGModel->dump_page(0, cout);
        GmoBoxDocPage* pPage = pGModel->get_page(0);
        GmoBox* pBDPC = pPage->get_child_box(0);     //DocPageContent
        GmoBox* pBSP = pBDPC->get_child_box(0);      //ScorePage
        GmoBox* pBox = pBSP->get_child_box(0);       //System
        CHECK( pBox != NULL );
        CHECK( pBox->is_box_system() == true );
        //CHECK( pBox->get_width() == 16000.0f );
        //CHECK( pBox->get_height() == 735.0f );
        //CHECK( pBox->get_left() == 1000.0f );
        //CHECK( pBox->get_top() == 1500.0f );
        delete pGModel;
    }