Skip to content

Commit

Permalink
Make so all open dialogs close when phone rotates.
Browse files Browse the repository at this point in the history
Make desktop interface default for tablets.
Fixup a few other little things.
  • Loading branch information
wcjohns committed Aug 15, 2024
1 parent c0ade7b commit 249eb3c
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 17 deletions.
2 changes: 1 addition & 1 deletion InterSpec_resources/InterSpecMobileCommon.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ul.HorizontalMenu {
padding-left: 1px;
padding-right:1px;
padding-bottom: 2px;
height: 22px;
height: 25px;
display: block;
}

Expand Down
2 changes: 1 addition & 1 deletion data/default_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<pref name="ExternalRidExe" type="String"></pref>
<pref name="AlwaysCallExternalRid" type="Integer">0</pref>
<pref name="AutoShowSpecMultimedia" type="Boolean">false</pref>
<pref name="TabletUseDesktopMenus" type="Boolean">false</pref>
<pref name="TabletUseDesktopMenus" type="Boolean">true</pref>
<pref name="RefLineShowRiid" type="Boolean">true</pref>
<pref name="RefLineShowPrev" type="Boolean">true</pref>
<pref name="RefLineShowAssoc" type="Boolean">true</pref>
Expand Down
85 changes: 84 additions & 1 deletion src/InterSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,91 @@ void InterSpec::layoutSizeChanged( int w, int h )
if( (w > 20) && (h > 20) )
{
const bool isVertical = (h > w);

// If we are changing orientation - close all the open windows
// TODO: close are restore all the windows, instead of just closing them
#if( USE_CSS_FLEX_LAYOUT )
if( m_toolsTabs->isVisible() != isVertical )
#else
if( static_cast<bool>(m_toolsTabs) != isVertical )
#endif
{
//m_energyCalWindow and m_nuclideSearchWindow will get closed by `setToolTabsVisible(...)`
if( m_gammaCountDialog )
deleteGammaCountDialog();

if( m_shieldingSourceFitWindow )
closeShieldingSourceFit();

#if( USE_REL_ACT_TOOL )
if( m_relActAutoWindow )
m_relActAutoWindow->hide(); //rejects if, calling `handleRelActAutoClose()`
if( m_relActManualWindow )
m_relActManualWindow->hide(); //rejects if, calling `handleRelActManualClose()`
#endif

if( m_multimedia )
programmaticallyCloseMultimediaWindow();

#if( USE_REMOTE_RID )
if( m_autoRemoteRidResultDialog )
programaticallyCloseAutoRemoteRidResultDialog();
#endif
if( m_gammaXsToolWindow )
m_gammaXsToolWindow->hide(); //calls deleteGammaXsTool
if( m_doseCalcWindow )
deleteDoseCalcTool();
if( m_1overR2Calc )
deleteOneOverR2Calc();
if( m_unitsConverter )
deleteUnitsConverterTool();
if( m_fluxTool )
deleteFluxTool();
if( m_makeDrfTool )
handleCloseMakeDrfWindow( m_makeDrfTool );
#if( USE_LEAFLET_MAP )
if( m_leafletWindow )
programmaticallyCloseLeafletMap();
#endif
if( m_enterUri )
m_enterUri->accept();
assert( !m_enterUri );
if( m_terminalWindow )
m_terminalWindow->hide();
#if( USE_REMOTE_RID )
if( m_remoteRidWindow )
deleteRemoteRidWindow();
#endif
#if( USE_DETECTION_LIMIT_TOOL )
if( m_simpleMdaWindow )
handleSimpleMdaWindowClose();
if( m_detectionLimitWindow )
handleDetectionLimitWindowClose();
#endif
if( m_helpWindow )
closeHelpWindow();
if( m_licenseWindow )
deleteLicenseAndDisclaimersWindow();
if( m_useInfoWindow )
deleteWelcomeDialog( true );
if( m_decayInfoWindow )
deleteDecayInfoWindow();
if( m_addFwhmTool )
deleteFwhmFromForegroundWindow();
if( m_preserveCalibWindow )
deleteEnergyCalPreserveWindow();
#if( USE_SEARCH_MODE_3D_CHART )
if( m_3dViewWindow )
handle3DSearchModeChartClose( m_3dViewWindow );
#endif
if( m_riidDisplay )
programmaticallyCloseRiidResults();
if( m_drfSelectWindow )
closeDrfSelectWindow();
}//if( we are changing orientation )

setToolTabsVisible( isVertical );
}
}//if( (w > 20) && (h > 20) )
}//if( isPhone() )
#endif

