Skip to content

Commit

Permalink
Highlight board editor unplaced package list selection in schematic
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr committed Oct 30, 2024
1 parent d5a46d2 commit 8c20d3b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/imp/imp_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,18 @@ void ImpBoard::construct()
}
this->tool_begin(ToolID::MAP_PACKAGE, true, components);
});
unplaced_box->signal_selected().connect([this](const auto &items) {
json j;
j["op"] = "board-select";
j["selection"] = nullptr;
for (const auto &it : items) {
json k;
k["type"] = static_cast<int>(ObjectType::COMPONENT);
k["uuid"] = (std::string)it.at(0);
j["selection"].push_back(k);
}
send_json(j);
});
core_board.signal_rebuilt().connect(sigc::mem_fun(*this, &ImpBoard::update_unplaced));
update_unplaced();
core_board.signal_tool_changed().connect(
Expand Down
19 changes: 17 additions & 2 deletions src/widgets/unplaced_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ UnplacedBox::UnplacedBox(const std::string &title) : Gtk::Box(Gtk::Orientation::
view->set_rubber_banding(true);
view->append_column(title, list_columns.text);
view->get_column(0)->set_sort_column(list_columns.text);
view->get_selection()->signal_changed().connect(
[this] { button_place->set_sensitive(view->get_selection()->count_selected_rows()); });
view->get_selection()->signal_changed().connect([this] {
button_place->set_sensitive(view->get_selection()->count_selected_rows());
auto paths = view->get_selection()->get_selected_rows();
std::vector<UUIDPath<2>> uuids;
for (const auto &path : paths) {
auto it = store->get_iter(path);
if (it) {
Gtk::TreeModel::Row row = *it;
uuids.emplace_back(row[list_columns.uuid]);
}
}
if (uuids.size()) {
s_signal_selected.emit(uuids);
}
});
view->show();

auto sc = Gtk::manage(new Gtk::ScrolledWindow());
Expand Down Expand Up @@ -83,6 +96,7 @@ void UnplacedBox::row_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewC

void UnplacedBox::update(const std::map<UUIDPath<2>, std::string> &items)
{
s_signal_selected.block();
set_visible(items.size());
std::set<UUIDPath<2>> items_available;
{
Expand All @@ -106,6 +120,7 @@ void UnplacedBox::update(const std::map<UUIDPath<2>, std::string> &items)
row[list_columns.uuid] = uu;
}
}
s_signal_selected.unblock();
}

void UnplacedBox::set_title(const std::string &title)
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/unplaced_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ class UnplacedBox : public Gtk::Box {
void update(const std::map<UUIDPath<2>, std::string> &items);
void set_title(const std::string &title);
typedef sigc::signal<void, std::vector<UUIDPath<2>>> type_signal_place;
typedef sigc::signal<void, std::vector<UUIDPath<2>>> type_signal_selected;
type_signal_place signal_place()
{
return s_signal_place;
}

type_signal_selected signal_selected()
{
return s_signal_selected;
}

private:
class ListColumns : public Gtk::TreeModelColumnRecord {
public:
Expand All @@ -36,6 +42,7 @@ class UnplacedBox : public Gtk::Box {
Gtk::ToolButton *button_place = nullptr;

type_signal_place s_signal_place;
type_signal_selected s_signal_selected;
void row_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *column);
};
} // namespace horizon

0 comments on commit 8c20d3b

Please sign in to comment.