Separate pivot visibility and location options

This commit is contained in:
David Capello 2015-08-14 10:09:15 -03:00
parent 43606935f9
commit 75a743f141
10 changed files with 70 additions and 67 deletions

View File

@ -52,17 +52,16 @@
<value id="ALL_LAYERS" value="0" />
<value id="CURRENT_LAYER" value="1" />
</enum>
<enum id="PivotMode">
<value id="HIDDEN" value="0" />
<value id="NORTHWEST" value="1" />
<value id="NORTH" value="2" />
<value id="NORTHEAST" value="3" />
<value id="WEST" value="4" />
<value id="CENTER" value="5" />
<value id="EAST" value="6" />
<value id="SOUTHWEST" value="7" />
<value id="SOUTH" value="8" />
<value id="SOUTHEAST" value="9" />
<enum id="PivotPosition">
<value id="NORTHWEST" value="0" />
<value id="NORTH" value="1" />
<value id="NORTHEAST" value="2" />
<value id="WEST" value="3" />
<value id="CENTER" value="4" />
<value id="EAST" value="5" />
<value id="SOUTHWEST" value="6" />
<value id="SOUTH" value="7" />
<value id="SOUTHEAST" value="8" />
</enum>
</types>
@ -124,7 +123,8 @@
</section>
<section id="selection">
<option id="mode" type="app::tools::SelectionMode" default="app::tools::SelectionMode::DEFAULT" />
<option id="pivot" type="PivotMode" default="PivotMode::HIDDEN" />
<option id="pivot_visibility" type="bool" default="false" />
<option id="pivot_position" type="PivotPosition" default="PivotPosition::CENTER" />
<option id="opaque" type="bool" default="false" />
<option id="auto_opaque" type="bool" default="true" />
<option id="transparent_color" type="app::Color" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -381,16 +381,15 @@
<part id="ink_lock_alpha" x="160" y="160" w="16" h="16" />
<part id="selection_opaque" x="208" y="176" w="16" h="10" />
<part id="selection_masked" x="224" y="176" w="16" h="10" />
<part id="pivot_hidden" x="208" y="192" w="7" h="7" />
<part id="pivot_northwest" x="216" y="192" w="7" h="7" />
<part id="pivot_north" x="224" y="192" w="7" h="7" />
<part id="pivot_northeast" x="232" y="192" w="7" h="7" />
<part id="pivot_west" x="216" y="200" w="7" h="7" />
<part id="pivot_center" x="224" y="200" w="7" h="7" />
<part id="pivot_east" x="232" y="200" w="7" h="7" />
<part id="pivot_southwest" x="216" y="208" w="7" h="7" />
<part id="pivot_south" x="224" y="208" w="7" h="7" />
<part id="pivot_southeast" x="232" y="208" w="7" h="7" />
<part id="pivot_northwest" x="208" y="192" w="7" h="7" />
<part id="pivot_north" x="216" y="192" w="7" h="7" />
<part id="pivot_northeast" x="224" y="192" w="7" h="7" />
<part id="pivot_west" x="208" y="200" w="7" h="7" />
<part id="pivot_center" x="216" y="200" w="7" h="7" />
<part id="pivot_east" x="224" y="200" w="7" h="7" />
<part id="pivot_southwest" x="208" y="208" w="7" h="7" />
<part id="pivot_south" x="216" y="208" w="7" h="7" />
<part id="pivot_southeast" x="224" y="208" w="7" h="7" />
<part id="icon_rgb" x="0" y="256" w="16" h="16" />
<part id="icon_grayscale" x="16" y="256" w="16" h="16" />
<part id="icon_indexed" x="32" y="256" w="16" h="16" />

View File

