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 )
{
m_DisplayOptionsLayout->addWidget( m->GetDisplayOptions() );
m->GetDisplayOptions()->show();
if( m->GetDisplayOptions()->AreAllHidden() )
m->GetDisplayOptions()->hide();
}
if( isSelectionEnabled() )
......
......@@ -919,6 +919,7 @@ void UIMainWindow::removeFromCurrentProject()
updateTypeFilters();
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 @@
#ifndef UIPARAM_H
#define UIPARAM_H
#include <QString>
#include <QtWidgets>
class UIParamSet;
class UIParam : public QObject
......@@ -18,6 +22,7 @@ class UIParam : public QObject
Q_OBJECT
protected:
UIParamSet *m_Group;
QString m_Id;
QString m_Name;
QString m_Description;
......@@ -25,78 +30,37 @@ protected:
QWidget *m_Widget;
public:
inline UIParam( const QString& id,
const QString& name,
const QString& description ) :
QObject(),
m_Id( id ),
m_Name( name ),
m_Description( description ),
m_Label( NULL ),
m_Widget( NULL )
{}
virtual ~UIParam() {}
inline const QString& Id() const { return m_Id; }
inline const QString& Name() const { return m_Name; }
inline const QString& Description() const { return m_Description; }
inline virtual void 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 );
}
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(); }
UIParam( const QString& id, const QString& name, const QString& description );
virtual ~UIParam() {}
inline const QString& Id() const { return m_Id; }
inline const QString& Name() const { return m_Name; }
inline const QString& Description() const { return m_Description; }
inline void SetGroup( UIParamSet *g ) { m_Group = g; }
inline UIParamSet* Group() const { return m_Group; }
virtual void ArrangeInLayout( QGridLayout *l, int line );
virtual void ConnectModificationSignal() = 0;
void SetVisible( bool visible = true );
inline void SetHidden ( bool hidden = true ) { SetVisible( !hidden ); }
inline bool IsVisible() const { return m_Widget->isVisible(); }
inline bool IsHidden () const { return m_Widget->isHidden (); }
void SetEnabled ( bool enabled = true );
inline void SetDisabled( bool disabled = true ) { SetEnabled( !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 bool SetValueString( const QString &valueString ) = 0;
signals:
void parameterUpdated( UIParam *p );
void parameterUpdated( UIParam *p );
protected slots:
void triggerParameterUpdate() { emit parameterUpdated(this); }
void triggerParameterUpdate() { emit parameterUpdated(this); }
};
......
......@@ -33,6 +33,8 @@ UIParamSet::~UIParamSet()
void UIParamSet::Add( UIParam *param )
{
param->SetGroup( this );
UIParamAction *act = dynamic_cast<UIParamAction*>( param );
if( act )
m_Actions.push_back( act );
......@@ -90,3 +92,16 @@ void UIParamSet::updateChildrenLists( GenericUIData *d )
for( auto l : m_ChildrenLists )
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:
inline const QList<UIParamAction*>& GetActions() const { return m_Actions; }
inline bool IsEmpty() const { return m_ParamById.empty() && !m_AnimationCtrl; }
bool AreAllHidden() const;
signals:
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