2020-01-13 01:44:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
|
|
|
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _APP_SETTINGS_H
|
|
|
|
#define _APP_SETTINGS_H
|
|
|
|
|
|
|
|
#include <gal/color4d.h>
|
|
|
|
#include <settings/json_settings.h>
|
|
|
|
|
2020-06-28 02:48:48 +00:00
|
|
|
/**
|
|
|
|
* Cross-probing behavior
|
|
|
|
*/
|
|
|
|
struct CROSS_PROBING_SETTINGS
|
|
|
|
{
|
|
|
|
bool center_on_items; ///< Automatically pan to cross-probed items
|
|
|
|
bool zoom_to_fit; ///< Zoom to fit items (ignored if center_on_items is off)
|
|
|
|
bool auto_highlight; ///< Automatically turn on highlight mode in the target frame
|
|
|
|
};
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
/**
|
|
|
|
* Common cursor settings, available to every frame
|
|
|
|
*/
|
|
|
|
struct CURSOR_SETTINGS
|
|
|
|
{
|
|
|
|
bool always_show_cursor;
|
|
|
|
bool fullscreen_cursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Common grid settings, available to every frame
|
|
|
|
*/
|
|
|
|
struct GRID_SETTINGS
|
|
|
|
{
|
|
|
|
bool axes_enabled;
|
2020-06-12 10:58:56 +00:00
|
|
|
std::vector<wxString> sizes;
|
|
|
|
wxString user_grid_x;
|
|
|
|
wxString user_grid_y;
|
|
|
|
int last_size_idx;
|
2020-06-14 15:08:47 +00:00
|
|
|
int fast_grid_1;
|
|
|
|
int fast_grid_2;
|
2020-01-13 01:44:19 +00:00
|
|
|
double line_width;
|
|
|
|
double min_spacing;
|
|
|
|
bool show;
|
|
|
|
int style;
|
|
|
|
};
|
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
/**
|
|
|
|
* Stores the common settings that are saved and loaded for each window / frame
|
|
|
|
*/
|
|
|
|
struct WINDOW_SETTINGS
|
|
|
|
{
|
|
|
|
bool maximized;
|
|
|
|
wxString mru_path;
|
|
|
|
int size_x;
|
|
|
|
int size_y;
|
|
|
|
wxString perspective;
|
|
|
|
int pos_x;
|
|
|
|
int pos_y;
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
std::vector<double> zoom_factors;
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
CURSOR_SETTINGS cursor;
|
|
|
|
GRID_SETTINGS grid;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad
|
|
|
|
* application. It stores settings that should exist for every app, but may be different from
|
|
|
|
* app to app depending on the user's preferences.
|
|
|
|
*
|
|
|
|
* COMMON_SETTINGS stores settings that are always the same across all applications.
|
|
|
|
*/
|
|
|
|
class APP_SETTINGS_BASE : public JSON_SETTINGS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
struct FIND_REPLACE
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
wxString find_string;
|
|
|
|
std::vector<wxString> find_history;
|
|
|
|
wxString replace_string;
|
|
|
|
std::vector<wxString> replace_history;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GRAPHICS
|
|
|
|
{
|
|
|
|
int canvas_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LIB_TREE
|
|
|
|
{
|
|
|
|
int column_width;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PRINTING
|
|
|
|
{
|
2020-05-16 14:47:43 +00:00
|
|
|
bool background; ///< Whether or not to print background color
|
|
|
|
bool monochrome; ///< Whether or not to print in monochrome
|
|
|
|
double scale; ///< Printout scale
|
|
|
|
bool use_theme; ///< If false, display color theme will be used
|
|
|
|
wxString color_theme; ///< Color theme to use for printing
|
|
|
|
bool title_block; ///< Whether or not to print title block
|
|
|
|
std::vector<int> layers; ///< List of enabled layers for printing
|
2020-01-13 01:44:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SYSTEM
|
|
|
|
{
|
|
|
|
bool first_run_shown;
|
|
|
|
int max_undo_items;
|
|
|
|
std::vector<wxString> file_history;
|
|
|
|
int units;
|
|
|
|
};
|
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
virtual ~APP_SETTINGS_BASE() {}
|
|
|
|
|
|
|
|
virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
|
|
|
|
|
|
|
|
public:
|
2020-06-28 02:48:48 +00:00
|
|
|
CROSS_PROBING_SETTINGS m_CrossProbing;
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
FIND_REPLACE m_FindReplace;
|
|
|
|
|
|
|
|
GRAPHICS m_Graphics;
|
|
|
|
|
|
|
|
LIB_TREE m_LibTree;
|
|
|
|
|
|
|
|
PRINTING m_Printing;
|
|
|
|
|
|
|
|
SYSTEM m_System;
|
|
|
|
|
|
|
|
WINDOW_SETTINGS m_Window;
|
|
|
|
|
2020-02-03 16:46:58 +00:00
|
|
|
/// Active color theme name
|
|
|
|
wxString m_ColorTheme;
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
///! Local schema version for common app settings
|
|
|
|
int m_appSettingsSchemaVersion;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual std::string getLegacyFrameName() const { return std::string(); }
|
|
|
|
|
|
|
|
///! Migrates the find/replace history string lists
|
|
|
|
void migrateFindReplace( wxConfigBase* aCfg );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Migrates legacy window settings into the JSON document
|
|
|
|
* @param aCfg is the wxConfig object to read from
|
|
|
|
* @param aFrameName is the prefix for window settings in the legacy config file
|
|
|
|
* @param aJsonPath is the prefix for storing window settings in the JSON file
|
|
|
|
* @return true if all settings were migrated
|
|
|
|
*/
|
|
|
|
bool migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrameName,
|
|
|
|
const std::string& aJsonPath );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds parameters for the given window object
|
|
|
|
* @param aWindow is the target window settings object
|
|
|
|
* @param aJsonPath is the path to read parameters from
|
|
|
|
*/
|
|
|
|
void addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|