Small improvements to 3D file selector UI
This commit is contained in:
parent
fc5556c811
commit
1028535561
|
@ -27,12 +27,18 @@
|
|||
#include "3d_cache/3d_info.h"
|
||||
#include "3d_cache/3d_cache.h"
|
||||
#include "3d_cache/dialogs/panel_prev_model.h"
|
||||
#include "3d_cache_dialogs.h"
|
||||
|
||||
#define ID_FILE_TREE ( wxID_LAST + 1 )
|
||||
#define ID_SET_DIR ( ID_FILE_TREE + 1 )
|
||||
#define ID_CFG_PATHS ( ID_SET_DIR + 1 )
|
||||
|
||||
#define ID_FILE_TREE 1000
|
||||
|
||||
wxBEGIN_EVENT_TABLE( DLG_SELECT_3DMODEL, wxDialog )
|
||||
EVT_DIRCTRL_SELECTIONCHANGED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnSelectionChanged )
|
||||
EVT_DIRCTRL_FILEACTIVATED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnFileActivated )
|
||||
EVT_CHOICE( ID_SET_DIR, DLG_SELECT_3DMODEL::SetRootDir )
|
||||
EVT_BUTTON( ID_CFG_PATHS, DLG_SELECT_3DMODEL::Cfg3DPaths )
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -51,8 +57,10 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
else
|
||||
m_resolver = NULL;
|
||||
|
||||
wxBoxSizer* bSizer0 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
bSizer1 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bSizer2;
|
||||
bSizer2 = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -60,14 +68,15 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
// set to NULL to avoid segfaults when m_FileTree is instantiated
|
||||
// and wxGenericDirCtrl events are posted
|
||||
m_preview = NULL;
|
||||
dirChoices = NULL;
|
||||
|
||||
m_FileTree = new wxGenericDirCtrl( this, ID_FILE_TREE, prevModelSelectDir, wxDefaultPosition,
|
||||
wxSize( 500,300 ), wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS
|
||||
wxSize( 300,100 ), wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS
|
||||
| wxDIRCTRL_SELECT_FIRST | wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, wxEmptyString, 0 );
|
||||
|
||||
|
||||
m_FileTree->ShowHidden( false );
|
||||
m_FileTree->SetMinSize( wxSize( 500,150 ) );
|
||||
m_FileTree->SetMinSize( wxSize( 300,100 ) );
|
||||
m_FileTree->SetLabel( wxT( "3D_MODEL_SELECTOR" ) );
|
||||
|
||||
bSizer2->Add( m_FileTree, 1, wxEXPAND | wxALL, 5 );
|
||||
|
@ -80,7 +89,7 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
previewSizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_preview = new PANEL_PREV_3D( this, m_cache );
|
||||
previewSizer->Add( m_preview, 1, wxEXPAND | wxALL, 5 );
|
||||
bSizer1->Add( previewSizer, 1, wxEXPAND, 5 );
|
||||
bSizer1->Add( previewSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
// create the filter list
|
||||
if( NULL != m_cache )
|
||||
|
@ -121,6 +130,18 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
m_FileTree->SetFilterIndex( 0 );
|
||||
}
|
||||
|
||||
// Add the path choice box and config button
|
||||
wxBoxSizer* hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
|
||||
dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition,
|
||||
wxSize( 320, 20 ) );
|
||||
dirChoices->SetMinSize( wxSize( 320, 12 ) );
|
||||
|
||||
wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
|
||||
wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Paths" ) );
|
||||
hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
|
||||
hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
|
||||
hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
|
||||
|
||||
wxButton* btn_OK = new wxButton( this, wxID_OK, _T( "OK" ) );
|
||||
wxButton* btn_Cancel = new wxButton( this, wxID_CANCEL, _T( "Cancel" ) );
|
||||
|
||||
|
@ -128,11 +149,14 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
|
|||
hSizer1->AddButton( btn_OK );
|
||||
hSizer1->AddButton( btn_Cancel );
|
||||
hSizer1->Realize();
|
||||
bSizer1->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
|
||||
bSizer0->Add( bSizer1, 1, wxALL | wxEXPAND, 5 );
|
||||
bSizer0->Add( hboxDirChoice, 0, wxALL | wxEXPAND, 5 );
|
||||
bSizer0->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
|
||||
|
||||
this->SetSizerAndFit( bSizer1 );
|
||||
updateDirChoiceList();
|
||||
|
||||
this->SetSizerAndFit( bSizer0 );
|
||||
this->Layout();
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
}
|
||||
|
||||
|
@ -188,3 +212,50 @@ void DLG_SELECT_3DMODEL::OnFileActivated( wxTreeEvent& event )
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DLG_SELECT_3DMODEL::SetRootDir( wxCommandEvent& event )
|
||||
{
|
||||
if( !m_FileTree )
|
||||
return;
|
||||
|
||||
m_FileTree->SetPath( dirChoices->GetString( dirChoices->GetSelection() ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DLG_SELECT_3DMODEL::Cfg3DPaths( wxCommandEvent& event )
|
||||
{
|
||||
if( S3D::Configure3DPaths( this, m_resolver ) )
|
||||
updateDirChoiceList();
|
||||
}
|
||||
|
||||
|
||||
void DLG_SELECT_3DMODEL::updateDirChoiceList( void )
|
||||
{
|
||||
if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices )
|
||||
return;
|
||||
|
||||
std::list< S3D_ALIAS > const* md = m_resolver->GetPaths();
|
||||
std::list< S3D_ALIAS >::const_iterator sL = md->begin();
|
||||
std::list< S3D_ALIAS >::const_iterator eL = md->end();
|
||||
std::vector< wxString > cl;
|
||||
|
||||
while( sL != eL )
|
||||
{
|
||||
if( !sL->m_pathexp.empty() && !sL->m_duplicate )
|
||||
cl.push_back( sL->m_pathexp );
|
||||
|
||||
++sL;
|
||||
}
|
||||
|
||||
if( !cl.empty() )
|
||||
{
|
||||
dirChoices->Clear();
|
||||
dirChoices->Append( (int)cl.size(), &cl[0] );
|
||||
dirChoices->Select( 0 );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ private:
|
|||
|
||||
wxGenericDirCtrl* m_FileTree;
|
||||
PANEL_PREV_3D* m_preview;
|
||||
wxChoice* dirChoices;
|
||||
|
||||
void updateDirChoiceList( void );
|
||||
|
||||
public:
|
||||
DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, S3D_INFO* aModelItem,
|
||||
|
@ -61,6 +64,8 @@ public:
|
|||
bool TransferDataFromWindow();
|
||||
void OnSelectionChanged( wxTreeEvent& event );
|
||||
void OnFileActivated( wxTreeEvent& event );
|
||||
void SetRootDir( wxCommandEvent& event );
|
||||
void Cfg3DPaths( wxCommandEvent& event );
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "3d_filename_resolver.h"
|
||||
#include "plugins/3dapi/ifsg_api.h"
|
||||
#include "panel_prev_model.h"
|
||||
#include "3d_cache_dialogs.h"
|
||||
|
||||
|
||||
// ensure -360 < rotation < 360
|
||||
|
@ -63,9 +62,7 @@ static void checkRotation( double& rot )
|
|||
|
||||
|
||||
enum {
|
||||
ID_SET_DIR = wxID_LAST + 1,
|
||||
ID_CFG_PATHS,
|
||||
ID_SCALEX,
|
||||
ID_SCALEX = wxID_LAST + 1,
|
||||
ID_SCALEY,
|
||||
ID_SCALEZ,
|
||||
ID_ROTX,
|
||||
|
@ -85,7 +82,6 @@ enum {
|
|||
};
|
||||
|
||||
wxBEGIN_EVENT_TABLE( PANEL_PREV_3D, wxPanel)
|
||||
EVT_CHOICE( ID_SET_DIR, PANEL_PREV_3D::SetRootDir )
|
||||
EVT_TEXT_ENTER( ID_SCALEX, PANEL_PREV_3D::updateOrientation )
|
||||
EVT_TEXT_ENTER( ID_SCALEY, PANEL_PREV_3D::updateOrientation )
|
||||
EVT_TEXT_ENTER( ID_SCALEZ, PANEL_PREV_3D::updateOrientation )
|
||||
|
@ -95,8 +91,6 @@ wxBEGIN_EVENT_TABLE( PANEL_PREV_3D, wxPanel)
|
|||
EVT_TEXT_ENTER( ID_OFFX, PANEL_PREV_3D::updateOrientation )
|
||||
EVT_TEXT_ENTER( ID_OFFY, PANEL_PREV_3D::updateOrientation )
|
||||
EVT_TEXT_ENTER( ID_OFFZ, PANEL_PREV_3D::updateOrientation )
|
||||
EVT_BUTTON( ID_SET_DIR, PANEL_PREV_3D::SetRootDir )
|
||||
EVT_BUTTON( ID_CFG_PATHS, PANEL_PREV_3D::Cfg3DPaths )
|
||||
EVT_BUTTON( ID_3D_ISO, PANEL_PREV_3D::View3DISO )
|
||||
EVT_BUTTON( ID_3D_UPDATE, PANEL_PREV_3D::View3DUpdate )
|
||||
EVT_BUTTON( ID_3D_LEFT, PANEL_PREV_3D::View3DLeft )
|
||||
|
@ -131,8 +125,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager ) :
|
|||
wxBoxSizer* mainBox = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticBoxSizer* vbox = new wxStaticBoxSizer( wxVERTICAL, this, _( "3D Model Orientation" ) );
|
||||
wxBoxSizer* hboxDirChoice = NULL;
|
||||
dirChoices = NULL;
|
||||
|
||||
m_FileTree = NULL;
|
||||
|
||||
|
@ -140,22 +132,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager ) :
|
|||
m_FileTree = (wxGenericDirCtrl*)
|
||||
aParent->FindWindowByLabel( wxT( "3D_MODEL_SELECTOR" ), aParent );
|
||||
|
||||
if( NULL != m_FileTree )
|
||||
{
|
||||
hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
|
||||
dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition,
|
||||
wxSize( 320, 20 ) );
|
||||
dirChoices->SetMinSize( wxSize( 320, 12 ) );
|
||||
|
||||
wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
|
||||
wxButton* usePath = new wxButton( this, ID_SET_DIR, _( "Change" ) );
|
||||
wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Paths" ) );
|
||||
hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
|
||||
hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
|
||||
hboxDirChoice->Add( usePath, 0, wxALL, 5 );
|
||||
hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
|
||||
}
|
||||
|
||||
wxFloatingPointValidator< float > valScale( 6 );
|
||||
valScale.SetRange( 0.001, 100 );
|
||||
wxFloatingPointValidator< float > valRotate( 2 );
|
||||
|
@ -245,9 +221,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager ) :
|
|||
vbOffset->Add( hbO2, 0, wxEXPAND | wxALL, 2 );
|
||||
vbOffset->Add( hbO3, 0, wxEXPAND | wxALL, 2 );
|
||||
|
||||
if( NULL != hboxDirChoice )
|
||||
mainBox->Add( hboxDirChoice, 0, wxEXPAND );
|
||||
|
||||
// hbox holding orientation data and preview
|
||||
wxBoxSizer* hbox = new wxBoxSizer( wxHORIZONTAL );
|
||||
// vbox holding orientation data
|
||||
|
@ -318,7 +291,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager ) :
|
|||
vboxPrev->Hide( hbBB, true );
|
||||
}
|
||||
|
||||
updateDirChoiceList();
|
||||
SetSizerAndFit( mainBox );
|
||||
Centre();
|
||||
|
||||
|
@ -341,56 +313,6 @@ PANEL_PREV_3D::~PANEL_PREV_3D()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_PREV_3D::updateDirChoiceList( void )
|
||||
{
|
||||
if( NULL == m_FileTree || NULL == m_ModelManager || NULL == dirChoices )
|
||||
return;
|
||||
|
||||
if( NULL != m_resolver )
|
||||
{
|
||||
std::list< S3D_ALIAS > const* md = m_resolver->GetPaths();
|
||||
std::list< S3D_ALIAS >::const_iterator sL = md->begin();
|
||||
std::list< S3D_ALIAS >::const_iterator eL = md->end();
|
||||
std::vector< wxString > cl;
|
||||
|
||||
while( sL != eL )
|
||||
{
|
||||
if( !sL->m_pathexp.empty() && !sL->m_duplicate )
|
||||
cl.push_back( sL->m_pathexp );
|
||||
|
||||
++sL;
|
||||
}
|
||||
|
||||
if( !cl.empty() )
|
||||
{
|
||||
dirChoices->Clear();
|
||||
dirChoices->Append( (int)cl.size(), &cl[0] );
|
||||
dirChoices->Select( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void PANEL_PREV_3D::SetRootDir( wxCommandEvent& event )
|
||||
{
|
||||
if( !m_FileTree )
|
||||
return;
|
||||
|
||||
m_FileTree->SetPath( dirChoices->GetString( dirChoices->GetSelection() ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void PANEL_PREV_3D::Cfg3DPaths( wxCommandEvent& event )
|
||||
{
|
||||
if( S3D::Configure3DPaths( this, m_resolver ) )
|
||||
updateDirChoiceList();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_PREV_3D::View3DISO( wxCommandEvent& event )
|
||||
{
|
||||
// XXX - TO BE IMPLEMENTED
|
||||
|
|
|
@ -51,8 +51,6 @@ public:
|
|||
PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager );
|
||||
~PANEL_PREV_3D();
|
||||
|
||||
void SetRootDir( wxCommandEvent& event );
|
||||
void Cfg3DPaths( wxCommandEvent& event );
|
||||
// 3D views
|
||||
void View3DISO( wxCommandEvent& event );
|
||||
void View3DUpdate( wxCommandEvent& event );
|
||||
|
@ -74,7 +72,6 @@ private:
|
|||
S3D_CACHE* m_ModelManager;
|
||||
S3D_FILENAME_RESOLVER* m_resolver;
|
||||
wxGenericDirCtrl* m_FileTree;
|
||||
wxChoice* dirChoices;
|
||||
wxTextCtrl* xscale;
|
||||
wxTextCtrl* yscale;
|
||||
wxTextCtrl* zscale;
|
||||
|
@ -91,7 +88,6 @@ private:
|
|||
|
||||
|
||||
private:
|
||||
void updateDirChoiceList( void );
|
||||
void updateOrientation( wxCommandEvent &event );
|
||||
|
||||
void getOrientationVars( SGPOINT& scale, SGPOINT& rotation, SGPOINT& offset );
|
||||
|
|
Loading…
Reference in New Issue