Horizon
preferences.hpp
1 #pragma once
2 #include "canvas/grid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include <sigc++/sigc++.h>
5 #include <string>
6 #include "action_catalog.hpp"
7 #include "action.hpp"
8 #include "core/core.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
14 public:
15  enum class BackgroundColor { BLUE, BLACK };
16  BackgroundColor background_color = BackgroundColor::BLUE;
17 
18  Grid::Style grid_style = Grid::Style::CROSS;
19  float grid_opacity = .5;
20  float highlight_dim = .3;
21  float highlight_shadow = .3;
22  float highlight_lighten = .3;
23  unsigned int msaa = 0;
24 
25  enum class GridFineModifier { CTRL, ALT };
26  GridFineModifier grid_fine_modifier = GridFineModifier::ALT;
27 
28  void load_from_json(const json &j);
29  json serialize() const;
30 };
31 
33 public:
34  bool show_all_junctions = false;
35  bool drag_start_net_line = true;
36 
37  void load_from_json(const json &j);
38  json serialize() const;
39 };
40 
42 public:
43  bool drag_start_track = true;
44 
45  void load_from_json(const json &j);
46  json serialize() const;
47 };
48 
50 public:
51  std::map<std::pair<ActionID, ToolID>, std::map<ActionCatalogItem::Availability, std::vector<KeySequence2>>> keys;
52 
53  void load_from_json(const json &j);
54  void append_from_json(const json &j);
55  json serialize() const;
56 };
57 
58 class ImpPreferences : public sigc::trackable {
59 public:
61  void set_filename(const std::string &filename);
62  void load();
63  void load_default();
64  void save();
65  bool lock();
66  void unlock();
67  static std::string get_preferences_filename();
68 
69  CanvasPreferences canvas_non_layer;
70  CanvasPreferences canvas_layer;
71  SchematicPreferences schematic;
72  BoardPreferences board;
73  KeySequencesPreferences key_sequences;
74 
75  typedef sigc::signal<void> type_signal_changed;
76  type_signal_changed signal_changed()
77  {
78  return s_signal_changed;
79  }
80 
81 private:
82  std::string filename;
83  type_signal_changed s_signal_changed;
84  json serialize() const;
85 };
86 } // namespace horizon
a class to store JSON values
Definition: json.hpp:161
Definition: preferences.hpp:13
Definition: preferences.hpp:32
Definition: preferences.hpp:58
Definition: block.cpp:7
Definition: preferences.hpp:41
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
Definition: preferences.hpp:49