mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-26 21:44:25 +02:00
Update to v098r09 release.
byuu says: Changelog: - fixed major nall/vector/prepend bug - renamed hiro/ListView to hiro/TableView - added new hiro/ListView control which is a simplified abstraction of hiro/TableView - updated higan's cheat database window and icarus' scan dialog to use the new ListView control - compilation works once again on all platforms (Windows, Cocoa, GTK, Qt) - the loki skeleton compiles once again (removed nall/DSP references; updated port/device ID names) Small catch: need to capture layout resize events internally in Windows to call resizeColumns. For now, just resize the icarus window to get it to use the full window width for list view items.
This commit is contained in:
@@ -18,7 +18,7 @@ private:
|
||||
Button pathRefresh{&pathLayout, Size{0, 0}, 0};
|
||||
Button pathHome{&pathLayout, Size{0, 0}, 0};
|
||||
Button pathUp{&pathLayout, Size{0, 0}, 0};
|
||||
ListView view{&layout, Size{~0, ~0}, 5};
|
||||
TableView view{&layout, Size{~0, ~0}, 5};
|
||||
HorizontalLayout controlLayout{&layout, Size{~0, 0}};
|
||||
ComboButton filterList{&controlLayout, Size{120, 0}, 5};
|
||||
LineEdit fileName{&controlLayout, Size{~0, 0}, 5};
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
};
|
||||
|
||||
//accept button clicked, or enter pressed on file name line edit
|
||||
//also called by list view activate after special case handling
|
||||
//also called by table view activate after special case handling
|
||||
auto BrowserDialogWindow::accept() -> void {
|
||||
auto batched = view.batched();
|
||||
|
||||
@@ -71,7 +71,7 @@ auto BrowserDialogWindow::accept() -> void {
|
||||
if(state.response) window.setModal(false);
|
||||
}
|
||||
|
||||
//list view item double-clicked, or enter pressed on selected list view item
|
||||
//table view item double-clicked, or enter pressed on selected table view item
|
||||
auto BrowserDialogWindow::activate() -> void {
|
||||
auto selectedItem = view.selected();
|
||||
|
||||
@@ -89,7 +89,7 @@ auto BrowserDialogWindow::activate() -> void {
|
||||
accept();
|
||||
}
|
||||
|
||||
//list view item changed
|
||||
//table view item changed
|
||||
auto BrowserDialogWindow::change() -> void {
|
||||
fileName.setText("");
|
||||
if(state.action == "saveFile") {
|
||||
@@ -162,8 +162,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
pathName.setText(state.path = path);
|
||||
|
||||
view.reset();
|
||||
view.append(ListViewHeader().setVisible(false)
|
||||
.append(ListViewColumn().setExpandable())
|
||||
view.append(TableViewHeader().setVisible(false)
|
||||
.append(TableViewColumn().setExpandable())
|
||||
);
|
||||
|
||||
auto contents = directory::icontents(path);
|
||||
@@ -174,8 +174,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
content.rtrim("/");
|
||||
if(folderMode && isMatch(content)) continue;
|
||||
|
||||
view.append(ListViewItem()
|
||||
.append(ListViewCell().setText(content).setIcon(Icon::Emblem::Folder))
|
||||
view.append(TableViewItem()
|
||||
.append(TableViewCell().setText(content).setIcon(Icon::Emblem::Folder))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
content.rtrim("/");
|
||||
if(!isMatch(content)) continue;
|
||||
|
||||
view.append(ListViewItem()
|
||||
.append(ListViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
|
||||
view.append(TableViewItem()
|
||||
.append(TableViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,8 @@ namespace hiro {
|
||||
#include "fixed-layout.cpp"
|
||||
#include "horizontal-layout.cpp"
|
||||
#include "vertical-layout.cpp"
|
||||
#include "list-view-item.cpp"
|
||||
#include "list-view.cpp"
|
||||
#include "browser-dialog.cpp"
|
||||
#include "message-dialog.cpp"
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ namespace hiro {
|
||||
#include "fixed-layout.hpp"
|
||||
#include "horizontal-layout.hpp"
|
||||
#include "vertical-layout.hpp"
|
||||
#include "list-view-item.hpp"
|
||||
#include "list-view.hpp"
|
||||
#include "shared.hpp"
|
||||
#include "browser-dialog.hpp"
|
||||
#include "message-dialog.hpp"
|
||||
|
49
hiro/extension/list-view-item.cpp
Normal file
49
hiro/extension/list-view-item.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
mListViewItem::mListViewItem() {
|
||||
append(TableViewCell());
|
||||
}
|
||||
|
||||
auto mListViewItem::checkable() const -> bool {
|
||||
return cell(0).checkable();
|
||||
}
|
||||
|
||||
auto mListViewItem::checked() const -> bool {
|
||||
return cell(0).checked();
|
||||
}
|
||||
|
||||
auto mListViewItem::icon() const -> image {
|
||||
return cell(0).icon();
|
||||
}
|
||||
|
||||
auto mListViewItem::reset() -> type& {
|
||||
mTableViewItem::reset();
|
||||
append(TableViewCell());
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewItem::setCheckable(bool checkable) -> type& {
|
||||
cell(0).setCheckable(checkable);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewItem::setChecked(bool checked) -> type& {
|
||||
cell(0).setChecked(checked);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewItem::setIcon(const image& icon) -> type& {
|
||||
cell(0).setIcon(icon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewItem::setText(const string& text) -> type& {
|
||||
cell(0).setText(text);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewItem::text() const -> string {
|
||||
return cell(0).text();
|
||||
}
|
||||
|
||||
#endif
|
24
hiro/extension/list-view-item.hpp
Normal file
24
hiro/extension/list-view-item.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
struct ListViewItem;
|
||||
struct mListViewItem;
|
||||
using sListViewItem = shared_pointer<mListViewItem>;
|
||||
|
||||
struct mListViewItem : mTableViewItem {
|
||||
using type = mListViewItem;
|
||||
using mTableViewItem::append;
|
||||
using mTableViewItem::remove;
|
||||
|
||||
mListViewItem();
|
||||
auto checkable() const -> bool;
|
||||
auto checked() const -> bool;
|
||||
auto icon() const -> image;
|
||||
auto reset() -> type&;
|
||||
auto setCheckable(bool checkable) -> type&;
|
||||
auto setChecked(bool checked) -> type&;
|
||||
auto setIcon(const image& icon = {}) -> type&;
|
||||
auto setText(const string& text) -> type&;
|
||||
auto text() const -> string;
|
||||
};
|
||||
|
||||
#endif
|
51
hiro/extension/list-view.cpp
Normal file
51
hiro/extension/list-view.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
mListView::mListView() {
|
||||
mTableView::onToggle([&](TableViewCell cell) {
|
||||
if(auto item = cell->parentTableViewItem()) {
|
||||
if(auto shared = item->instance.acquire()) {
|
||||
doToggle(ListViewItem{shared});
|
||||
}
|
||||
}
|
||||
});
|
||||
append(TableViewHeader().setVisible(false).append(TableViewColumn().setExpandable()));
|
||||
}
|
||||
|
||||
auto mListView::batched() const -> vector<ListViewItem> {
|
||||
auto batched = mTableView::batched();
|
||||
vector<ListViewItem> result;
|
||||
for(auto item : batched) result.append(ListViewItem{item});
|
||||
return result;
|
||||
}
|
||||
|
||||
auto mListView::doToggle(ListViewItem item) const -> void {
|
||||
if(state.onToggle) state.onToggle(item);
|
||||
}
|
||||
|
||||
auto mListView::item(uint position) const -> ListViewItem {
|
||||
return ListViewItem{mTableView::item(position)};
|
||||
}
|
||||
|
||||
auto mListView::items() const -> vector<ListViewItem> {
|
||||
auto items = mTableView::items();
|
||||
vector<ListViewItem> result;
|
||||
for(auto item : items) result.append(ListViewItem{item});
|
||||
return result;
|
||||
}
|
||||
|
||||
auto mListView::onToggle(const function<void (ListViewItem)>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::reset() -> type& {
|
||||
mTableView::reset();
|
||||
append(TableViewHeader().setVisible(false).append(TableViewColumn().setExpandable()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::selected() const -> ListViewItem {
|
||||
return ListViewItem{mTableView::selected()};
|
||||
}
|
||||
|
||||
#endif
|
27
hiro/extension/list-view.hpp
Normal file
27
hiro/extension/list-view.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
struct ListView;
|
||||
struct mListView;
|
||||
using sListView = shared_pointer<mListView>;
|
||||
|
||||
struct mListView : mTableView {
|
||||
using type = mListView;
|
||||
using mTableView::append;
|
||||
using mTableView::remove;
|
||||
|
||||
mListView();
|
||||
auto batched() const -> vector<ListViewItem>;
|
||||
auto doToggle(ListViewItem) const -> void;
|
||||
auto item(uint position) const -> ListViewItem;
|
||||
auto items() const -> vector<ListViewItem>;
|
||||
auto onToggle(const function<void (ListViewItem)>& callback) -> type&;
|
||||
auto reset() -> type& override;
|
||||
auto selected() const -> ListViewItem;
|
||||
|
||||
//private:
|
||||
struct State {
|
||||
function<void (ListViewItem)> onToggle;
|
||||
} state;
|
||||
};
|
||||
|
||||
#endif
|
@@ -33,3 +33,56 @@ struct VerticalLayout : sVerticalLayout {
|
||||
auto setSpacing(signed spacing = 5) { return self().setSpacing(spacing), *this; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
struct ListViewItem : sListViewItem {
|
||||
DeclareSharedObject(ListViewItem)
|
||||
|
||||
auto alignment() const { return self().alignment(); }
|
||||
auto backgroundColor() const { return self().backgroundColor(); }
|
||||
auto checkable() const { return self().checkable(); }
|
||||
auto checked() const { return self().checked(); }
|
||||
auto foregroundColor() const { return self().foregroundColor(); }
|
||||
auto icon() const { return self().icon(); }
|
||||
auto reset() { return self().reset(), *this; }
|
||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||
auto setCheckable(bool checkable = true) { return self().setCheckable(checkable), *this; }
|
||||
auto setChecked(bool checked = true) { return self().setChecked(checked), *this; }
|
||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||
auto text() const { return self().text(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
struct ListView : sListView {
|
||||
DeclareSharedWidget(ListView)
|
||||
|
||||
auto alignment() const { return self().alignment(); }
|
||||
auto append(sListViewItem item) { return self().append(item), *this; }
|
||||
auto backgroundColor() const { return self().backgroundColor(); }
|
||||
auto batchable() const { return self().batchable(); }
|
||||
auto batched() const { return self().batched(); }
|
||||
auto doActivate() const { return self().doActivate(); }
|
||||
auto doChange() const { return self().doChange(); }
|
||||
auto doContext() const { return self().doContext(); }
|
||||
auto doToggle(ListViewItem item) const { return self().doToggle(item); }
|
||||
auto foregroundColor() const { return self().foregroundColor(); }
|
||||
auto item(uint position) const { return self().item(position); }
|
||||
auto itemCount() const { return self().itemCount(); }
|
||||
auto items() const { return self().items(); }
|
||||
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) { return self().onChange(callback), *this; }
|
||||
auto onContext(const function<void ()>& callback = {}) { return self().onContext(callback), *this; }
|
||||
auto onToggle(const function<void (ListViewItem)>& callback = {}) { return self().onToggle(callback), *this; }
|
||||
auto remove(sListViewItem item) { return self().remove(item), *this; }
|
||||
auto reset() { return self().reset(), *this; }
|
||||
auto selected() { return self().selected(); }
|
||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||
auto setBatchable(bool batchable = true) { return self().setBatchable(batchable), *this; }
|
||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||
};
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user