Use enums for on-preview geometry
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <assert.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "controllines.h"
|
#include "controllines.h"
|
||||||
@@ -27,6 +28,53 @@
|
|||||||
|
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
|
|
||||||
|
enum GeometryIndex {
|
||||||
|
MO_CANVAS,
|
||||||
|
MO_OBJECT_COUNT,
|
||||||
|
|
||||||
|
VISIBLE_OBJECT_COUNT = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offsets for mouse-over geometry that can be compared to the mouse-over object
|
||||||
|
* ID modded with the control line object count.
|
||||||
|
*/
|
||||||
|
enum GeometryOffset {
|
||||||
|
OFFSET_LINE = (MO_OBJECT_COUNT + ::ControlLine::LINE) % ::ControlLine::OBJECT_COUNT,
|
||||||
|
OFFSET_ICON = (MO_OBJECT_COUNT + ::ControlLine::ICON) % ::ControlLine::OBJECT_COUNT,
|
||||||
|
OFFSET_BEGIN = (MO_OBJECT_COUNT + ::ControlLine::BEGIN) % ::ControlLine::OBJECT_COUNT,
|
||||||
|
OFFSET_END = (MO_OBJECT_COUNT + ::ControlLine::END) % ::ControlLine::OBJECT_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the object matches the offset.
|
||||||
|
*/
|
||||||
|
constexpr bool checkOffset(int object_id, enum GeometryOffset offset)
|
||||||
|
{
|
||||||
|
return object_id % ::ControlLine::OBJECT_COUNT == offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a control line mouse-over geometry ID to the visible geometry ID.
|
||||||
|
*/
|
||||||
|
constexpr int mouseOverIdToVisibleId(int mouse_over_id)
|
||||||
|
{
|
||||||
|
return mouse_over_id - MO_OBJECT_COUNT + VISIBLE_OBJECT_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a control line mouse-over geometry ID to the control line ID.
|
||||||
|
*/
|
||||||
|
constexpr int mouseOverIdToLineId(int mouse_over_id)
|
||||||
|
{
|
||||||
|
return (mouse_over_id - MO_OBJECT_COUNT) / ::ControlLine::OBJECT_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
::ControlLine::~ControlLine() = default;
|
::ControlLine::~ControlLine() = default;
|
||||||
|
|
||||||
ControlLineManager::ControlLineManager():
|
ControlLineManager::ControlLineManager():
|
||||||
@@ -96,8 +144,8 @@ bool ControlLineManager::button1Pressed(int modifierKey)
|
|||||||
|
|
||||||
const int object = dataProvider->getObject();
|
const int object = dataProvider->getObject();
|
||||||
|
|
||||||
if (object > 0) { // A control line.
|
if (object >= MO_OBJECT_COUNT) { // A control line.
|
||||||
if (object % ::ControlLine::OBJ_COUNT == 2) { // Icon.
|
if (checkOffset(object, OFFSET_ICON)) { // Icon.
|
||||||
action = Action::PICKING;
|
action = Action::PICKING;
|
||||||
} else {
|
} else {
|
||||||
selected_object = object;
|
selected_object = object;
|
||||||
@@ -109,7 +157,7 @@ bool ControlLineManager::button1Pressed(int modifierKey)
|
|||||||
}
|
}
|
||||||
addLine(dataProvider->posImage, dataProvider->posImage);
|
addLine(dataProvider->posImage, dataProvider->posImage);
|
||||||
drawing_line = true;
|
drawing_line = true;
|
||||||
selected_object = mouseOverGeometry.size() - 1; // Select endpoint.
|
selected_object = mouseOverGeometry.size() - ::ControlLine::OBJECT_COUNT + ::ControlLine::END; // Select endpoint.
|
||||||
action = Action::DRAGGING;
|
action = Action::DRAGGING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +168,7 @@ bool ControlLineManager::button1Released(void)
|
|||||||
{
|
{
|
||||||
action = Action::NONE;
|
action = Action::NONE;
|
||||||
|
|
||||||
if (selected_object > 0) {
|
if (selected_object >= MO_OBJECT_COUNT) {
|
||||||
mouseOverGeometry[selected_object]->state = Geometry::NORMAL;
|
mouseOverGeometry[selected_object]->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +185,7 @@ bool ControlLineManager::button3Pressed(int modifierKey)
|
|||||||
|
|
||||||
action = Action::NONE;
|
action = Action::NONE;
|
||||||
|
|
||||||
if (!provider || provider->getObject() < 1) {
|
if (!provider || provider->getObject() < MO_OBJECT_COUNT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,14 +203,13 @@ bool ControlLineManager::pick1(bool picked)
|
|||||||
|
|
||||||
EditDataProvider* provider = getEditProvider();
|
EditDataProvider* provider = getEditProvider();
|
||||||
|
|
||||||
if (!provider || provider->getObject() % ::ControlLine::OBJ_COUNT != 2) {
|
if (!provider || !checkOffset(provider->getObject(), OFFSET_ICON)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change line type.
|
// Change line type.
|
||||||
int object_id = provider->getObject();
|
int object_id = provider->getObject();
|
||||||
::ControlLine& line =
|
::ControlLine& line = *control_lines[mouseOverIdToLineId(object_id)];
|
||||||
*control_lines[(object_id - 1) / ::ControlLine::OBJ_COUNT];
|
|
||||||
|
|
||||||
if (line.type == rtengine::ControlLine::HORIZONTAL) {
|
if (line.type == rtengine::ControlLine::HORIZONTAL) {
|
||||||
line.icon = line.icon_v;
|
line.icon = line.icon_v;
|
||||||
@@ -172,7 +219,7 @@ bool ControlLineManager::pick1(bool picked)
|
|||||||
line.type = rtengine::ControlLine::HORIZONTAL;
|
line.type = rtengine::ControlLine::HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
visibleGeometry[object_id - 1] = line.icon.get();
|
visibleGeometry[mouseOverIdToVisibleId(object_id)] = line.icon.get();
|
||||||
|
|
||||||
edited = true;
|
edited = true;
|
||||||
callbacks->lineChanged();
|
callbacks->lineChanged();
|
||||||
@@ -194,7 +241,7 @@ bool ControlLineManager::pick3(bool picked)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeLine((provider->getObject() - 1) / ::ControlLine::OBJ_COUNT);
|
removeLine(mouseOverIdToLineId(provider->getObject()));
|
||||||
prev_obj = -1;
|
prev_obj = -1;
|
||||||
selected_object = -1;
|
selected_object = -1;
|
||||||
return true;
|
return true;
|
||||||
@@ -208,28 +255,28 @@ bool ControlLineManager::drag1(int modifierKey)
|
|||||||
|
|
||||||
EditDataProvider* provider = getEditProvider();
|
EditDataProvider* provider = getEditProvider();
|
||||||
|
|
||||||
if (!provider || selected_object < 1) {
|
if (!provider || selected_object < MO_OBJECT_COUNT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ControlLine& control_line =
|
::ControlLine& control_line =
|
||||||
*control_lines[(selected_object - 1) / ::ControlLine::OBJ_COUNT];
|
*control_lines[mouseOverIdToLineId(selected_object)];
|
||||||
// 0 == end, 1 == line, 2 == icon, 3 == begin
|
// 0 == end, 1 == line, 2 == icon, 3 == begin
|
||||||
int component = selected_object % ::ControlLine::OBJ_COUNT;
|
int component = selected_object % ::ControlLine::OBJECT_COUNT;
|
||||||
Coord mouse = provider->posImage + provider->deltaImage;
|
Coord mouse = provider->posImage + provider->deltaImage;
|
||||||
Coord delta = provider->deltaImage - drag_delta;
|
Coord delta = provider->deltaImage - drag_delta;
|
||||||
int ih, iw;
|
int ih, iw;
|
||||||
provider->getImageSize(iw, ih);
|
provider->getImageSize(iw, ih);
|
||||||
|
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case (0): // end
|
case (OFFSET_END): // end
|
||||||
control_line.end->center = mouse;
|
control_line.end->center = mouse;
|
||||||
control_line.end->center.clip(iw, ih);
|
control_line.end->center.clip(iw, ih);
|
||||||
control_line.line->end = control_line.end->center;
|
control_line.line->end = control_line.end->center;
|
||||||
control_line.end->state = Geometry::DRAGGED;
|
control_line.end->state = Geometry::DRAGGED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (1): { // line
|
case (OFFSET_LINE): { // line
|
||||||
// Constrain delta so the end stays above the image.
|
// Constrain delta so the end stays above the image.
|
||||||
Coord new_delta = control_line.end->center + delta;
|
Coord new_delta = control_line.end->center + delta;
|
||||||
new_delta.clip(iw, ih);
|
new_delta.clip(iw, ih);
|
||||||
@@ -248,7 +295,7 @@ bool ControlLineManager::drag1(int modifierKey)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case (3): // begin
|
case (OFFSET_BEGIN): // begin
|
||||||
control_line.begin->center = mouse;
|
control_line.begin->center = mouse;
|
||||||
control_line.begin->center.clip(iw, ih);
|
control_line.begin->center.clip(iw, ih);
|
||||||
control_line.line->begin = control_line.begin->center;
|
control_line.line->begin = control_line.begin->center;
|
||||||
@@ -274,11 +321,11 @@ void ControlLineManager::releaseEdit(void)
|
|||||||
{
|
{
|
||||||
action = Action::NONE;
|
action = Action::NONE;
|
||||||
|
|
||||||
if (selected_object > 0) {
|
if (selected_object >= MO_OBJECT_COUNT) {
|
||||||
mouseOverGeometry[selected_object]->state = Geometry::NORMAL;
|
mouseOverGeometry[selected_object]->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
if (prev_obj > 0) {
|
if (prev_obj >= MO_OBJECT_COUNT) {
|
||||||
visibleGeometry[prev_obj - 1]->state = Geometry::NORMAL;
|
visibleGeometry[mouseOverIdToVisibleId(prev_obj)]->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
edited = true;
|
edited = true;
|
||||||
@@ -307,7 +354,7 @@ bool ControlLineManager::mouseOver(int modifierKey)
|
|||||||
|
|
||||||
int cur_obj = provider->getObject();
|
int cur_obj = provider->getObject();
|
||||||
|
|
||||||
if (cur_obj == 0) { // Canvas
|
if (cur_obj == MO_CANVAS) { // Canvas
|
||||||
if (draw_mode && modifierKey & GDK_CONTROL_MASK) {
|
if (draw_mode && modifierKey & GDK_CONTROL_MASK) {
|
||||||
cursor = CSCrosshair;
|
cursor = CSCrosshair;
|
||||||
} else {
|
} else {
|
||||||
@@ -315,16 +362,16 @@ bool ControlLineManager::mouseOver(int modifierKey)
|
|||||||
}
|
}
|
||||||
} else if (cur_obj < 0) { // Nothing
|
} else if (cur_obj < 0) { // Nothing
|
||||||
cursor = CSArrow;
|
cursor = CSArrow;
|
||||||
} else if (cur_obj % ::ControlLine::OBJ_COUNT == 2) { // Icon
|
} else if (checkOffset(cur_obj, OFFSET_ICON)) { // Icon
|
||||||
visibleGeometry[cur_obj - 1]->state = Geometry::PRELIGHT;
|
visibleGeometry[mouseOverIdToVisibleId(cur_obj)]->state = Geometry::PRELIGHT;
|
||||||
cursor = CSArrow;
|
cursor = CSArrow;
|
||||||
} else { // Object
|
} else { // Object
|
||||||
visibleGeometry[cur_obj - 1]->state = Geometry::PRELIGHT;
|
visibleGeometry[mouseOverIdToVisibleId(cur_obj)]->state = Geometry::PRELIGHT;
|
||||||
cursor = CSMove2D;
|
cursor = CSMove2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_obj != cur_obj && prev_obj > 0) {
|
if (prev_obj != cur_obj && prev_obj >= MO_OBJECT_COUNT) {
|
||||||
visibleGeometry[prev_obj - 1]->state = Geometry::NORMAL;
|
visibleGeometry[mouseOverIdToVisibleId(prev_obj)]->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_obj = cur_obj;
|
prev_obj = cur_obj;
|
||||||
@@ -418,14 +465,29 @@ void ControlLineManager::addLine(Coord begin, Coord end,
|
|||||||
control_line->line = std::move(line);
|
control_line->line = std::move(line);
|
||||||
control_line->type = type;
|
control_line->type = type;
|
||||||
|
|
||||||
|
auto assertEqual = [](size_t a, int b) {
|
||||||
|
assert(b >= 0);
|
||||||
|
assert(a == static_cast<size_t>(b));
|
||||||
|
};
|
||||||
|
|
||||||
|
const int base_visible_offset = VISIBLE_OBJECT_COUNT + ::ControlLine::OBJECT_COUNT * control_lines.size();
|
||||||
|
assertEqual(visibleGeometry.size(), base_visible_offset + ::ControlLine::LINE);
|
||||||
EditSubscriber::visibleGeometry.push_back(control_line->line.get());
|
EditSubscriber::visibleGeometry.push_back(control_line->line.get());
|
||||||
|
assertEqual(visibleGeometry.size(), base_visible_offset + ::ControlLine::ICON);
|
||||||
EditSubscriber::visibleGeometry.push_back(control_line->icon.get());
|
EditSubscriber::visibleGeometry.push_back(control_line->icon.get());
|
||||||
|
assertEqual(visibleGeometry.size(), base_visible_offset + ::ControlLine::BEGIN);
|
||||||
EditSubscriber::visibleGeometry.push_back(control_line->begin.get());
|
EditSubscriber::visibleGeometry.push_back(control_line->begin.get());
|
||||||
|
assertEqual(visibleGeometry.size(), base_visible_offset + ::ControlLine::END);
|
||||||
EditSubscriber::visibleGeometry.push_back(control_line->end.get());
|
EditSubscriber::visibleGeometry.push_back(control_line->end.get());
|
||||||
|
|
||||||
|
const int base_mo_count = MO_OBJECT_COUNT + ::ControlLine::OBJECT_COUNT * control_lines.size();
|
||||||
|
assertEqual(mouseOverGeometry.size(), base_mo_count + ::ControlLine::LINE);
|
||||||
EditSubscriber::mouseOverGeometry.push_back(control_line->line.get());
|
EditSubscriber::mouseOverGeometry.push_back(control_line->line.get());
|
||||||
|
assertEqual(mouseOverGeometry.size(), base_mo_count + ::ControlLine::ICON);
|
||||||
EditSubscriber::mouseOverGeometry.push_back(control_line->icon.get());
|
EditSubscriber::mouseOverGeometry.push_back(control_line->icon.get());
|
||||||
|
assertEqual(mouseOverGeometry.size(), base_mo_count + ::ControlLine::BEGIN);
|
||||||
EditSubscriber::mouseOverGeometry.push_back(control_line->begin.get());
|
EditSubscriber::mouseOverGeometry.push_back(control_line->begin.get());
|
||||||
|
assertEqual(mouseOverGeometry.size(), base_mo_count + ::ControlLine::END);
|
||||||
EditSubscriber::mouseOverGeometry.push_back(control_line->end.get());
|
EditSubscriber::mouseOverGeometry.push_back(control_line->end.get());
|
||||||
|
|
||||||
control_lines.push_back(std::move(control_line));
|
control_lines.push_back(std::move(control_line));
|
||||||
@@ -433,7 +495,7 @@ void ControlLineManager::addLine(Coord begin, Coord end,
|
|||||||
|
|
||||||
void ControlLineManager::autoSetLineType(int object_id)
|
void ControlLineManager::autoSetLineType(int object_id)
|
||||||
{
|
{
|
||||||
int line_id = (object_id - 1) / ::ControlLine::OBJ_COUNT;
|
int line_id = mouseOverIdToLineId(object_id);
|
||||||
::ControlLine& line = *control_lines[line_id];
|
::ControlLine& line = *control_lines[line_id];
|
||||||
|
|
||||||
int dx = line.begin->center.x - line.end->center.x;
|
int dx = line.begin->center.x - line.end->center.x;
|
||||||
@@ -461,7 +523,8 @@ void ControlLineManager::autoSetLineType(int object_id)
|
|||||||
if (type != line.type) { // Need to update line type.
|
if (type != line.type) { // Need to update line type.
|
||||||
line.type = type;
|
line.type = type;
|
||||||
line.icon = icon;
|
line.icon = icon;
|
||||||
visibleGeometry[line_id * ::ControlLine::OBJ_COUNT + 1] =
|
visibleGeometry[line_id * ::ControlLine::OBJECT_COUNT
|
||||||
|
+ VISIBLE_OBJECT_COUNT + ::ControlLine::ICON] =
|
||||||
line.icon.get();
|
line.icon.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,7 +532,7 @@ void ControlLineManager::autoSetLineType(int object_id)
|
|||||||
void ControlLineManager::removeAll(void)
|
void ControlLineManager::removeAll(void)
|
||||||
{
|
{
|
||||||
visibleGeometry.clear();
|
visibleGeometry.clear();
|
||||||
mouseOverGeometry.erase(mouseOverGeometry.begin() + 1,
|
mouseOverGeometry.erase(mouseOverGeometry.begin() + MO_OBJECT_COUNT,
|
||||||
mouseOverGeometry.end());
|
mouseOverGeometry.end());
|
||||||
control_lines.clear();
|
control_lines.clear();
|
||||||
prev_obj = -1;
|
prev_obj = -1;
|
||||||
@@ -485,14 +548,13 @@ void ControlLineManager::removeLine(size_t line_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
visibleGeometry.erase(
|
visibleGeometry.erase(
|
||||||
visibleGeometry.begin() + ::ControlLine::OBJ_COUNT * line_id,
|
visibleGeometry.begin() + ::ControlLine::OBJECT_COUNT * line_id + VISIBLE_OBJECT_COUNT,
|
||||||
visibleGeometry.begin() + ::ControlLine::OBJ_COUNT * line_id
|
visibleGeometry.begin() + ::ControlLine::OBJECT_COUNT * line_id + VISIBLE_OBJECT_COUNT
|
||||||
+ ::ControlLine::OBJ_COUNT
|
+ ::ControlLine::OBJECT_COUNT
|
||||||
);
|
);
|
||||||
mouseOverGeometry.erase(
|
mouseOverGeometry.erase(
|
||||||
mouseOverGeometry.begin() + ::ControlLine::OBJ_COUNT * line_id + 1,
|
mouseOverGeometry.begin() + ::ControlLine::OBJECT_COUNT * line_id + MO_OBJECT_COUNT,
|
||||||
mouseOverGeometry.begin() + ::ControlLine::OBJ_COUNT * line_id
|
mouseOverGeometry.begin() + ::ControlLine::OBJECT_COUNT * line_id + MO_OBJECT_COUNT + ::ControlLine::OBJECT_COUNT
|
||||||
+ ::ControlLine::OBJ_COUNT + 1
|
|
||||||
);
|
);
|
||||||
control_lines.erase(control_lines.begin() + line_id);
|
control_lines.erase(control_lines.begin() + line_id);
|
||||||
|
|
||||||
|
@@ -30,7 +30,14 @@ class Rectangle;
|
|||||||
class RTSurface;
|
class RTSurface;
|
||||||
|
|
||||||
struct ControlLine {
|
struct ControlLine {
|
||||||
static constexpr int OBJ_COUNT = 4;
|
enum ObjectIndex {
|
||||||
|
LINE,
|
||||||
|
ICON,
|
||||||
|
BEGIN,
|
||||||
|
END,
|
||||||
|
OBJECT_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
std::unique_ptr<Line> line;
|
std::unique_ptr<Line> line;
|
||||||
std::shared_ptr<OPIcon> icon;
|
std::shared_ptr<OPIcon> icon;
|
||||||
std::shared_ptr<OPIcon> icon_h, icon_v;
|
std::shared_ptr<OPIcon> icon_h, icon_v;
|
||||||
|
@@ -12,6 +12,14 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
|
enum GeometryIndex {
|
||||||
|
H_LINE,
|
||||||
|
V_LINE,
|
||||||
|
FEATHER_LINE_1,
|
||||||
|
FEATHER_LINE_2,
|
||||||
|
CENTER_CIRCLE,
|
||||||
|
};
|
||||||
|
|
||||||
Gradient::Gradient () : FoldableToolPanel(this, "gradient", M("TP_GRADIENT_LABEL"), false, true), EditSubscriber(ET_OBJECTS), lastObject(-1), draggedPointOldAngle(-1000.)
|
Gradient::Gradient () : FoldableToolPanel(this, "gradient", M("TP_GRADIENT_LABEL"), false, true), EditSubscriber(ET_OBJECTS), lastObject(-1), draggedPointOldAngle(-1000.)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -191,24 +199,24 @@ void Gradient::updateGeometry(const int centerX, const int centerY, const double
|
|||||||
};
|
};
|
||||||
|
|
||||||
// update horizontal line
|
// update horizontal line
|
||||||
updateLine (visibleGeometry.at(0), 1500., 0., 180.);
|
updateLine (visibleGeometry.at(H_LINE), 1500., 0., 180.);
|
||||||
updateLine (mouseOverGeometry.at(0), 1500., 0., 180.);
|
updateLine (mouseOverGeometry.at(H_LINE), 1500., 0., 180.);
|
||||||
|
|
||||||
// update vertical line
|
// update vertical line
|
||||||
updateLine (visibleGeometry.at(1), 700., 90., 270.);
|
updateLine (visibleGeometry.at(V_LINE), 700., 90., 270.);
|
||||||
updateLine (mouseOverGeometry.at(1), 700., 90., 270.);
|
updateLine (mouseOverGeometry.at(V_LINE), 700., 90., 270.);
|
||||||
|
|
||||||
// update upper feather line
|
// update upper feather line
|
||||||
updateLineWithDecay (visibleGeometry.at(2), 350., 270.);
|
updateLineWithDecay (visibleGeometry.at(FEATHER_LINE_1), 350., 270.);
|
||||||
updateLineWithDecay (mouseOverGeometry.at(2), 350., 270.);
|
updateLineWithDecay (mouseOverGeometry.at(FEATHER_LINE_1), 350., 270.);
|
||||||
|
|
||||||
// update lower feather line
|
// update lower feather line
|
||||||
updateLineWithDecay (visibleGeometry.at(3), 350., 90.);
|
updateLineWithDecay (visibleGeometry.at(FEATHER_LINE_2), 350., 90.);
|
||||||
updateLineWithDecay (mouseOverGeometry.at(3), 350., 90.);
|
updateLineWithDecay (mouseOverGeometry.at(FEATHER_LINE_2), 350., 90.);
|
||||||
|
|
||||||
// update circle's position
|
// update circle's position
|
||||||
updateCircle (visibleGeometry.at(4));
|
updateCircle (visibleGeometry.at(CENTER_CIRCLE));
|
||||||
updateCircle (mouseOverGeometry.at(4));
|
updateCircle (mouseOverGeometry.at(CENTER_CIRCLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gradient::write (ProcParams* pp, ParamsEdited* pedited)
|
void Gradient::write (ProcParams* pp, ParamsEdited* pedited)
|
||||||
@@ -333,12 +341,12 @@ void Gradient::editToggled ()
|
|||||||
CursorShape Gradient::getCursor(int objectID, int xPos, int yPos) const
|
CursorShape Gradient::getCursor(int objectID, int xPos, int yPos) const
|
||||||
{
|
{
|
||||||
switch (objectID) {
|
switch (objectID) {
|
||||||
case (0):
|
case (H_LINE):
|
||||||
case (1):
|
case (V_LINE):
|
||||||
return CSMoveRotate;
|
return CSMoveRotate;
|
||||||
|
|
||||||
case (2):
|
case (FEATHER_LINE_1):
|
||||||
case (3): {
|
case (FEATHER_LINE_2): {
|
||||||
int angle = degree->getIntValue();
|
int angle = degree->getIntValue();
|
||||||
|
|
||||||
if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) {
|
if (angle < -135 || (angle >= -45 && angle <= 45) || angle > 135) {
|
||||||
@@ -348,7 +356,7 @@ CursorShape Gradient::getCursor(int objectID, int xPos, int yPos) const
|
|||||||
return CSMove1DH;
|
return CSMove1DH;
|
||||||
}
|
}
|
||||||
|
|
||||||
case (4):
|
case (CENTER_CIRCLE):
|
||||||
return CSMove2D;
|
return CSMove2D;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -362,18 +370,18 @@ bool Gradient::mouseOver(int modifierKey)
|
|||||||
|
|
||||||
if (editProvider && editProvider->getObject() != lastObject) {
|
if (editProvider && editProvider->getObject() != lastObject) {
|
||||||
if (lastObject > -1) {
|
if (lastObject > -1) {
|
||||||
if (lastObject == 2 || lastObject == 3) {
|
if (lastObject == FEATHER_LINE_1 || lastObject == FEATHER_LINE_2) {
|
||||||
EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_1)->state = Geometry::NORMAL;
|
||||||
EditSubscriber::visibleGeometry.at(3)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_2)->state = Geometry::NORMAL;
|
||||||
} else {
|
} else {
|
||||||
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editProvider->getObject() > -1) {
|
if (editProvider->getObject() > -1) {
|
||||||
if (editProvider->getObject() == 2 || editProvider->getObject() == 3) {
|
if (editProvider->getObject() == FEATHER_LINE_1 || editProvider->getObject() == FEATHER_LINE_2) {
|
||||||
EditSubscriber::visibleGeometry.at(2)->state = Geometry::PRELIGHT;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_1)->state = Geometry::PRELIGHT;
|
||||||
EditSubscriber::visibleGeometry.at(3)->state = Geometry::PRELIGHT;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_2)->state = Geometry::PRELIGHT;
|
||||||
} else {
|
} else {
|
||||||
EditSubscriber::visibleGeometry.at(editProvider->getObject())->state = Geometry::PRELIGHT;
|
EditSubscriber::visibleGeometry.at(editProvider->getObject())->state = Geometry::PRELIGHT;
|
||||||
}
|
}
|
||||||
@@ -415,7 +423,7 @@ bool Gradient::button1Pressed(int modifierKey)
|
|||||||
//printf("\ndraggedPointOldAngle=%.3f\n\n", draggedPointOldAngle);
|
//printf("\ndraggedPointOldAngle=%.3f\n\n", draggedPointOldAngle);
|
||||||
draggedPointAdjusterAngle = degree->getValue();
|
draggedPointAdjusterAngle = degree->getValue();
|
||||||
|
|
||||||
if (lastObject == 2 || lastObject == 3) {
|
if (lastObject == FEATHER_LINE_1 || lastObject == FEATHER_LINE_2) {
|
||||||
// Dragging a line to change the angle
|
// Dragging a line to change the angle
|
||||||
PolarCoord draggedPoint;
|
PolarCoord draggedPoint;
|
||||||
rtengine::Coord currPos;
|
rtengine::Coord currPos;
|
||||||
@@ -431,7 +439,7 @@ bool Gradient::button1Pressed(int modifierKey)
|
|||||||
// compute the projected value of the dragged point
|
// compute the projected value of the dragged point
|
||||||
draggedFeatherOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI);
|
draggedFeatherOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI);
|
||||||
|
|
||||||
if (lastObject == 3) {
|
if (lastObject == FEATHER_LINE_2) {
|
||||||
draggedFeatherOffset = -draggedFeatherOffset;
|
draggedFeatherOffset = -draggedFeatherOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,9 +450,9 @@ bool Gradient::button1Pressed(int modifierKey)
|
|||||||
return false;
|
return false;
|
||||||
} else { // should theoretically always be true
|
} else { // should theoretically always be true
|
||||||
// this will let this class ignore further drag events
|
// this will let this class ignore further drag events
|
||||||
if (lastObject == 2 || lastObject == 3) {
|
if (lastObject == FEATHER_LINE_1 || lastObject == FEATHER_LINE_2) {
|
||||||
EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_1)->state = Geometry::NORMAL;
|
||||||
EditSubscriber::visibleGeometry.at(3)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_2)->state = Geometry::NORMAL;
|
||||||
} else {
|
} else {
|
||||||
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
@@ -472,7 +480,7 @@ bool Gradient::drag1(int modifierKey)
|
|||||||
double halfSizeW = imW / 2.;
|
double halfSizeW = imW / 2.;
|
||||||
double halfSizeH = imH / 2.;
|
double halfSizeH = imH / 2.;
|
||||||
|
|
||||||
if (lastObject == 0 || lastObject == 1) {
|
if (lastObject == H_LINE || lastObject == V_LINE) {
|
||||||
|
|
||||||
// Dragging a line to change the angle
|
// Dragging a line to change the angle
|
||||||
PolarCoord draggedPoint;
|
PolarCoord draggedPoint;
|
||||||
@@ -516,7 +524,7 @@ bool Gradient::drag1(int modifierKey)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (lastObject == 2 || lastObject == 3) {
|
} else if (lastObject == FEATHER_LINE_1 || lastObject == FEATHER_LINE_2) {
|
||||||
// Dragging the upper or lower feather bar
|
// Dragging the upper or lower feather bar
|
||||||
PolarCoord draggedPoint;
|
PolarCoord draggedPoint;
|
||||||
rtengine::Coord currPos;
|
rtengine::Coord currPos;
|
||||||
@@ -533,11 +541,11 @@ bool Gradient::drag1(int modifierKey)
|
|||||||
draggedPoint = currPos - centerPos;
|
draggedPoint = currPos - centerPos;
|
||||||
double currDraggedFeatherOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI);
|
double currDraggedFeatherOffset = draggedPoint.radius * sin((draggedPoint.angle - degree->getValue()) / 180.*rtengine::RT_PI);
|
||||||
|
|
||||||
if (lastObject == 2)
|
if (lastObject == FEATHER_LINE_1)
|
||||||
// Dragging the upper feather bar
|
// Dragging the upper feather bar
|
||||||
{
|
{
|
||||||
currDraggedFeatherOffset -= draggedFeatherOffset;
|
currDraggedFeatherOffset -= draggedFeatherOffset;
|
||||||
} else if (lastObject == 3)
|
} else if (lastObject == FEATHER_LINE_2)
|
||||||
// Dragging the lower feather bar
|
// Dragging the lower feather bar
|
||||||
{
|
{
|
||||||
currDraggedFeatherOffset = -currDraggedFeatherOffset + draggedFeatherOffset;
|
currDraggedFeatherOffset = -currDraggedFeatherOffset + draggedFeatherOffset;
|
||||||
@@ -555,7 +563,7 @@ bool Gradient::drag1(int modifierKey)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (lastObject == 4) {
|
} else if (lastObject == CENTER_CIRCLE) {
|
||||||
// Dragging the circle to change the center
|
// Dragging the circle to change the center
|
||||||
rtengine::Coord currPos;
|
rtengine::Coord currPos;
|
||||||
draggedCenter += provider->deltaPrevImage;
|
draggedCenter += provider->deltaPrevImage;
|
||||||
@@ -583,9 +591,9 @@ bool Gradient::drag1(int modifierKey)
|
|||||||
void Gradient::releaseEdit()
|
void Gradient::releaseEdit()
|
||||||
{
|
{
|
||||||
if (lastObject >= 0) {
|
if (lastObject >= 0) {
|
||||||
if (lastObject == 2 || lastObject == 3) {
|
if (lastObject == FEATHER_LINE_1 || lastObject == FEATHER_LINE_2) {
|
||||||
EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_1)->state = Geometry::NORMAL;
|
||||||
EditSubscriber::visibleGeometry.at(3)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(FEATHER_LINE_2)->state = Geometry::NORMAL;
|
||||||
} else {
|
} else {
|
||||||
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at(lastObject)->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
|
104
rtgui/spot.cc
104
rtgui/spot.cc
@@ -29,8 +29,23 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
#define STATIC_VISIBLE_OBJ_NBR 6
|
enum GeometryIndex {
|
||||||
#define STATIC_MO_OBJ_NBR 6
|
MO_TARGET_DISK,
|
||||||
|
MO_SOURCE_DISC,
|
||||||
|
MO_TARGET_CIRCLE,
|
||||||
|
MO_SOURCE_CIRCLE,
|
||||||
|
MO_TARGET_FEATHER_CIRCLE,
|
||||||
|
MO_SOURCE_FEATHER_CIRCLE,
|
||||||
|
MO_OBJECT_COUNT,
|
||||||
|
|
||||||
|
VISIBLE_SOURCE_ICON = 0,
|
||||||
|
VISIBLE_SOURCE_FEATHER_CIRCLE,
|
||||||
|
VISIBLE_LINK,
|
||||||
|
VISIBLE_SOURCE_CIRCLE,
|
||||||
|
VISIBLE_TARGET_FEATHER_CIRCLE,
|
||||||
|
VISIBLE_TARGET_CIRCLE,
|
||||||
|
VISIBLE_OBJECT_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
Spot::Spot() :
|
Spot::Spot() :
|
||||||
FoldableToolPanel(this, "spot", M ("TP_SPOT_LABEL"), true, true),
|
FoldableToolPanel(this, "spot", M ("TP_SPOT_LABEL"), true, true),
|
||||||
@@ -106,7 +121,7 @@ Spot::~Spot()
|
|||||||
{
|
{
|
||||||
// delete all dynamically allocated geometry
|
// delete all dynamically allocated geometry
|
||||||
if (EditSubscriber::visibleGeometry.size()) {
|
if (EditSubscriber::visibleGeometry.size()) {
|
||||||
for (size_t i = 0; i < EditSubscriber::visibleGeometry.size() - STATIC_VISIBLE_OBJ_NBR; ++i) { // static visible geometry at the end if the list
|
for (size_t i = 0; i < EditSubscriber::visibleGeometry.size() - VISIBLE_OBJECT_COUNT; ++i) { // static visible geometry at the end of the list
|
||||||
delete EditSubscriber::visibleGeometry.at (i);
|
delete EditSubscriber::visibleGeometry.at (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,16 +286,16 @@ Geometry* Spot::getVisibleGeometryFromMO (int MOID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MOID == 0) {
|
if (MOID == MO_TARGET_DISK) {
|
||||||
return getActiveSpotIcon();
|
return getActiveSpotIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MOID == 1) { // sourceMODisc
|
if (MOID == MO_SOURCE_DISC) {
|
||||||
return &sourceIcon;
|
return &sourceIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MOID > STATIC_MO_OBJ_NBR) {
|
if (MOID > MO_OBJECT_COUNT) {
|
||||||
return EditSubscriber::visibleGeometry.at(MOID - STATIC_MO_OBJ_NBR);
|
return EditSubscriber::visibleGeometry.at(MOID - MO_OBJECT_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EditSubscriber::mouseOverGeometry.at (MOID);
|
return EditSubscriber::mouseOverGeometry.at (MOID);
|
||||||
@@ -296,30 +311,36 @@ void Spot::createGeometry ()
|
|||||||
|
|
||||||
//printf("CreateGeometry(%d)\n", nbrEntry);
|
//printf("CreateGeometry(%d)\n", nbrEntry);
|
||||||
// delete all dynamically allocated geometry
|
// delete all dynamically allocated geometry
|
||||||
if (EditSubscriber::visibleGeometry.size() > STATIC_VISIBLE_OBJ_NBR)
|
if (EditSubscriber::visibleGeometry.size() > VISIBLE_OBJECT_COUNT)
|
||||||
for (size_t i = 0; i < EditSubscriber::visibleGeometry.size() - STATIC_VISIBLE_OBJ_NBR; ++i) { // static visible geometry at the end if the list
|
for (size_t i = 0; i < EditSubscriber::visibleGeometry.size() - VISIBLE_OBJECT_COUNT; ++i) { // static visible geometry at the end of the list
|
||||||
delete EditSubscriber::visibleGeometry.at (i);
|
delete EditSubscriber::visibleGeometry.at (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mouse over geometry starts with the static geometry, then the spot's icon geometry
|
// mouse over geometry starts with the static geometry, then the spot's icon geometry
|
||||||
EditSubscriber::mouseOverGeometry.resize (STATIC_MO_OBJ_NBR + nbrEntry);
|
EditSubscriber::mouseOverGeometry.resize (MO_OBJECT_COUNT + nbrEntry);
|
||||||
// visible geometry starts with the spot's icon geometry, then the static geometry
|
// visible geometry starts with the spot's icon geometry, then the static geometry
|
||||||
EditSubscriber::visibleGeometry.resize (nbrEntry + STATIC_VISIBLE_OBJ_NBR);
|
EditSubscriber::visibleGeometry.resize (nbrEntry + VISIBLE_OBJECT_COUNT);
|
||||||
|
|
||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &targetMODisc; // STATIC_MO_OBJ_NBR + 0
|
assert(i == MO_TARGET_DISK);
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &sourceMODisc; // STATIC_MO_OBJ_NBR + 1
|
EditSubscriber::mouseOverGeometry.at (i++) = &targetMODisc; // MO_OBJECT_COUNT + 0
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &targetCircle; // STATIC_MO_OBJ_NBR + 2
|
assert(i == MO_SOURCE_DISC);
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &sourceCircle; // STATIC_MO_OBJ_NBR + 3
|
EditSubscriber::mouseOverGeometry.at (i++) = &sourceMODisc; // MO_OBJECT_COUNT + 1
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &targetFeatherCircle; // STATIC_MO_OBJ_NBR + 4
|
assert(i == MO_TARGET_CIRCLE);
|
||||||
EditSubscriber::mouseOverGeometry.at (i++) = &sourceFeatherCircle; // STATIC_MO_OBJ_NBR + 5
|
EditSubscriber::mouseOverGeometry.at (i++) = &targetCircle; // MO_OBJECT_COUNT + 2
|
||||||
|
assert(i == MO_SOURCE_CIRCLE);
|
||||||
|
EditSubscriber::mouseOverGeometry.at (i++) = &sourceCircle; // MO_OBJECT_COUNT + 3
|
||||||
|
assert(i == MO_TARGET_FEATHER_CIRCLE);
|
||||||
|
EditSubscriber::mouseOverGeometry.at (i++) = &targetFeatherCircle; // MO_OBJECT_COUNT + 4
|
||||||
|
assert(i == MO_SOURCE_FEATHER_CIRCLE);
|
||||||
|
EditSubscriber::mouseOverGeometry.at (i++) = &sourceFeatherCircle; // MO_OBJECT_COUNT + 5
|
||||||
|
|
||||||
// recreate all spots geometry
|
// recreate all spots geometry
|
||||||
Cairo::RefPtr<RTSurface> normalImg = sourceIcon.getNormalImg();
|
Cairo::RefPtr<RTSurface> normalImg = sourceIcon.getNormalImg();
|
||||||
Cairo::RefPtr<RTSurface> prelightImg = sourceIcon.getPrelightImg();
|
Cairo::RefPtr<RTSurface> prelightImg = sourceIcon.getPrelightImg();
|
||||||
Cairo::RefPtr<RTSurface> activeImg = sourceIcon.getActiveImg();
|
Cairo::RefPtr<RTSurface> activeImg = sourceIcon.getActiveImg();
|
||||||
|
|
||||||
for (; j < EditSubscriber::visibleGeometry.size() - STATIC_VISIBLE_OBJ_NBR; ++i, ++j) {
|
for (; j < EditSubscriber::visibleGeometry.size() - VISIBLE_OBJECT_COUNT; ++i, ++j) {
|
||||||
EditSubscriber::mouseOverGeometry.at (i) = EditSubscriber::visibleGeometry.at (j) = new OPIcon (normalImg, activeImg, prelightImg, Cairo::RefPtr<RTSurface> (nullptr), Cairo::RefPtr<RTSurface> (nullptr), Geometry::DP_CENTERCENTER);
|
EditSubscriber::mouseOverGeometry.at (i) = EditSubscriber::visibleGeometry.at (j) = new OPIcon (normalImg, activeImg, prelightImg, Cairo::RefPtr<RTSurface> (nullptr), Cairo::RefPtr<RTSurface> (nullptr), Geometry::DP_CENTERCENTER);
|
||||||
EditSubscriber::visibleGeometry.at (j)->setActive (true);
|
EditSubscriber::visibleGeometry.at (j)->setActive (true);
|
||||||
EditSubscriber::visibleGeometry.at (j)->datum = Geometry::IMAGE;
|
EditSubscriber::visibleGeometry.at (j)->datum = Geometry::IMAGE;
|
||||||
@@ -327,12 +348,19 @@ void Spot::createGeometry ()
|
|||||||
//printf("mouseOverGeometry.at(%d) = %p\n", (unsigned int)i, (void*)EditSubscriber::mouseOverGeometry.at(i));
|
//printf("mouseOverGeometry.at(%d) = %p\n", (unsigned int)i, (void*)EditSubscriber::mouseOverGeometry.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &sourceIcon; // STATIC_VISIBLE_OBJ_NBR + 0
|
int visibleOffset = j;
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &sourceFeatherCircle; // STATIC_VISIBLE_OBJ_NBR + 1
|
assert(j - visibleOffset == VISIBLE_SOURCE_ICON);
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &link; // STATIC_VISIBLE_OBJ_NBR + 2
|
EditSubscriber::visibleGeometry.at (j++) = &sourceIcon; // VISIBLE_OBJECT_COUNT + 0
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &sourceCircle; // STATIC_VISIBLE_OBJ_NBR + 3
|
assert(j - visibleOffset == VISIBLE_SOURCE_FEATHER_CIRCLE);
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &targetFeatherCircle; // STATIC_VISIBLE_OBJ_NBR + 4
|
EditSubscriber::visibleGeometry.at (j++) = &sourceFeatherCircle; // VISIBLE_OBJECT_COUNT + 1
|
||||||
EditSubscriber::visibleGeometry.at (j++) = &targetCircle; // STATIC_VISIBLE_OBJ_NBR + 5
|
assert(j - visibleOffset == VISIBLE_LINK);
|
||||||
|
EditSubscriber::visibleGeometry.at (j++) = &link; // VISIBLE_OBJECT_COUNT + 2
|
||||||
|
assert(j - visibleOffset == VISIBLE_SOURCE_CIRCLE);
|
||||||
|
EditSubscriber::visibleGeometry.at (j++) = &sourceCircle; // VISIBLE_OBJECT_COUNT + 3
|
||||||
|
assert(j - visibleOffset == VISIBLE_TARGET_FEATHER_CIRCLE);
|
||||||
|
EditSubscriber::visibleGeometry.at (j++) = &targetFeatherCircle; // VISIBLE_OBJECT_COUNT + 4
|
||||||
|
assert(j - visibleOffset == VISIBLE_TARGET_CIRCLE);
|
||||||
|
EditSubscriber::visibleGeometry.at (j++) = &targetCircle; // VISIBLE_OBJECT_COUNT + 5
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spot::updateGeometry()
|
void Spot::updateGeometry()
|
||||||
@@ -440,7 +468,7 @@ void Spot::addNewEntry()
|
|||||||
se.sourcePos = se.targetPos;
|
se.sourcePos = se.targetPos;
|
||||||
spots.push_back (se); // this make a copy of se ...
|
spots.push_back (se); // this make a copy of se ...
|
||||||
activeSpot = spots.size() - 1;
|
activeSpot = spots.size() - 1;
|
||||||
lastObject = 1;
|
lastObject = MO_SOURCE_DISC;
|
||||||
|
|
||||||
//printf("ActiveSpot = %d\n", activeSpot);
|
//printf("ActiveSpot = %d\n", activeSpot);
|
||||||
|
|
||||||
@@ -487,11 +515,11 @@ CursorShape Spot::getCursor (int objectID, int xPos, int yPos) const
|
|||||||
return CSEmpty;
|
return CSEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectID == 0 || objectID == 1) {
|
if (objectID == MO_TARGET_DISK || objectID == MO_SOURCE_DISC) {
|
||||||
return CSMove2D;
|
return CSMove2D;
|
||||||
}
|
}
|
||||||
if (objectID >= 2 && objectID <= 5) {
|
if (objectID >= MO_TARGET_CIRCLE && objectID <= MO_SOURCE_FEATHER_CIRCLE) {
|
||||||
Coord delta(Coord(xPos, yPos) - ((objectID == 3 || objectID == 5) ? spots.at(activeSpot).sourcePos : spots.at(activeSpot).targetPos));
|
Coord delta(Coord(xPos, yPos) - ((objectID == MO_SOURCE_CIRCLE || objectID == MO_SOURCE_FEATHER_CIRCLE) ? spots.at(activeSpot).sourcePos : spots.at(activeSpot).targetPos));
|
||||||
PolarCoord polarPos(delta);
|
PolarCoord polarPos(delta);
|
||||||
if (polarPos.angle < 0.) {
|
if (polarPos.angle < 0.) {
|
||||||
polarPos.angle += 180.;
|
polarPos.angle += 180.;
|
||||||
@@ -529,19 +557,19 @@ bool Spot::mouseOver (int modifierKey)
|
|||||||
if (editProvider->getObject() > -1) {
|
if (editProvider->getObject() > -1) {
|
||||||
getVisibleGeometryFromMO (editProvider->getObject())->state = Geometry::PRELIGHT;
|
getVisibleGeometryFromMO (editProvider->getObject())->state = Geometry::PRELIGHT;
|
||||||
|
|
||||||
if (editProvider->getObject() >= STATIC_MO_OBJ_NBR) {
|
if (editProvider->getObject() >= MO_OBJECT_COUNT) {
|
||||||
// a Spot is being edited
|
// a Spot is being edited
|
||||||
int oldActiveSpot = activeSpot;
|
int oldActiveSpot = activeSpot;
|
||||||
activeSpot = editProvider->getObject() - STATIC_MO_OBJ_NBR;
|
activeSpot = editProvider->getObject() - MO_OBJECT_COUNT;
|
||||||
|
|
||||||
if (activeSpot != oldActiveSpot) {
|
if (activeSpot != oldActiveSpot) {
|
||||||
if (oldActiveSpot > -1) {
|
if (oldActiveSpot > -1) {
|
||||||
EditSubscriber::visibleGeometry.at (oldActiveSpot)->state = Geometry::NORMAL;
|
EditSubscriber::visibleGeometry.at (oldActiveSpot)->state = Geometry::NORMAL;
|
||||||
EditSubscriber::mouseOverGeometry.at (oldActiveSpot + STATIC_MO_OBJ_NBR)->state = Geometry::NORMAL;
|
EditSubscriber::mouseOverGeometry.at (oldActiveSpot + MO_OBJECT_COUNT)->state = Geometry::NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSubscriber::visibleGeometry.at (activeSpot)->state = Geometry::PRELIGHT;
|
EditSubscriber::visibleGeometry.at (activeSpot)->state = Geometry::PRELIGHT;
|
||||||
EditSubscriber::mouseOverGeometry.at (activeSpot + STATIC_MO_OBJ_NBR)->state = Geometry::PRELIGHT;
|
EditSubscriber::mouseOverGeometry.at (activeSpot + MO_OBJECT_COUNT)->state = Geometry::PRELIGHT;
|
||||||
//printf("ActiveSpot = %d (was %d before)\n", activeSpot, oldActiveSpot);
|
//printf("ActiveSpot = %d (was %d before)\n", activeSpot, oldActiveSpot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,7 +578,7 @@ bool Spot::mouseOver (int modifierKey)
|
|||||||
lastObject = editProvider->getObject();
|
lastObject = editProvider->getObject();
|
||||||
|
|
||||||
if (lastObject > -1 && EditSubscriber::mouseOverGeometry.at (lastObject) == getActiveSpotIcon()) {
|
if (lastObject > -1 && EditSubscriber::mouseOverGeometry.at (lastObject) == getActiveSpotIcon()) {
|
||||||
lastObject = 0; // targetMODisc
|
lastObject = MO_TARGET_DISK;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
@@ -578,7 +606,7 @@ bool Spot::button1Pressed (int modifierKey)
|
|||||||
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
||||||
return true;
|
return true;
|
||||||
} else if (lastObject > -1) {
|
} else if (lastObject > -1) {
|
||||||
draggedSide = lastObject == 0 ? DraggedSide::TARGET : lastObject == 1 ? DraggedSide::SOURCE : DraggedSide::NONE;
|
draggedSide = lastObject == MO_TARGET_DISK ? DraggedSide::TARGET : lastObject == MO_SOURCE_DISC ? DraggedSide::SOURCE : DraggedSide::NONE;
|
||||||
getVisibleGeometryFromMO (lastObject)->state = Geometry::DRAGGED;
|
getVisibleGeometryFromMO (lastObject)->state = Geometry::DRAGGED;
|
||||||
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
||||||
return true;
|
return true;
|
||||||
@@ -630,8 +658,8 @@ bool Spot::button3Pressed (int modifierKey)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((modifierKey & GDK_CONTROL_MASK) && (EditSubscriber::mouseOverGeometry.at (lastObject) == &targetMODisc || lastObject >= STATIC_MO_OBJ_NBR)) {
|
if ((modifierKey & GDK_CONTROL_MASK) && (EditSubscriber::mouseOverGeometry.at (lastObject) == &targetMODisc || lastObject >= MO_OBJECT_COUNT)) {
|
||||||
lastObject = 1; // sourceMODisc
|
lastObject = MO_SOURCE_DISC;
|
||||||
sourceIcon.state = Geometry::DRAGGED;
|
sourceIcon.state = Geometry::DRAGGED;
|
||||||
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
|
||||||
draggedSide = DraggedSide::SOURCE;
|
draggedSide = DraggedSide::SOURCE;
|
||||||
@@ -687,8 +715,8 @@ bool Spot::drag1 (int modifierKey)
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSubscriber::mouseOverGeometry.at (activeSpot + STATIC_MO_OBJ_NBR)->state = Geometry::DRAGGED;
|
EditSubscriber::mouseOverGeometry.at (activeSpot + MO_OBJECT_COUNT)->state = Geometry::DRAGGED;
|
||||||
} else if (loGeom == &targetMODisc || lastObject >= STATIC_MO_OBJ_NBR) {
|
} else if (loGeom == &targetMODisc || lastObject >= MO_OBJECT_COUNT) {
|
||||||
//printf("targetMODisc / deltaPrevImage = %d / %d\n", editProvider->deltaPrevImage.x, editProvider->deltaPrevImage.y);
|
//printf("targetMODisc / deltaPrevImage = %d / %d\n", editProvider->deltaPrevImage.x, editProvider->deltaPrevImage.y);
|
||||||
rtengine::Coord currPos = spots.at (activeSpot).targetPos;
|
rtengine::Coord currPos = spots.at (activeSpot).targetPos;
|
||||||
spots.at (activeSpot).targetPos += editProvider->deltaPrevImage;
|
spots.at (activeSpot).targetPos += editProvider->deltaPrevImage;
|
||||||
|
Reference in New Issue
Block a user