@ -566,11 +566,11 @@ class ContextBar::PivotField : public ButtonSet {
public:
PivotField()
: ButtonSet(1) {
addItem(SkinTheme::instance()->parts.pivotHidden());
addItem(SkinTheme::instance()->parts.pivotCenter());
ItemChange.connect(Bind<void>(&PivotField::onPopup, this));
Preferences::instance().selection.pivot.AfterChange.connect(
Preferences::instance().selection.pivotPosition.AfterChange.connect(
Bind<void>(&PivotField::onPivotChange, this));
onPivotChange();
@ -584,7 +584,7 @@ private:
gfx::Rect bounds = getBounds();
Menu menu;
CheckBox hidden("Hidden pivot by default");
CheckBox visible("Display pivot by default");
HBox box;
ButtonSet buttonset(3);
buttonset.addItem(theme->parts.pivotNorthwest());
@ -598,27 +598,25 @@ private:
buttonset.addItem(theme->parts.pivotSoutheast());
box.addChild(&buttonset);
menu.addChild(&hidden);
menu.addChild(&visible);
menu.addChild(new MenuSeparator);
menu.addChild(&box);
app::gen::PivotMode mode = Preferences::instance().selection.pivot();
if (mode == app::gen::PivotMode::HIDDEN)
hidden.setSelected(true);
else {
buttonset.setSelectedItem(int(mode)-1);
}
bool isVisible = Preferences::instance().selection.pivotVisibility();
app::gen::PivotPosition pos = Preferences::instance().selection.pivotPosition();
visible.setSelected(isVisible);
buttonset.setSelectedItem(int(pos));
hidden.Click.connect(
[&hidden](Event&){
Preferences::instance().selection.pivot(app::gen::PivotMode::HIDDEN);
hidden.closeWindow();
visible.Click.connect(
[&visible](Event&){
Preferences::instance().selection.pivotVisibility(
visible.isSelected());
});
buttonset.ItemChange.connect(
[&buttonset](){
Preferences::instance().selection.pivot(app::gen::PivotMode(buttonset.selectedItem()+1));
buttonset.closeWindow();
Preferences::instance().selection.pivotPosition(
app::gen::PivotPosition(buttonset.selectedItem()));
});
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
@ -627,17 +625,16 @@ private:
void onPivotChange() {
SkinTheme* theme = SkinTheme::instance();
SkinPartPtr part;
switch (Preferences::instance().selection.pivot()) {
case app::gen::PivotMode::HIDDEN: part = theme->parts.pivotHidden(); break;
case app::gen::PivotMode::NORTHWEST: part = theme->parts.pivotNorthwest(); break;
case app::gen::PivotMode::NORTH: part = theme->parts.pivotNorth(); break;
case app::gen::PivotMode::NORTHEAST: part = theme->parts.pivotNortheast(); break;
case app::gen::PivotMode::WEST: part = theme->parts.pivotWest(); break;
case app::gen::PivotMode::CENTER: part = theme->parts.pivotCenter(); break;
case app::gen::PivotMode::EAST: part = theme->parts.pivotEast(); break;
case app::gen::PivotMode::SOUTHWEST: part = theme->parts.pivotSouthwest(); break;
case app::gen::PivotMode::SOUTH: part = theme->parts.pivotSouth(); break;
case app::gen::PivotMode::SOUTHEAST: part = theme->parts.pivotSoutheast(); break;
switch (Preferences::instance().selection.pivotPosition()) {
case app::gen::PivotPosition::NORTHWEST: part = theme->parts.pivotNorthwest(); break;
case app::gen::PivotPosition::NORTH: part = theme->parts.pivotNorth(); break;
case app::gen::PivotPosition::NORTHEAST: part = theme->parts.pivotNortheast(); break;
case app::gen::PivotPosition::WEST: part = theme->parts.pivotWest(); break;
case app::gen::PivotPosition::CENTER: part = theme->parts.pivotCenter(); break;
case app::gen::PivotPosition::EAST: part = theme->parts.pivotEast(); break;
case app::gen::PivotPosition::SOUTHWEST: part = theme->parts.pivotSouthwest(); break;
case app::gen::PivotPosition::SOUTH: part = theme->parts.pivotSouth(); break;
case app::gen::PivotPosition::SOUTHEAST: part = theme->parts.pivotSoutheast(); break;
}
if (part)
getItem(0)->setIcon(part);

View File

@ -26,30 +26,30 @@ void set_pivot_from_preferences(gfx::Transformation& t)
gfx::PointT<double> se(corners[gfx::Transformation::Corners::RIGHT_BOTTOM]);
gfx::PointT<double> pivotPos((nw + se) / 2);
app::gen::PivotMode pivotMode = Preferences::instance().selection.pivot();
switch (pivotMode) {
case app::gen::PivotMode::NORTHWEST:
app::gen::PivotPosition pivot = Preferences::instance().selection.pivotPosition();
switch (pivot) {
case app::gen::PivotPosition::NORTHWEST:
pivotPos = nw;
break;
case app::gen::PivotMode::NORTH:
case app::gen::PivotPosition::NORTH:
pivotPos = (nw + ne) / 2.0;
break;
case app::gen::PivotMode::NORTHEAST:
case app::gen::PivotPosition::NORTHEAST:
pivotPos = ne;
break;
case app::gen::PivotMode::WEST:
case app::gen::PivotPosition::WEST:
pivotPos = (nw + sw) / 2.0;
break;
case app::gen::PivotMode::EAST:
case app::gen::PivotPosition::EAST:
pivotPos = (ne + se) / 2.0;
break;
case app::gen::PivotMode::SOUTHWEST:
case app::gen::PivotPosition::SOUTHWEST:
pivotPos = sw;
break;
case app::gen::PivotMode::SOUTH:
case app::gen::PivotPosition::SOUTH:
pivotPos = (sw + se) / 2.0;
break;
case app::gen::PivotMode::SOUTHEAST:
case app::gen::PivotPosition::SOUTHEAST:
pivotPos = se;
break;
}

View File

@ -76,8 +76,11 @@ PixelsMovement::PixelsMovement(
m_initialMask = new Mask(*mask);
m_currentMask = new Mask(*mask);
m_pivotConn =
Preferences::instance().selection.pivot.AfterChange.connect(
m_pivotVisConn =
Preferences::instance().selection.pivotVisibility.AfterChange.connect(
Bind<void>(&PixelsMovement::onPivotChange, this));
m_pivotPosConn =
Preferences::instance().selection.pivotPosition.AfterChange.connect(
Bind<void>(&PixelsMovement::onPivotChange, this));
m_rotAlgoConn =
Preferences::instance().selection.rotationAlgorithm.AfterChange.connect(

View File

@ -122,7 +122,8 @@ namespace app {
Mask* m_currentMask;
bool m_opaque;
color_t m_maskColor;
ScopedConnection m_pivotConn;
ScopedConnection m_pivotVisConn;
ScopedConnection m_pivotPosConn;
ScopedConnection m_rotAlgoConn;
};

View File

@ -94,8 +94,11 @@ void StandbyState::onEnterState(Editor* editor)
{
editor->setDecorator(m_decorator);
m_pivotConn =
Preferences::instance().selection.pivot.AfterChange.connect(
m_pivotVisConn =
Preferences::instance().selection.pivotVisibility.AfterChange.connect(
Bind<void>(&StandbyState::onPivotChange, this, editor));
m_pivotPosConn =
Preferences::instance().selection.pivotPosition.AfterChange.connect(
Bind<void>(&StandbyState::onPivotChange, this, editor));
}

View File

@ -70,7 +70,8 @@ namespace app {
void onPivotChange(Editor* editor);
Decorator* m_decorator;
ScopedConnection m_pivotConn;
ScopedConnection m_pivotVisConn;
ScopedConnection m_pivotPosConn;
};
} // namespace app

View File

@ -256,8 +256,7 @@ void TransformHandles::adjustHandle(int& x, int& y, int handle_w, int handle_h,
bool TransformHandles::visiblePivot(fixmath::fixed angle) const
{
return (Preferences::instance().selection.pivot() != app::gen::PivotMode::HIDDEN ||
angle != 0);
return (Preferences::instance().selection.pivotVisibility() || angle != 0);
}
} // namespace app