1 #include "rule_editor_via.hpp"
2 #include "board/rule_via.hpp"
3 #include "document/idocument_board.hpp"
4 #include "rule_match_editor.hpp"
5 #include "widgets/parameter_set_editor.hpp"
6 #include "widgets/spin_button_dim.hpp"
7 #include "widgets/pool_browser_button.hpp"
8 #include "widgets/pool_browser_padstack.hpp"
9 
10 namespace horizon {
populate()11 void RuleEditorVia::populate()
12 {
13     rule2 = &dynamic_cast<RuleVia &>(rule);
14 
15     auto editor = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 10));
16 
17     auto grid = Gtk::manage(new Gtk::Grid());
18     grid->set_row_spacing(10);
19     grid->set_column_spacing(20);
20     grid->set_margin_start(20);
21     grid->set_margin_end(20);
22     {
23         auto la = Gtk::manage(new Gtk::Label("Match"));
24         la->get_style_context()->add_class("dim-label");
25         la->set_halign(Gtk::ALIGN_START);
26         grid->attach(*la, 0, 0, 1, 1);
27     }
28     {
29         auto la = Gtk::manage(new Gtk::Label("Padstack"));
30         la->get_style_context()->add_class("dim-label");
31         la->set_halign(Gtk::ALIGN_START);
32         grid->attach(*la, 1, 0, 1, 1);
33     }
34 
35     auto match_editor = Gtk::manage(new RuleMatchEditor(rule2->match, core));
36     match_editor->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
37     match_editor->signal_updated().connect([this] { s_signal_updated.emit(); });
38     grid->attach(*match_editor, 0, 1, 1, 1);
39 
40     auto &c = dynamic_cast<IDocumentBoard &>(core);
41     auto ps_button = Gtk::manage(new PoolBrowserButton(ObjectType::PADSTACK, c.get_pool()));
42     {
43         auto &br = dynamic_cast<PoolBrowserPadstack &>(ps_button->get_browser());
44         br.set_padstacks_included({Padstack::Type::VIA});
45     }
46     ps_button->property_selected_uuid() = rule2->padstack;
47     ps_button->property_selected_uuid().signal_changed().connect(
48             [this, ps_button] { rule2->padstack = ps_button->property_selected_uuid(); });
49     grid->attach(*ps_button, 1, 1, 1, 1);
50 
51     grid->show_all();
52     editor->pack_start(*grid, false, false, 0);
53 
54     auto pse = Gtk::manage(new ParameterSetEditor(&rule2->parameter_set));
55     pse->set_button_margin_left(20);
56     pse->show();
57     editor->pack_start(*pse, true, true, 0);
58 
59     pack_start(*editor, true, true, 0);
60     editor->show();
61 }
62 } // namespace horizon
63