Commit 40a9e2a2 authored by Frédéric Larue's avatar Frédéric Larue

Management of UIParam visibility improved.

parent 81bf7cab
...@@ -337,6 +337,8 @@ bool GLViewer::addDisplayable( GenericUIData *m ) ...@@ -337,6 +337,8 @@ bool GLViewer::addDisplayable( GenericUIData *m )
{ {
m_DisplayOptionsLayout->addWidget( m->GetDisplayOptions() ); m_DisplayOptionsLayout->addWidget( m->GetDisplayOptions() );
m->GetDisplayOptions()->show(); m->GetDisplayOptions()->show();
if( m->GetDisplayOptions()->AreAllHidden() )
m->GetDisplayOptions()->hide();
} }
if( isSelectionEnabled() ) if( isSelectionEnabled() )
......
...@@ -919,6 +919,7 @@ void UIMainWindow::removeFromCurrentProject() ...@@ -919,6 +919,7 @@ void UIMainWindow::removeFromCurrentProject()
updateTypeFilters(); updateTypeFilters();
updateCurrentProjectContent(); updateCurrentProjectContent();
update();
} }
} }
......
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#include <UIParam.h>
#include <UIParamSet.h>
UIParam::UIParam( const QString& id,
const QString& name,
const QString& description ) :
QObject(),
m_Group( NULL ),
m_Id( id ),
m_Name( name ),
m_Description( description ),
m_Label( NULL ),
m_Widget( NULL )
{
}
void UIParam::ArrangeInLayout( QGridLayout *l, int line )
{
m_Label = new QLabel( Name()+':', l->parentWidget() );
m_Widget->setParent( l->parentWidget() );
if( !m_Description.isNull() && !m_Description.isEmpty() )
{
m_Label->setToolTip( m_Description );
m_Widget->setToolTip( m_Description );
}
l->addWidget( m_Label , line,0 );
l->addWidget( m_Widget, line,1 );
}
void UIParam::SetVisible( bool visible )
{
m_Widget->setVisible( visible );
if( m_Label )
m_Label->setVisible( visible );
}
void UIParam::SetEnabled( bool enabled )
{
m_Widget->setEnabled( enabled );
if( m_Label )
m_Label->setEnabled( enabled );
}
...@@ -9,8 +9,12 @@ ...@@ -9,8 +9,12 @@
#ifndef UIPARAM_H #ifndef UIPARAM_H
#define UIPARAM_H #define UIPARAM_H
#include <QString> #include <QString>
#include <QtWidgets> #include <QtWidgets>
class UIParamSet;
class UIParam : public QObject class UIParam : public QObject
...@@ -18,6 +22,7 @@ class UIParam : public QObject ...@@ -18,6 +22,7 @@ class UIParam : public QObject
Q_OBJECT Q_OBJECT
protected: protected:
UIParamSet *m_Group;
QString m_Id; QString m_Id;
QString m_Name; QString m_Name;
QString m_Description; QString m_Description;
...@@ -25,78 +30,37 @@ protected: ...@@ -25,78 +30,37 @@ protected:
QWidget *m_Widget; QWidget *m_Widget;
public: public:
inline UIParam( const QString& id, UIParam( const QString& id, const QString& name, const QString& description );
const QString& name, virtual ~UIParam() {}
const QString& description ) :
QObject(), inline const QString& Id() const { return m_Id; }
m_Id( id ), inline const QString& Name() const { return m_Name; }
m_Name( name ), inline const QString& Description() const { return m_Description; }
m_Description( description ),
m_Label( NULL ), inline void SetGroup( UIParamSet *g ) { m_Group = g; }
m_Widget( NULL ) inline UIParamSet* Group() const { return m_Group; }
{}
virtual void ArrangeInLayout( QGridLayout *l, int line );
virtual ~UIParam() {} virtual void ConnectModificationSignal() = 0;
inline const QString& Id() const { return m_Id; } void SetVisible( bool visible = true );
inline const QString& Name() const { return m_Name; } inline void SetHidden ( bool hidden = true ) { SetVisible( !hidden ); }
inline const QString& Description() const { return m_Description; } inline bool IsVisible() const { return m_Widget->isVisible(); }
inline bool IsHidden () const { return m_Widget->isHidden (); }
inline virtual void ArrangeInLayout( QGridLayout *l, int line )
{ void SetEnabled ( bool enabled = true );
m_Label = new QLabel( Name()+':', l->parentWidget() ); inline void SetDisabled( bool disabled = true ) { SetEnabled( !disabled ); }
m_Widget->setParent( l->parentWidget() ); inline bool IsEnabled () const { return m_Widget->isEnabled(); }
inline bool IsDisabled() const { return !m_Widget->isEnabled(); }
if( !m_Description.isNull() && !m_Description.isEmpty() )
{
m_Label->setToolTip( m_Description );
m_Widget->setToolTip( m_Description );
}
l->addWidget( m_Label , line,0 );
l->addWidget( m_Widget, line,1 );
}
virtual void ConnectModificationSignal() = 0;
inline void SetVisible( bool visible = true )
{
if( m_Label )
m_Label->setVisible( visible );
m_Widget->setVisible( visible );
}
inline void SetHidden ( bool hidden = true )
{
if( m_Label )
m_Label->setHidden( hidden );
m_Widget->setHidden( hidden );
}
inline bool IsVisible() const { return m_Widget->isVisible(); }
inline bool IsHidden () const { return m_Widget->isHidden (); }
inline void SetEnabled ( bool enabled = true )
{
if( m_Label )
m_Label->setEnabled( enabled );
m_Widget->setEnabled( enabled );
}
inline void SetDisabled( bool disabled = true )
{
if( m_Label )
m_Label->setDisabled( disabled );
m_Widget->setDisabled( disabled );
}
inline bool IsEnabled () const { return m_Widget->isEnabled(); }
inline bool IsDisabled() const { return !m_Widget->isEnabled(); }
inline virtual QString ValueString() const = 0; inline virtual QString ValueString() const = 0;
inline virtual bool SetValueString( const QString &valueString ) = 0; inline virtual bool SetValueString( const QString &valueString ) = 0;
signals: signals:
void parameterUpdated( UIParam *p ); void parameterUpdated( UIParam *p );
protected slots: protected slots:
void triggerParameterUpdate() { emit parameterUpdated(this); } void triggerParameterUpdate() { emit parameterUpdated(this); }
}; };
......
...@@ -33,6 +33,8 @@ UIParamSet::~UIParamSet() ...@@ -33,6 +33,8 @@ UIParamSet::~UIParamSet()
void UIParamSet::Add( UIParam *param ) void UIParamSet::Add( UIParam *param )
{ {
param->SetGroup( this );
UIParamAction *act = dynamic_cast<UIParamAction*>( param ); UIParamAction *act = dynamic_cast<UIParamAction*>( param );
if( act ) if( act )
m_Actions.push_back( act ); m_Actions.push_back( act );
...@@ -90,3 +92,16 @@ void UIParamSet::updateChildrenLists( GenericUIData *d ) ...@@ -90,3 +92,16 @@ void UIParamSet::updateChildrenLists( GenericUIData *d )
for( auto l : m_ChildrenLists ) for( auto l : m_ChildrenLists )
l->Update( d ); l->Update( d );
} }
bool UIParamSet::AreAllHidden() const
{
for( auto p : m_ParamById )
if( p->IsVisible() )
return false;
if( m_AnimationCtrl && m_AnimationCtrl->IsVisible() )
return false;
return true;
}
...@@ -94,6 +94,8 @@ public: ...@@ -94,6 +94,8 @@ public:
inline const QList<UIParamAction*>& GetActions() const { return m_Actions; } inline const QList<UIParamAction*>& GetActions() const { return m_Actions; }
inline bool IsEmpty() const { return m_ParamById.empty() && !m_AnimationCtrl; } inline bool IsEmpty() const { return m_ParamById.empty() && !m_AnimationCtrl; }
bool AreAllHidden() const;
signals: signals:
void parameterUpdated( UIParam *p ); void parameterUpdated( UIParam *p );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment