[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src/client TilePresentation.h TilePresen...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src/client TilePresentation.h TilePresen... |
Date: |
Thu, 27 Feb 2003 08:33:31 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/27 08:33:30
Modified files:
src/client : TilePresentation.h TilePresentation.cpp
Log message:
- add a rotate button
- tile buttons are automatically shown/hidden on new tiles or tile
removal
Patches:
Index: camino/src/client/TilePresentation.cpp
diff -u camino/src/client/TilePresentation.cpp:1.5
camino/src/client/TilePresentation.cpp:1.6
--- camino/src/client/TilePresentation.cpp:1.5 Thu Feb 27 05:22:34 2003
+++ camino/src/client/TilePresentation.cpp Thu Feb 27 08:33:30 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: TilePresentation.cpp,v 1.5 2003/02/27 10:22:34 pfremy Exp $
+** Version : $Id: TilePresentation.cpp,v 1.6 2003/02/27 13:33:30 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 28/01/2003
@@ -37,7 +37,7 @@
TilePresentation::TilePresentation( QWidget * parent, const char * name )
: QVBox( parent, name )
{
- _selected = -1;
+ _selectedIndex = -1;
QSignalMapper * sigmap = new QSignalMapper( this );
setSpacing( 10 );
@@ -56,9 +56,15 @@
QWidget * w = new QWidget( this );
setStretchFactor( w, 10 );
- QHBox * box = new QHBox( this );
- new QLabel( "Selected tile :", box );
- _selectedTile = new TileButton( box );
+ QHBox * hbox = new QHBox( this );
+ hbox->setSpacing( 10 );
+ QVBox * vbox = new QVBox( hbox );
+ vbox->setSpacing( 10 );
+ new QLabel( "Selected tile :", vbox );
+ _rotateButton = new QPushButton( "rotate", vbox );
+ _selectedTile = new TileButton( hbox );
+ _selectedTile->setFlat( true );
+ _selectedTile->setAlwaysShow( true );
connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_selectTile( int )
) );
}
@@ -74,7 +80,7 @@
void TilePresentation::slot_selectTile( int num )
{
_selectedTile->setTile( _buttonList.at(num)->getTileType() );
- _selected = num;
+ _selectedIndex = num;
}
void TilePresentation::addTile( Tile::TileType tile )
@@ -91,6 +97,24 @@
_buttonList.first()->setTile( tile );
}
+void TilePresentation::removeTile( Tile::TileType tile )
+{
+ QPtrListIterator<TileButton> it( _buttonList );
+ for( ; it.current(); ++it ) {
+ if (it.current()->_type == tile) {
+ it.current()->setTile( Tile::TILE_UNKNOWN);
+ return;
+ }
+ }
+ qDebug("TilePresentation::removeTile() - Could not find tile %d !",
tile);
+}
+
+void TilePresentation::removeSelectedTile()
+{
+ removeTile( _selectedTile->_type );
+}
+
+
//
// ----- TileButton -----
//
@@ -98,7 +122,8 @@
TileButton::TileButton( QWidget * parent, const char * name )
: QPushButton( parent, name )
{
- _type = Tile::TILE_UNKNOWN;
+ _alwaysShow = false;
+ setTile( Tile::TILE_UNKNOWN );
// setFlat( true );
reinit();
}
@@ -110,6 +135,15 @@
// setPixmap( theme.getTilePixmap( (int)type, 0 ) );
setPixmap( Theme::getTheme()->pixmapForTile( type ) );
setFixedSize( pixmap()->width() + 2, pixmap()->height() + 2 );
+ if ( _alwaysShow == false) {
+ if ( type == Tile::TILE_UNKNOWN ) {
+ hide();
+ } else {
+ show();
+ }
+ } else {
+ show();
+ }
}
void TileButton::reinit()
@@ -117,3 +151,8 @@
setTile( _type );
}
+void TileButton::setAlwaysShow( bool as )
+{
+ _alwaysShow = as;
+ setTile( _type );
+}
Index: camino/src/client/TilePresentation.h
diff -u camino/src/client/TilePresentation.h:1.5
camino/src/client/TilePresentation.h:1.6
--- camino/src/client/TilePresentation.h:1.5 Thu Feb 27 05:22:34 2003
+++ camino/src/client/TilePresentation.h Thu Feb 27 08:33:30 2003
@@ -5,7 +5,7 @@
** TilePresentation.h
** Displays tiles of the player
**
-** Version : $Id: TilePresentation.h,v 1.5 2003/02/27 10:22:34 pfremy Exp $
+** Version : $Id: TilePresentation.h,v 1.6 2003/02/27 13:33:30 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 28/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -55,6 +55,8 @@
TilePresentation( QWidget * parent = 0, const char * name = 0 );
void reupdate();
void addTile( Tile::TileType tile );
+ void removeTile( Tile::TileType tile );
+ void removeSelectedTile();
public slots:
void slot_selectTile( int num );
@@ -65,7 +67,8 @@
protected:
QPtrList< TileButton > _buttonList;
TileButton * _selectedTile;
- int _selected;
+ QPushButton * _rotateButton;
+ int _selectedIndex;
};
class TileButton : public QPushButton
@@ -73,13 +76,14 @@
public:
TileButton( QWidget * parent = 0, const char * name = 0 );
+ void setAlwaysShow( bool as );
void setTile( Tile::TileType type );
Tile::TileType getTileType() { return _type; }
void reinit();
protected:
-
+ bool _alwaysShow;
Tile::TileType _type;
friend class TilePresentation;