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:
parent
79850824c4
commit
aa62e46702
9 changed files with 96 additions and 9 deletions
|
@ -1,5 +1,68 @@
|
||||||
#include "baseformlayer.h"
|
#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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,30 @@
|
||||||
/* Base form, with automatic layer control */
|
/* Base form, with automatic layer control */
|
||||||
|
|
||||||
#include "baseform.h"
|
#include "baseform.h"
|
||||||
|
#include "../lib_paysages/layers.h"
|
||||||
|
|
||||||
class BaseFormLayer:public BaseForm
|
class BaseFormLayer:public BaseForm
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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
|
#endif
|
||||||
|
|
|
@ -16,7 +16,7 @@ DialogLayers::DialogLayers(QWidget *parent, Layers* layers, QString title, FormL
|
||||||
|
|
||||||
setLayout(new QVBoxLayout());
|
setLayout(new QVBoxLayout());
|
||||||
|
|
||||||
_form = form_builder(this);
|
_form = form_builder(this, _layers);
|
||||||
_form->hideButtons();
|
_form->hideButtons();
|
||||||
layout()->addWidget(_form);
|
layout()->addWidget(_form);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
class DialogLayers;
|
class DialogLayers;
|
||||||
class BaseFormLayer;
|
class BaseFormLayer;
|
||||||
|
|
||||||
typedef BaseFormLayer* (*FormLayerBuilder)(DialogLayers* parent);
|
typedef BaseFormLayer* (*FormLayerBuilder)(DialogLayers* parent, Layers* layers);
|
||||||
|
|
||||||
class DialogLayers : public DialogWithPreview
|
class DialogLayers : public DialogWithPreview
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,9 +141,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** 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):
|
FormTerrain::FormTerrain(QWidget *parent):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "formterraincanvas.h"
|
#include "formterraincanvas.h"
|
||||||
|
|
||||||
/**************** Form ****************/
|
/**************** Form ****************/
|
||||||
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent):
|
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
|
||||||
BaseFormLayer(parent)
|
BaseFormLayer(parent, layers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class FormTerrainCanvas : public BaseFormLayer
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormTerrainCanvas(QWidget* parent);
|
FormTerrainCanvas(QWidget* parent, Layers* layers);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void revertConfig();
|
virtual void revertConfig();
|
||||||
|
|
|
@ -33,6 +33,13 @@ Layers* layersCreate(LayerType type, int max_layer_count)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Layers* layersCreateCopy(Layers* original)
|
||||||
|
{
|
||||||
|
Layers* result = layersCreate(original->type, original->max_count);
|
||||||
|
layersCopy(original, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void layersDelete(Layers* layers)
|
void layersDelete(Layers* layers)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -28,6 +28,7 @@ typedef struct {
|
||||||
typedef struct Layers Layers;
|
typedef struct Layers Layers;
|
||||||
|
|
||||||
Layers* layersCreate(LayerType type, int max_layer_count);
|
Layers* layersCreate(LayerType type, int max_layer_count);
|
||||||
|
Layers* layersCreateCopy(Layers* original);
|
||||||
void layersDelete(Layers* layers);
|
void layersDelete(Layers* layers);
|
||||||
|
|
||||||
void layersCopy(Layers* source, Layers* destination);
|
void layersCopy(Layers* source, Layers* destination);
|
||||||
|
|
Loading…
Reference in a new issue