Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/ngscopeclient/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ static void MainWindow_OnChangedViewport([[maybe_unused]] ImGuiViewport *vp)
#define DBG_SUFFIX ""
#endif

MainWindow::MainWindow(shared_ptr<QueueHandle> queue)
: VulkanWindow("ngscopeclient " NGSCOPECLIENT_VERSION " " DBG_SUFFIX SAN_SUFFIX, queue)
MainWindow::MainWindow(shared_ptr<QueueHandle> queue, bool maximized, bool restored)
: VulkanWindow("ngscopeclient " NGSCOPECLIENT_VERSION " " DBG_SUFFIX SAN_SUFFIX, queue, maximized, restored)
, m_showDemo(false)
, m_nextWaveformGroup(1)
, m_toolbarIconSize(0)
Expand Down Expand Up @@ -610,7 +610,7 @@ void MainWindow::ResetStyle()
style.FontSizeBase = oldStyle.FontSizeBase;
style.FontScaleMain = oldStyle.FontScaleMain;
style.FontScaleDpi = oldStyle.FontScaleDpi;
style.ScaleAllSizes(style.FontScaleDpi);
style.ScaleAllSizes(VulkanWindow::m_forceDPIScaling ? VulkanWindow::m_forcedUIScale : style.FontScaleDpi);

switch(m_session.GetPreferences().GetEnumRaw("Appearance.General.theme"))
{
Expand Down Expand Up @@ -2604,6 +2604,12 @@ bool MainWindow::LoadUIConfiguration(int version, const YAML::Node& node)
m_pendingHeight = window["height"].as<int>();
m_softwareResizeRequested = true;
}
// Load trace alpha
if(window["traceAlpha"])
m_traceAlpha = window["traceAlpha"].as<float>();
// Load persistance s
if(window["persistenceDecay"])
m_persistenceDecay = window["persistenceDecay"].as<float>();
}

//Waveform groups
Expand Down Expand Up @@ -3294,6 +3300,8 @@ YAML::Node MainWindow::SerializeUIConfiguration()
window["height"] = m_height;
window["width"] = m_width;
window["fullscreen"] = m_fullscreen;
window["traceAlpha"] = m_traceAlpha;
window["persistenceDecay"] = m_persistenceDecay;
node["window"] = window;

//Waveform areas are hierarchical internally, but written as separate area and group headings
Expand Down
2 changes: 1 addition & 1 deletion src/ngscopeclient/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class DockDialogRequest
class MainWindow : public VulkanWindow
{
public:
MainWindow(std::shared_ptr<QueueHandle> queue);
MainWindow(std::shared_ptr<QueueHandle> queue, bool maximized, bool restored);
virtual ~MainWindow();

static bool OnMemoryPressureStatic(MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize);
Expand Down
5 changes: 5 additions & 0 deletions src/ngscopeclient/PreferenceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const Preference& PreferenceManager::GetPreference(const string& path) const
return this->m_treeRoot.GetLeaf(path);
}

Preference& PreferenceManager::GetPreference(const string& path)
{
return this->m_treeRoot.GetLeaf(path);
}

void PreferenceManager::DeterminePath()
{
#ifdef _WIN32
Expand Down
6 changes: 6 additions & 0 deletions src/ngscopeclient/PreferenceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ class PreferenceManager
PreferenceManager& operator=(const PreferenceManager&) = delete;
PreferenceManager& operator=(PreferenceManager&&) = default;

// Singleton access
static PreferenceManager& GetPreferences() { return m_instance; };

public:
void SavePreferences();
PreferenceCategory& AllPreferences();
Preference& GetPreference(const std::string& path);

std::string GetConfigDirectory()
{ return m_configDir; }
Expand Down Expand Up @@ -103,6 +107,8 @@ class PreferenceManager
PreferenceCategory m_treeRoot;
std::string m_filePath;
std::string m_configDir;
// Singleton instance
static PreferenceManager m_instance;
};

#endif // PreferenceManager_h
27 changes: 27 additions & 0 deletions src/ngscopeclient/PreferenceSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "PreferenceTypes.h"
#include "ngscopeclient.h"

PreferenceManager PreferenceManager::m_instance;

