paysages : Terrain canvas (WIP).

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@386 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-07-10 20:00:44 +00:00 committed by ThunderK
parent 79850824c4
commit aa62e46702
9 changed files with 96 additions and 9 deletions

View file

@ -1,5 +1,68 @@
#include "baseformlayer.h"
BaseFormLayer::BaseFormLayer(QWidget* parent) : BaseForm(parent, false, true)
BaseFormLayer::BaseFormLayer(QWidget* parent, Layers* layers) : BaseForm(parent, false, true)
{
_layers_original = layers;
_layers_modified = layersCreateCopy(_layers_original);
}
BaseFormLayer::~BaseFormLayer()
{
layersDelete(_layers_modified);
}
void BaseFormLayer::configChangeEvent()
{
/*texturesLayerCopyDefinition(&_layer, texturesGetLayer(&_definition, currentLayer()));
layersValidate(_layers_modified);*/
BaseForm::configChangeEvent();
}
QStringList BaseFormLayer::getLayers()
{
QStringList result;
for (int i = 0; i < layersCount(_layers_modified); i++)
{
result << QString::fromUtf8(layersGetName(_layers_modified, i));
}
return result;
}
void BaseFormLayer::layerAddedEvent()
{
if (layersAddLayer(_layers_modified, NULL) >= 0)
{
BaseForm::layerAddedEvent();
}
}
void BaseFormLayer::layerDeletedEvent(int layer)
{
layersDeleteLayer(_layers_modified, layer);
BaseForm::layerDeletedEvent(layer);
}
void BaseFormLayer::layerMovedEvent(int layer, int new_position)
{
layersMove(_layers_modified, layer, new_position);
BaseForm::layerMovedEvent(layer, new_position);
}
void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
{
layersSetName(_layers_modified, layer, new_name.toUtf8().data());
BaseForm::layerRenamedEvent(layer, new_name);
}
void BaseFormLayer::layerSelectedEvent(int layer)
{
//texturesLayerCopyDefinition(texturesGetLayer(&_definition, layer), &_layer);
BaseForm::layerSelectedEvent(layer);
}

View file

@ -4,14 +4,30 @@
/* Base form, with automatic layer control */
#include "baseform.h"
#include "../lib_paysages/layers.h"
class BaseFormLayer:public BaseForm
{
Q_OBJECT
public:
BaseFormLayer(QWidget* parent);
BaseFormLayer(QWidget* parent, Layers* layers);
~BaseFormLayer();
protected:
virtual QStringList getLayers();
virtual void layerAddedEvent();
virtual void layerDeletedEvent(int layer);
virtual void layerMovedEvent(int layer, int new_position);
virtual void layerRenamedEvent(int layer, QString new_name);
virtual void layerSelectedEvent(int layer);
protected slots:
virtual void configChangeEvent();
private:
Layers* _layers_original;
Layers* _layers_modified;
};
#endif

View file

@ -16,7 +16,7 @@ DialogLayers::DialogLayers(QWidget *parent, Layers* layers, QString title, FormL
setLayout(new QVBoxLayout());
_form = form_builder(this);
_form = form_builder(this, _layers);
_form->hideButtons();
layout()->addWidget(_form);

View file

@ -11,7 +11,7 @@
class DialogLayers;
class BaseFormLayer;
typedef BaseFormLayer* (*FormLayerBuilder)(DialogLayers* parent);
typedef BaseFormLayer* (*FormLayerBuilder)(DialogLayers* parent, Layers* layers);
class DialogLayers : public DialogWithPreview
{

View file

@ -141,9 +141,9 @@ private:
};
/**************** Form ****************/
static BaseFormLayer* _formBuilderCanvas(DialogLayers* parent)
static BaseFormLayer* _formBuilderCanvas(DialogLayers* parent, Layers* layers)
{
return new FormTerrainCanvas(parent);
return new FormTerrainCanvas(parent, layers);
}
FormTerrain::FormTerrain(QWidget *parent):

View file

@ -1,8 +1,8 @@
#include "formterraincanvas.h"
/**************** Form ****************/
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent):
BaseFormLayer(parent)
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
BaseFormLayer(parent, layers)
{
}

View file

@ -10,7 +10,7 @@ class FormTerrainCanvas : public BaseFormLayer
Q_OBJECT
public:
FormTerrainCanvas(QWidget* parent);
FormTerrainCanvas(QWidget* parent, Layers* layers);
public slots:
virtual void revertConfig();

View file

@ -33,6 +33,13 @@ Layers* layersCreate(LayerType type, int max_layer_count)
return result;
}
Layers* layersCreateCopy(Layers* original)
{
Layers* result = layersCreate(original->type, original->max_count);
layersCopy(original, result);
return result;
}
void layersDelete(Layers* layers)
{
int i;

View file

@ -28,6 +28,7 @@ typedef struct {
typedef struct Layers Layers;
Layers* layersCreate(LayerType type, int max_layer_count);
Layers* layersCreateCopy(Layers* original);
void layersDelete(Layers* layers);
void layersCopy(Layers* source, Layers* destination);