Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 7714 → Rev 7715

/branches/Version13x/Scribus/scribus/guidemanager.cpp
117,7 → 117,7
}
horizontalReferGroup->setButton(currentPage->guides.horizontalAutoRefer());
// allow the selection radio button?
horizontalSelectionAutoButton->setEnabled((m_Doc->m_Selection->count() <= 0));
horizontalSelectionAutoButton->setEnabled(!m_Doc->m_Selection->isEmpty());
 
// verticals
enable = currentPage->guides.verticalAutoGap() > 0.0 ? true : false;
132,7 → 132,7
}
verticalReferGroup->setButton(currentPage->guides.verticalAutoRefer());
// allow the selection radio button?
verticalSelectionAutoButton->setEnabled((m_Doc->m_Selection->count() <= 0));
verticalSelectionAutoButton->setEnabled(!m_Doc->m_Selection->isEmpty());
 
m_drawGuides = true;
drawGuides();
400,19 → 400,23
drawGuides();
}
 
void GuideManager::horizontalReferGroup_clicked( int val)
void GuideManager::horizontalReferGroup_clicked(int val)
{
currentPage->guides.setHorizontalAutoRefer(val);
if (val == 2 && horizontalSelectionAutoButton->isEnabled())
resetSelectionForPage();
drawGuides();
}
 
void GuideManager::verticalReferGroup_clicked( int val)
void GuideManager::verticalReferGroup_clicked(int val)
{
currentPage->guides.setVerticalAutoRefer(val);
if (val == 2 && verticalSelectionAutoButton->isEnabled())
resetSelectionForPage();
drawGuides();
}
 
void GuideManager::tabWidget_currentChanged( QWidget * )
void GuideManager::tabWidget_currentChanged(QWidget *)
{
drawGuides();
if (tabWidget->currentPageIndex() == 1)
548,13 → 552,11
 
Guides GuideManager::getAutoVerticals()
{
resetMarginsForPage();
 
Guides retval;
double columnSize;
int value = verticalAutoCountSpin->value();
double offset = 0;
double newPageWidth = locPageWidth;
double offset = 0.0;
double newPageWidth = currentPage->width();
 
if (value == 0)
return retval;
562,13 → 564,13
 
if (verticalReferGroup->selectedId() == 1)
{
newPageWidth = locPageWidth - currentPage->Margins.Left - currentPage->Margins.Right;
newPageWidth = newPageWidth - currentPage->Margins.Left - currentPage->Margins.Right;
offset = currentPage->Margins.Left;
}
else if (verticalReferGroup->selectedId() == 2)
else if (qRound(currentPage->guides.gx) != 0)
{
offset = gx;
newPageWidth = gw;
offset = currentPage->guides.gx;
newPageWidth = currentPage->guides.gw;
}
 
if (verticalAutoGapSpin->value() > 0.0)
592,13 → 594,11
 
Guides GuideManager::getAutoHorizontals()
{
resetMarginsForPage();
 
Guides retval;
double rowSize;
int value = horizontalAutoCountSpin->value();
double offset = 0;
double newPageHeight = locPageHeight;
double offset = 0.0;
double newPageHeight = currentPage->height();
 
if (value == 0)
return retval;
606,13 → 606,13
 
if (horizontalReferGroup->selectedId() == 1)
{
newPageHeight = locPageHeight - currentPage->Margins.Top - currentPage->Margins.Bottom;
newPageHeight = newPageHeight - currentPage->Margins.Top - currentPage->Margins.Bottom;
offset = currentPage->Margins.Top;
}
else if (horizontalReferGroup->selectedId() == 2)
else if (qRound(currentPage->guides.gy) != 0.0)
{
offset = gy;
newPageHeight = gh;
offset = currentPage->guides.gy;
newPageHeight = currentPage->guides.gh;
}
 
if (horizontalAutoGapSpin->value() > 0.0)
634,31 → 634,27
return retval;
}
 
void GuideManager::resetMarginsForPage()
void GuideManager::resetSelectionForPage()
{
locPageWidth = currentPage->width();
locPageHeight = currentPage->height();
int docSelectionCount = currentPage->doc()->m_Selection->count();
 
gx = gy = gw = gh = 0;
if (docSelectionCount == 0)
return;
currentPage->guides.gx = currentPage->guides.gy = currentPage->guides.gw = currentPage->guides.gh = 0.0;
 
// multiselection
if (docSelectionCount > 1)
{
double x, y;
m_Doc->m_Selection->getGroupRect(&x, &y, &gw, &gh);
gx = x - currentPage->xOffset();
gy = y - currentPage->yOffset();
m_Doc->m_Selection->getGroupRect(&x, &y, &currentPage->guides.gw, &currentPage->guides.gh);
currentPage->guides.gx = x - currentPage->xOffset();
currentPage->guides.gy = y - currentPage->yOffset();
}
// only one item selected
else if (docSelectionCount == 1)
{
PageItem *currItem = m_Doc->m_Selection->itemAt(0);
gx = currItem->xPos() - currentPage->xOffset();
gy = currItem->yPos() - currentPage->yOffset();
gw = currItem->width();
gh = currItem->height();
currentPage->guides.gx = currItem->xPos() - currentPage->xOffset();
currentPage->guides.gy = currItem->yPos() - currentPage->yOffset();
currentPage->guides.gw = currItem->width();
currentPage->guides.gh = currItem->height();
}
}
/branches/Version13x/Scribus/scribus/guidemanagercore.cpp
310,16 → 310,8
 
void GuideManagerCore::copy(GuideManagerCore *target)
{
target->addHorizontals(horizontalStdG, Standard);
target->addVerticals(verticalStdG, Standard);
target->addHorizontals(horizontalStdG, Auto);
target->addVerticals(verticalStdG, Auto);
target->setHorizontalAutoCount(m_horizontalAutoCount);
target->setVerticalAutoCount(m_verticalAutoCount);
target->setHorizontalAutoGap(m_horizontalAutoGap);
target->setVerticalAutoGap(m_verticalAutoGap);
target->setHorizontalAutoRefer(m_horizontalAutoRefer);
target->setVerticalAutoRefer(m_verticalAutoRefer);
copy(target, Standard);
copy(target, Auto);
}
 
void GuideManagerCore::copy(GuideManagerCore *target, GuideType type)
339,6 → 331,10
target->setVerticalAutoRefer(m_verticalAutoRefer);
target->addHorizontals(horizontalStdG, Auto);
target->addVerticals(verticalStdG, Auto);
target->gx = gx;
target->gy = gy;
target->gw = gw;
target->gh = gh;
break;
}
}
590,3 → 586,17
}
return retval;
}
 
