Skip to content

Commit 62bf64e

Browse files
committed
Remove board color preferences and use preset backgrounds
1 parent 39e99a4 commit 62bf64e

8 files changed

Lines changed: 39 additions & 67 deletions

File tree

src/imp/3d/3d_view.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -616,24 +616,12 @@ void View3DWindow::apply_preferences(const Preferences &prefs)
616616
canvas->set_appearance(prefs.canvas_layer.appearance);
617617
canvas->spacenav_prefs = prefs.spacenav.prefs;
618618
canvas->input_devices_prefs = prefs.input_devices.prefs;
619-
620619
if (prefs.view_3d.use_ortho_projection)
621620
proj_ortho_rb->set_active(true);
622621
else
623622
proj_persp_rb->set_active(true);
624-
canvas->set_projection(prefs.view_3d.use_ortho_projection ? Canvas3D::Projection::ORTHO
625-
: Canvas3D::Projection::PERSP);
626-
set_color_button_color(solder_mask_color_button, prefs.view_3d.solder_mask_color);
627-
canvas->set_solder_mask_color(prefs.view_3d.solder_mask_color);
628-
set_color_button_color(silkscreen_color_button, prefs.view_3d.silkscreen_color);
629-
canvas->set_silkscreen_color(prefs.view_3d.silkscreen_color);
630-
set_color_button_color(substrate_color_button, prefs.view_3d.substrate_color);
631-
canvas->set_substrate_color(prefs.view_3d.substrate_color);
632-
set_color_button_color(background_top_color_button, prefs.view_3d.bg_top_color);
633-
canvas->set_background_top_color(prefs.view_3d.bg_top_color);
634-
set_color_button_color(background_bottom_color_button, prefs.view_3d.bg_bottom_color);
635-
canvas->set_background_bottom_color(prefs.view_3d.bg_bottom_color);
636623
canvas->set_copper_color(prefs.view_3d.copper_color);
624+
background_color_preset_combo->set_active_id(prefs.view_3d.background_color_preset);
637625

638626
spnav_buttons = prefs.spacenav.buttons;
639627
const auto av = ActionCatalogItem::AVAILABLE_IN_3D;

src/pool-prj-mgr/preferences/preferences_row.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ PreferencesRowColorButton::PreferencesRowColorButton(const std::string &title, c
8080
bind_widget(btn, v, [this](const Color &) { preferences.signal_changed().emit(); });
8181
}
8282

83+
PreferencesRowComboBox::PreferencesRowComboBox(const std::string &title, const std::string &subtitle,
84+
Preferences &prefs, std::string &v,
85+
const std::vector<std::string> &names)
86+
: PreferencesRow(title, subtitle, prefs), value(v)
87+
{
88+
combo = Gtk::manage(new Gtk::ComboBoxText);
89+
for (const auto &name : names) {
90+
combo->append(name, name);
91+
}
92+
combo->set_valign(Gtk::ALIGN_CENTER);
93+
combo->show();
94+
pack_start(*combo, false, false, 0);
95+
combo->set_active_id(value);
96+
combo->signal_changed().connect([this] {
97+
value = combo->get_active_id();
98+
preferences.signal_changed().emit();
99+
});
100+
}
101+
102+
83103
PreferencesGroup::PreferencesGroup(const std::string &title) : Gtk::Box(Gtk::ORIENTATION_VERTICAL, 8)
84104
{
85105
auto la = Gtk::manage(new Gtk::Label);

src/pool-prj-mgr/preferences/preferences_row.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ template <typename T> class PreferencesRowEnum : public PreferencesRow {
9696
Gtk::ComboBoxText *combo = nullptr;
9797
};
9898

99+
class PreferencesRowComboBox : public PreferencesRow {
100+
public:
101+
PreferencesRowComboBox(const std::string &title, const std::string &subtitle, Preferences &prefs, std::string &v,
102+
const std::vector<std::string> &names);
103+
std::string &value;
104+
Gtk::ComboBoxText *combo = nullptr;
105+
};
106+
99107
class PreferencesRowColorButton : public PreferencesRow {
100108
public:
101109
PreferencesRowColorButton(const std::string &title, const std::string &subtitle, Preferences &prefs, Color &v);

src/pool-prj-mgr/preferences/preferences_window_misc.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,18 @@ MiscPreferencesEditor::MiscPreferencesEditor(Preferences &prefs) : preferences(p
9696
preferences.view_3d.use_ortho_projection));
9797
gr->add_row(*r);
9898
}
99-
{
100-
auto r = Gtk::manage(new PreferencesRowColorButton("Solder mask color", "Default solder mask color",
101-
preferences, preferences.view_3d.solder_mask_color));
102-
gr->add_row(*r);
103-
}
104-
{
105-
auto r = Gtk::manage(new PreferencesRowColorButton("Silkscreen color", "Default silkscreen color",
106-
preferences, preferences.view_3d.silkscreen_color));
107-
gr->add_row(*r);
108-
}
10999
{
110100
auto r = Gtk::manage(new PreferencesRowColorButton("Copper color", "Default copper color", preferences,
111101
preferences.view_3d.copper_color));
112102
gr->add_row(*r);
113103
}
114104
{
115-
auto r = Gtk::manage(new PreferencesRowColorButton("Substrate color", "Default substrate color",
116-
preferences, preferences.view_3d.substrate_color));
117-
gr->add_row(*r);
118-
}
119-
120-
{
121-
auto r =
122-
Gtk::manage(new PreferencesRowColorButton("Top background color", "Background gradient start color",
123-
preferences, preferences.view_3d.bg_top_color));
124-
gr->add_row(*r);
125-
}
126-
{
127-
auto r = Gtk::manage(new PreferencesRowColorButton("Bottom background color",
128-
"Background gradient end color", preferences,
129-
preferences.view_3d.bg_bottom_color));
105+
static const std::vector<std::string> items = {"Default", "Sunset 1", "Sunset 2", "White",
106+
"Black", "Grey", "Honey Dew", "80s Sunset",
107+
"Deep Sea Space", "Dark Skies", "Friday"};
108+
auto r = Gtk::manage(new PreferencesRowComboBox("Background color preset", "Default background color",
109+
preferences, preferences.view_3d.background_color_preset,
110+
items));
130111
gr->add_row(*r);
131112
}
132113
}

