mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-01 00:11:56 +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:
@@ -22,7 +22,7 @@ auto pMenuItem::destruct() -> void {
|
||||
qtMenuItem = nullptr;
|
||||
}
|
||||
|
||||
auto pMenuItem::setImage(const Image& icon) -> void {
|
||||
auto pMenuItem::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ auto pMenuItem::setText(const string& text) -> void {
|
||||
}
|
||||
|
||||
auto pMenuItem::_setState() -> void {
|
||||
qtMenuItem->setIcon(CreateImage(state().image));
|
||||
qtMenuItem->setIcon(CreateIcon(state().icon));
|
||||
qtMenuItem->setText(QString::fromUtf8(state().text));
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
auto _setState() -> void override;
|
||||
|
@@ -33,7 +33,7 @@ auto pMenu::append(sAction action) -> void {
|
||||
auto pMenu::remove(sAction action) -> void {
|
||||
}
|
||||
|
||||
auto pMenu::setImage(const Image& image) -> void {
|
||||
auto pMenu::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ auto pMenu::setText(const string& text) -> void {
|
||||
auto pMenu::_setState() -> void {
|
||||
qtMenu->setEnabled(self().enabled());
|
||||
qtMenu->setFont(pFont::create(self().font(true)));
|
||||
qtMenu->setIcon(CreateImage(state().image));
|
||||
qtMenu->setIcon(CreateIcon(state().icon));
|
||||
qtMenu->setTitle(QString::fromUtf8(state().text));
|
||||
qtMenu->menuAction()->setVisible(self().visible());
|
||||
|
||||
|
@@ -7,7 +7,7 @@ struct pMenu : public pAction {
|
||||
|
||||
auto append(sAction action) -> void;
|
||||
auto remove(sAction action) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _setState() -> void override;
|
||||
|
@@ -15,7 +15,7 @@ static auto CreateBrush(Color color) -> QBrush {
|
||||
return color ? QColor(color.red(), color.green(), color.blue()) : QBrush();
|
||||
}
|
||||
|
||||
static auto CreateIcon(const nall::image& icon, bool scale = false) -> QIcon {
|
||||
static auto CreateIcon(const image& icon, bool scale = false) -> QIcon {
|
||||
if(!icon) return QIcon();
|
||||
auto qtBuffer = icon;
|
||||
qtBuffer.transform();
|
||||
@@ -24,12 +24,6 @@ static auto CreateIcon(const nall::image& icon, bool scale = false) -> QIcon {
|
||||
return QIcon(QPixmap::fromImage(qtImage));
|
||||
}
|
||||
|
||||
static auto CreateImage(const Image& image, bool scale = false) -> QIcon {
|
||||
if(!image) return QIcon();
|
||||
QImage qtImage((const uint8_t*)image.data(), image.width(), image.height(), QImage::Format_ARGB32);
|
||||
return QIcon(QPixmap::fromImage(qtImage));
|
||||
}
|
||||
|
||||
static auto DropPaths(QDropEvent* event) -> lstring {
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
if(urls.size() == 0) return {};
|
||||
|
@@ -8,7 +8,7 @@ auto pButton::construct() -> void {
|
||||
qtButton->connect(qtButton, SIGNAL(released()), SLOT(onActivate()));
|
||||
|
||||
setBordered(state().bordered);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
@@ -24,13 +24,13 @@ auto pButton::minimumSize() const -> Size {
|
||||
auto size = pFont::size(qtWidget->font(), state().text ? state().text : " ");
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(state().image.height(), size.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(state().image.width(), size.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 ? 20 : 12), size.height() + 12};
|
||||
@@ -40,9 +40,9 @@ auto pButton::setBordered(bool bordered) -> void {
|
||||
qtButton->setAutoRaise(!bordered);
|
||||
}
|
||||
|
||||
auto pButton::setImage(const Image& image) -> void {
|
||||
qtButton->setIconSize(QSize(image.width(), image.height()));
|
||||
qtButton->setIcon(CreateImage(image));
|
||||
auto pButton::setIcon(const image& icon) -> void {
|
||||
qtButton->setIconSize(QSize(icon.width(), icon.height()));
|
||||
qtButton->setIcon(CreateIcon(icon));
|
||||
qtButton->setStyleSheet("text-align: top;");
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -18,7 +18,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};
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void {
|
||||
update();
|
||||
}
|
||||
|
||||
auto pCanvas::setImage(const Image& image) -> void {
|
||||
auto pCanvas::setIcon(const image& icon) -> void {
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ auto pCanvas::_rasterize() -> void {
|
||||
signed width = 0;
|
||||
signed 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();
|
||||
@@ -66,18 +66,18 @@ auto pCanvas::_rasterize() -> void {
|
||||
qtImageHeight = height;
|
||||
|
||||
if(!qtImage) qtImage = new QImage(width, height, QImage::Format_ARGB32);
|
||||
auto buffer = (uint32_t*)qtImage->bits();
|
||||
auto buffer = (uint32*)qtImage->bits();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ struct pCanvas : pWidget {
|
||||
auto setDroppable(bool droppable) -> void;
|
||||
auto setGeometry(Geometry geometry) -> void;
|
||||
auto setGradient(Gradient gradient) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto update() -> void;
|
||||
|
||||
auto _rasterize() -> void;
|
||||
|
@@ -21,13 +21,13 @@ auto pCheckButton::minimumSize() const -> Size {
|
||||
auto size = pFont::size(qtWidget->font(), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(state().image.height(), size.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(state().image.width(), size.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() + 20, size.height() + 12};
|
||||
@@ -41,7 +41,7 @@ auto pCheckButton::setChecked(bool checked) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pCheckButton::setImage(const Image& image) -> void {
|
||||
auto pCheckButton::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ auto pCheckButton::_setState() -> void {
|
||||
lock();
|
||||
qtCheckButton->setAutoRaise(!state().bordered);
|
||||
qtCheckButton->setChecked(state().checked);
|
||||
qtCheckButton->setIconSize(QSize(state().image.width(), state().image.height()));
|
||||
qtCheckButton->setIcon(CreateImage(state().image));
|
||||
qtCheckButton->setIconSize(QSize(state().icon.width(), state().icon.height()));
|
||||
qtCheckButton->setIcon(CreateIcon(state().icon));
|
||||
qtCheckButton->setStyleSheet("text-align: top;");
|
||||
switch(state().orientation) {
|
||||
case Orientation::Horizontal: qtCheckButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -19,7 +19,7 @@ auto pComboButtonItem::destruct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pComboButtonItem::setImage(const Image& image) -> void {
|
||||
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ auto pComboButtonItem::_parent() -> maybe<pComboButton&> {
|
||||
|
||||
auto pComboButtonItem::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->qtComboButton->setItemIcon(self().offset(), CreateImage(state().image));
|
||||
parent->qtComboButton->setItemIcon(self().offset(), CreateIcon(state().icon));
|
||||
if(state().selected) parent->qtComboButton->setCurrentIndex(self().offset());
|
||||
parent->qtComboButton->setItemText(self().offset(), QString::fromUtf8(state().text));
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ namespace hiro {
|
||||
struct pComboButtonItem : pObject {
|
||||
Declare(ComboButtonItem, Object)
|
||||
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
@@ -22,6 +22,12 @@ auto pFrame::destruct() -> void {
|
||||
qtWidget = qtFrame = nullptr;
|
||||
}
|
||||
|
||||
auto pFrame::append(sLayout layout) -> void {
|
||||
}
|
||||
|
||||
auto pFrame::remove(sLayout layout) -> void {
|
||||
}
|
||||
|
||||
auto pFrame::setEnabled(bool enabled) -> void {
|
||||
if(auto layout = state().layout) layout->setEnabled(layout->enabled(true));
|
||||
pWidget::setEnabled(enabled);
|
||||
|
@@ -5,6 +5,8 @@ namespace hiro {
|
||||
struct pFrame : pWidget {
|
||||
Declare(Frame, Widget)
|
||||
|
||||
auto append(sLayout layout) -> void;
|
||||
auto remove(sLayout layout) -> void;
|
||||
auto setEnabled(bool enabled) -> void override;
|
||||
auto setGeometry(Geometry geometry) -> void override;
|
||||
auto setText(const string& text) -> void;
|
||||
|
@@ -32,7 +32,7 @@ auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setImage(const Image& image) -> void {
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ auto pListViewCell::_setState() -> void {
|
||||
}
|
||||
parent->qtItem->setFont(self().offset(), pFont::create(self().font(true)));
|
||||
parent->qtItem->setForeground(self().offset(), CreateBrush(self().foregroundColor(true)));
|
||||
parent->qtItem->setIcon(self().offset(), CreateImage(state().image));
|
||||
parent->qtItem->setIcon(self().offset(), CreateIcon(state().icon));
|
||||
parent->qtItem->setText(self().offset(), QString::fromUtf8(state().text));
|
||||
parent->qtItem->setTextAlignment(self().offset(), CalculateAlignment(self().alignment(true)));
|
||||
grandparent->unlock();
|
||||
|
@@ -11,7 +11,7 @@ struct pListViewCell : pObject {
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setFont(const string& font) -> 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 _parent() -> maybe<pListViewItem&>;
|
||||
|
@@ -40,7 +40,7 @@ auto pListViewColumn::setHorizontalAlignment(double alignment) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setImage(const Image& image) -> void {
|
||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
//unsupported
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ struct pListViewColumn : pObject {
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setHorizontalAlignment(double alignment) -> 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;
|
||||
|
@@ -154,8 +154,8 @@ auto pListView::_widthOfColumn(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();
|
||||
@@ -172,8 +172,8 @@ auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||
if(cell->state.checkable) {
|
||||
width += 16 + 2;
|
||||
}
|
||||
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();
|
||||
|
@@ -22,13 +22,13 @@ auto pRadioButton::minimumSize() const -> Size {
|
||||
auto size = pFont::size(qtWidget->font(), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(state().image.height(), size.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(state().image.width(), size.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() + 20, size.height() + 12};
|
||||
@@ -59,7 +59,7 @@ auto pRadioButton::setGroup(sGroup group) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pRadioButton::setImage(const Image& image) -> void {
|
||||
auto pRadioButton::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ auto pRadioButton::_setState() -> void {
|
||||
}
|
||||
group->self()->unlock();
|
||||
}
|
||||
qtRadioButton->setIconSize(QSize(state().image.width(), state().image.height()));
|
||||
qtRadioButton->setIcon(CreateImage(state().image));
|
||||
qtRadioButton->setIconSize(QSize(state().icon.width(), state().icon.height()));
|
||||
qtRadioButton->setIcon(CreateIcon(state().icon));
|
||||
qtRadioButton->setStyleSheet("text-align: top;");
|
||||
switch(state().orientation) {
|
||||
case Orientation::Horizontal: qtRadioButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -34,7 +34,7 @@ auto pTabFrameItem::setGeometry(Geometry geometry) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pTabFrameItem::setImage(const Image& image) -> void {
|
||||
auto pTabFrameItem::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ auto pTabFrameItem::_parent() -> maybe<pTabFrame&> {
|
||||
|
||||
auto pTabFrameItem::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->qtTabFrame->setTabIcon(self().offset(), CreateImage(state().image));
|
||||
parent->qtTabFrame->setTabIcon(self().offset(), CreateIcon(state().icon));
|
||||
if(state().selected) parent->qtTabFrame->setCurrentIndex(self().offset());
|
||||
parent->qtTabFrame->setTabText(self().offset(), QString::fromUtf8(state().text));
|
||||
if(auto layout = state().layout) {
|
||||
|
@@ -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 setGeometry(Geometry geometry) -> void;
|
||||
auto setMovable(bool movable) -> void;
|
||||
auto setSelected() -> void;
|
||||
|
Reference in New Issue
Block a user