Skip to content

Commit

Permalink
Improve display on phone Portrait for most of the remaining tools.
Browse files Browse the repository at this point in the history
Still not 100%, but better display of most things in portrait mode on phones.

Fixed bug calling wrong method to get preference, when the user may not have altered the preference yet; notably when creating the Detection tool.
  • Loading branch information
wcjohns committed Aug 14, 2024
1 parent ef0ea21 commit c0ade7b
Show file tree
Hide file tree
Showing 30 changed files with 523 additions and 160 deletions.
3 changes: 3 additions & 0 deletions InterSpec/FluxTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ class FluxToolWidget : public Wt::WContainerWidget
InterSpec *m_interspec;
DetectorDisplay *m_detector;

/** Wether layout out for portrait phones or not. */
bool m_narrowLayout;

Wt::WText *m_msg;
Wt::WLineEdit *m_distance;
Wt::WString m_prevDistance; // For undo/redo
Expand Down
16 changes: 12 additions & 4 deletions InterSpec/InterSpecUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class InterSpecUser
*/
template<class T, class V>
static void addCallbackWhenChanged( Wt::Dbo::ptr<InterSpecUser> &user,
InterSpec *viewer,
const std::string &name, T *target,
void (V::*method)(bool) );

Expand All @@ -338,6 +339,7 @@ class InterSpecUser
*/
template<class T>
static void addCallbackWhenChanged( Wt::Dbo::ptr<InterSpecUser> &user,
InterSpec *viewer,
const std::string &name,
const T &fcn );

