mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 01:02:36 +02:00
Update to 20160106 OS X Preview for Developers release.
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
This commit is contained in:
@@ -9,7 +9,7 @@ static auto MenuItem_activate(GtkMenuItem*, pMenuItem* p) -> void {
|
||||
auto pMenuItem::construct() -> void {
|
||||
widget = gtk_image_menu_item_new_with_mnemonic("");
|
||||
g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(MenuItem_activate), (gpointer)this);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ auto pMenuItem::destruct() -> void {
|
||||
if(widget) gtk_widget_destroy(widget), widget = nullptr;
|
||||
}
|
||||
|
||||
auto pMenuItem::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image, true);
|
||||
auto pMenuItem::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon, true);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
|
||||
|
@@ -5,7 +5,7 @@ namespace hiro {
|
||||
struct pMenuItem : pAction {
|
||||
Declare(MenuItem, Action)
|
||||
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
};
|
||||
|
||||
|
@@ -6,7 +6,7 @@ auto pMenu::construct() -> void {
|
||||
gtkMenu = gtk_menu_new();
|
||||
widget = gtk_image_menu_item_new_with_mnemonic("");
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
|
||||
for(auto& action : state().actions) append(*action);
|
||||
@@ -35,9 +35,9 @@ auto pMenu::setFont(const Font& font) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pMenu::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image, true);
|
||||
auto pMenu::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon, true);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
|
||||
|
@@ -8,7 +8,7 @@ struct pMenu : pAction {
|
||||
auto append(sAction action) -> void;
|
||||
auto remove(sAction action) -> void;
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
GtkWidget* gtkMenu = nullptr;
|
||||
|
@@ -29,40 +29,11 @@ static auto CreatePixbuf(image icon, bool scale = false) -> GdkPixbuf* {
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static auto CreatePixbuf(const Image& image, bool scale = false) -> GdkPixbuf* {
|
||||
if(!image.state.data) return nullptr;
|
||||
|
||||
auto pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, image.width(), image.height());
|
||||
|
||||
//ARGB -> ABGR conversion
|
||||
const uint32_t* source = image.data();
|
||||
uint32_t* target = (uint32_t*)gdk_pixbuf_get_pixels(pixbuf);
|
||||
for(auto n : range(image.width() * image.height())) {
|
||||
uint32_t pixel = *source++;
|
||||
*target++ = (pixel & 0x00ff0000) >> 16 | (pixel & 0xff00ff00) | (pixel & 0x000000ff) << 16;
|
||||
}
|
||||
|
||||
if(scale) {
|
||||
auto scaled = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR);
|
||||
g_object_unref(pixbuf);
|
||||
pixbuf = scaled;
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static auto CreateImage(const nall::image& image, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(image, scale);
|
||||
auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
static auto CreateImage(const image& icon, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(icon, scale);
|
||||
auto gtkIcon = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
return gtkImage;
|
||||
}
|
||||
|
||||
static auto CreateImage(const Image& image, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(image, scale);
|
||||
auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
return gtkImage;
|
||||
return gtkIcon;
|
||||
}
|
||||
|
||||
static auto DropPaths(GtkSelectionData* data) -> lstring {
|
||||
|
@@ -9,7 +9,7 @@ auto pButton::construct() -> void {
|
||||
gtkButton = GTK_BUTTON(gtkWidget);
|
||||
|
||||
setBordered(state().bordered);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
@@ -26,13 +26,13 @@ auto pButton::minimumSize() const -> Size {
|
||||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + (state().text ? 24 : 12), size.height() + 12};
|
||||
@@ -42,9 +42,9 @@ auto pButton::setBordered(bool bordered) -> void {
|
||||
gtk_button_set_relief(gtkButton, bordered ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE);
|
||||
}
|
||||
|
||||
auto pButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
auto gtkImage = CreateImage(image);
|
||||
auto pButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
auto gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(gtkButton, (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(gtkButton, nullptr);
|
||||
|
@@ -7,7 +7,7 @@ struct pButton : pWidget {
|
||||
|
||||
auto minimumSize() const -> Size override;
|
||||
auto setBordered(bool bordered) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -73,7 +73,7 @@ auto pCanvas::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pCanvas::minimumSize() const -> Size {
|
||||
if(auto& image = state().image) return image.size();
|
||||
if(auto& icon = state().icon) return {(int)icon.width(), (int)icon.height()};
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void {
|
||||
update();
|
||||
}
|
||||
|
||||
auto pCanvas::setImage(const Image& image) -> void {
|
||||
auto pCanvas::setIcon(const image& icon) -> void {
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -109,9 +109,9 @@ auto pCanvas::update() -> void {
|
||||
auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
|
||||
if(surface == nullptr) return;
|
||||
|
||||
signed sx = 0, sy = 0, dx = 0, dy = 0;
|
||||
signed width = surfaceWidth;
|
||||
signed height = surfaceHeight;
|
||||
int sx = 0, sy = 0, dx = 0, dy = 0;
|
||||
int width = surfaceWidth;
|
||||
int height = surfaceHeight;
|
||||
auto geometry = pSizable::state().geometry;
|
||||
|
||||
if(width <= geometry.width()) {
|
||||
@@ -136,12 +136,12 @@ auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
|
||||
}
|
||||
|
||||
auto pCanvas::_rasterize() -> void {
|
||||
signed width = 0;
|
||||
signed height = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
if(auto& image = state().image) {
|
||||
width = image.width();
|
||||
height = image.height();
|
||||
if(auto& icon = state().icon) {
|
||||
width = icon.width();
|
||||
height = icon.height();
|
||||
} else {
|
||||
width = pSizable::state().geometry.width();
|
||||
height = pSizable::state().geometry.height();
|
||||
@@ -155,22 +155,22 @@ auto pCanvas::_rasterize() -> void {
|
||||
if(!surface) surface = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, width, height);
|
||||
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
|
||||
|
||||
if(auto& image = state().image) {
|
||||
memory::copy(buffer, state().image.data(), width * height * sizeof(uint32_t));
|
||||
if(auto& icon = state().icon) {
|
||||
memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32));
|
||||
} else if(auto& gradient = state().gradient) {
|
||||
auto& colors = gradient.state.colors;
|
||||
nall::image fill;
|
||||
image fill;
|
||||
fill.allocate(width, height);
|
||||
fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value());
|
||||
memory::copy(buffer, fill.data(), fill.size());
|
||||
} else {
|
||||
uint32_t color = state().color.value();
|
||||
uint32 color = state().color.value();
|
||||
for(auto n : range(width * height)) buffer[n] = color;
|
||||
}
|
||||
|
||||
//ARGB -> ABGR conversion
|
||||
for(auto n : range(width * height)) {
|
||||
uint32_t color = *buffer;
|
||||
uint32 color = *buffer;
|
||||
color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16);
|
||||
*buffer++ = color;
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ struct pCanvas : pWidget {
|
||||
auto setDroppable(bool droppable) -> void;
|
||||
auto setGeometry(Geometry geometry) -> void override;
|
||||
auto setGradient(Gradient gradient) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto update() -> void;
|
||||
|
||||
auto _onExpose(GdkEventExpose* event) -> void;
|
||||
@@ -19,8 +19,8 @@ struct pCanvas : pWidget {
|
||||
auto _release() -> void;
|
||||
|
||||
GdkPixbuf* surface = nullptr;
|
||||
unsigned surfaceWidth = 0;
|
||||
unsigned surfaceHeight = 0;
|
||||
uint surfaceWidth = 0;
|
||||
uint surfaceHeight = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ auto pCheckButton::construct() -> void {
|
||||
|
||||
setBordered(state().bordered);
|
||||
setChecked(state().checked);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
@@ -29,13 +29,13 @@ auto pCheckButton::minimumSize() const -> Size {
|
||||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + 24, size.height() + 12};
|
||||
@@ -51,9 +51,9 @@ auto pCheckButton::setChecked(bool checked) -> void {
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pCheckButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image);
|
||||
auto pCheckButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);
|
||||
|
@@ -8,7 +8,7 @@ struct pCheckButton : pWidget {
|
||||
auto minimumSize() const -> Size override;
|
||||
auto setBordered(bool bordered) -> void;
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
};
|
||||
|
@@ -8,10 +8,10 @@ auto pComboButtonItem::construct() -> void {
|
||||
auto pComboButtonItem::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pComboButtonItem::setImage(const Image& image) -> void {
|
||||
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
auto size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(image, true);
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ namespace hiro {
|
||||
struct pComboButtonItem : pObject {
|
||||
Declare(ComboButtonItem, Object)
|
||||
|
||||
auto setImage(const Image& icon) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -32,7 +32,7 @@ auto pComboButton::append(sComboButtonItem item) -> void {
|
||||
lock();
|
||||
if(auto self = item->self()) {
|
||||
gtk_list_store_append(gtkListStore, &self->gtkIter);
|
||||
self->setImage(item->state.image);
|
||||
self->setIcon(item->state.icon);
|
||||
if(item->state.selected) self->setSelected();
|
||||
self->setText(item->state.text);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ auto pComboButton::minimumSize() const -> Size {
|
||||
signed maximumWidth = 0;
|
||||
for(auto& item : state().items) {
|
||||
maximumWidth = max(maximumWidth,
|
||||
(item->state.image ? pFont::size(font, " ").height() + 2 : 0)
|
||||
(item->state.icon ? pFont::size(font, " ").height() + 2 : 0)
|
||||
+ pFont::size(font, item->state.text).width()
|
||||
);
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@ auto pIconViewItem::construct() -> void {
|
||||
auto pIconViewItem::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pIconViewItem::setImage(const Image& image) -> void {
|
||||
auto pIconViewItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->setItemImage(self().offset(), image);
|
||||
parent->setItemIcon(self().offset(), icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ namespace hiro {
|
||||
struct pIconViewItem : pObject {
|
||||
Declare(IconViewItem, Object)
|
||||
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected(bool selected) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -65,7 +65,7 @@ auto pIconView::destruct() -> void {
|
||||
auto pIconView::append(sIconViewItem item) -> void {
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(store, &iter);
|
||||
setItemImage(item->offset(), item->state.image);
|
||||
setItemIcon(item->offset(), item->state.icon);
|
||||
setItemSelected(item->offset(), item->state.selected);
|
||||
setItemText(item->offset(), item->state.text);
|
||||
}
|
||||
@@ -121,12 +121,12 @@ auto pIconView::setGeometry(Geometry geometry) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pIconView::setItemImage(unsigned position, const Image& image) -> void {
|
||||
auto pIconView::setItemIcon(unsigned position, const image& icon) -> void {
|
||||
if(position >= self().itemCount()) return;
|
||||
GtkTreeIter iter;
|
||||
if(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, string{position})) {
|
||||
if(image) {
|
||||
GdkPixbuf* pixbuf = CreatePixbuf(image);
|
||||
if(icon) {
|
||||
GdkPixbuf* pixbuf = CreatePixbuf(icon);
|
||||
gtk_list_store_set(store, &iter, 0, pixbuf, -1);
|
||||
} else {
|
||||
gtk_list_store_set(store, &iter, 0, nullptr, -1);
|
||||
|
@@ -13,7 +13,7 @@ struct pIconView : pWidget {
|
||||
auto setFlow(Orientation flow) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setGeometry(Geometry geometry) -> void;
|
||||
auto setItemImage(unsigned position, const Image& image) -> void;
|
||||
auto setItemIcon(unsigned position, const image& icon) -> void;
|
||||
auto setItemSelected(unsigned position, bool selected) -> void;
|
||||
auto setItemSelected(const vector<signed>& selections) -> void;
|
||||
auto setItemSelectedAll() -> void;
|
||||
|
@@ -25,7 +25,7 @@ auto pListViewCell::setChecked(bool checked) -> void {
|
||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setImage(const Image& image) -> void {
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ auto pListViewCell::_setState() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 0, state().checked, -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().image), -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().icon), -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 2, state().text.data(), -1);
|
||||
grandparent->unlock();
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ struct pListViewCell : pObject {
|
||||
auto setCheckable(bool checkable) -> void;
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
|
@@ -81,9 +81,9 @@ auto pListViewColumn::setFont(const Font& font) -> void {
|
||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(image));
|
||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
||||
} else {
|
||||
gtk_image_clear(GTK_IMAGE(gtkHeaderIcon));
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ struct pListViewColumn : pObject {
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setHorizontalAlignment(double) -> void {}
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setResizable(bool resizable) -> void;
|
||||
auto setSortable(bool sortable) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
@@ -155,8 +155,8 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||
if(cell->state.checkable) {
|
||||
width += 24;
|
||||
}
|
||||
if(auto& image = cell->state.image) {
|
||||
width += image.width() + 2;
|
||||
if(auto& icon = cell->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = cell->state.text) {
|
||||
width += pFont::size(cell->font(true), text).width();
|
||||
@@ -170,8 +170,8 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto column = header->column(_column)) {
|
||||
if(auto& image = column->state.image) {
|
||||
width += image.width() + 2;
|
||||
if(auto& icon = column->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = column->state.text) {
|
||||
width += pFont::size(column->font(true), text).width();
|
||||
|
@@ -13,7 +13,7 @@ auto pRadioButton::construct() -> void {
|
||||
gtkWidget = gtk_toggle_button_new();
|
||||
|
||||
setBordered(state().bordered);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
@@ -30,13 +30,13 @@ auto pRadioButton::minimumSize() const -> Size {
|
||||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + 24, size.height() + 12};
|
||||
@@ -76,9 +76,9 @@ auto pRadioButton::setGroup(sGroup group) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pRadioButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image);
|
||||
auto pRadioButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);
|
||||
|
@@ -9,7 +9,7 @@ struct pRadioButton : pWidget {
|
||||
auto setBordered(bool bordered) -> void;
|
||||
auto setChecked() -> void;
|
||||
auto setGroup(sGroup group) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -22,9 +22,9 @@ auto pTabFrameItem::setClosable(bool closable) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pTabFrameItem::setImage(const Image& image) -> void {
|
||||
auto pTabFrameItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->setItemImage(self().offset(), image);
|
||||
parent->setItemIcon(self().offset(), icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ struct pTabFrameItem : pObject {
|
||||
auto append(sLayout layout) -> void;
|
||||
auto remove(sLayout layout) -> void;
|
||||
auto setClosable(bool closable) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setMovable(bool movable) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
@@ -178,7 +178,7 @@ auto pTabFrame::setItemClosable(unsigned position, bool closable) -> void {
|
||||
_synchronizeTab(position);
|
||||
}
|
||||
|
||||
auto pTabFrame::setItemImage(unsigned position, const Image& image) -> void {
|
||||
auto pTabFrame::setItemIcon(unsigned position, const image& icon) -> void {
|
||||
_synchronizeTab(position);
|
||||
}
|
||||
|
||||
@@ -239,15 +239,15 @@ auto pTabFrame::_synchronizeTab(unsigned position) -> void {
|
||||
auto& item = state().items[position];
|
||||
auto& tab = tabs[position];
|
||||
gtk_widget_set_visible(tab.close, item->closable());
|
||||
if(auto& image = item->state.image) {
|
||||
unsigned size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(image, true);
|
||||
if(auto& icon = item->state.icon) {
|
||||
uint size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(tab.image), pixbuf);
|
||||
} else {
|
||||
gtk_image_clear(GTK_IMAGE(tab.image));
|
||||
}
|
||||
string text = {
|
||||
item->state.image && item->state.text ? " " : "",
|
||||
item->state.icon && item->state.text ? " " : "",
|
||||
item->state.text,
|
||||
item->state.text && item->state.closable ? " " : ""
|
||||
};
|
||||
|
@@ -12,7 +12,7 @@ struct pTabFrame : pWidget {
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setGeometry(Geometry geometry) -> void override;
|
||||
auto setItemClosable(unsigned position, bool closable) -> void;
|
||||
auto setItemImage(unsigned position, const Image& image) -> void;
|
||||
auto setItemIcon(unsigned position, const image& icon) -> void;
|
||||
auto setItemLayout(unsigned position, sLayout layout) -> void;
|
||||
auto setItemMovable(unsigned position, bool movable) -> void;
|
||||
auto setItemSelected(unsigned position) -> void;
|
||||
|
@@ -10,7 +10,7 @@ auto pTreeViewItem::construct() -> void {
|
||||
gtk_tree_store_append(parentWidget->gtkTreeStore, >kIter, nullptr);
|
||||
}
|
||||
setChecked(state().checked);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
}
|
||||
}
|
||||
@@ -65,10 +65,10 @@ auto pTreeViewItem::setFocused() -> void {
|
||||
auto pTreeViewItem::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pTreeViewItem::setImage(const Image& image) -> void {
|
||||
auto pTreeViewItem::setIcon(const image& icon) -> void {
|
||||
if(auto parentWidget = _parentWidget()) {
|
||||
if(image) {
|
||||
auto pixbuf = CreatePixbuf(image);
|
||||
if(icon) {
|
||||
auto pixbuf = CreatePixbuf(icon);
|
||||
gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, pixbuf, -1);
|
||||
} else {
|
||||
gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, nullptr, -1);
|
||||
|
@@ -13,7 +13,7 @@ struct pTreeViewItem : pObject {
|
||||
auto setExpanded(bool expanded) -> void;
|
||||
auto setFocused() -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -143,7 +143,7 @@ auto pTreeView::_doDataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer
|
||||
if(renderer == GTK_CELL_RENDERER(gtkCellToggle)) {
|
||||
gtk_cell_renderer_set_visible(renderer, item->state.checkable);
|
||||
} else if(renderer == GTK_CELL_RENDERER(gtkCellPixbuf)) {
|
||||
gtk_cell_renderer_set_visible(renderer, (bool)item->state.image);
|
||||
gtk_cell_renderer_set_visible(renderer, (bool)item->state.icon);
|
||||
} else if(renderer == GTK_CELL_RENDERER(gtkCellText)) {
|
||||
auto font = pFont::create(item->font(true));
|
||||
g_object_set(G_OBJECT(renderer), "font-desc", font, nullptr);
|
||||
|
Reference in New Issue
Block a user