Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply the patch by dawoodalbadi for aligning images inside of the frame #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions scribus/ui/propertiespalette_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ PropertiesPalette_Image::PropertiesPalette_Image( QWidget* parent) : QWidget(par
connect(renderIntent , SIGNAL(activated(int)) , this, SLOT(handleIntent()));
connect(compressionMethod , SIGNAL(activated(int)) , this, SLOT(handleCompressionMethod()));
connect(compressionQuality , SIGNAL(activated(int)) , this, SLOT(handleCompressionQuality()));
connect(alignvertical , SIGNAL(currentIndexChanged(int)) , this, SLOT(alignImageVertical(int)));
connect(alignhorozintal , SIGNAL(currentIndexChanged(int)), this, SLOT(alignImageHorozintal(int)));
}

void PropertiesPalette_Image::updateSpinBoxConstants()
Expand Down Expand Up @@ -902,4 +904,59 @@ void PropertiesPalette_Image::spinboxFinishUserAction()
}
}

void PropertiesPalette_Image::alignImageVertical(int idx){
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;

if ((m_haveDoc) && (m_haveItem) && (m_item->asImageFrame()))
{
double newY;
double imageHeight = m_item->pixm.height() * m_item->imageYScale() * m_item->pixm.imgInfo.lowResScale;
double frameHeight= m_item->height();

switch (idx)
{
case 1:
newY = 0;
break;
case 2:
newY = (frameHeight - imageHeight) / 2.0;
break;
case 3:
newY = frameHeight - imageHeight;
break;
default:
newY = m_item->imageYOffset(); //do nothing
break;
}
m_doc->itemSelection_SetImageOffset(m_item->imageXOffset(), newY / m_item->imageYScale());
}
}

void PropertiesPalette_Image::alignImageHorozintal(int idx) {
if (!m_ScMW || m_ScMW->scriptIsRunning())
return;

if ((m_haveDoc) && (m_haveItem) && (m_item->asImageFrame()))
{
double newX;
double imageWidth = m_item->pixm.width() * m_item->imageXScale() * m_item->pixm.imgInfo.lowResScale;
double frameWidth = m_item->width();
switch (idx)
{
case 1:
newX = 0;
break;
case 2:
newX = (frameWidth - imageWidth) / 2.0;
break;
case 3:
newX = frameWidth - imageWidth;
break;
default:
newX = m_item->imageXOffset(); // do nothing
break;
}
m_doc->itemSelection_SetImageOffset(newX / m_item->imageXScale(), m_item->imageYOffset());
}
}
2 changes: 2 additions & 0 deletions scribus/ui/propertiespalette_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ private slots:

void handleImageEffects();
void handleExtImgProperties();
void alignImageVertical(int);
void alignImageHorozintal(int);

signals:
void UpdtGui(int);
Expand Down
131 changes: 106 additions & 25 deletions scribus/ui/propertiespalette_imagebase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>286</width>
<height>617</height>
<width>297</width>
<height>690</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,7 +17,16 @@
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
Expand Down Expand Up @@ -63,13 +72,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="yposImgLabel">
<property name="text">
<string>Y-Pos:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="ScrSpinBox" name="imageYOffsetSpinBox">
<property name="sizePolicy">
Expand All @@ -80,6 +82,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="yposImgLabel">
<property name="text">
<string>Y-Pos:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="ScrSpinBox" name="imagePageNumber">
<property name="specialValueText">
Expand All @@ -89,6 +98,77 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="alignmentGroupBox">
<property name="title">
<string>Alignment</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Horizontal</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vertical</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="alignhorozintal">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Center</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="alignvertical">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Top</string>
</property>
</item>
<item>
<property name="text">
<string>Middle</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="scalingGroupBox">
<property name="title">
Expand Down Expand Up @@ -200,17 +280,17 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="cbProportional">
<item row="7" column="0">
<widget class="QRadioButton" name="frameScale">
<property name="text">
<string>Proportional</string>
<string>To Frame Size</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QRadioButton" name="frameScale">
<item row="8" column="0">
<widget class="QCheckBox" name="cbProportional">
<property name="text">
<string>To Frame Size</string>
<string>Proportional</string>
</property>
</widget>
</item>
Expand All @@ -223,13 +303,6 @@
<string>Color Management</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="inputProfLabel">
<property name="text">
<string>Input Profile</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="inputProfiles">
<property name="sizePolicy">
Expand All @@ -250,6 +323,13 @@
<item row="1" column="1">
<widget class="QComboBox" name="renderIntent"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="inputProfLabel">
<property name="text">
<string>Input Profile</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -326,6 +406,9 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -365,8 +448,6 @@
<tabstop>imgDpiY</tabstop>
<tabstop>keepImageWHRatioButton</tabstop>
<tabstop>keepImageDPIRatioButton</tabstop>
<tabstop>frameScale</tabstop>
<tabstop>cbProportional</tabstop>
<tabstop>inputProfiles</tabstop>
<tabstop>renderIntent</tabstop>
<tabstop>compressionMethod</tabstop>
Expand Down