Expand Down Expand Up @@ -1240,14 +1242,17 @@ void InterSpecUser::setPreferenceValue( Wt::Dbo::ptr<InterSpecUser> user,

template<class T>
void InterSpecUser::addCallbackWhenChanged( Wt::Dbo::ptr<InterSpecUser> &user,
InterSpec *viewer,
const std::string &name, const T &fcn )
{
assert( user );
if( !user ) //shouldnt ever happen
return;

//Make sure a valid bool preference
user->preferenceValue<bool>( name );
//Make sure a valid bool preference (note using call with pointer to InterSpec
// incase the user has never changed the preference value, so not in
// `user->m_preferences` yet.
user->preferenceValue<bool>( name, viewer );

std::shared_ptr<Wt::Signals::signal<void(bool)>> &signal = user->m_onBoolChangeSignals[name];
if( !signal )
Expand All @@ -1258,15 +1263,18 @@ void InterSpecUser::addCallbackWhenChanged( Wt::Dbo::ptr<InterSpecUser> &user,

template<class T, class V>
void InterSpecUser::addCallbackWhenChanged( Wt::Dbo::ptr<InterSpecUser> &user,
InterSpec *viewer,
const std::string &name,
T *target, void (V::*method)(bool) )
{
assert( user );
if( !user ) //shouldnt ever happen
return;

//Make sure a valid bool preference
user->preferenceValue<bool>( name );
//Make sure a valid bool preference (note using call with pointer to InterSpec
// incase the user has never changed the preference value, so not in
// `user->m_preferences` yet.
user->preferenceValue<bool>( name, viewer );

// Retrieve (or create) the signal, and connect things up
std::shared_ptr<Wt::Signals::signal<void(bool)>> &signal = user->m_onBoolChangeSignals[name];
Expand Down
3 changes: 2 additions & 1 deletion InterSpec/LicenseAndDisclaimersWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "InterSpec/AuxWindow.h"

//forward declarations
class InterSpec;
class SideMenuItem; //defined in UseInfoWindow.h

namespace Wt
Expand All @@ -54,7 +55,7 @@ class LicenseAndDisclaimersWindow : public AuxWindow
\param screen_width width in pixels of the screen
\param screen_height height in pixels of the screen
*/
LicenseAndDisclaimersWindow( int screen_width, int screen_height );
LicenseAndDisclaimersWindow( InterSpec *viewer );
~LicenseAndDisclaimersWindow();

/** Handles the "path" component of an app URL.
Expand Down
17 changes: 17 additions & 0 deletions InterSpec_resources/DrfSelect.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

.DrfSelectNarrow {
font-size: x-small;
}

.DetectorLabel
{
font-size: 12px;
Expand Down Expand Up @@ -52,6 +57,18 @@ table.FormulaDrfTbl label
padding-bottom: 3px;
}

.DetEditMenuHorizontal {

}

.DetEditNarrowSecondFooter {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
}

.DetectorDiamDiv
{

Expand Down
14 changes: 10 additions & 4 deletions InterSpec_resources/InterSpecMobileCommon.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,22 @@ ul.HorizontalMenu > li {
padding-right: 2px;
}

.IsPhone.Portrait button
{
.IsPhone.Portrait button {
font-size: x-small;
}

.IsPhone.Portrait .modal-footer button, .IsPhone.Portrait .PhoneAuxWindowHeader button {
font-size: 10pt;
}

@media (max-width: 350px) {
.IsPhone.Portrait button
{
.IsPhone.Portrait button {
font-size: 6pt;
}

.IsPhone.Portrait .modal-footer button, .IsPhone.Portrait .PhoneAuxWindowHeader button {
font-size: 10pt;
}
}

.mobilePopupMenuOverlay {
Expand Down
2 changes: 1 addition & 1 deletion InterSpec_resources/LeafletRadMap.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ we could do something like below, as well as specifying the border
padding-right: 5px;
background-color: #fff;
color: #000 !important;
}
}
7 changes: 6 additions & 1 deletion InterSpec_resources/LeafletRadMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ LeafletRadMap = function (elem,options) {
this.options.loadTxt = "Load";
if( typeof this.options.measurementsAsTxt !== "string" )
this.options.measurementsAsTxt = "measurements as";
if( typeof this.options.loadTxtShort !== "string" )
this.options.loadTxtShort = "Load as";
if( typeof this.options.realTimeTxt !== "string" )
this.options.realTimeTxt = "Real Time";
if( typeof this.options.liveTimeTxt !== "string" )
Expand Down Expand Up @@ -293,7 +295,10 @@ LeafletRadMap.prototype.handleUserDrawingUpdate = function(){
self.btnsDiv.innerHTML = '';

const msg = document.createElement('div');
msg.innerHTML = self.options.loadTxt + " " + wantedSamples.length + " " + self.options.measurementsAsTxt + ":";
if( window.innerWidth < 675 )
msg.innerHTML = self.options.loadTxtShort + ":";
else
msg.innerHTML = self.options.loadTxt + " " + wantedSamples.length + " " + self.options.measurementsAsTxt + ":";
self.btnsDiv.appendChild( msg );

const foreground = document.createElement('button');
Expand Down
19 changes: 19 additions & 0 deletions InterSpec_resources/MoreNuclideInfoDisplay.css
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,22 @@ uses to control its maximum width.
list-style-type: none;
padding-inline-start: 5px;
}

@media screen and (max-device-width: 480px) {
.MoreNuclideInfoDisplay {
font-size: x-small;
}

.MoreNuclideInfoDisplay .MoreNucInfoTitle {
font-size: medium;
}

.MoreNuclideInfoDisplay .MoreNucInfoSection .MoreNucInfoSubTitle {
font-size: small;
}

.MoreNuclideInfoDisplay .HalfLife {
font-size: 6px;
}
}

3 changes: 2 additions & 1 deletion InterSpec_resources/app_text/FluxTool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<message id="ftw-simple">Simple</message>
<message id="ftw-standard">Standard</message>
<message id="ftw-more">More</message>
<message id="ftw-copy">ftw-copy-btn</message>
<message id="ftw-copy-btn">Copy To Clipboard</message>
<message id="ftw-copy-btn-narrow">Copy</message>
<message id="ftw-invalid-dist">Invalid Distance</message>
<message id="ftw-no-drf">No Detector Response Function Chosen</message>
<message id="ftw-no-foreground">No foreground spectrum loaded</message>
Expand Down
3 changes: 2 additions & 1 deletion InterSpec_resources/app_text/FluxTool_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<message id="ftw-simple">Simple</message>
<message id="ftw-standard">Standard</message>
<message id="ftw-more">Plus</message>
<message id="ftw-copy">ftw-copy-btn</message>
<message id="ftw-copy-btn">Copier</message>
<message id="ftw-copy-btn-narrow">Copier</message>
<message id="ftw-invalid-dist">Distance Invalide</message>
<message id="ftw-no-drf">Aucune Fonction de Réponse du Détecteur Choisie</message>
<message id="ftw-no-foreground">Aucun spectre de premier plan chargé</message>
Expand Down
6 changes: 3 additions & 3 deletions InterSpec_resources/app_text/GammaCountDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
<message id="gcd-background-scale-note">Background is being scaled by {1}</message>
<message id="gcd-and-secondary-scaled"> and secondary by </message>
<message id="gcd-secondary-scale-note">Secondary background is being scaled by </message>
<message id="gcd-foreground-above-background">Foreground is {1} σ below background.</message>
<message id="gcd-foreground-below-background">Foreground is {1} σ above background.</message>
</messages>
<message id="gcd-foreground-above-background">Foreground is {1} σ above background.</message>
<message id="gcd-foreground-below-background">Foreground is {1} σ below background.</message>
</messages>
1 change: 1 addition & 0 deletions InterSpec_resources/app_text/InterSpec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<message id="Delete">Delete</message>
<message id="Photopeak">Photopeak</message>
<message id="Nuclide">Nuclide</message>
<message id="Nuc.">Nuc.</message>
<message id="Skew">Skew</message>
<message id="CPS">CPS</message>
<message id="CSV">CSV</message>
Expand Down
1 change: 1 addition & 0 deletions InterSpec_resources/app_text/LeafletRadMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
<message id="lrm-err-loading-samples">Error loading map-selected samples: {1}</message>
<message id="lrm-displayed-as">Displayed as</message>
<message id="lrm-measurements-as">measurements as</message>
<message id="lrm-load-meas-as-short">Load as</message>
</messages>
16 changes: 15 additions & 1 deletion src/CompactFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#include <Wt/WDoubleValidator>
#include <Wt/WRegExpValidator>

#if( !USE_GOOGLE_MAP && !USE_LEAFLET_MAP )
#include <Wt/WAnchor>
#endif

// Disable streamsize <=> size_t warnings in boost
#pragma warning(disable:4244)

Expand Down Expand Up @@ -894,7 +898,7 @@ void CompactFileManager::updateSummaryTable( SpecUtils::SpectrumType type,

table->show();

char buffer[64] = { '\0' };
char buffer[128] = { '\0' };
const WString second_label = WString::tr("units-label-seconds-short");
const WString live_time_label = WString::tr("Live Time");
const WString real_time_label = WString::tr("Real Time");
Expand Down Expand Up @@ -1003,12 +1007,22 @@ void CompactFileManager::updateSummaryTable( SpecUtils::SpectrumType type,
cell = table->elementAt(table_pos / num_info_col, 1 + 2*(table_pos % num_info_col) );

snprintf( buffer, sizeof(buffer), "%.4f,%.4f", hist->latitude(), hist->longitude() );
#if( USE_GOOGLE_MAP || USE_LEAFLET_MAP )
snprintf( buffer, sizeof(buffer), "%.4f,%.4f", hist->latitude(), hist->longitude() );
WPushButton *gps = new WPushButton( buffer, cell );
gps->addStyleClass( "LinkBtn GpsBtn" );
gps->clicked().connect( boost::bind( &InterSpec::createMapWindow, m_interspec, type, false) );

snprintf( buffer, sizeof(buffer), "%.6f,%.6f - click to show a map", hist->latitude(), hist->longitude() );
gps->setToolTip( buffer );
#else
// Make a link to google maps
WString coordText = WString::fromUTF8(buffer);
snprintf( buffer, sizeof(buffer), "https://maps.google.com/?q=%.7f,%.7f", hist->latitude(), hist->longitude() );
WAnchor *mapLink = new WAnchor( WLink(buffer), coordText, cell );
mapLink->setTarget( AnchorTarget::TargetNewWindow );
mapLink->setToolTip( "Will open a web browser window showing this location." );
#endif
}//if( hist->has_gps_info() )

if( meas && !meas->manufacturer().empty() )
Expand Down
4 changes: 2 additions & 2 deletions src/DetectionLimitTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ class MdaPeakRow : public WContainerWidget
//Right now we are just having DetectionLimitTool completely refresh on activity units change,
// but we could be a little more fine-grained about this.
//InterSpec *viewer = InterSpec::instance();
//InterSpecUser::addCallbackWhenChanged( viewer->m_user, "DisplayBecquerel",
//InterSpecUser::addCallbackWhenChanged( viewer->m_user, viewer, "DisplayBecquerel",
// boost::bind(&MdaPeakRow::setSimplePoisonTxt, this) );
}//MdaPeakRow constructor

Expand Down Expand Up @@ -1398,7 +1398,7 @@ DetectionLimitTool::DetectionLimitTool( InterSpec *viewer,
handleUserNuclideChange();

// Update the displayed activity units, when the user changes this preference.
InterSpecUser::addCallbackWhenChanged( viewer->m_user, "DisplayBecquerel",
InterSpecUser::addCallbackWhenChanged( viewer->m_user, viewer, "DisplayBecquerel",
boost::bind(&DetectionLimitTool::handleInputChange, this) );


Expand Down
19 changes: 11 additions & 8 deletions src/DoseCalcWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ void DoseCalcWidget::init()
workLayout->addWidget( enterDiv, 0, 0 );
workLayout->addWidget( answerDiv, 1, 0 );
workLayout->setColumnStretch( 0, 1 );
//workLayout->setRowStretch( 0, 1 );
//workLayout->setRowStretch( 1, 1 );
workLayout->setRowStretch( 0, 1 );
workLayout->setRowStretch( 1, 1 );
}else
{
answerLayout->setContentsMargins( 9, 1, 9, 5 );
Expand Down Expand Up @@ -757,12 +757,15 @@ void DoseCalcWidget::init()
m_issueTxt->addStyleClass( "DoseIssueTxt" );
answerLayout->addWidget( m_issueTxt, answerLayout->rowCount(), 0, AlignBottom );

for( int i = 1; i < answerLayout->rowCount(); ++i )
answerLayout->setRowStretch( i, 1 );
answerLayout->setRowStretch( stayRow, 2 );

for( int i = 1; i < enterLayout->rowCount(); ++i )
enterLayout->setRowStretch( i, 1 );
if( !narrowLayout )
{
for( int i = 1; i < answerLayout->rowCount(); ++i )
answerLayout->setRowStretch( i, 1 );
answerLayout->setRowStretch( stayRow, 2 );

for( int i = 1; i < enterLayout->rowCount(); ++i )
enterLayout->setRowStretch( i, 1 );
}//if( !narrowLayout )

try
{
Expand Down
Loading

0 comments on commit c0ade7b

Please sign in to comment.