Expand Down
52 changes: 40 additions & 12 deletions src/UseInfoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include <Wt/WGridLayout>
#include <Wt/Json/Parser>
#include <Wt/Json/Object>
#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <Wt/WMediaPlayer>
#include <Wt/WRadioButton>
#include <Wt/WStandardItem>
Expand Down Expand Up @@ -676,9 +678,10 @@ UseInfoWindow::UseInfoWindow( std::function<void(bool)> showAgainCallback,
"icon for detailed information about <code>InterSpec</code>s tools and features."
"</p>";

WGridLayout *rightLayout = nullptr;
if( m_viewer->isPhone() )
{
WGridLayout *rightLayout = new WGridLayout();
rightLayout = new WGridLayout();
rightLayout->setContentsMargins( 0, 0, 0, 0 );
rightLayout->setVerticalSpacing( 0 );
rightLayout->setHorizontalSpacing( 0 );
Expand Down Expand Up @@ -707,7 +710,7 @@ UseInfoWindow::UseInfoWindow( std::function<void(bool)> showAgainCallback,
*/
}else
{
WGridLayout* rightLayout = new WGridLayout();
rightLayout = new WGridLayout();
welcomeContainer->setLayout(rightLayout);

rightLayout->addWidget( text, 0, 0 );
Expand Down Expand Up @@ -747,7 +750,7 @@ UseInfoWindow::UseInfoWindow( std::function<void(bool)> showAgainCallback,

auto showLicenceAndTerms = [](){
// We'll keep from capturing closing the window and opening the new window as two
// seperate undo/redo events.
// separate undo/redo events.
{
UndoRedoManager::BlockUndoRedoInserts blocker;
InterSpec *viewer = InterSpec::instance();
Expand Down Expand Up @@ -817,30 +820,55 @@ UseInfoWindow::UseInfoWindow( std::function<void(bool)> showAgainCallback,

if( showAgainCallback )
{
WCheckBox *cb = new WCheckBox( "show at start when no spectra", bottom );
cb->setFloatSide( Left );
//WGridLayout *rightLayout = nullptr;
bool isVertical = false;
if( m_viewer->isPhone() )
{
int w = m_viewer->renderedWidth();
int h = m_viewer->renderedHeight();
if( w < 100 )
{
w = wApp->environment().screenWidth();
h = wApp->environment().screenHeight();
}
isVertical = ((w > 100) && (w < h));
}//if( isPhone )


WCheckBox *showAgainCb = nullptr;
assert( rightLayout );
if( isVertical && rightLayout )
{
showAgainCb = new WCheckBox( "show at start when no spectra" );
rightLayout->addWidget( showAgainCb, rightLayout->rowCount(), 0 );
}else
{
// Put CB into header
showAgainCb = new WCheckBox( "show at start when no spectra", bottom );
}
showAgainCb->setFloatSide( Left );

try
{
const bool showAtStartup = viewer->m_user->preferenceValue<bool>( "ShowSplashScreen" );
cb->setChecked( showAtStartup );
showAgainCb->setChecked( showAtStartup );
}catch(...)
{
// probably wont ever get here, but JIC
}


cb->checked().connect( boost::bind( showAgainCallback, true ) );
cb->unChecked().connect( boost::bind( showAgainCallback, false ) );
showAgainCb->checked().connect( boost::bind( showAgainCallback, true ) );
showAgainCb->unChecked().connect( boost::bind( showAgainCallback, false ) );
if( m_viewer->isMobile() )
{
cb->setFloatSide(Right);
cb->setMargin(10,Right);
cb->setMargin(3,Top);
showAgainCb->setFloatSide(Right);
showAgainCb->setMargin(10,Right);
showAgainCb->setMargin(3,Top);
}//isPhone
}//if( !force )

WPushButton *ok = addCloseButtonToFooter( "Close" );
WPushButton *ok = addCloseButtonToFooter( WString::tr("Close") );
ok->clicked().connect( boost::bind( &AuxWindow::hide, this ) );

if( viewer
Expand Down
4 changes: 2 additions & 2 deletions target/ios/InterSpec/InterSpec.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
"$(PROJECT_DIR)/build-iphoneos",
"$(PROJECT_DIR)/build-iphoneos/LibInterSpec",
);
MARKETING_VERSION = 1.0.12;
MARKETING_VERSION = 1.0.13;
OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = (
"-ftemplate-depth=512",
Expand Down Expand Up @@ -497,7 +497,7 @@
"$(PROJECT_DIR)/build-iphoneos",
"$(PROJECT_DIR)/build-iphoneos/LibInterSpec",
);
MARKETING_VERSION = 1.0.12;
MARKETING_VERSION = 1.0.13;
OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = (
"-ftemplate-depth=512",
Expand Down

0 comments on commit 249eb3c

Please sign in to comment.