void PreferenceManager::InitializeDefaults()
{
auto& appearance = this->m_treeRoot.AddCategory("Appearance");
Expand Down Expand Up @@ -483,6 +485,31 @@ void PreferenceManager::InitializeDefaults()
.EnumValue("Multi window", VIEWPORT_ENABLE)
.EnumValue("Single window", VIEWPORT_DISABLE)
);
windows.AddPreference(
Preference::Enum("startup_mode", STARTUP_MODE_WINDOWED)
.Label("Window startup mode")
.Description(
"Specifies the way Ngscopeclient window should be opened at startup.\n"
"\n"
"The default is windowed: the application is started in a fixed 1280x720 window.\n"
"Other options are:\n"
" - Maximized: the window is maximized on the main screen,\n"
" - Last State: the window is restored at the last position and size.\n"
)
.EnumValue("Windowed", STARTUP_MODE_WINDOWED)
.EnumValue("Maximized", STARTUP_MODE_MAXIMIZED)
.EnumValue("Last State", STARTUP_MODE_LAST_STATE)
);
auto& windowStartup = appearance.AddCategory("Startup");
windowStartup.AddPreference(Preference::Bool("startup_fullscreen", false).Invisible());
windowStartup.AddPreference(Preference::Bool("startup_maximized", false).Invisible());
windowStartup.AddPreference(Preference::Int ("startup_pos_x", 0).Invisible());
windowStartup.AddPreference(Preference::Int ("startup_pos_y", 0).Invisible());
windowStartup.AddPreference(Preference::Int ("startup_size_width", 0).Invisible());
windowStartup.AddPreference(Preference::Int ("startup_size_heigth", 0).Invisible());
windowStartup.AddPreference(Preference::String ("monitor_name", "").Invisible());
windowStartup.AddPreference(Preference::Int ("monitor_width", 0).Invisible());
windowStartup.AddPreference(Preference::Int ("monitor_heigth", 0).Invisible());

auto& drivers = this->m_treeRoot.AddCategory("Drivers");
auto& dgeneral = drivers.AddCategory("General");
Expand Down
7 changes: 7 additions & 0 deletions src/ngscopeclient/PreferenceTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ enum ViewportMode
VIEWPORT_DISABLE
};

enum StartupMode
{
STARTUP_MODE_WINDOWED,
STARTUP_MODE_MAXIMIZED,
STARTUP_MODE_LAST_STATE
};

enum DataWidth
{
WIDTH_AUTO,
Expand Down
8 changes: 4 additions & 4 deletions src/ngscopeclient/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2857,15 +2857,15 @@ void Session::ApplyPreferences(shared_ptr<Oscilloscope> scope)
auto lecroy = dynamic_pointer_cast<LeCroyOscilloscope>(scope);
if(lecroy)
{
if(m_preferences.GetBool("Drivers.Teledyne LeCroy.force_16bit"))
if(GetPreferences().GetBool("Drivers.Teledyne LeCroy.force_16bit"))
lecroy->ForceHDMode(true);

//else auto resolution depending on instrument type
}
auto siglent = dynamic_pointer_cast<SiglentSCPIOscilloscope>(scope);
if(siglent)
{
auto dataWidth = m_preferences.GetEnumRaw("Drivers.Siglent SDS HD.data_width");
auto dataWidth = GetPreferences().GetEnumRaw("Drivers.Siglent SDS HD.data_width");
if(dataWidth == WIDTH_8_BITS)
{
siglent->ForceHDMode(false);
Expand All @@ -2878,7 +2878,7 @@ void Session::ApplyPreferences(shared_ptr<Oscilloscope> scope)
auto rsrtb = dynamic_pointer_cast<RSRTB2kOscilloscope>(scope);
if(rsrtb)
{
auto dataWidth = m_preferences.GetEnumRaw("Drivers.RohdeSchwarz RTB.data_width");
auto dataWidth = GetPreferences().GetEnumRaw("Drivers.RohdeSchwarz RTB.data_width");
if(dataWidth == WIDTH_8_BITS)
{
rsrtb->ForceHDMode(false);
Expand All @@ -2891,7 +2891,7 @@ void Session::ApplyPreferences(shared_ptr<Oscilloscope> scope)
auto rigol = dynamic_pointer_cast<RigolOscilloscope>(scope);
if(rigol)
{
auto dataWidth = m_preferences.GetEnumRaw("Drivers.Rigol DHO.data_width");
auto dataWidth = GetPreferences().GetEnumRaw("Drivers.Rigol DHO.data_width");
if(dataWidth == WIDTH_8_BITS)
{
rigol->ForceHDMode(false);
Expand Down
7 changes: 2 additions & 5 deletions src/ngscopeclient/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,12 @@ class Session
protected:
std::optional<TimePoint> m_hoverTime;

public:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// End user preferences (persistent across sessions)

//Preferences state
PreferenceManager m_preferences;

public:
PreferenceManager& GetPreferences()
{ return m_preferences; }
{ return PreferenceManager::GetPreferences(); }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Reference filters (used to query legal inputs to filters etc)
Expand Down
Loading
Loading