mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-31 19:51:52 +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:
@@ -44,17 +44,17 @@
|
||||
#include "widget/icon-view-item.cpp"
|
||||
#include "widget/label.cpp"
|
||||
#include "widget/line-edit.cpp"
|
||||
#include "widget/list-view.cpp"
|
||||
#include "widget/list-view-header.cpp"
|
||||
#include "widget/list-view-column.cpp"
|
||||
#include "widget/list-view-item.cpp"
|
||||
#include "widget/list-view-cell.cpp"
|
||||
#include "widget/progress-bar.cpp"
|
||||
#include "widget/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
#include "widget/source-edit.cpp"
|
||||
#include "widget/tab-frame.cpp"
|
||||
#include "widget/tab-frame-item.cpp"
|
||||
#include "widget/table-view.cpp"
|
||||
#include "widget/table-view-header.cpp"
|
||||
#include "widget/table-view-column.cpp"
|
||||
#include "widget/table-view-item.cpp"
|
||||
#include "widget/table-view-cell.cpp"
|
||||
#include "widget/text-edit.cpp"
|
||||
#include "widget/tree-view.cpp"
|
||||
#include "widget/tree-view-item.cpp"
|
||||
|
@@ -55,17 +55,17 @@ namespace hiro {
|
||||
#include "widget/icon-view-item.hpp"
|
||||
#include "widget/label.hpp"
|
||||
#include "widget/line-edit.hpp"
|
||||
#include "widget/list-view.hpp"
|
||||
#include "widget/list-view-header.hpp"
|
||||
#include "widget/list-view-column.hpp"
|
||||
#include "widget/list-view-item.hpp"
|
||||
#include "widget/list-view-cell.hpp"
|
||||
#include "widget/progress-bar.hpp"
|
||||
#include "widget/radio-button.hpp"
|
||||
#include "widget/radio-label.hpp"
|
||||
#include "widget/source-edit.hpp"
|
||||
#include "widget/tab-frame.hpp"
|
||||
#include "widget/tab-frame-item.hpp"
|
||||
#include "widget/table-view.hpp"
|
||||
#include "widget/table-view-header.hpp"
|
||||
#include "widget/table-view-column.hpp"
|
||||
#include "widget/table-view-item.hpp"
|
||||
#include "widget/table-view-cell.hpp"
|
||||
#include "widget/text-edit.hpp"
|
||||
#include "widget/tree-view.hpp"
|
||||
#include "widget/tree-view-item.hpp"
|
||||
|
@@ -1,41 +0,0 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewHeader::construct() -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewHeader::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pListViewHeader::append(sListViewColumn column) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewHeader::remove(sListViewColumn column) -> void {
|
||||
}
|
||||
|
||||
auto pListViewHeader::setVisible(bool visible) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewHeader::_parent() -> maybe<pListView&> {
|
||||
if(auto parent = self().parentListView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewHeader::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
gtk_tree_view_set_headers_visible(parent->gtkTreeView, self().visible());
|
||||
for(auto& column : state().columns) {
|
||||
if(auto self = column->self()) self->_setState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,18 +0,0 @@
|
||||
#if defined(Hiro_ListView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewHeader : pObject {
|
||||
Declare(ListViewHeader, Object)
|
||||
|
||||
auto append(sListViewColumn column) -> void;
|
||||
auto remove(sListViewColumn column) -> void;
|
||||
auto setVisible(bool visible) -> void override;
|
||||
|
||||
auto _parent() -> maybe<pListView&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,51 +1,51 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewCell::construct() -> void {
|
||||
auto pTableViewCell::construct() -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::destruct() -> void {
|
||||
auto pTableViewCell::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setAlignment(Alignment alignment) -> void {
|
||||
auto pTableViewCell::setAlignment(Alignment alignment) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setBackgroundColor(Color color) -> void {
|
||||
auto pTableViewCell::setBackgroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
||||
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setChecked(bool checked) -> void {
|
||||
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setText(const string& text) -> void {
|
||||
auto pTableViewCell::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::_grandparent() -> maybe<pListView&> {
|
||||
auto pTableViewCell::_grandparent() -> maybe<pTableView&> {
|
||||
if(auto parent = _parent()) return parent->_parent();
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
||||
if(auto parent = self().parentListViewItem()) {
|
||||
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||
if(auto parent = self().parentTableViewItem()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_setState() -> void {
|
||||
auto pTableViewCell::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
@@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewCell : pObject {
|
||||
Declare(ListViewCell, Object)
|
||||
struct pTableViewCell : pObject {
|
||||
Declare(TableViewCell, Object)
|
||||
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@@ -13,8 +13,8 @@ struct pListViewCell : pObject {
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewItem&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewItem&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewColumn::construct() -> void {
|
||||
auto pTableViewColumn::construct() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
auto handle = grandparent.data();
|
||||
unsigned offset = self().offset();
|
||||
@@ -23,21 +23,21 @@ auto pListViewColumn::construct() -> void {
|
||||
gtkCellToggle = gtk_cell_renderer_toggle_new();
|
||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellToggle, false);
|
||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellToggle, "active", 3 * offset + 0, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellToggle), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellToggle), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||
|
||||
gtkCellIcon = gtk_cell_renderer_pixbuf_new();
|
||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellIcon, false);
|
||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellIcon, "pixbuf", 3 * offset + 1, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellIcon), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellIcon), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||
|
||||
gtkCellText = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellText, true); //text must expand to cell width for horizontal alignment to work
|
||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellText, "text", 3 * offset + 2, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellText), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellText), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||
|
||||
g_signal_connect(G_OBJECT(gtkColumn), "clicked", G_CALLBACK(ListView_headerActivate), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellText), "edited", G_CALLBACK(ListView_edit), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(ListView_toggle), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkColumn), "clicked", G_CALLBACK(TableView_headerActivate), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellText), "edited", G_CALLBACK(TableView_edit), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(TableView_toggle), (gpointer)handle);
|
||||
|
||||
gtk_tree_view_append_column(grandparent->gtkTreeView, gtkColumn);
|
||||
gtk_widget_show_all(gtkHeader);
|
||||
@@ -47,7 +47,7 @@ auto pListViewColumn::construct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::destruct() -> void {
|
||||
auto pTableViewColumn::destruct() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
gtk_tree_view_remove_column(grandparent->gtkTreeView, gtkColumn);
|
||||
gtkColumn = nullptr;
|
||||
@@ -55,33 +55,33 @@ auto pListViewColumn::destruct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::setActive() -> void {
|
||||
auto pTableViewColumn::setActive() -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setAlignment(Alignment alignment) -> void {
|
||||
auto pTableViewColumn::setAlignment(Alignment alignment) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setBackgroundColor(Color color) -> void {
|
||||
auto pTableViewColumn::setBackgroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setEditable(bool editable) -> void {
|
||||
auto pTableViewColumn::setEditable(bool editable) -> void {
|
||||
g_object_set(G_OBJECT(gtkCellText), "editable", editable ? true : false, nullptr);
|
||||
}
|
||||
|
||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
||||
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->resizeColumns();
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::setFont(const Font& font) -> void {
|
||||
auto pTableViewColumn::setFont(const Font& font) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
||||
auto pTableViewColumn::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
auto pTableViewColumn::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
||||
} else {
|
||||
@@ -89,41 +89,41 @@ auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::setResizable(bool resizable) -> void {
|
||||
auto pTableViewColumn::setResizable(bool resizable) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
||||
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setText(const string& text) -> void {
|
||||
auto pTableViewColumn::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setVisible(bool visible) -> void {
|
||||
auto pTableViewColumn::setVisible(bool visible) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setWidth(signed width) -> void {
|
||||
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->resizeColumns();
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::_grandparent() -> maybe<pListView&> {
|
||||
auto pTableViewColumn::_grandparent() -> maybe<pTableView&> {
|
||||
if(auto parent = _parent()) return parent->_parent();
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
||||
if(auto parent = self().parentListViewHeader()) {
|
||||
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||
if(auto parent = self().parentTableViewHeader()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_setState() -> void {
|
||||
auto pTableViewColumn::_setState() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
gtk_tree_view_set_search_column(grandparent->gtkTreeView, 3 * self().offset() + 2);
|
||||
gtk_tree_view_column_set_resizable(gtkColumn, state().resizable);
|
@@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewColumn : pObject {
|
||||
Declare(ListViewColumn, Object)
|
||||
struct pTableViewColumn : pObject {
|
||||
Declare(TableViewColumn, Object)
|
||||
|
||||
auto setActive() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
@@ -21,8 +21,8 @@ struct pListViewColumn : pObject {
|
||||
auto setVisible(bool visible) -> void override;
|
||||
auto setWidth(signed width) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewHeader&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewHeader&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
GtkTreeViewColumn* gtkColumn = nullptr;
|
41
hiro/gtk/widget/table-view-header.cpp
Normal file
41
hiro/gtk/widget/table-view-header.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pTableViewHeader::construct() -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pTableViewHeader::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pTableViewHeader::append(sTableViewColumn column) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pTableViewHeader::remove(sTableViewColumn column) -> void {
|
||||
}
|
||||
|
||||
auto pTableViewHeader::setVisible(bool visible) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pTableViewHeader::_parent() -> maybe<pTableView&> {
|
||||
if(auto parent = self().parentTableView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pTableViewHeader::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
gtk_tree_view_set_headers_visible(parent->gtkTreeView, self().visible());
|
||||
for(auto& column : state().columns) {
|
||||
if(auto self = column->self()) self->_setState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
18
hiro/gtk/widget/table-view-header.hpp
Normal file
18
hiro/gtk/widget/table-view-header.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pTableViewHeader : pObject {
|
||||
Declare(TableViewHeader, Object)
|
||||
|
||||
auto append(sTableViewColumn column) -> void;
|
||||
auto remove(sTableViewColumn column) -> void;
|
||||
auto setVisible(bool visible) -> void override;
|
||||
|
||||
auto _parent() -> maybe<pTableView&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,8 +1,8 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewItem::construct() -> void {
|
||||
auto pTableViewItem::construct() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
gtk_list_store_append(parent->gtkListStore, >kIter);
|
||||
@@ -11,7 +11,7 @@ auto pListViewItem::construct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewItem::destruct() -> void {
|
||||
auto pTableViewItem::destruct() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
gtk_list_store_remove(parent->gtkListStore, >kIter);
|
||||
@@ -20,19 +20,19 @@ auto pListViewItem::destruct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewItem::append(sListViewCell cell) -> void {
|
||||
auto pTableViewItem::append(sTableViewCell cell) -> void {
|
||||
}
|
||||
|
||||
auto pListViewItem::remove(sListViewCell cell) -> void {
|
||||
auto pTableViewItem::remove(sTableViewCell cell) -> void {
|
||||
}
|
||||
|
||||
auto pListViewItem::setAlignment(Alignment alignment) -> void {
|
||||
auto pTableViewItem::setAlignment(Alignment alignment) -> void {
|
||||
}
|
||||
|
||||
auto pListViewItem::setBackgroundColor(Color color) -> void {
|
||||
auto pTableViewItem::setBackgroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewItem::setFocused() -> void {
|
||||
auto pTableViewItem::setFocused() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
GtkTreePath* path = gtk_tree_path_new_from_string(string{self().offset()});
|
||||
gtk_tree_view_set_cursor(parent->gtkTreeView, path, nullptr, false);
|
||||
@@ -41,21 +41,21 @@ auto pListViewItem::setFocused() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewItem::setForegroundColor(Color color) -> void {
|
||||
auto pTableViewItem::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewItem::setSelected(bool selected) -> void {
|
||||
auto pTableViewItem::setSelected(bool selected) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
||||
if(auto parent = self().parentListView()) {
|
||||
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||
if(auto parent = self().parentTableView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewItem::_setState() -> void {
|
||||
auto pTableViewItem::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
if(state().selected) {
|
@@ -1,19 +1,19 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewItem : pObject {
|
||||
Declare(ListViewItem, Object)
|
||||
struct pTableViewItem : pObject {
|
||||
Declare(TableViewItem, Object)
|
||||
|
||||
auto append(sListViewCell cell) -> void;
|
||||
auto remove(sListViewCell cell) -> void;
|
||||
auto append(sTableViewCell cell) -> void;
|
||||
auto remove(sTableViewCell cell) -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setFocused() -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setSelected(bool selected) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pTableView&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
GtkTreeIter gtkIter;
|
@@ -1,21 +1,21 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
static auto ListView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pListView* p) -> void { return p->_doActivate(); }
|
||||
static auto ListView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pListView* p) -> signed { return p->_doEvent(event); }
|
||||
static auto ListView_change(GtkTreeSelection*, pListView* p) -> void { return p->_doChange(); }
|
||||
static auto ListView_edit(GtkCellRendererText* renderer, const char* path, const char* text, pListView* p) -> void { return p->_doEdit(renderer, path, text); }
|
||||
static auto ListView_headerActivate(GtkTreeViewColumn* column, pListView* p) -> void { return p->_doHeaderActivate(column); }
|
||||
static auto ListView_mouseMoveEvent(GtkWidget*, GdkEvent*, pListView* p) -> signed { return p->_doMouseMove(); }
|
||||
static auto ListView_popup(GtkTreeView*, pListView* p) -> void { return p->_doContext(); }
|
||||
static auto TableView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pTableView* p) -> void { return p->_doActivate(); }
|
||||
static auto TableView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pTableView* p) -> signed { return p->_doEvent(event); }
|
||||
static auto TableView_change(GtkTreeSelection*, pTableView* p) -> void { return p->_doChange(); }
|
||||
static auto TableView_edit(GtkCellRendererText* renderer, const char* path, const char* text, pTableView* p) -> void { return p->_doEdit(renderer, path, text); }
|
||||
static auto TableView_headerActivate(GtkTreeViewColumn* column, pTableView* p) -> void { return p->_doHeaderActivate(column); }
|
||||
static auto TableView_mouseMoveEvent(GtkWidget*, GdkEvent*, pTableView* p) -> signed { return p->_doMouseMove(); }
|
||||
static auto TableView_popup(GtkTreeView*, pTableView* p) -> void { return p->_doContext(); }
|
||||
|
||||
static auto ListView_dataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, pListView* p) -> void { return p->_doDataFunc(column, renderer, iter); }
|
||||
static auto ListView_toggle(GtkCellRendererToggle* toggle, const char* path, pListView* p) -> void { return p->_doToggle(toggle, path); }
|
||||
static auto TableView_dataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, pTableView* p) -> void { return p->_doDataFunc(column, renderer, iter); }
|
||||
static auto TableView_toggle(GtkCellRendererToggle* toggle, const char* path, pTableView* p) -> void { return p->_doToggle(toggle, path); }
|
||||
|
||||
//gtk_tree_view_set_rules_hint(gtkTreeView, true);
|
||||
|
||||
auto pListView::construct() -> void {
|
||||
auto pTableView::construct() -> void {
|
||||
gtkWidget = gtk_scrolled_window_new(0, 0);
|
||||
gtkScrolledWindow = GTK_SCROLLED_WINDOW(gtkWidget);
|
||||
gtk_scrolled_window_set_policy(gtkScrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
@@ -35,38 +35,38 @@ auto pListView::construct() -> void {
|
||||
setFont(self().font(true));
|
||||
setForegroundColor(state().foregroundColor);
|
||||
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-press-event", G_CALLBACK(ListView_buttonEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-release-event", G_CALLBACK(ListView_buttonEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "motion-notify-event", G_CALLBACK(ListView_mouseMoveEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "popup-menu", G_CALLBACK(ListView_popup), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "row-activated", G_CALLBACK(ListView_activate), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeSelection), "changed", G_CALLBACK(ListView_change), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-press-event", G_CALLBACK(TableView_buttonEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-release-event", G_CALLBACK(TableView_buttonEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "motion-notify-event", G_CALLBACK(TableView_mouseMoveEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "popup-menu", G_CALLBACK(TableView_popup), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "row-activated", G_CALLBACK(TableView_activate), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeSelection), "changed", G_CALLBACK(TableView_change), (gpointer)this);
|
||||
|
||||
pWidget::construct();
|
||||
}
|
||||
|
||||
auto pListView::destruct() -> void {
|
||||
auto pTableView::destruct() -> void {
|
||||
gtk_widget_destroy(gtkWidgetChild);
|
||||
gtk_widget_destroy(gtkWidget);
|
||||
}
|
||||
|
||||
auto pListView::append(sListViewHeader header) -> void {
|
||||
auto pTableView::append(sTableViewHeader header) -> void {
|
||||
}
|
||||
|
||||
auto pListView::append(sListViewItem item) -> void {
|
||||
auto pTableView::append(sTableViewItem item) -> void {
|
||||
}
|
||||
|
||||
auto pListView::focused() const -> bool {
|
||||
auto pTableView::focused() const -> bool {
|
||||
return GTK_WIDGET_HAS_FOCUS(gtkTreeView);
|
||||
}
|
||||
|
||||
auto pListView::remove(sListViewHeader header) -> void {
|
||||
auto pTableView::remove(sTableViewHeader header) -> void {
|
||||
}
|
||||
|
||||
auto pListView::remove(sListViewItem item) -> void {
|
||||
auto pTableView::remove(sTableViewItem item) -> void {
|
||||
}
|
||||
|
||||
auto pListView::resizeColumns() -> void {
|
||||
auto pTableView::resizeColumns() -> void {
|
||||
lock();
|
||||
|
||||
if(auto& header = state().header) {
|
||||
@@ -102,23 +102,23 @@ auto pListView::resizeColumns() -> void {
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pListView::setAlignment(Alignment alignment) -> void {
|
||||
auto pTableView::setAlignment(Alignment alignment) -> void {
|
||||
}
|
||||
|
||||
auto pListView::setBackgroundColor(Color color) -> void {
|
||||
auto pTableView::setBackgroundColor(Color color) -> void {
|
||||
GdkColor gdkColor = CreateColor(color);
|
||||
gtk_widget_modify_base(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||
}
|
||||
|
||||
auto pListView::setBatchable(bool batchable) -> void {
|
||||
auto pTableView::setBatchable(bool batchable) -> void {
|
||||
gtk_tree_selection_set_mode(gtkTreeSelection, batchable ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
|
||||
}
|
||||
|
||||
auto pListView::setBordered(bool bordered) -> void {
|
||||
auto pTableView::setBordered(bool bordered) -> void {
|
||||
gtk_tree_view_set_grid_lines(gtkTreeView, bordered ? GTK_TREE_VIEW_GRID_LINES_BOTH : GTK_TREE_VIEW_GRID_LINES_NONE);
|
||||
}
|
||||
|
||||
auto pListView::setFocused() -> void {
|
||||
auto pTableView::setFocused() -> void {
|
||||
//gtk_widget_grab_focus() will select the first item if nothing is currently selected
|
||||
//this behavior is undesirable. detect selection state first, and restore if required
|
||||
lock();
|
||||
@@ -128,18 +128,18 @@ auto pListView::setFocused() -> void {
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pListView::setFont(const Font& font) -> void {
|
||||
auto pTableView::setFont(const Font& font) -> void {
|
||||
if(auto& header = state().header) {
|
||||
if(auto self = header->self()) self->_setState();
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::setForegroundColor(Color color) -> void {
|
||||
auto pTableView::setForegroundColor(Color color) -> void {
|
||||
GdkColor gdkColor = CreateColor(color);
|
||||
gtk_widget_modify_text(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||
}
|
||||
|
||||
auto pListView::setGeometry(Geometry geometry) -> void {
|
||||
auto pTableView::setGeometry(Geometry geometry) -> void {
|
||||
pWidget::setGeometry(geometry);
|
||||
if(auto& header = state().header) {
|
||||
for(auto& column : header->state.columns) {
|
||||
@@ -148,7 +148,7 @@ auto pListView::setGeometry(Geometry geometry) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||
auto pTableView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto item = self().item(_row)) {
|
||||
if(auto cell = item->cell(_column)) {
|
||||
@@ -166,7 +166,7 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||
auto pTableView::_columnWidth(unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto column = header->column(_column)) {
|
||||
@@ -181,7 +181,7 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_createModel() -> void {
|
||||
auto pTableView::_createModel() -> void {
|
||||
gtk_tree_view_set_model(gtkTreeView, nullptr);
|
||||
gtkListStore = nullptr;
|
||||
gtkTreeModel = nullptr;
|
||||
@@ -204,19 +204,19 @@ auto pListView::_createModel() -> void {
|
||||
gtk_tree_view_set_model(gtkTreeView, gtkTreeModel);
|
||||
}
|
||||
|
||||
auto pListView::_doActivate() -> void {
|
||||
auto pTableView::_doActivate() -> void {
|
||||
if(!locked()) self().doActivate();
|
||||
}
|
||||
|
||||
auto pListView::_doChange() -> void {
|
||||
auto pTableView::_doChange() -> void {
|
||||
if(!locked()) _updateSelected();
|
||||
}
|
||||
|
||||
auto pListView::_doContext() -> void {
|
||||
auto pTableView::_doContext() -> void {
|
||||
if(!locked()) self().doContext();
|
||||
}
|
||||
|
||||
auto pListView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* renderer, GtkTreeIter* iter) -> void {
|
||||
auto pTableView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* renderer, GtkTreeIter* iter) -> void {
|
||||
auto path = gtk_tree_model_get_string_from_iter(gtkTreeModel, iter);
|
||||
auto row = natural(path);
|
||||
g_free(path);
|
||||
@@ -266,7 +266,7 @@ auto pListView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* rende
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* path, const char* text) -> void {
|
||||
auto pTableView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* path, const char* text) -> void {
|
||||
if(auto& header = state().header) {
|
||||
for(auto& column : header->state.columns) {
|
||||
if(auto delegate = column->self()) {
|
||||
@@ -287,12 +287,12 @@ auto pListView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* pa
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::_doEvent(GdkEventButton* event) -> signed {
|
||||
auto pTableView::_doEvent(GdkEventButton* event) -> signed {
|
||||
GtkTreePath* path = nullptr;
|
||||
gtk_tree_view_get_path_at_pos(gtkTreeView, event->x, event->y, &path, nullptr, nullptr, nullptr);
|
||||
|
||||
if(event->type == GDK_BUTTON_PRESS) {
|
||||
//when clicking in empty space below the last list view item; GTK+ does not deselect all items;
|
||||
//when clicking in empty space below the last table view item; GTK+ does not deselect all items;
|
||||
//below code enables this functionality, to match behavior with all other UI toolkits (and because it's very convenient to have)
|
||||
if(path == nullptr && gtk_tree_selection_count_selected_rows(gtkTreeSelection) > 0) {
|
||||
for(auto& item : state().items) item->setSelected(false);
|
||||
@@ -316,7 +316,7 @@ auto pListView::_doEvent(GdkEventButton* event) -> signed {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto pListView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
||||
auto pTableView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
||||
if(auto& header = state().header) {
|
||||
for(auto& column : header->state.columns) {
|
||||
if(auto delegate = column->self()) {
|
||||
@@ -330,15 +330,15 @@ auto pListView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void
|
||||
}
|
||||
|
||||
//GtkTreeView::cursor-changed and GtkTreeSelection::changed do not send signals for changes during rubber-banding selection
|
||||
//so here we capture motion-notify-event, and if the selections have changed, invoke ListView::onChange
|
||||
auto pListView::_doMouseMove() -> signed {
|
||||
//so here we capture motion-notify-event, and if the selections have changed, invoke TableView::onChange
|
||||
auto pTableView::_doMouseMove() -> signed {
|
||||
if(gtk_tree_view_is_rubber_banding_active(gtkTreeView)) {
|
||||
if(!locked()) _updateSelected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
auto pListView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const char* path) -> void {
|
||||
auto pTableView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const char* path) -> void {
|
||||
if(auto& header = state().header) {
|
||||
for(auto& column : header->state.columns) {
|
||||
if(auto delegate = column->self()) {
|
||||
@@ -361,7 +361,7 @@ auto pListView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const ch
|
||||
//if different, invoke the onChange callback unless locked, and cache current selection
|
||||
//this prevents firing an onChange event when the actual selection has not changed
|
||||
//this is particularly important for the motion-notify-event binding
|
||||
auto pListView::_updateSelected() -> void {
|
||||
auto pTableView::_updateSelected() -> void {
|
||||
vector<unsigned> selected;
|
||||
|
||||
GList* list = gtk_tree_selection_get_selected_rows(gtkTreeSelection, >kTreeModel);
|
||||
@@ -402,7 +402,7 @@ auto pListView::_updateSelected() -> void {
|
||||
if(!locked()) self().doChange();
|
||||
}
|
||||
|
||||
auto pListView::_width(unsigned column) -> unsigned {
|
||||
auto pTableView::_width(unsigned column) -> unsigned {
|
||||
if(auto& header = state().header) {
|
||||
if(auto width = header->column(column).width()) return width;
|
||||
unsigned width = 1;
|
@@ -1,15 +1,15 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListView : pWidget {
|
||||
Declare(ListView, Widget)
|
||||
struct pTableView : pWidget {
|
||||
Declare(TableView, Widget)
|
||||
|
||||
auto append(sListViewHeader column) -> void;
|
||||
auto append(sListViewItem item) -> void;
|
||||
auto append(sTableViewHeader column) -> void;
|
||||
auto append(sTableViewItem item) -> void;
|
||||
auto focused() const -> bool override;
|
||||
auto remove(sListViewHeader column) -> void;
|
||||
auto remove(sListViewItem item) -> void;
|
||||
auto remove(sTableViewHeader column) -> void;
|
||||
auto remove(sTableViewItem item) -> void;
|
||||
auto resizeColumns() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
Reference in New Issue
Block a user