src/preferences/preferences.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,30 +219,18 @@ json View3DPreferences::serialize() const
219219
{
220220
json j;
221221
j["use_ortho_projection"] = use_ortho_projection;
222-
j["solder_mask_color"] = color_to_json(solder_mask_color);
223222
j["copper_color"] = color_to_json(copper_color);
224-
j["silkscreen_color"] = color_to_json(silkscreen_color);
225-
j["substrate_color"] = color_to_json(substrate_color);
226-
j["bg_top_color"] = color_to_json(bg_top_color);
227-
j["bg_bottom_color"] = color_to_json(bg_bottom_color);
223+
j["background_color_preset"] = background_color_preset;
228224
return j;
229225
}
230226

231227
void View3DPreferences::load_from_json(const json &j)
232228
{
233229
use_ortho_projection = j.value("use_ortho_projection", false);
234-
if (j.count("solder_mask_color"))
235-
solder_mask_color = color_from_json(j.at("solder_mask_color"));
236230
if (j.count("copper_color"))
237231
copper_color = color_from_json(j.at("copper_color"));
238-
if (j.count("silkscreen_color"))
239-
silkscreen_color = color_from_json(j.at("silkscreen_color"));
240-
if (j.count("substrate_color"))
241-
substrate_color = color_from_json(j.at("substrate_color"));
242-
if (j.count("bg_top_color"))
243-
bg_top_color = color_from_json(j.at("bg_top_color"));
244-
if (j.count("bg_bottom_color"))
245-
bg_bottom_color = color_from_json(j.at("bg_bottom_color"));
232+
if (j.count("background_color_preset"))
233+
background_color_preset = j.value("background_color_preset", "Default");
246234
}
247235

248236
json ZoomPreferences::serialize() const

src/preferences/preferences.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ class BoardPreferences {
4848
class View3DPreferences {
4949
public:
5050
bool use_ortho_projection = false;
51-
Color solder_mask_color = {0, .5, 0};
5251
Color copper_color = {1, .8, 0};
53-
Color silkscreen_color = {1, 1, 1};
54-
Color substrate_color = {.2, .15, 0};
55-
Color bg_top_color = {.2, .2, .4};
56-
Color bg_bottom_color = {.59, .59, .66};
52+
std::string background_color_preset = "Default";
5753

5854
void load_from_json(const json &j);
5955
json serialize() const;

src/util/gtk_util.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
#endif
1515

1616
namespace horizon {
17-
void set_color_button_color(Gtk::ColorButton *color_button, const class Color &v)
18-
{
19-
Gdk::Color c;
20-
c.set_rgb_p(v.r, v.g, v.b);
21-
color_button->set_color(c);
22-
}
23-
2417
void bind_widget(Gtk::Switch *sw, bool &v)
2518
{
2619
sw->set_active(v);

src/util/gtk_util.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#include <gtkmm.h>
33
#include <stdint.h>
44
namespace horizon {
5-
void set_color_button_color(Gtk::ColorButton *color_button, const class Color &v);
6-
75
void bind_widget(class SpinButtonDim *sp, int64_t &v);
86
void bind_widget(class SpinButtonDim *sp, uint64_t &v);
97

0 commit comments

Comments
 (0)