Browse Source

First step towards transforming TextureEditor into widget

master
Krisjanis Rijnieks 9 years ago
parent
commit
324b2378cf
  1. 12
      example/example.xcodeproj/project.pbxproj
  2. 2
      src/Commands/DeselectTexCoordCmd.cpp
  3. 6
      src/Commands/DeselectTexCoordCmd.h
  4. 2
      src/Commands/MvAllTexCoordsCmd.cpp
  5. 6
      src/Commands/MvAllTexCoordsCmd.h
  6. 2
      src/Commands/MvTexCoordCmd.cpp
  7. 6
      src/Commands/MvTexCoordCmd.h
  8. 2
      src/Commands/SelNextTexCoordCmd.cpp
  9. 6
      src/Commands/SelNextTexCoordCmd.h
  10. 2
      src/Commands/SelPrevTexCoordCmd.cpp
  11. 6
      src/Commands/SelPrevTexCoordCmd.h
  12. 44
      src/Gui/Widgets/TextureEditorWidget.cpp
  13. 17
      src/Gui/Widgets/TextureEditorWidget.h
  14. 2
      src/Surfaces/SurfaceManagerGui.cpp
  15. 6
      src/Surfaces/SurfaceManagerGui.h

12
example/example.xcodeproj/project.pbxproj

@ -103,10 +103,10 @@
01C207891D82FA4A00742588 /* ProjectionEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C2073D1D82FA4A00742588 /* ProjectionEditor.cpp */; };
01C2078A1D82FA4A00742588 /* RadioList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C2073F1D82FA4A00742588 /* RadioList.cpp */; };
01C2078B1D82FA4A00742588 /* SourcesEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C207411D82FA4A00742588 /* SourcesEditor.cpp */; };
01C2078C1D82FA4A00742588 /* TextureEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C207431D82FA4A00742588 /* TextureEditor.cpp */; };
01C2078D1D82FA4A00742588 /* HomographyHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C207461D82FA4A00742588 /* HomographyHelper.cpp */; };
01C2078E1D82FA4A00742588 /* TerminalListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C207481D82FA4A00742588 /* TerminalListener.cpp */; };
01CD0BC31D87CD9A00BBCE25 /* TranslateCanvasCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01CD0BC21D87CD9A00BBCE25 /* TranslateCanvasCmd.cpp */; };
01FA14F31D97FF2A005831AA /* TextureEditorWidget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01FA14F21D97FF2A005831AA /* TextureEditorWidget.cpp */; };
3926483B192224DA0008A7F5 /* ofxXmlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */; };
39264841192224F90008A7F5 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483D192224F90008A7F5 /* tinyxml.cpp */; };
39264842192224F90008A7F5 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483F192224F90008A7F5 /* tinyxmlerror.cpp */; };
@ -377,14 +377,14 @@
01C207401D82FA4A00742588 /* RadioList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RadioList.h; sourceTree = "<group>"; };
01C207411D82FA4A00742588 /* SourcesEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourcesEditor.cpp; sourceTree = "<group>"; };
01C207421D82FA4A00742588 /* SourcesEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourcesEditor.h; sourceTree = "<group>"; };
01C207431D82FA4A00742588 /* TextureEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureEditor.cpp; sourceTree = "<group>"; };
01C207441D82FA4A00742588 /* TextureEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureEditor.h; sourceTree = "<group>"; };
01C207461D82FA4A00742588 /* HomographyHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HomographyHelper.cpp; sourceTree = "<group>"; };
01C207471D82FA4A00742588 /* HomographyHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomographyHelper.h; sourceTree = "<group>"; };
01C207481D82FA4A00742588 /* TerminalListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TerminalListener.cpp; sourceTree = "<group>"; };
01C207491D82FA4A00742588 /* TerminalListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TerminalListener.h; sourceTree = "<group>"; };
01CD0BC11D87CD9A00BBCE25 /* TranslateCanvasCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TranslateCanvasCmd.h; sourceTree = "<group>"; };
01CD0BC21D87CD9A00BBCE25 /* TranslateCanvasCmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TranslateCanvasCmd.cpp; sourceTree = "<group>"; };
01FA14F11D97FF2A005831AA /* TextureEditorWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureEditorWidget.h; sourceTree = "<group>"; };
01FA14F21D97FF2A005831AA /* TextureEditorWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureEditorWidget.cpp; sourceTree = "<group>"; };
39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ofxXmlSettings.cpp; path = ../../ofxXmlSettings/src/ofxXmlSettings.cpp; sourceTree = "<group>"; };
3926483A192224DA0008A7F5 /* ofxXmlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ofxXmlSettings.h; path = ../../ofxXmlSettings/src/ofxXmlSettings.h; sourceTree = "<group>"; };
3926483D192224F90008A7F5 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = "<group>"; };
@ -813,6 +813,8 @@
01C2070B1D82FA4900742588 /* SurfaceHighlightWidget.h */,
01C2070C1D82FA4900742588 /* TextureHighlightWidget.cpp */,
01C2070D1D82FA4900742588 /* TextureHighlightWidget.h */,
01FA14F21D97FF2A005831AA /* TextureEditorWidget.cpp */,
01FA14F11D97FF2A005831AA /* TextureEditorWidget.h */,
);
path = Widgets;
sourceTree = "<group>";
@ -894,8 +896,6 @@
01C207401D82FA4A00742588 /* RadioList.h */,
01C207411D82FA4A00742588 /* SourcesEditor.cpp */,
01C207421D82FA4A00742588 /* SourcesEditor.h */,
01C207431D82FA4A00742588 /* TextureEditor.cpp */,
01C207441D82FA4A00742588 /* TextureEditor.h */,
);
path = UserInterface;
sourceTree = "<group>";
@ -1191,7 +1191,6 @@
3995C20A1C79069B00123352 /* Settings.cpp in Sources */,
01C207841D82FA4A00742588 /* SurfaceManagerGui.cpp in Sources */,
01C207761D82FA4A00742588 /* Info.cpp in Sources */,
01C2078C1D82FA4A00742588 /* TextureEditor.cpp in Sources */,
0130C96F1CE65AA600911E17 /* ByteBufferWriter.cpp in Sources */,
01C2076E1D82FA4A00742588 /* StartDragSurfaceCmd.cpp in Sources */,
0130C97E1CE65AA600911E17 /* RegexPathFilter.cpp in Sources */,
@ -1251,6 +1250,7 @@
0130C97A1CE65AA600911E17 /* LinkFilter.cpp in Sources */,
01C207821D82FA4A00742588 /* SurfaceFactory.cpp in Sources */,
01C2077C1D82FA4A00742588 /* ImageSource.cpp in Sources */,
01FA14F31D97FF2A005831AA /* TextureEditorWidget.cpp in Sources */,
E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */,
0130C96C1CE65AA600911E17 /* ByteBufferReader.cpp in Sources */,
3933D5D719BB87BD000ACA55 /* ofxPanel.cpp in Sources */,

