Exemplo n.º 1
0
//---------------------------------------------------------------------------------------
void Layouter::layout_item(ImoContentObj* pItem, GmoBox* pParentBox)
{
    LOMSE_LOG_DEBUG(Logger::k_layout, str(boost::format(
        "Laying out id %d %s") % pItem->get_id() % pItem->get_name() ));

    m_pCurLayouter = create_layouter(pItem);

    m_pCurLayouter->prepare_to_start_layout();
    while (!m_pCurLayouter->is_item_layouted())
    {
        m_pCurLayouter->create_main_box(pParentBox, m_pageCursor,
                                        m_availableWidth, m_availableHeight);
        m_pCurLayouter->layout_in_box();
        m_pCurLayouter->set_box_height();

        if (!m_pCurLayouter->is_item_layouted())
        {
            pParentBox = start_new_page();
        }
    }
    m_pCurLayouter->add_end_margins();

    //update cursor and available space
    GmoBox* pChildBox = m_pCurLayouter->get_item_main_box();
    if (pChildBox)  //AWARE: NullLayouter does not create a box
    {
        m_pageCursor.y = pChildBox->get_bottom();
        m_availableHeight -= pChildBox->get_height();
    }

    if (!pItem->is_score())
        delete m_pCurLayouter;
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------------------
LUnits TableSectionLayouter::add_row(GmoBox* pParentMainBox)
{
    GmoBox* pRowBox = m_pRowLayouter->get_item_main_box();
    pParentMainBox->add_child_box(pRowBox);

    LUnits height = pRowBox->get_height();
    m_pageCursor.y += height;
    m_availableHeight -= height;

    delete m_pRowLayouter;
    m_pRowLayouter = nullptr;

    return height;
}
 TEST_FIXTURE(DocLayouterTestFixture, DocLayouter_DocPageHasBoxContent)
 {
     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();
     GmoBoxDocPage* pPage = pGModel->get_page(0);
     GmoBox* pBox = pPage->get_child_box(0);
     CHECK( pBox->is_box_doc_page_content() == true );
     CHECK( pBox->get_width() == 16000.0f );
     CHECK( pBox->get_height() == 2735.0f );
     CHECK( pBox->get_left() == 1000.0f );
     CHECK( pBox->get_top() == 1500.0f );
     delete pGModel;
 }