QString GuideManagerIO::writeSelection(Page *page)
{
return QString("%1 %2 %3 %4").arg(page->guides.gx).arg(page->guides.gy).arg(page->guides.gw).arg(page->guides.gh);
}
 
void GuideManagerIO::readSelection(const QString guideString, Page *page)
{
QStringList gVal(QStringList::split(' ', guideString));
page->guides.gx = gVal[0].toDouble();
page->guides.gy = gVal[1].toDouble();
page->guides.gw = gVal[2].toDouble();
page->guides.gh = gVal[3].toDouble();
}
/branches/Version13x/Scribus/scribus/guidemanagercore.h
23,15 → 23,17
 
/*! \brief Core manipulation with the guides.
Basic idea:
- keep all guides operation here.
- guides will be handled "on the fly", no by modal dialog.
- 2 types of guides: Standard = created one by one. Auto = created by automatic division algorithms.
- guides are handled "on the fly", no by modal dialog.
- 2 types of guides: Standard = created one by one.
Auto = created by automatic division algorithms.
Automatic guides are kept by 2 ways: 1st its parameters (m_horizontalAutoCount etc.)
to setup the GUI and compute guides itself. 2nd the horizontalAutoG etc. set
with precomputed values from GUI actions for drawing.
- user can move only Stnadard ones
- Auto guides can be deleted only in manipulation dialog
- Auto guides are painted in different color / (propably) with diff. line.
 
Implementing of class Guide() as standalone entity looks great in object
design bit it's too slow */
\author Petr vanek <petr@scribus.info>
*/
class SCRIBUS_API GuideManagerCore
{
public:
98,6 → 100,12
//! \brief Properties for Auto guides remembrance. See GuideManager.
void setVerticalAutoRefer(int val) { m_verticalAutoRefer = val; };
 
/*! \brief Selection/group coordinates
It's used to simulate the original selection "freezed in time"
for parent page */
double gx, gy, gw, gh;
 
 
private:
UndoManager * const undoManager;
Page* m_page;
160,6 → 168,9
 
static QString writeHorizontalGuides(Page *page, GuideManagerCore::GuideType type);
static QString writeVerticalGuides(Page *page, GuideManagerCore::GuideType type);
 
static void readSelection(const QString guideString, Page *page);
static QString writeSelection(Page *page);
};
 
#endif
/branches/Version13x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
861,6 → 861,7
pg.setAttribute("AGverticalAutoCount", page->guides.verticalAutoCount());
pg.setAttribute("AGhorizontalAutoRefer", page->guides.horizontalAutoRefer());
pg.setAttribute("AGverticalAutoRefer", page->guides.verticalAutoRefer());
pg.setAttribute("AGSelection", GuideManagerIO::writeSelection(page));
dc->appendChild(pg);
}
}
/branches/Version13x/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
1006,6 → 1006,8
Apage,
GuideManagerCore::Standard,
pg.hasAttribute("NumHGuides"));
GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
}
if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
{
2721,6 → 2723,8
Apage,
GuideManagerCore::Standard,
pg.hasAttribute("NumHGuides"));
GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
}
if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
{
/branches/Version13x/Scribus/scribus/guidemanager.h
64,7 → 64,7
\warning Be careful with UI file guidemanagerbase.ui it uses ScrPaletteBase
as base class instead of QDialog. It should provide correct header file too.
 
\author Petr Vanek <petr@yarpen.cz>
\author Petr vanek <petr@scribus.info>
\author Alessandro Rimoldi
\author Franz Schmid
*/
167,13 → 167,6
is no selection on current page. */
void windowActivationChange(bool oldActive);
 
//! \brief width of the current page
double locPageWidth;
//! \brief height of the current page
double locPageHeight;
//! \brief position of the group of selected objects
double gx, gy, gw, gh;
 
/*! \brief Create automatic horizontal guides.
Calculates positions of the guides. */
Guides getAutoHorizontals();
182,10 → 175,11
Calculates positions of the guides. */
Guides getAutoVerticals();
 
/*! \brief Recalculate the margins and measurements for the current page.
/*! \brief Recalculate the selection position and measurements for the current page.
It's used for automatic guides position. It's called for every
page when is "apply to all pages" switched on */
void resetMarginsForPage();
selection GUI widgets change to handle selection change only
when needed. */
void resetSelectionForPage();
 
protected slots:
void addHorButton_clicked();