2
src/Commands/DeselectTexCoordCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
DeselectTexCoordCmd::DeselectTexCoordCmd(TextureEditor * te){
DeselectTexCoordCmd::DeselectTexCoordCmd(TextureEditorWidget * te){
_textureEditor = te;
}

6
src/Commands/DeselectTexCoordCmd.h

@ -1,7 +1,7 @@
#pragma once
#include "BaseCmd.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
#include "CircleJoint.h"
class ofxPiMapper;
@ -12,12 +12,12 @@ namespace piMapper {
class DeselectTexCoordCmd : public BaseUndoCmd {
public:
DeselectTexCoordCmd(TextureEditor * te);
DeselectTexCoordCmd(TextureEditorWidget * te);
void exec();
void undo();
private:
TextureEditor * _textureEditor;
TextureEditorWidget * _textureEditor;
int _selectedTexCoord;
};

2
src/Commands/MvAllTexCoordsCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
MvAllTexCoordsCmd::MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor){
MvAllTexCoordsCmd::MvAllTexCoordsCmd(BaseSurface * surface, TextureEditorWidget * texEditor){
_surface = surface;
_texEditor = texEditor;
}

6
src/Commands/MvAllTexCoordsCmd.h

@ -6,7 +6,7 @@
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
namespace ofx {
namespace piMapper {
@ -14,14 +14,14 @@ namespace piMapper {
class MvAllTexCoordsCmd : public BaseUndoCmd {
public:
MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor);
MvAllTexCoordsCmd(BaseSurface * surface, TextureEditorWidget * texEditor);
void exec();
void undo();
private:
vector <ofVec2f> _texCoords;
BaseSurface * _surface;
TextureEditor * _texEditor;
TextureEditorWidget * _texEditor;
};

2
src/Commands/MvTexCoordCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
MvTexCoordCmd::MvTexCoordCmd(int jointIndex, TextureEditor * texEditor){
MvTexCoordCmd::MvTexCoordCmd(int jointIndex, TextureEditorWidget * texEditor){
_jointIndex = jointIndex;
_texEditor = texEditor;
}

6
src/Commands/MvTexCoordCmd.h

@ -6,7 +6,7 @@
#include "BaseCmd.h"
#include "CircleJoint.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
namespace ofx {
namespace piMapper {
@ -14,14 +14,14 @@ namespace piMapper {
class MvTexCoordCmd : public BaseUndoCmd {
public:
MvTexCoordCmd(int jointIndex, TextureEditor * texEditor);
MvTexCoordCmd(int jointIndex, TextureEditorWidget * texEditor);
void exec();
void undo();
private:
ofVec2f _jointPosition;
int _jointIndex;
TextureEditor * _texEditor;
TextureEditorWidget * _texEditor;
};

2
src/Commands/SelNextTexCoordCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
SelNextTexCoordCmd::SelNextTexCoordCmd(TextureEditor * te){
SelNextTexCoordCmd::SelNextTexCoordCmd(TextureEditorWidget * te){
_textureEditor = te;
}

6
src/Commands/SelNextTexCoordCmd.h

@ -1,7 +1,7 @@
#pragma once
#include "BaseCmd.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
class ofxPiMapper;
@ -11,12 +11,12 @@ namespace piMapper {
class SelNextTexCoordCmd : public BaseUndoCmd {
public:
SelNextTexCoordCmd(TextureEditor * te);
SelNextTexCoordCmd(TextureEditorWidget * te);
void exec();
void undo();
private:
TextureEditor * _textureEditor;
TextureEditorWidget * _textureEditor;
};

2
src/Commands/SelPrevTexCoordCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
SelPrevTexCoordCmd::SelPrevTexCoordCmd(TextureEditor * te){
SelPrevTexCoordCmd::SelPrevTexCoordCmd(TextureEditorWidget * te){
_textureEditor = te;
}

6
src/Commands/SelPrevTexCoordCmd.h

@ -1,7 +1,7 @@
#pragma once
#include "BaseCmd.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
class ofxPiMapper;
@ -11,12 +11,12 @@ namespace piMapper {
class SelPrevTexCoordCmd : public BaseUndoCmd {
public:
SelPrevTexCoordCmd(TextureEditor * te);
SelPrevTexCoordCmd(TextureEditorWidget * te);
void exec();
void undo();
private:
TextureEditor * _textureEditor;
TextureEditorWidget * _textureEditor;
};

44
src/UserInterface/TextureEditor.cpp → src/Gui/Widgets/TextureEditorWidget.cpp

@ -1,13 +1,17 @@
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
namespace ofx {
namespace piMapper {
TextureEditor::TextureEditor(){
TextureEditorWidget::TextureEditorWidget(){
clear();
}
void TextureEditor::update(){
void TextureEditorWidget::setup(){
// Nothing here yet.
}
void TextureEditorWidget::update(){
if(surface == 0){
return;
}
@ -75,19 +79,19 @@ void TextureEditor::update(){
} // else
}
void TextureEditor::mousePressed(ofMouseEventArgs & args){
void TextureEditorWidget::mousePressed(ofMouseEventArgs & args){
for(unsigned int i = 0; i < joints.size(); ++i){
joints[i]->mousePressed(args);
}
}
void TextureEditor::mouseDragged(ofMouseEventArgs & args){
void TextureEditorWidget::mouseDragged(ofMouseEventArgs & args){
for(unsigned int i = 0; i < joints.size(); ++i){
joints[i]->mouseDragged(args);
}
}
void TextureEditor::draw(){
void TextureEditorWidget::draw(){
if(surface == 0){
return;
}
@ -97,23 +101,23 @@ void TextureEditor::draw(){
drawJoints();
}
void TextureEditor::drawJoints(){
void TextureEditorWidget::drawJoints(){
for(int i = 0; i < joints.size(); i++){
joints[i]->draw();
}
}
void TextureEditor::setSurface(BaseSurface * newSurface){
void TextureEditorWidget::setSurface(BaseSurface * newSurface){
surface = newSurface;
createJoints();
}
void TextureEditor::clear(){
void TextureEditorWidget::clear(){
surface = 0;
clearJoints();
}
void TextureEditor::createJoints(){
void TextureEditorWidget::createJoints(){
if(surface == 0){
return;
}
@ -154,20 +158,20 @@ void TextureEditor::createJoints(){
}
}
void TextureEditor::clearJoints(){
void TextureEditorWidget::clearJoints(){
while(joints.size()){
delete joints.back();
joints.pop_back();
}
}
void TextureEditor::unselectAllJoints(){
void TextureEditorWidget::unselectAllJoints(){
for(int i = 0; i < joints.size(); i++){
joints[i]->unselect();
}
}
void TextureEditor::selectNextTexCoord(){
void TextureEditorWidget::selectNextTexCoord(){
if(joints.size() <= 0){
return;
}
@ -189,7 +193,7 @@ void TextureEditor::selectNextTexCoord(){
joints[0]->select();
}
void TextureEditor::selectPrevTexCoord(){
void TextureEditorWidget::selectPrevTexCoord(){
if(joints.size() <= 0){
return;
}
@ -213,7 +217,7 @@ void TextureEditor::selectPrevTexCoord(){
joints[joints.size() - 1]->select();
}
void TextureEditor::moveTexCoords(ofVec2f by){
void TextureEditorWidget::moveTexCoords(ofVec2f by){
if(surface == 0){
return;
}
@ -266,13 +270,13 @@ void TextureEditor::moveTexCoords(ofVec2f by){
}
}
void TextureEditor::stopDragJoints(){
void TextureEditorWidget::stopDragJoints(){
for(int i = 0; i < joints.size(); i++){
joints[i]->stopDrag();
}
}
void TextureEditor::moveSelection(ofVec2f by){
void TextureEditorWidget::moveSelection(ofVec2f by){
// check if joints selected
bool bJointSelected = false;
BaseJoint * selectedJoint;
@ -291,7 +295,7 @@ void TextureEditor::moveSelection(ofVec2f by){
}
}
void TextureEditor::constrainJointsToQuad(int selectedJointIndex){
void TextureEditorWidget::constrainJointsToQuad(int selectedJointIndex){
switch(selectedJointIndex){
case 0:
joints[1]->position = ofVec2f(joints[1]->position.x, joints[0]->position.y);
@ -319,7 +323,7 @@ void TextureEditor::constrainJointsToQuad(int selectedJointIndex){
} // switch
}
CircleJoint * TextureEditor::hitTestJoints(ofVec2f pos){
CircleJoint * TextureEditorWidget::hitTestJoints(ofVec2f pos){
for(int i = 0; i < joints.size(); i++){
if(joints[i]->hitTest(pos)){
return joints[i];
@ -328,7 +332,7 @@ CircleJoint * TextureEditor::hitTestJoints(ofVec2f pos){
return 0;
}
vector <CircleJoint *> & TextureEditor::getJoints(){
vector <CircleJoint *> & TextureEditorWidget::getJoints(){
return joints;
}

17
src/UserInterface/TextureEditor.h → src/Gui/Widgets/TextureEditorWidget.h

@ -6,19 +6,30 @@
#include "GridWarpSurface.h"
#include "CircleJoint.h"
#include "SurfaceType.h"
#include "GuiBaseWidget.h"
namespace ofx {
namespace piMapper {
class TextureEditor {
class TextureEditorWidget : public GuiBaseWidget {
public:
TextureEditor();
TextureEditorWidget();
void setup();
void update(); // Maybe the Application pointer would make sense there. Not sure yet.
void draw();
// These come from GuiBaseWidget
void onMousePressed(ofMouseEventArgs & e){}
void onMouseReleased(ofMouseEventArgs & e){}
void onMouseDragged(ofMouseEventArgs & e){}
void mousePressed(ofMouseEventArgs & args);
void mouseDragged(ofMouseEventArgs & args);
void draw();
bool inside(float x, float y){ return false; }
void drawJoints();
void setSurface(BaseSurface * newSurface);
void clear();

2
src/Surfaces/SurfaceManagerGui.cpp

@ -90,7 +90,7 @@ ProjectionEditor * SurfaceManagerGui::getProjectionEditor(){
return &projectionEditor;
}
TextureEditor * SurfaceManagerGui::getTextureEditor(){
TextureEditorWidget * SurfaceManagerGui::getTextureEditor(){
return &textureEditor;
}

6
src/Surfaces/SurfaceManagerGui.h

@ -6,7 +6,7 @@
#include "ofGraphics.h"
#include "SurfaceManager.h"
#include "TextureEditor.h"
#include "TextureEditorWidget.h"
#include "ProjectionEditor.h"
#include "SourcesEditor.h"
#include "GuiMode.h"
@ -37,7 +37,7 @@ class SurfaceManagerGui {
void stopDrag();
ProjectionEditor * getProjectionEditor();
TextureEditor * getTextureEditor();
TextureEditorWidget * getTextureEditor();
SourcesEditor * getSourcesEditor();
void onVertexChanged(int & i);
@ -52,7 +52,7 @@ class SurfaceManagerGui {
private:
SurfaceManager * surfaceManager;
MediaServer * mediaServer;
TextureEditor textureEditor;
TextureEditorWidget textureEditor;
ProjectionEditor projectionEditor;
SourcesEditor sourcesEditor;

Loading…
Cancel
Save