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:
Tim Allen 2016-01-07 19:14:33 +11:00
parent 4d193d7d94
commit 0b923489dd
308 changed files with 699 additions and 1326 deletions

View File

@ -1,5 +1,5 @@
AdvancedSettings::AdvancedSettings(TabFrame* parent) : TabFrameItem(parent) { AdvancedSettings::AdvancedSettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Action::Settings); setIcon(Icon::Action::Settings);
setText("Advanced"); setText("Advanced");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) { AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Device::Speaker); setIcon(Icon::Device::Speaker);
setText("Audio"); setText("Audio");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) { HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Device::Keyboard); setIcon(Icon::Device::Keyboard);
setText("Hotkeys"); setText("Hotkeys");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) { InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Device::Joypad); setIcon(Icon::Device::Joypad);
setText("Input"); setText("Input");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
TimingSettings::TimingSettings(TabFrame* parent) : TabFrameItem(parent) { TimingSettings::TimingSettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Device::Clock); setIcon(Icon::Device::Clock);
setText("Timing"); setText("Timing");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
VideoSettings::VideoSettings(TabFrame* parent) : TabFrameItem(parent) { VideoSettings::VideoSettings(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Device::Display); setIcon(Icon::Device::Display);
setText("Video"); setText("Video");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
CheatEditor::CheatEditor(TabFrame* parent) : TabFrameItem(parent) { CheatEditor::CheatEditor(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Edit::Replace); setIcon(Icon::Edit::Replace);
setText("Cheat Editor"); setText("Cheat Editor");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
ManifestViewer::ManifestViewer(TabFrame* parent) : TabFrameItem(parent) { ManifestViewer::ManifestViewer(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Emblem::Text); setIcon(Icon::Emblem::Text);
setText("Manifest Viewer"); setText("Manifest Viewer");
layout.setMargin(5); layout.setMargin(5);

View File

@ -1,5 +1,5 @@
StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) { StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) {
setImage(Icon::Application::FileManager); setIcon(Icon::Application::FileManager);
setText("State Manager"); setText("State Manager");
layout.setMargin(5); layout.setMargin(5);

View File

@ -24,7 +24,7 @@ auto pMenuItem::construct() -> void {
cocoaAction = cocoaMenuItem = [[CocoaMenuItem alloc] initWith:self()]; cocoaAction = cocoaMenuItem = [[CocoaMenuItem alloc] initWith:self()];
pAction::construct(); pAction::construct();
setImage(state().image); setIcon(state().icon);
setText(state().text); setText(state().text);
} }
} }
@ -35,10 +35,10 @@ auto pMenuItem::destruct() -> void {
} }
} }
auto pMenuItem::setImage(const Image& image) -> void { auto pMenuItem::setIcon(const image& icon) -> void {
@autoreleasepool { @autoreleasepool {
uint size = 15; //there is no API to retrieve the optimal size uint size = 15; //there is no API to retrieve the optimal size
[cocoaAction setImage:NSMakeImage(image, size, size)]; [cocoaAction setImage:NSMakeImage(icon, size, size)];
} }
} }

View File

@ -13,7 +13,7 @@ namespace hiro {
struct pMenuItem : pAction { struct pMenuItem : pAction {
Declare(MenuItem, Action) Declare(MenuItem, Action)
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;
CocoaMenuItem* cocoaMenuItem = nullptr; CocoaMenuItem* cocoaMenuItem = nullptr;

View File

@ -25,7 +25,7 @@ auto pMenu::construct() -> void {
cocoaAction = cocoaMenu = [[CocoaMenu alloc] initWith:self()]; cocoaAction = cocoaMenu = [[CocoaMenu alloc] initWith:self()];
pAction::construct(); pAction::construct();
setImage(state().image); setIcon(state().icon);
setText(state().text); setText(state().text);
} }
} }
@ -53,10 +53,10 @@ auto pMenu::remove(sAction action) -> void {
} }
} }
auto pMenu::setImage(const Image& image) -> void { auto pMenu::setIcon(const image& icon) -> void {
@autoreleasepool { @autoreleasepool {
uint size = 15; //there is no API to retrieve the optimal size uint size = 15; //there is no API to retrieve the optimal size
[cocoaAction setImage:NSMakeImage(image, size, size)]; [cocoaAction setImage:NSMakeImage(icon, size, size)];
} }
} }

View File

@ -16,7 +16,7 @@ struct pMenu : pAction {
auto append(sAction action) -> void; auto append(sAction action) -> void;
auto remove(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 setText(const string& text) -> void;
CocoaMenu* cocoaMenu = nullptr; CocoaMenu* cocoaMenu = nullptr;

View File

@ -36,6 +36,7 @@ auto pStatusBar::setVisible(bool visible) -> void {
@autoreleasepool { @autoreleasepool {
if(auto parent = _parent()) { if(auto parent = _parent()) {
[[parent->cocoaWindow statusBar] setHidden:!visible]; [[parent->cocoaWindow statusBar] setHidden:!visible];
parent->setGeometry(parent->state().geometry);
} }
} }
} }

View File

@ -2,40 +2,25 @@ auto NSMakeColor(const hiro::Color& color) -> NSColor* {
return [NSColor colorWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)]; return [NSColor colorWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)];
} }
auto NSMakeImage(hiro::Image image, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* { auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* {
if(!image.state.data) return nil; if(!icon) return nil;
//convert ARGB8888 to ABGR8888 if(scaleWidth && scaleHeight) icon.scale(scaleWidth, scaleHeight);
auto p = image.data(); icon.transform(0, 32, 255u << 24, 255u << 0, 255u << 8, 255u << 16); //Cocoa stores images in ABGR format
for(auto n : range(image.width() * image.height())) {
uint32 color = *p;
color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16);
*p++ = color;
}
//create NSImage from memory //create NSImage from memory
NSImage* cocoaImage = [[[NSImage alloc] initWithSize:NSMakeSize(image.width(), image.height())] autorelease]; NSImage* cocoaImage = [[[NSImage alloc] initWithSize:NSMakeSize(icon.width(), icon.height())] autorelease];
NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:nil initWithBitmapDataPlanes:nil
pixelsWide:image.width() pixelsHigh:image.height() pixelsWide:icon.width() pixelsHigh:icon.height()
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES
isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
bytesPerRow:4*image.width() bitsPerPixel:32 bytesPerRow:(4 * icon.width()) bitsPerPixel:32
] autorelease]; ] autorelease];
memory::copy([bitmap bitmapData], image.data(), 4 * image.width() * image.height()); memory::copy([bitmap bitmapData], icon.data(), 4 * icon.width() * icon.height());
[cocoaImage addRepresentation:bitmap]; [cocoaImage addRepresentation:bitmap];
if(!scaleWidth || !scaleHeight) return cocoaImage; return cocoaImage;
//scale image
[cocoaImage setScalesWhenResized:YES];
NSImage* scaleImage = [[[NSImage alloc] initWithSize:NSMakeSize(scaleWidth, scaleHeight)] autorelease];
[scaleImage lockFocus];
[cocoaImage setSize:NSMakeSize(scaleWidth, scaleHeight)];
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
[cocoaImage drawAtPoint:NSZeroPoint fromRect:CGRectMake(0, 0, scaleWidth, scaleHeight) operation:NSCompositeCopy fraction:1.0];
[scaleImage unlockFocus];
return scaleImage;
} }
auto DropPathsOperation(id<NSDraggingInfo> sender) -> NSDragOperation { auto DropPathsOperation(id<NSDraggingInfo> sender) -> NSDragOperation {

View File

@ -27,7 +27,7 @@ auto pButton::construct() -> void {
pWidget::construct(); pWidget::construct();
setBordered(state().bordered); setBordered(state().bordered);
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
} }
@ -35,6 +35,7 @@ auto pButton::construct() -> void {
auto pButton::destruct() -> void { auto pButton::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
@ -43,16 +44,16 @@ auto pButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + (state().text ? 20 : 4), size.height() + 4}; return {size.width() + (state().text ? 20 : 8), size.height() + 8};
} }
auto pButton::setBordered(bool bordered) -> void { auto pButton::setBordered(bool bordered) -> void {
@ -65,14 +66,9 @@ auto pButton::setGeometry(Geometry geometry) -> void {
}); });
} }
auto pButton::setImage(const Image& image) -> void { auto pButton::setIcon(const image& icon) -> void {
@autoreleasepool { @autoreleasepool {
if(!image) { [cocoaView setImage:NSMakeImage(icon)];
[cocoaView setImage:nil];
return;
}
[cocoaView setImage:NSMakeImage(image)];
} }
} }

View File

@ -16,7 +16,7 @@ struct pButton : pWidget {
auto minimumSize() const -> Size override; auto minimumSize() const -> Size override;
auto setBordered(bool bordered) -> void; auto setBordered(bool bordered) -> void;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -99,6 +99,7 @@ auto pCanvas::construct() -> void {
auto pCanvas::destruct() -> void { auto pCanvas::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
@ -146,7 +147,7 @@ auto pCanvas::setGeometry(Geometry geometry) -> void {
auto pCanvas::setGradient(Gradient gradient) -> void { auto pCanvas::setGradient(Gradient gradient) -> void {
} }
auto pCanvas::setImage(const Image& image) -> void { auto pCanvas::setIcon(const image& icon) -> void {
} }
auto pCanvas::update() -> void { auto pCanvas::update() -> void {

View File

@ -31,7 +31,7 @@ struct pCanvas : pWidget {
auto setDroppable(bool droppable) -> void; auto setDroppable(bool droppable) -> void;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setGradient(Gradient gradient) -> void; auto setGradient(Gradient gradient) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto update() -> void; auto update() -> void;
auto _rasterize() -> void; auto _rasterize() -> void;

View File

@ -30,7 +30,7 @@ auto pCheckButton::construct() -> void {
setBordered(state().bordered); setBordered(state().bordered);
setChecked(state().checked); setChecked(state().checked);
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
} }
@ -38,6 +38,7 @@ auto pCheckButton::construct() -> void {
auto pCheckButton::destruct() -> void { auto pCheckButton::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
@ -46,16 +47,16 @@ auto pCheckButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + 20, size.height() + 4}; return {size.width() + (state().text ? 20 : 8), size.height() + 8};
} }
auto pCheckButton::setBordered(bool bordered) -> void { auto pCheckButton::setBordered(bool bordered) -> void {
@ -74,14 +75,9 @@ auto pCheckButton::setGeometry(Geometry geometry) -> void {
}); });
} }
auto pCheckButton::setImage(const Image& image) -> void { auto pCheckButton::setIcon(const image& icon) -> void {
@autoreleasepool { @autoreleasepool {
if(!image) { [cocoaView setImage:NSMakeImage(icon)];
[cocoaView setImage:nil];
return;
}
[cocoaView setImage:NSMakeImage(image)];
} }
} }

View File

@ -17,7 +17,7 @@ struct pCheckButton : pWidget {
auto setBordered(bool bordered) -> void; auto setBordered(bool bordered) -> void;
auto setChecked(bool checked) -> void; auto setChecked(bool checked) -> void;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -34,6 +34,7 @@ auto pCheckLabel::construct() -> void {
auto pCheckLabel::destruct() -> void { auto pCheckLabel::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -8,7 +8,7 @@ auto pComboButtonItem::construct() -> void {
auto pComboButtonItem::destruct() -> void { auto pComboButtonItem::destruct() -> void {
} }
auto pComboButtonItem::setImage(const Image& icon) -> void { auto pComboButtonItem::setIcon(const image& icon) -> void {
} }
auto pComboButtonItem::setSelected() -> void { auto pComboButtonItem::setSelected() -> void {

View File

@ -5,7 +5,7 @@ namespace hiro {
struct pComboButtonItem : pObject { struct pComboButtonItem : pObject {
Declare(ComboButtonItem, Object) Declare(ComboButtonItem, Object)
auto setImage(const Image& icon) -> void; auto setIcon(const image& icon) -> void;
auto setSelected() -> void; auto setSelected() -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -30,6 +30,7 @@ auto pComboButton::construct() -> void {
auto pComboButton::destruct() -> void { auto pComboButton::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -36,6 +36,7 @@ void pConsole::constructor() {
void pConsole::destructor() { void pConsole::destructor() {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -26,6 +26,7 @@ auto pFrame::construct() -> void {
auto pFrame::destruct() -> void { auto pFrame::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -42,6 +42,7 @@ void pHexEdit::constructor() {
void pHexEdit::destructor() { void pHexEdit::destructor() {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -66,6 +66,7 @@ auto pHorizontalScrollBar::construct() -> void {
auto pHorizontalScrollBar::destruct() -> void { auto pHorizontalScrollBar::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -34,6 +34,7 @@ auto pHorizontalSlider::construct() -> void {
auto pHorizontalSlider::destruct() -> void { auto pHorizontalSlider::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -29,6 +29,7 @@ auto pLabel::construct() -> void {
auto pLabel::destruct() -> void { auto pLabel::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -42,6 +42,7 @@ auto pLineEdit::construct() -> void {
auto pLineEdit::destruct() -> void { auto pLineEdit::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -23,7 +23,7 @@ auto pListViewCell::setChecked(bool checked) -> void {
auto pListViewCell::setForegroundColor(Color color) -> void { auto pListViewCell::setForegroundColor(Color color) -> void {
} }
auto pListViewCell::setImage(const Image& image) -> void { auto pListViewCell::setIcon(const image& icon) -> void {
} }
auto pListViewCell::setText(const string& text) -> void { auto pListViewCell::setText(const string& text) -> void {

View File

@ -10,7 +10,7 @@ struct pListViewCell : pObject {
auto setCheckable(bool checkable) -> void; auto setCheckable(bool checkable) -> void;
auto setChecked(bool checked) -> void; auto setChecked(bool checked) -> void;
auto setForegroundColor(Color color) -> 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 setText(const string& text) -> void;
auto _grandparent() -> maybe<pListView&>; auto _grandparent() -> maybe<pListView&>;

View File

@ -42,7 +42,7 @@ auto pListViewColumn::setForegroundColor(Color color) -> void {
auto pListViewColumn::setHorizontalAlignment(double alignment) -> void { auto pListViewColumn::setHorizontalAlignment(double alignment) -> void {
} }
auto pListViewColumn::setImage(const Image& image) -> void { auto pListViewColumn::setIcon(const image& icon) -> void {
} }
auto pListViewColumn::setResizable(bool resizable) -> void { auto pListViewColumn::setResizable(bool resizable) -> void {

View File

@ -13,7 +13,7 @@ struct pListViewColumn : pObject {
auto setFont(const Font& font) -> void override; auto setFont(const Font& font) -> void override;
auto setForegroundColor(Color color) -> void; auto setForegroundColor(Color color) -> void;
auto setHorizontalAlignment(double) -> void; auto setHorizontalAlignment(double) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setResizable(bool resizable) -> void; auto setResizable(bool resizable) -> void;
auto setSortable(bool sortable) -> void; auto setSortable(bool sortable) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -177,8 +177,8 @@
frame.size.width -= frame.size.height + 2; frame.size.width -= frame.size.height + 2;
} }
if(listViewCell->state.image) { if(listViewCell->state.icon) {
NSImage* image = NSMakeImage(listViewCell->state.image, frame.size.height, frame.size.height); NSImage* image = NSMakeImage(listViewCell->state.icon, frame.size.height, frame.size.height);
[[NSGraphicsContext currentContext] saveGraphicsState]; [[NSGraphicsContext currentContext] saveGraphicsState];
NSRect targetRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height); NSRect targetRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
NSRect sourceRect = NSMakeRect(0, 0, [image size].width, [image size].height); NSRect sourceRect = NSMakeRect(0, 0, [image size].width, [image size].height);
@ -269,6 +269,7 @@ auto pListView::construct() -> void {
auto pListView::destruct() -> void { auto pListView::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
@ -361,8 +362,8 @@ auto pListView::_cellWidth(uint row, uint column) -> uint {
if(pListViewCell->state.checkable) { if(pListViewCell->state.checkable) {
width += 24; width += 24;
} }
if(auto& image = pListViewCell->state.image) { if(auto& icon = pListViewCell->state.icon) {
width += image.width() + 2; width += icon.width() + 2;
} }
if(auto& text = pListViewCell->state.text) { if(auto& text = pListViewCell->state.text) {
width += pFont::size(pListViewCell->font(true), text).width(); width += pFont::size(pListViewCell->font(true), text).width();
@ -376,8 +377,8 @@ auto pListView::_columnWidth(uint column) -> uint {
uint width = 8; uint width = 8;
if(auto& header = state().header) { if(auto& header = state().header) {
if(auto pListViewColumn = header->column(column)) { if(auto pListViewColumn = header->column(column)) {
if(auto& image = pListViewColumn->state.image) { if(auto& icon = pListViewColumn->state.icon) {
width += image.width() + 2; width += icon.width() + 2;
} }
if(auto& text = pListViewColumn->state.text) { if(auto& text = pListViewColumn->state.text) {
width += pFont::size(pListViewColumn->font(true), text).width(); width += pFont::size(pListViewColumn->font(true), text).width();

View File

@ -28,6 +28,7 @@ auto pProgressBar::construct() -> void {
auto pProgressBar::destruct() -> void { auto pProgressBar::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -31,7 +31,7 @@ auto pRadioButton::construct() -> void {
setBordered(state().bordered); setBordered(state().bordered);
if(state().checked) setChecked(); if(state().checked) setChecked();
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
} }
@ -39,6 +39,7 @@ auto pRadioButton::construct() -> void {
auto pRadioButton::destruct() -> void { auto pRadioButton::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
@ -47,16 +48,16 @@ auto pRadioButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + 20, size.height() + 4}; return {size.width() + (state().text ? 20 : 8), size.height() + 8};
} }
auto pRadioButton::setBordered(bool bordered) -> void { auto pRadioButton::setBordered(bool bordered) -> void {
@ -89,14 +90,9 @@ auto pRadioButton::setGeometry(Geometry geometry) -> void {
auto pRadioButton::setGroup(sGroup group) -> void { auto pRadioButton::setGroup(sGroup group) -> void {
} }
auto pRadioButton::setImage(const Image& image) -> void { auto pRadioButton::setIcon(const image& icon) -> void {
@autoreleasepool { @autoreleasepool {
if(!image) { [cocoaView setImage:NSMakeImage(icon)];
[cocoaView setImage:nil];
return;
}
[cocoaView setImage:NSMakeImage(image)];
} }
} }

View File

@ -18,7 +18,7 @@ struct pRadioButton : pWidget {
auto setChecked() -> void; auto setChecked() -> void;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setGroup(sGroup group) -> void; auto setGroup(sGroup group) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -34,6 +34,7 @@ auto pRadioLabel::construct() -> void {
auto pRadioLabel::destruct() -> void { auto pRadioLabel::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -17,7 +17,7 @@ auto pTabFrameItem::remove(sLayout layout) -> void {
auto pTabFrameItem::setClosable(bool closable) -> void { auto pTabFrameItem::setClosable(bool closable) -> void {
} }
auto pTabFrameItem::setImage(const Image& image) -> void { auto pTabFrameItem::setIcon(const image& icon) -> void {
} }
auto pTabFrameItem::setMovable(bool movable) -> void { auto pTabFrameItem::setMovable(bool movable) -> void {

View File

@ -8,7 +8,7 @@ struct pTabFrameItem : pObject {
auto append(sLayout layout) -> void; auto append(sLayout layout) -> void;
auto remove(sLayout layout) -> void; auto remove(sLayout layout) -> void;
auto setClosable(bool closable) -> void; auto setClosable(bool closable) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setMovable(bool movable) -> void; auto setMovable(bool movable) -> void;
auto setSelected() -> void; auto setSelected() -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -33,7 +33,7 @@
int selection = [cocoaTabFrame indexOfTabViewItem:self]; int selection = [cocoaTabFrame indexOfTabViewItem:self];
if(selection >= 0) { if(selection >= 0) {
if(auto item = tabFrame->item(selection)) { if(auto item = tabFrame->item(selection)) {
if(item->state.image) { if(item->state.icon) {
uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height(); uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height();
sizeOfLabel.width += iconSize + 2; sizeOfLabel.width += iconSize + 2;
} }
@ -46,9 +46,9 @@
int selection = [cocoaTabFrame indexOfTabViewItem:self]; int selection = [cocoaTabFrame indexOfTabViewItem:self];
if(selection >= 0) { if(selection >= 0) {
if(auto item = tabFrame->item(selection)) { if(auto item = tabFrame->item(selection)) {
if(item->state.image) { if(item->state.icon) {
uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height(); uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height();
NSImage* image = NSMakeImage(item->state.image); NSImage* image = NSMakeImage(item->state.icon);
[[NSGraphicsContext currentContext] saveGraphicsState]; [[NSGraphicsContext currentContext] saveGraphicsState];
NSRect targetRect = NSMakeRect(tabRect.origin.x, tabRect.origin.y + 2, iconSize, iconSize); NSRect targetRect = NSMakeRect(tabRect.origin.x, tabRect.origin.y + 2, iconSize, iconSize);
@ -78,6 +78,7 @@ auto pTabFrame::construct() -> void {
auto pTabFrame::destruct() -> void { auto pTabFrame::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -59,6 +59,7 @@ auto pTextEdit::construct() -> void {
auto pTextEdit::destruct() -> void { auto pTextEdit::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -66,6 +66,7 @@ auto pVerticalScrollBar::construct() -> void {
auto pVerticalScrollBar::destruct() -> void { auto pVerticalScrollBar::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -34,6 +34,7 @@ auto pVerticalSlider::construct() -> void {
auto pVerticalSlider::destruct() -> void { auto pVerticalSlider::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -48,6 +48,7 @@ auto pViewport::construct() -> void {
auto pViewport::destruct() -> void { auto pViewport::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }

View File

@ -21,18 +21,11 @@ auto pWidget::construct() -> void {
auto pWidget::destruct() -> void { auto pWidget::destruct() -> void {
@autoreleasepool { @autoreleasepool {
[cocoaView removeFromSuperview];
[cocoaView release]; [cocoaView release];
} }
} }
/*
bool pWidget::enabled() {
@autoreleasepool {
return [cocoaView respondsToSelector:@selector(enabled)] && [cocoaView enabled];
}
}
*/
auto pWidget::focused() const -> bool { auto pWidget::focused() const -> bool {
@autoreleasepool { @autoreleasepool {
return cocoaView == [[cocoaView window] firstResponder]; return cocoaView == [[cocoaView window] firstResponder];
@ -80,6 +73,14 @@ auto pWidget::setVisible(bool visible) -> void {
} }
} }
/*
bool pWidget::enabled() {
@autoreleasepool {
return [cocoaView respondsToSelector:@selector(enabled)] && [cocoaView enabled];
}
}
*/
} }
#endif #endif

View File

@ -337,8 +337,10 @@ auto pWindow::sizeEvent() -> void {
auto pWindow::statusBarHeight() -> uint { auto pWindow::statusBarHeight() -> uint {
if(auto& statusBar = state().statusBar) { if(auto& statusBar = state().statusBar) {
if(statusBar->visible()) {
return pFont::size(statusBar->font(true), " ").height() + 6; return pFont::size(statusBar->font(true), " ").height() + 6;
} }
}
return 0; return 0;
} }

View File

@ -17,7 +17,6 @@
#define Hiro_Size #define Hiro_Size
#define Hiro_Geometry #define Hiro_Geometry
#define Hiro_Font #define Hiro_Font
#define Hiro_Image
#define Hiro_Application #define Hiro_Application
#define Hiro_Desktop #define Hiro_Desktop

View File

@ -10,8 +10,8 @@ auto mMenuItem::doActivate() const -> void {
if(state.onActivate) return state.onActivate(); if(state.onActivate) return state.onActivate();
} }
auto mMenuItem::image() const -> Image { auto mMenuItem::icon() const -> image {
return state.image; return state.icon;
} }
auto mMenuItem::onActivate(const function<void ()>& callback) -> type& { auto mMenuItem::onActivate(const function<void ()>& callback) -> type& {
@ -19,9 +19,9 @@ auto mMenuItem::onActivate(const function<void ()>& callback) -> type& {
return *this; return *this;
} }
auto mMenuItem::setImage(const Image& image) -> type& { auto mMenuItem::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -33,8 +33,8 @@ auto mMenu::append(sAction action) -> type& {
return *this; return *this;
} }
auto mMenu::image() const -> Image { auto mMenu::icon() const -> image {
return state.image; return state.icon;
} }
auto mMenu::remove(sAction action) -> type& { auto mMenu::remove(sAction action) -> type& {
@ -52,9 +52,9 @@ auto mMenu::reset() -> type& {
return *this; return *this;
} }
auto mMenu::setImage(const Image& image) -> type& { auto mMenu::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -39,7 +39,6 @@ namespace hiro {
#include "size.cpp" #include "size.cpp"
#include "geometry.cpp" #include "geometry.cpp"
#include "font.cpp" #include "font.cpp"
#include "image.cpp"
#include "application.cpp" #include "application.cpp"
#include "desktop.cpp" #include "desktop.cpp"

View File

@ -14,6 +14,7 @@
#include <nall/vector.hpp> #include <nall/vector.hpp>
using nall::function; using nall::function;
using nall::image;
using nall::lstring; using nall::lstring;
using nall::maybe; using nall::maybe;
using nall::nothing; using nall::nothing;
@ -327,36 +328,6 @@ struct Font {
}; };
#endif #endif
#if defined(Hiro_Image)
struct Image {
using type = Image;
Image();
Image(const Image& source);
Image(const string& source);
Image(const vector<uint8_t>& source);
Image(const uint32_t* data, Size size);
~Image();
explicit operator bool() const;
auto operator=(const Image& source) -> type&;
auto data() const -> uint32_t*;
auto height() const -> signed;
auto reset() -> type&;
auto setImage(const uint32_t* data, Size size) -> type&;
auto setSize(Size size = {}) -> type&;
auto size() const -> Size;
auto width() const -> signed;
//private:
struct State {
uint32_t* data = nullptr;
Size size;
} state;
};
#endif
#if defined(Hiro_Hotkey) #if defined(Hiro_Hotkey)
struct Hotkey { struct Hotkey {
using type = Hotkey; using type = Hotkey;
@ -837,10 +808,10 @@ struct mMenu : mAction {
auto actionCount() const -> unsigned; auto actionCount() const -> unsigned;
auto actions() const -> vector<Action>; auto actions() const -> vector<Action>;
auto append(sAction action) -> type&; auto append(sAction action) -> type&;
auto image() const -> Image; auto icon() const -> image;
auto remove(sAction action) -> type&; auto remove(sAction action) -> type&;
auto reset() -> type&; auto reset() -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override; auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
@ -848,7 +819,7 @@ struct mMenu : mAction {
//private: //private:
struct State { struct State {
vector<sAction> actions; vector<sAction> actions;
Image image; image icon;
string text; string text;
} state; } state;
@ -871,15 +842,15 @@ struct mMenuItem : mAction {
Declare(MenuItem) Declare(MenuItem)
auto doActivate() const -> void; auto doActivate() const -> void;
auto image() const -> Image; auto icon() const -> image;
auto onActivate(const function<void ()>& callback = {}) -> type&; auto onActivate(const function<void ()>& callback = {}) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
//private: //private:
struct State { struct State {
Image image; image icon;
function<void ()> onActivate; function<void ()> onActivate;
string text; string text;
} state; } state;
@ -987,11 +958,11 @@ struct mButton : mWidget {
auto bordered() const -> bool; auto bordered() const -> bool;
auto doActivate() const -> void; auto doActivate() const -> void;
auto image() const -> Image; auto icon() const -> image;
auto onActivate(const function<void ()>& callback = {}) -> type&; auto onActivate(const function<void ()>& callback = {}) -> type&;
auto orientation() const -> Orientation; auto orientation() const -> Orientation;
auto setBordered(bool bordered = true) -> type&; auto setBordered(bool bordered = true) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&; auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
@ -999,7 +970,7 @@ struct mButton : mWidget {
//private: //private:
struct State { struct State {
bool bordered = true; bool bordered = true;
Image image; image icon;
function<void ()> onActivate; function<void ()> onActivate;
Orientation orientation = Orientation::Horizontal; Orientation orientation = Orientation::Horizontal;
string text; string text;
@ -1020,7 +991,7 @@ struct mCanvas : mWidget {
auto doMousePress(Mouse::Button button) const -> void; auto doMousePress(Mouse::Button button) const -> void;
auto doMouseRelease(Mouse::Button button) const -> void; auto doMouseRelease(Mouse::Button button) const -> void;
auto gradient() const -> Gradient; auto gradient() const -> Gradient;
auto image() const -> Image; auto icon() const -> image;
auto onDrop(const function<void (lstring)>& callback = {}) -> type&; auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
auto onMouseLeave(const function<void ()>& callback = {}) -> type&; auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
auto onMouseMove(const function<void (Position)>& callback = {}) -> type&; auto onMouseMove(const function<void (Position)>& callback = {}) -> type&;
@ -1029,7 +1000,7 @@ struct mCanvas : mWidget {
auto setColor(Color color = {}) -> type&; auto setColor(Color color = {}) -> type&;
auto setDroppable(bool droppable = true) -> type&; auto setDroppable(bool droppable = true) -> type&;
auto setGradient(Gradient gradient = {}) -> type&; auto setGradient(Gradient gradient = {}) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setSize(Size size = {}) -> type&; auto setSize(Size size = {}) -> type&;
auto size() const -> Size; auto size() const -> Size;
auto update() -> type&; auto update() -> type&;
@ -1039,7 +1010,7 @@ struct mCanvas : mWidget {
Color color; Color color;
bool droppable = false; bool droppable = false;
Gradient gradient; Gradient gradient;
Image image; image icon;
function<void (lstring)> onDrop; function<void (lstring)> onDrop;
function<void ()> onMouseLeave; function<void ()> onMouseLeave;
function<void (Position)> onMouseMove; function<void (Position)> onMouseMove;
@ -1056,12 +1027,12 @@ struct mCheckButton : mWidget {
auto bordered() const -> bool; auto bordered() const -> bool;
auto checked() const -> bool; auto checked() const -> bool;
auto doToggle() const -> void; auto doToggle() const -> void;
auto image() const -> Image; auto icon() const -> image;
auto onToggle(const function<void ()>& callback = {}) -> type&; auto onToggle(const function<void ()>& callback = {}) -> type&;
auto orientation() const -> Orientation; auto orientation() const -> Orientation;
auto setBordered(bool bordered = true) -> type&; auto setBordered(bool bordered = true) -> type&;
auto setChecked(bool checked = true) -> type&; auto setChecked(bool checked = true) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&; auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
@ -1070,7 +1041,7 @@ struct mCheckButton : mWidget {
struct State { struct State {
bool bordered = true; bool bordered = true;
bool checked = false; bool checked = false;
Image image; image icon;
function<void ()> onToggle; function<void ()> onToggle;
Orientation orientation = Orientation::Horizontal; Orientation orientation = Orientation::Horizontal;
string text; string text;
@ -1128,17 +1099,17 @@ struct mComboButton : mWidget {
struct mComboButtonItem : mObject { struct mComboButtonItem : mObject {
Declare(ComboButtonItem) Declare(ComboButtonItem)
auto image() const -> Image; auto icon() const -> image;
auto remove() -> type& override; auto remove() -> type& override;
auto selected() const -> bool; auto selected() const -> bool;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setSelected() -> type&; auto setSelected() -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
//private: //private:
struct State { struct State {
Image image; image icon;
bool selected = false; bool selected = false;
string text; string text;
} state; } state;
@ -1322,17 +1293,17 @@ struct mIconView : mWidget {
struct mIconViewItem : mObject { struct mIconViewItem : mObject {
Declare(IconViewItem) Declare(IconViewItem)
auto image() const -> Image; auto icon() const -> image;
auto remove() -> type& override; auto remove() -> type& override;
auto selected() const -> bool; auto selected() const -> bool;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setSelected(bool selected = true) -> type&; auto setSelected(bool selected = true) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
//private: //private:
struct State { struct State {
Image image; image icon;
bool selected = false; bool selected = false;
string text; string text;
} state; } state;
@ -1478,7 +1449,7 @@ struct mListViewColumn : mObject {
auto expandable() const -> bool; auto expandable() const -> bool;
auto foregroundColor() const -> Color; auto foregroundColor() const -> Color;
auto horizontalAlignment() const -> double; auto horizontalAlignment() const -> double;
auto image() const -> Image; auto icon() const -> image;
auto remove() -> type& override; auto remove() -> type& override;
auto resizable() const -> bool; auto resizable() const -> bool;
auto setActive() -> type&; auto setActive() -> type&;
@ -1488,7 +1459,7 @@ struct mListViewColumn : mObject {
auto setExpandable(bool expandable = true) -> type&; auto setExpandable(bool expandable = true) -> type&;
auto setForegroundColor(Color color = {}) -> type&; auto setForegroundColor(Color color = {}) -> type&;
auto setHorizontalAlignment(double alignment = 0.0) -> type&; auto setHorizontalAlignment(double alignment = 0.0) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setResizable(bool resizable = true) -> type&; auto setResizable(bool resizable = true) -> type&;
auto setSortable(bool sortable = true) -> type&; auto setSortable(bool sortable = true) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
@ -1508,7 +1479,7 @@ struct mListViewColumn : mObject {
bool expandable = false; bool expandable = false;
Color foregroundColor; Color foregroundColor;
double horizontalAlignment = 0.0; double horizontalAlignment = 0.0;
Image image; image icon;
bool resizable = true; bool resizable = true;
bool sortable = false; bool sortable = false;
string text; string text;
@ -1561,13 +1532,13 @@ struct mListViewCell : mObject {
auto checked() const -> bool; auto checked() const -> bool;
auto font(bool recursive = false) const -> Font; auto font(bool recursive = false) const -> Font;
auto foregroundColor(bool recursive = false) const -> Color; auto foregroundColor(bool recursive = false) const -> Color;
auto image() const -> Image; auto icon() const -> image;
auto setAlignment(Alignment alignment = {}) -> type&; auto setAlignment(Alignment alignment = {}) -> type&;
auto setBackgroundColor(Color color = {}) -> type&; auto setBackgroundColor(Color color = {}) -> type&;
auto setCheckable(bool checkable = true) -> type&; auto setCheckable(bool checkable = true) -> type&;
auto setChecked(bool checked = true) -> type&; auto setChecked(bool checked = true) -> type&;
auto setForegroundColor(Color color = {}) -> type&; auto setForegroundColor(Color color = {}) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
@ -1578,7 +1549,7 @@ struct mListViewCell : mObject {
bool checkable = false; bool checkable = false;
bool checked = false; bool checked = false;
Color foregroundColor; Color foregroundColor;
Image image; image icon;
string text; string text;
} state; } state;
}; };
@ -1606,13 +1577,13 @@ struct mRadioButton : mWidget {
auto checked() const -> bool; auto checked() const -> bool;
auto doActivate() const -> void; auto doActivate() const -> void;
auto group() const -> Group override; auto group() const -> Group override;
auto image() const -> Image; auto icon() const -> image;
auto onActivate(const function<void ()>& callback = {}) -> type&; auto onActivate(const function<void ()>& callback = {}) -> type&;
auto orientation() const -> Orientation; auto orientation() const -> Orientation;
auto setBordered(bool bordered = true) -> type&; auto setBordered(bool bordered = true) -> type&;
auto setChecked() -> type&; auto setChecked() -> type&;
auto setGroup(sGroup group = {}) -> type& override; auto setGroup(sGroup group = {}) -> type& override;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&; auto setOrientation(Orientation orientation = Orientation::Horizontal) -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
auto text() const -> string; auto text() const -> string;
@ -1622,7 +1593,7 @@ struct mRadioButton : mWidget {
bool bordered = true; bool bordered = true;
bool checked = false; bool checked = false;
sGroup group; sGroup group;
Image image; image icon;
function<void ()> onActivate; function<void ()> onActivate;
Orientation orientation = Orientation::Horizontal; Orientation orientation = Orientation::Horizontal;
string text; string text;
@ -1718,7 +1689,7 @@ struct mTabFrameItem : mObject {
auto append(sLayout layout) -> type&; auto append(sLayout layout) -> type&;
auto closable() const -> bool; auto closable() const -> bool;
auto image() const -> Image; auto icon() const -> image;
auto layout() const -> Layout; auto layout() const -> Layout;
auto movable() const -> bool; auto movable() const -> bool;
auto remove() -> type& override; auto remove() -> type& override;
@ -1726,7 +1697,7 @@ struct mTabFrameItem : mObject {
auto reset() -> type&; auto reset() -> type&;
auto selected() const -> bool; auto selected() const -> bool;
auto setClosable(bool closable = true) -> type&; auto setClosable(bool closable = true) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setMovable(bool movable = true) -> type&; auto setMovable(bool movable = true) -> type&;
auto setParent(mObject* object = nullptr, signed offset = -1) -> type& override; auto setParent(mObject* object = nullptr, signed offset = -1) -> type& override;
auto setSelected() -> type&; auto setSelected() -> type&;
@ -1736,7 +1707,7 @@ struct mTabFrameItem : mObject {
//private: //private:
struct State { struct State {
bool closable = false; bool closable = false;
Image image; image icon;
sLayout layout; sLayout layout;
bool movable = false; bool movable = false;
bool selected = false; bool selected = false;
@ -1833,7 +1804,7 @@ struct mTreeViewItem : mObject {
auto checkable() const -> bool; auto checkable() const -> bool;
auto checked() const -> bool; auto checked() const -> bool;
auto foregroundColor(bool recursive = false) const -> Color; auto foregroundColor(bool recursive = false) const -> Color;
auto image() const -> Image; auto icon() const -> image;
auto item(const string& path) const -> TreeViewItem; auto item(const string& path) const -> TreeViewItem;
auto itemCount() const -> unsigned; auto itemCount() const -> unsigned;
auto items() const -> vector<TreeViewItem>; auto items() const -> vector<TreeViewItem>;
@ -1847,7 +1818,7 @@ struct mTreeViewItem : mObject {
auto setExpanded(bool expanded = true) -> type&; auto setExpanded(bool expanded = true) -> type&;
auto setFocused() -> type& override; auto setFocused() -> type& override;
auto setForegroundColor(Color color = {}) -> type&; auto setForegroundColor(Color color = {}) -> type&;
auto setImage(const Image& image = {}) -> type&; auto setIcon(const image& icon = {}) -> type&;
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type&; auto setParent(mObject* parent = nullptr, signed offset = -1) -> type&;
auto setSelected() -> type&; auto setSelected() -> type&;
auto setText(const string& text = "") -> type&; auto setText(const string& text = "") -> type&;
@ -1859,7 +1830,7 @@ struct mTreeViewItem : mObject {
bool checkable = false; bool checkable = false;
bool checked = false; bool checked = false;
Color foregroundColor; Color foregroundColor;
Image image; image icon;
vector<sTreeViewItem> items; vector<sTreeViewItem> items;
string text; string text;
} state; } state;

View File

@ -1,83 +0,0 @@
#if defined(Hiro_Image)
Image::Image() {
}
Image::Image(const Image& source) {
operator=(source);
}
Image::Image(const string& source) {
nall::image image{source};
image.transform();
setImage((const uint32_t*)image.data(), Size{(signed)image.width(), (signed)image.height()});
}
Image::Image(const vector<uint8_t>& source) {
nall::image image{source};
image.transform();
setImage((const uint32_t*)image.data(), Size{(signed)image.width(), (signed)image.height()});
}
Image::Image(const uint32_t* data, Size size) {
setImage(data, size);
}
Image::~Image() {
reset();
}
Image::operator bool() const {
return state.data;
}
auto Image::operator=(const Image& source) -> type& {
reset();
if(state.size = source.state.size) {
state.data = new uint32_t[state.size.width() * state.size.height()];
memory::copy(state.data, source.state.data, state.size.width() * state.size.height() * sizeof(uint32_t));
}
return *this;
}
auto Image::data() const -> uint32_t* {
return state.data;
}
auto Image::height() const -> signed {
return state.size.height();
}
auto Image::reset() -> type& {
if(state.data) delete[] state.data;
state.data = nullptr;
state.size = {};
return *this;
}
auto Image::setImage(const uint32_t* data, Size size) -> type& {
reset();
if(data && size) {
state.size = size;
state.data = new uint32_t[size.width() * size.height()];
memory::copy(state.data, data, size.width() * size.height() * sizeof(uint32_t));
}
return *this;
}
auto Image::setSize(Size size) -> type& {
state.size = size;
if(state.data) delete[] state.data;
if(state.size) state.data = new uint32_t[size.width() * size.height()];
return *this;
}
auto Image::size() const -> Size {
return state.size;
}
auto Image::width() const -> signed {
return state.size.width();
}
#endif

View File

@ -128,10 +128,10 @@ struct Menu : sMenu {
auto actionCount() const { return self().actionCount(); } auto actionCount() const { return self().actionCount(); }
auto actions() const { return self().actions(); } auto actions() const { return self().actions(); }
auto append(sAction action) { return self().append(action), *this; } auto append(sAction action) { return self().append(action), *this; }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto remove(sAction action) { return self().remove(action), *this; } auto remove(sAction action) { return self().remove(action), *this; }
auto reset() { return self().reset(), *this; } auto reset() { return self().reset(), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
}; };
@ -150,9 +150,9 @@ struct MenuItem : sMenuItem {
using internalType = mMenuItem; using internalType = mMenuItem;
auto doActivate() const { return self().doActivate(); } auto doActivate() const { return self().doActivate(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; } auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
}; };
@ -215,11 +215,11 @@ struct Button : sButton {
auto bordered() const { return self().bordered(); } auto bordered() const { return self().bordered(); }
auto doActivate() const { return self().doActivate(); } auto doActivate() const { return self().doActivate(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; } auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
auto orientation() const { return self().orientation(); } auto orientation() const { return self().orientation(); }
auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; } auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; } auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
@ -240,7 +240,7 @@ struct Canvas : sCanvas {
auto doMousePress(Mouse::Button button) const { return self().doMousePress(button); } auto doMousePress(Mouse::Button button) const { return self().doMousePress(button); }
auto doMouseRelease(Mouse::Button button) const { return self().doMouseRelease(button); } auto doMouseRelease(Mouse::Button button) const { return self().doMouseRelease(button); }
auto gradient() const { return self().gradient(); } auto gradient() const { return self().gradient(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto onDrop(const function<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; } auto onDrop(const function<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; }
auto onMouseLeave(const function<void ()>& callback = {}) { return self().onMouseLeave(callback), *this; } auto onMouseLeave(const function<void ()>& callback = {}) { return self().onMouseLeave(callback), *this; }
auto onMouseMove(const function<void (Position)>& callback = {}) { return self().onMouseMove(callback), *this; } auto onMouseMove(const function<void (Position)>& callback = {}) { return self().onMouseMove(callback), *this; }
@ -249,7 +249,7 @@ struct Canvas : sCanvas {
auto setColor(Color color) { return self().setColor(color), *this; } auto setColor(Color color) { return self().setColor(color), *this; }
auto setDroppable(bool droppable = true) { return self().setDroppable(droppable), *this; } auto setDroppable(bool droppable = true) { return self().setDroppable(droppable), *this; }
auto setGradient(Gradient gradient = {}) { return self().setGradient(gradient), *this; } auto setGradient(Gradient gradient = {}) { return self().setGradient(gradient), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setSize(Size size = {}) { return self().setSize(size), *this; } auto setSize(Size size = {}) { return self().setSize(size), *this; }
auto update() { return self().update(), *this; } auto update() { return self().update(), *this; }
}; };
@ -263,12 +263,12 @@ struct CheckButton : sCheckButton {
auto bordered() const { return self().bordered(); } auto bordered() const { return self().bordered(); }
auto checked() const { return self().checked(); } auto checked() const { return self().checked(); }
auto doToggle() const { return self().doToggle(); } auto doToggle() const { return self().doToggle(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto onToggle(const function<void ()>& callback = {}) { return self().onToggle(callback), *this; } auto onToggle(const function<void ()>& callback = {}) { return self().onToggle(callback), *this; }
auto orientation() const { return self().orientation(); } auto orientation() const { return self().orientation(); }
auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; } auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; }
auto setChecked(bool checked = true) { return self().setChecked(checked), *this; } auto setChecked(bool checked = true) { return self().setChecked(checked), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; } auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
@ -294,9 +294,9 @@ struct ComboButtonItem : sComboButtonItem {
DeclareSharedObject(ComboButtonItem) DeclareSharedObject(ComboButtonItem)
using internalType = mComboButtonItem; using internalType = mComboButtonItem;
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto selected() const { return self().selected(); } auto selected() const { return self().selected(); }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setSelected() { return self().setSelected(), *this; } auto setSelected() { return self().setSelected(), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
@ -411,9 +411,9 @@ struct IconViewItem : sIconViewItem {
DeclareSharedObject(IconViewItem) DeclareSharedObject(IconViewItem)
using internalType = mIconViewItem; using internalType = mIconViewItem;
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto selected() const { return self().selected(); } auto selected() const { return self().selected(); }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setSelected(bool selected = true) { return self().setSelected(selected), *this; } auto setSelected(bool selected = true) { return self().setSelected(selected), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
@ -497,7 +497,7 @@ struct ListViewColumn : sListViewColumn {
auto expandable() const { return self().expandable(); } auto expandable() const { return self().expandable(); }
auto foregroundColor() const { return self().foregroundColor(); } auto foregroundColor() const { return self().foregroundColor(); }
auto horizontalAlignment() const { return self().horizontalAlignment(); } auto horizontalAlignment() const { return self().horizontalAlignment(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto resizable() const { return self().resizable(); } auto resizable() const { return self().resizable(); }
auto setActive() { return self().setActive(), *this; } auto setActive() { return self().setActive(), *this; }
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; } auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
@ -505,7 +505,7 @@ struct ListViewColumn : sListViewColumn {
auto setEditable(bool editable = true) { return self().setEditable(editable), *this; } auto setEditable(bool editable = true) { return self().setEditable(editable), *this; }
auto setExpandable(bool expandable = true) { return self().setExpandable(expandable), *this; } auto setExpandable(bool expandable = true) { return self().setExpandable(expandable), *this; }
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; } auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setResizable(bool resizable = true) { return self().setResizable(resizable), *this; } auto setResizable(bool resizable = true) { return self().setResizable(resizable), *this; }
auto setSortable(bool sortable = true) { return self().setSortable(sortable), *this; } auto setSortable(bool sortable = true) { return self().setSortable(sortable), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
@ -540,13 +540,13 @@ struct ListViewCell : sListViewCell {
auto checkable() const { return self().checkable(); } auto checkable() const { return self().checkable(); }
auto checked() const { return self().checked(); } auto checked() const { return self().checked(); }
auto foregroundColor() const { return self().foregroundColor(); } auto foregroundColor() const { return self().foregroundColor(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; } auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; } auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
auto setCheckable(bool checkable = true) const { return self().setCheckable(checkable), *this; } auto setCheckable(bool checkable = true) const { return self().setCheckable(checkable), *this; }
auto setChecked(bool checked = true) const { return self().setChecked(checked), *this; } auto setChecked(bool checked = true) const { return self().setChecked(checked), *this; }
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; } auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
}; };
@ -634,12 +634,12 @@ struct RadioButton : sRadioButton {
auto checked() const { return self().checked(); } auto checked() const { return self().checked(); }
auto doActivate() const { return self().doActivate(); } auto doActivate() const { return self().doActivate(); }
auto group() const { return self().group(); } auto group() const { return self().group(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; } auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
auto orientation() const { return self().orientation(); } auto orientation() const { return self().orientation(); }
auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; } auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; }
auto setChecked() { return self().setChecked(), *this; } auto setChecked() { return self().setChecked(), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; } auto setOrientation(Orientation orientation = Orientation::Horizontal) { return self().setOrientation(orientation), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }
@ -684,14 +684,14 @@ struct TabFrameItem : sTabFrameItem {
auto append(sLayout layout) { return self().append(layout), *this; } auto append(sLayout layout) { return self().append(layout), *this; }
auto closable() const { return self().closable(); } auto closable() const { return self().closable(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto layout() const { return self().layout(); } auto layout() const { return self().layout(); }
auto movable() const { return self().movable(); } auto movable() const { return self().movable(); }
auto remove(sLayout layout) { return self().remove(layout), *this; } auto remove(sLayout layout) { return self().remove(layout), *this; }
auto reset() { return self().reset(), *this; } auto reset() { return self().reset(), *this; }
auto selected() const { return self().selected(); } auto selected() const { return self().selected(); }
auto setClosable(bool closable = true) { return self().setClosable(closable), *this; } auto setClosable(bool closable = true) { return self().setClosable(closable), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setMovable(bool movable = true) { return self().setMovable(movable), *this; } auto setMovable(bool movable = true) { return self().setMovable(movable), *this; }
auto setSelected() { return self().setSelected(), *this; } auto setSelected() { return self().setSelected(), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
@ -756,7 +756,7 @@ struct TreeViewItem : sTreeViewItem {
auto checkable() const { return self().checkable(); } auto checkable() const { return self().checkable(); }
auto checked() const { return self().checked(); } auto checked() const { return self().checked(); }
auto foregroundColor() const { return self().foregroundColor(); } auto foregroundColor() const { return self().foregroundColor(); }
auto image() const { return self().image(); } auto icon() const { return self().icon(); }
auto item(const string& path) const { return self().item(path); } auto item(const string& path) const { return self().item(path); }
auto itemCount() const { return self().itemCount(); } auto itemCount() const { return self().itemCount(); }
auto items() const { return self().items(); } auto items() const { return self().items(); }
@ -768,7 +768,7 @@ struct TreeViewItem : sTreeViewItem {
auto setChecked(bool checked = true) { return self().setChecked(checked), *this; } auto setChecked(bool checked = true) { return self().setChecked(checked), *this; }
auto setExpanded(bool expanded = true) { return self().setExpanded(expanded), *this; } auto setExpanded(bool expanded = true) { return self().setExpanded(expanded), *this; }
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; } auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
auto setImage(const Image& image = {}) { return self().setImage(image), *this; } auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
auto setSelected() { return self().setSelected(), *this; } auto setSelected() { return self().setSelected(), *this; }
auto setText(const string& text = "") { return self().setText(text), *this; } auto setText(const string& text = "") { return self().setText(text), *this; }
auto text() const { return self().text(); } auto text() const { return self().text(); }

View File

@ -14,8 +14,8 @@ auto mButton::doActivate() const -> void {
if(state.onActivate) return state.onActivate(); if(state.onActivate) return state.onActivate();
} }
auto mButton::image() const -> Image { auto mButton::icon() const -> image {
return state.image; return state.icon;
} }
auto mButton::onActivate(const function<void ()>& callback) -> type& { auto mButton::onActivate(const function<void ()>& callback) -> type& {
@ -33,9 +33,9 @@ auto mButton::setBordered(bool bordered) -> type& {
return *this; return *this;
} }
auto mButton::setImage(const Image& image) -> type& { auto mButton::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -10,8 +10,8 @@ auto mCanvas::color() const -> Color {
return state.color; return state.color;
} }
auto mCanvas::data() -> uint32_t* { auto mCanvas::data() -> uint32* {
return state.image.data(); return (uint32*)state.icon.data();
} }
auto mCanvas::droppable() const -> bool { auto mCanvas::droppable() const -> bool {
@ -42,8 +42,8 @@ auto mCanvas::gradient() const -> Gradient {
return state.gradient; return state.gradient;
} }
auto mCanvas::image() const -> Image { auto mCanvas::icon() const -> image {
return state.image; return state.icon;
} }
auto mCanvas::onDrop(const function<void (lstring)>& callback) -> type& { auto mCanvas::onDrop(const function<void (lstring)>& callback) -> type& {
@ -89,21 +89,20 @@ auto mCanvas::setGradient(Gradient gradient) -> type& {
return *this; return *this;
} }
auto mCanvas::setImage(const Image& image) -> type& { auto mCanvas::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }
auto mCanvas::setSize(Size size) -> type& { auto mCanvas::setSize(Size size) -> type& {
Image image; image icon;
image.setSize(size); icon.allocate(size.width(), size.height());
memory::fill(image.data(), size.width() * size.height() * sizeof(uint32_t), 0x00); return setIcon(icon);
return setImage(image);
} }
auto mCanvas::size() const -> Size { auto mCanvas::size() const -> Size {
return state.image.size(); return {(int)state.icon.width(), (int)state.icon.height()};
} }
auto mCanvas::update() -> type& { auto mCanvas::update() -> type& {

View File

@ -18,8 +18,8 @@ auto mCheckButton::doToggle() const -> void {
if(state.onToggle) return state.onToggle(); if(state.onToggle) return state.onToggle();
} }
auto mCheckButton::image() const -> Image { auto mCheckButton::icon() const -> image {
return state.image; return state.icon;
} }
auto mCheckButton::onToggle(const function<void ()>& callback) -> type& { auto mCheckButton::onToggle(const function<void ()>& callback) -> type& {
@ -43,9 +43,9 @@ auto mCheckButton::setChecked(bool checked) -> type& {
return *this; return *this;
} }
auto mCheckButton::setImage(const Image& image) -> type& { auto mCheckButton::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -6,8 +6,8 @@ auto mComboButtonItem::allocate() -> pObject* {
// //
auto mComboButtonItem::image() const -> Image { auto mComboButtonItem::icon() const -> image {
return state.image; return state.icon;
} }
auto mComboButtonItem::remove() -> type& { auto mComboButtonItem::remove() -> type& {
@ -19,9 +19,9 @@ auto mComboButtonItem::selected() const -> bool {
return state.selected; return state.selected;
} }
auto mComboButtonItem::setImage(const Image& image) -> type& { auto mComboButtonItem::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -6,8 +6,8 @@ auto mIconViewItem::allocate() -> pObject* {
// //
auto mIconViewItem::image() const -> Image { auto mIconViewItem::icon() const -> image {
return state.image; return state.icon;
} }
auto mIconViewItem::remove() -> type& { auto mIconViewItem::remove() -> type& {
@ -19,9 +19,9 @@ auto mIconViewItem::selected() const -> bool {
return state.selected; return state.selected;
} }
auto mIconViewItem::setImage(const Image& image) -> type& { auto mIconViewItem::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -94,8 +94,8 @@ auto mListViewCell::foregroundColor(bool recursive) const -> Color {
return state.foregroundColor; return state.foregroundColor;
} }
auto mListViewCell::image() const -> Image { auto mListViewCell::icon() const -> image {
return state.image; return state.icon;
} }
auto mListViewCell::setAlignment(Alignment alignment) -> type& { auto mListViewCell::setAlignment(Alignment alignment) -> type& {
@ -129,9 +129,9 @@ auto mListViewCell::setForegroundColor(Color color) -> type& {
return *this; return *this;
} }
auto mListViewCell::setImage(const Image& image) -> type& { auto mListViewCell::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -35,8 +35,8 @@ auto mListViewColumn::horizontalAlignment() const -> double {
return state.horizontalAlignment; return state.horizontalAlignment;
} }
auto mListViewColumn::image() const -> Image { auto mListViewColumn::icon() const -> image {
return state.image; return state.icon;
} }
auto mListViewColumn::remove() -> type& { auto mListViewColumn::remove() -> type& {
@ -91,9 +91,9 @@ auto mListViewColumn::setHorizontalAlignment(double alignment) -> type& {
return *this; return *this;
} }
auto mListViewColumn::setImage(const Image& image) -> type& { auto mListViewColumn::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -22,8 +22,8 @@ auto mRadioButton::group() const -> Group {
return state.group; return state.group;
} }
auto mRadioButton::image() const -> Image { auto mRadioButton::icon() const -> image {
return state.image; return state.icon;
} }
auto mRadioButton::onActivate(const function<void ()>& callback) -> type& { auto mRadioButton::onActivate(const function<void ()>& callback) -> type& {
@ -62,9 +62,9 @@ auto mRadioButton::setGroup(sGroup group) -> type& {
return *this; return *this;
} }
auto mRadioButton::setImage(const Image& image) -> type& { auto mRadioButton::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -23,8 +23,8 @@ auto mTabFrameItem::closable() const -> bool {
return state.closable; return state.closable;
} }
auto mTabFrameItem::image() const -> Image { auto mTabFrameItem::icon() const -> image {
return state.image; return state.icon;
} }
auto mTabFrameItem::layout() const -> Layout { auto mTabFrameItem::layout() const -> Layout {
@ -62,9 +62,9 @@ auto mTabFrameItem::setClosable(bool closable) -> type& {
return *this; return *this;
} }
auto mTabFrameItem::setImage(const Image& image) -> type& { auto mTabFrameItem::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -52,8 +52,8 @@ auto mTreeViewItem::foregroundColor(bool recursive) const -> Color {
return {}; return {};
} }
auto mTreeViewItem::image() const -> Image { auto mTreeViewItem::icon() const -> image {
return state.image; return state.icon;
} }
auto mTreeViewItem::item(const string& path) const -> TreeViewItem { auto mTreeViewItem::item(const string& path) const -> TreeViewItem {
@ -137,9 +137,9 @@ auto mTreeViewItem::setForegroundColor(Color color) -> type& {
return *this; return *this;
} }
auto mTreeViewItem::setImage(const Image& image) -> type& { auto mTreeViewItem::setIcon(const image& icon) -> type& {
state.image = image; state.icon = icon;
signal(setImage, image); signal(setIcon, icon);
return *this; return *this;
} }

View File

@ -118,9 +118,9 @@ auto BrowserDialogWindow::run() -> lstring {
layout.setMargin(5); layout.setMargin(5);
pathName.onActivate([&] { setPath(pathName.text()); }); pathName.onActivate([&] { setPath(pathName.text()); });
pathRefresh.setBordered(false).setImage(Icon::Action::Refresh).onActivate([&] { setPath(state.path); }); pathRefresh.setBordered(false).setIcon(Icon::Action::Refresh).onActivate([&] { setPath(state.path); });
pathHome.setBordered(false).setImage(Icon::Go::Home).onActivate([&] { setPath(userpath()); }); pathHome.setBordered(false).setIcon(Icon::Go::Home).onActivate([&] { setPath(userpath()); });
pathUp.setBordered(false).setImage(Icon::Go::Up).onActivate([&] { setPath(dirname(state.path)); }); pathUp.setBordered(false).setIcon(Icon::Go::Up).onActivate([&] { setPath(dirname(state.path)); });
view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); }); view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); });
filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); }); filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); });
for(auto& filter : state.filters) { for(auto& filter : state.filters) {
@ -175,7 +175,7 @@ auto BrowserDialogWindow::setPath(string path) -> void {
if(folderMode && isMatch(content)) continue; if(folderMode && isMatch(content)) continue;
view.append(ListViewItem() view.append(ListViewItem()
.append(ListViewCell().setText(content).setImage(Icon::Emblem::Folder)) .append(ListViewCell().setText(content).setIcon(Icon::Emblem::Folder))
); );
} }
@ -185,7 +185,7 @@ auto BrowserDialogWindow::setPath(string path) -> void {
if(!isMatch(content)) continue; if(!isMatch(content)) continue;
view.append(ListViewItem() view.append(ListViewItem()
.append(ListViewCell().setText(content).setImage(folderMode ? Icon::Action::Open : Icon::Emblem::File)) .append(ListViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
); );
} }

View File

@ -6,19 +6,19 @@ MessageDialog::MessageDialog(const string& text) {
auto MessageDialog::error(const lstring& buttons) -> string { auto MessageDialog::error(const lstring& buttons) -> string {
state.buttons = buttons; state.buttons = buttons;
state.image = Icon::Prompt::Error; state.icon = Icon::Prompt::Error;
return _run(); return _run();
} }
auto MessageDialog::information(const lstring& buttons) -> string { auto MessageDialog::information(const lstring& buttons) -> string {
state.buttons = buttons; state.buttons = buttons;
state.image = Icon::Prompt::Information; state.icon = Icon::Prompt::Information;
return _run(); return _run();
} }
auto MessageDialog::question(const lstring& buttons) -> string { auto MessageDialog::question(const lstring& buttons) -> string {
state.buttons = buttons; state.buttons = buttons;
state.image = Icon::Prompt::Question; state.icon = Icon::Prompt::Question;
return _run(); return _run();
} }
@ -39,7 +39,7 @@ auto MessageDialog::setTitle(const string& title) -> type& {
auto MessageDialog::warning(const lstring& buttons) -> string { auto MessageDialog::warning(const lstring& buttons) -> string {
state.buttons = buttons; state.buttons = buttons;
state.image = Icon::Prompt::Warning; state.icon = Icon::Prompt::Warning;
return _run(); return _run();
} }
@ -53,7 +53,7 @@ auto MessageDialog::_run() -> string {
Widget controlSpacer{&controlLayout, Size{~0, 0}}; Widget controlSpacer{&controlLayout, Size{~0, 0}};
layout.setMargin(5); layout.setMargin(5);
messageIcon.setImage(state.image); messageIcon.setIcon(state.icon);
messageText.setText(state.text); messageText.setText(state.text);
for(auto n : range(state.buttons)) { for(auto n : range(state.buttons)) {
Button button{&controlLayout, Size{80, 0}, 5}; Button button{&controlLayout, Size{80, 0}, 5};

View File

@ -15,7 +15,7 @@ struct MessageDialog {
private: private:
struct State { struct State {
lstring buttons; lstring buttons;
vector<uint8_t> image; vector<uint8> icon;
sWindow parent; sWindow parent;
string response; string response;
string text; string text;

View File

@ -9,7 +9,7 @@ static auto MenuItem_activate(GtkMenuItem*, pMenuItem* p) -> void {
auto pMenuItem::construct() -> void { auto pMenuItem::construct() -> void {
widget = gtk_image_menu_item_new_with_mnemonic(""); widget = gtk_image_menu_item_new_with_mnemonic("");
g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(MenuItem_activate), (gpointer)this); g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(MenuItem_activate), (gpointer)this);
setImage(state().image); setIcon(state().icon);
setText(state().text); setText(state().text);
} }
@ -17,9 +17,9 @@ auto pMenuItem::destruct() -> void {
if(widget) gtk_widget_destroy(widget), widget = nullptr; if(widget) gtk_widget_destroy(widget), widget = nullptr;
} }
auto pMenuItem::setImage(const Image& image) -> void { auto pMenuItem::setIcon(const image& icon) -> void {
if(image) { if(icon) {
GtkImage* gtkImage = CreateImage(image, true); GtkImage* gtkImage = CreateImage(icon, true);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
} else { } else {
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);

View File

@ -5,7 +5,7 @@ namespace hiro {
struct pMenuItem : pAction { struct pMenuItem : pAction {
Declare(MenuItem, Action) Declare(MenuItem, Action)
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;
}; };

View File

@ -6,7 +6,7 @@ auto pMenu::construct() -> void {
gtkMenu = gtk_menu_new(); gtkMenu = gtk_menu_new();
widget = gtk_image_menu_item_new_with_mnemonic(""); widget = gtk_image_menu_item_new_with_mnemonic("");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu);
setImage(state().image); setIcon(state().icon);
setText(state().text); setText(state().text);
for(auto& action : state().actions) append(*action); 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 { auto pMenu::setIcon(const image& icon) -> void {
if(image) { if(icon) {
GtkImage* gtkImage = CreateImage(image, true); GtkImage* gtkImage = CreateImage(icon, true);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
} else { } else {
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);

View File

@ -8,7 +8,7 @@ struct pMenu : pAction {
auto append(sAction action) -> void; auto append(sAction action) -> void;
auto remove(sAction action) -> void; auto remove(sAction action) -> void;
auto setFont(const Font& font) -> void override; 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; auto setText(const string& text) -> void;
GtkWidget* gtkMenu = nullptr; GtkWidget* gtkMenu = nullptr;

View File

@ -29,40 +29,11 @@ static auto CreatePixbuf(image icon, bool scale = false) -> GdkPixbuf* {
return pixbuf; return pixbuf;
} }
static auto CreatePixbuf(const Image& image, bool scale = false) -> GdkPixbuf* { static auto CreateImage(const image& icon, bool scale = false) -> GtkImage* {
if(!image.state.data) return nullptr; auto pixbuf = CreatePixbuf(icon, scale);
auto gtkIcon = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
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); g_object_unref(pixbuf);
pixbuf = scaled; return gtkIcon;
}
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);
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;
} }
static auto DropPaths(GtkSelectionData* data) -> lstring { static auto DropPaths(GtkSelectionData* data) -> lstring {

View File

@ -9,7 +9,7 @@ auto pButton::construct() -> void {
gtkButton = GTK_BUTTON(gtkWidget); gtkButton = GTK_BUTTON(gtkWidget);
setBordered(state().bordered); setBordered(state().bordered);
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
@ -26,13 +26,13 @@ auto pButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + (state().text ? 24 : 12), size.height() + 12}; 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); gtk_button_set_relief(gtkButton, bordered ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE);
} }
auto pButton::setImage(const Image& image) -> void { auto pButton::setIcon(const image& icon) -> void {
if(image) { if(icon) {
auto gtkImage = CreateImage(image); auto gtkImage = CreateImage(icon);
gtk_button_set_image(gtkButton, (GtkWidget*)gtkImage); gtk_button_set_image(gtkButton, (GtkWidget*)gtkImage);
} else { } else {
gtk_button_set_image(gtkButton, nullptr); gtk_button_set_image(gtkButton, nullptr);

View File

@ -7,7 +7,7 @@ struct pButton : pWidget {
auto minimumSize() const -> Size override; auto minimumSize() const -> Size override;
auto setBordered(bool bordered) -> void; auto setBordered(bool bordered) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -73,7 +73,7 @@ auto pCanvas::destruct() -> void {
} }
auto pCanvas::minimumSize() const -> Size { 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}; return {0, 0};
} }
@ -97,7 +97,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void {
update(); update();
} }
auto pCanvas::setImage(const Image& image) -> void { auto pCanvas::setIcon(const image& icon) -> void {
update(); update();
} }
@ -109,9 +109,9 @@ auto pCanvas::update() -> void {
auto pCanvas::_onExpose(GdkEventExpose* expose) -> void { auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
if(surface == nullptr) return; if(surface == nullptr) return;
signed sx = 0, sy = 0, dx = 0, dy = 0; int sx = 0, sy = 0, dx = 0, dy = 0;
signed width = surfaceWidth; int width = surfaceWidth;
signed height = surfaceHeight; int height = surfaceHeight;
auto geometry = pSizable::state().geometry; auto geometry = pSizable::state().geometry;
if(width <= geometry.width()) { if(width <= geometry.width()) {
@ -136,12 +136,12 @@ auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
} }
auto pCanvas::_rasterize() -> void { auto pCanvas::_rasterize() -> void {
signed width = 0; int width = 0;
signed height = 0; int height = 0;
if(auto& image = state().image) { if(auto& icon = state().icon) {
width = image.width(); width = icon.width();
height = image.height(); height = icon.height();
} else { } else {
width = pSizable::state().geometry.width(); width = pSizable::state().geometry.width();
height = pSizable::state().geometry.height(); 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); if(!surface) surface = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, width, height);
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface); auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
if(auto& image = state().image) { if(auto& icon = state().icon) {
memory::copy(buffer, state().image.data(), width * height * sizeof(uint32_t)); memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32));
} else if(auto& gradient = state().gradient) { } else if(auto& gradient = state().gradient) {
auto& colors = gradient.state.colors; auto& colors = gradient.state.colors;
nall::image fill; image fill;
fill.allocate(width, height); fill.allocate(width, height);
fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value()); fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value());
memory::copy(buffer, fill.data(), fill.size()); memory::copy(buffer, fill.data(), fill.size());
} else { } else {
uint32_t color = state().color.value(); uint32 color = state().color.value();
for(auto n : range(width * height)) buffer[n] = color; for(auto n : range(width * height)) buffer[n] = color;
} }
//ARGB -> ABGR conversion //ARGB -> ABGR conversion
for(auto n : range(width * height)) { for(auto n : range(width * height)) {
uint32_t color = *buffer; uint32 color = *buffer;
color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16); color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16);
*buffer++ = color; *buffer++ = color;
} }

View File

@ -10,7 +10,7 @@ struct pCanvas : pWidget {
auto setDroppable(bool droppable) -> void; auto setDroppable(bool droppable) -> void;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setGradient(Gradient gradient) -> void; auto setGradient(Gradient gradient) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto update() -> void; auto update() -> void;
auto _onExpose(GdkEventExpose* event) -> void; auto _onExpose(GdkEventExpose* event) -> void;
@ -19,8 +19,8 @@ struct pCanvas : pWidget {
auto _release() -> void; auto _release() -> void;
GdkPixbuf* surface = nullptr; GdkPixbuf* surface = nullptr;
unsigned surfaceWidth = 0; uint surfaceWidth = 0;
unsigned surfaceHeight = 0; uint surfaceHeight = 0;
}; };
} }

View File

@ -12,7 +12,7 @@ auto pCheckButton::construct() -> void {
setBordered(state().bordered); setBordered(state().bordered);
setChecked(state().checked); setChecked(state().checked);
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
@ -29,13 +29,13 @@ auto pCheckButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + 24, size.height() + 12}; return {size.width() + 24, size.height() + 12};
@ -51,9 +51,9 @@ auto pCheckButton::setChecked(bool checked) -> void {
unlock(); unlock();
} }
auto pCheckButton::setImage(const Image& image) -> void { auto pCheckButton::setIcon(const image& icon) -> void {
if(image) { if(icon) {
GtkImage* gtkImage = CreateImage(image); GtkImage* gtkImage = CreateImage(icon);
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage); gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
} else { } else {
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr); gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);

View File

@ -8,7 +8,7 @@ struct pCheckButton : pWidget {
auto minimumSize() const -> Size override; auto minimumSize() const -> Size override;
auto setBordered(bool bordered) -> void; auto setBordered(bool bordered) -> void;
auto setChecked(bool checked) -> void; auto setChecked(bool checked) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;
}; };

View File

@ -8,10 +8,10 @@ auto pComboButtonItem::construct() -> void {
auto pComboButtonItem::destruct() -> void { auto pComboButtonItem::destruct() -> void {
} }
auto pComboButtonItem::setImage(const Image& image) -> void { auto pComboButtonItem::setIcon(const image& icon) -> void {
if(auto parent = _parent()) { if(auto parent = _parent()) {
auto size = pFont::size(self().font(true), " ").height(); auto size = pFont::size(self().font(true), " ").height();
auto pixbuf = CreatePixbuf(image, true); auto pixbuf = CreatePixbuf(icon, true);
gtk_list_store_set(parent->gtkListStore, &gtkIter, 0, pixbuf, -1); gtk_list_store_set(parent->gtkListStore, &gtkIter, 0, pixbuf, -1);
} }
} }

View File

@ -5,7 +5,7 @@ namespace hiro {
struct pComboButtonItem : pObject { struct pComboButtonItem : pObject {
Declare(ComboButtonItem, Object) Declare(ComboButtonItem, Object)
auto setImage(const Image& icon) -> void; auto setIcon(const image& icon) -> void;
auto setSelected() -> void; auto setSelected() -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -32,7 +32,7 @@ auto pComboButton::append(sComboButtonItem item) -> void {
lock(); lock();
if(auto self = item->self()) { if(auto self = item->self()) {
gtk_list_store_append(gtkListStore, &self->gtkIter); gtk_list_store_append(gtkListStore, &self->gtkIter);
self->setImage(item->state.image); self->setIcon(item->state.icon);
if(item->state.selected) self->setSelected(); if(item->state.selected) self->setSelected();
self->setText(item->state.text); self->setText(item->state.text);
} }
@ -45,7 +45,7 @@ auto pComboButton::minimumSize() const -> Size {
signed maximumWidth = 0; signed maximumWidth = 0;
for(auto& item : state().items) { for(auto& item : state().items) {
maximumWidth = max(maximumWidth, 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() + pFont::size(font, item->state.text).width()
); );
} }

View File

@ -8,9 +8,9 @@ auto pIconViewItem::construct() -> void {
auto pIconViewItem::destruct() -> void { auto pIconViewItem::destruct() -> void {
} }
auto pIconViewItem::setImage(const Image& image) -> void { auto pIconViewItem::setIcon(const image& icon) -> void {
if(auto parent = _parent()) { if(auto parent = _parent()) {
parent->setItemImage(self().offset(), image); parent->setItemIcon(self().offset(), icon);
} }
} }

View File

@ -5,7 +5,7 @@ namespace hiro {
struct pIconViewItem : pObject { struct pIconViewItem : pObject {
Declare(IconViewItem, Object) Declare(IconViewItem, Object)
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setSelected(bool selected) -> void; auto setSelected(bool selected) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -65,7 +65,7 @@ auto pIconView::destruct() -> void {
auto pIconView::append(sIconViewItem item) -> void { auto pIconView::append(sIconViewItem item) -> void {
GtkTreeIter iter; GtkTreeIter iter;
gtk_list_store_append(store, &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); setItemSelected(item->offset(), item->state.selected);
setItemText(item->offset(), item->state.text); 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; if(position >= self().itemCount()) return;
GtkTreeIter iter; GtkTreeIter iter;
if(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, string{position})) { if(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, string{position})) {
if(image) { if(icon) {
GdkPixbuf* pixbuf = CreatePixbuf(image); GdkPixbuf* pixbuf = CreatePixbuf(icon);
gtk_list_store_set(store, &iter, 0, pixbuf, -1); gtk_list_store_set(store, &iter, 0, pixbuf, -1);
} else { } else {
gtk_list_store_set(store, &iter, 0, nullptr, -1); gtk_list_store_set(store, &iter, 0, nullptr, -1);

View File

@ -13,7 +13,7 @@ struct pIconView : pWidget {
auto setFlow(Orientation flow) -> void; auto setFlow(Orientation flow) -> void;
auto setForegroundColor(Color color) -> void; auto setForegroundColor(Color color) -> void;
auto setGeometry(Geometry geometry) -> 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(unsigned position, bool selected) -> void;
auto setItemSelected(const vector<signed>& selections) -> void; auto setItemSelected(const vector<signed>& selections) -> void;
auto setItemSelectedAll() -> void; auto setItemSelectedAll() -> void;

View File

@ -25,7 +25,7 @@ auto pListViewCell::setChecked(bool checked) -> void {
auto pListViewCell::setForegroundColor(Color color) -> void { auto pListViewCell::setForegroundColor(Color color) -> void {
} }
auto pListViewCell::setImage(const Image& image) -> void { auto pListViewCell::setIcon(const image& icon) -> void {
_setState(); _setState();
} }
@ -50,7 +50,7 @@ auto pListViewCell::_setState() -> void {
if(auto grandparent = _grandparent()) { if(auto grandparent = _grandparent()) {
grandparent->lock(); 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() + 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); gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 2, state().text.data(), -1);
grandparent->unlock(); grandparent->unlock();
} }

View File

@ -10,7 +10,7 @@ struct pListViewCell : pObject {
auto setCheckable(bool checkable) -> void; auto setCheckable(bool checkable) -> void;
auto setChecked(bool checked) -> void; auto setChecked(bool checked) -> void;
auto setForegroundColor(Color color) -> 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 setText(const string& text) -> void;
auto _grandparent() -> maybe<pListView&>; auto _grandparent() -> maybe<pListView&>;

View File

@ -81,9 +81,9 @@ auto pListViewColumn::setFont(const Font& font) -> void {
auto pListViewColumn::setForegroundColor(Color color) -> void { auto pListViewColumn::setForegroundColor(Color color) -> void {
} }
auto pListViewColumn::setImage(const Image& image) -> void { auto pListViewColumn::setIcon(const image& icon) -> void {
if(image) { if(icon) {
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(image)); gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
} else { } else {
gtk_image_clear(GTK_IMAGE(gtkHeaderIcon)); gtk_image_clear(GTK_IMAGE(gtkHeaderIcon));
} }

View File

@ -13,7 +13,7 @@ struct pListViewColumn : pObject {
auto setFont(const Font& font) -> void override; auto setFont(const Font& font) -> void override;
auto setForegroundColor(Color color) -> void; auto setForegroundColor(Color color) -> void;
auto setHorizontalAlignment(double) -> void {} auto setHorizontalAlignment(double) -> void {}
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setResizable(bool resizable) -> void; auto setResizable(bool resizable) -> void;
auto setSortable(bool sortable) -> void; auto setSortable(bool sortable) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -155,8 +155,8 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
if(cell->state.checkable) { if(cell->state.checkable) {
width += 24; width += 24;
} }
if(auto& image = cell->state.image) { if(auto& icon = cell->state.icon) {
width += image.width() + 2; width += icon.width() + 2;
} }
if(auto& text = cell->state.text) { if(auto& text = cell->state.text) {
width += pFont::size(cell->font(true), text).width(); width += pFont::size(cell->font(true), text).width();
@ -170,8 +170,8 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
unsigned width = 8; unsigned width = 8;
if(auto& header = state().header) { if(auto& header = state().header) {
if(auto column = header->column(_column)) { if(auto column = header->column(_column)) {
if(auto& image = column->state.image) { if(auto& icon = column->state.icon) {
width += image.width() + 2; width += icon.width() + 2;
} }
if(auto& text = column->state.text) { if(auto& text = column->state.text) {
width += pFont::size(column->font(true), text).width(); width += pFont::size(column->font(true), text).width();

View File

@ -13,7 +13,7 @@ auto pRadioButton::construct() -> void {
gtkWidget = gtk_toggle_button_new(); gtkWidget = gtk_toggle_button_new();
setBordered(state().bordered); setBordered(state().bordered);
setImage(state().image); setIcon(state().icon);
setOrientation(state().orientation); setOrientation(state().orientation);
setText(state().text); setText(state().text);
@ -30,13 +30,13 @@ auto pRadioButton::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text); Size size = pFont::size(self().font(true), state().text);
if(state().orientation == Orientation::Horizontal) { if(state().orientation == Orientation::Horizontal) {
size.setWidth(size.width() + state().image.width()); size.setWidth(size.width() + state().icon.width());
size.setHeight(max(size.height(), state().image.height())); size.setHeight(max(size.height(), state().icon.height()));
} }
if(state().orientation == Orientation::Vertical) { if(state().orientation == Orientation::Vertical) {
size.setWidth(max(size.width(), state().image.width())); size.setWidth(max(size.width(), state().icon.width()));
size.setHeight(size.height() + state().image.height()); size.setHeight(size.height() + state().icon.height());
} }
return {size.width() + 24, size.height() + 12}; return {size.width() + 24, size.height() + 12};
@ -76,9 +76,9 @@ auto pRadioButton::setGroup(sGroup group) -> void {
} }
} }
auto pRadioButton::setImage(const Image& image) -> void { auto pRadioButton::setIcon(const image& icon) -> void {
if(image) { if(icon) {
GtkImage* gtkImage = CreateImage(image); GtkImage* gtkImage = CreateImage(icon);
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage); gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
} else { } else {
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr); gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);

View File

@ -9,7 +9,7 @@ struct pRadioButton : pWidget {
auto setBordered(bool bordered) -> void; auto setBordered(bool bordered) -> void;
auto setChecked() -> void; auto setChecked() -> void;
auto setGroup(sGroup group) -> void; auto setGroup(sGroup group) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setOrientation(Orientation orientation) -> void; auto setOrientation(Orientation orientation) -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -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()) { if(auto parent = _parent()) {
parent->setItemImage(self().offset(), image); parent->setItemIcon(self().offset(), icon);
} }
} }

View File

@ -8,7 +8,7 @@ struct pTabFrameItem : pObject {
auto append(sLayout layout) -> void; auto append(sLayout layout) -> void;
auto remove(sLayout layout) -> void; auto remove(sLayout layout) -> void;
auto setClosable(bool closable) -> void; auto setClosable(bool closable) -> void;
auto setImage(const Image& image) -> void; auto setIcon(const image& icon) -> void;
auto setMovable(bool movable) -> void; auto setMovable(bool movable) -> void;
auto setSelected() -> void; auto setSelected() -> void;
auto setText(const string& text) -> void; auto setText(const string& text) -> void;

View File

@ -178,7 +178,7 @@ auto pTabFrame::setItemClosable(unsigned position, bool closable) -> void {
_synchronizeTab(position); _synchronizeTab(position);
} }
auto pTabFrame::setItemImage(unsigned position, const Image& image) -> void { auto pTabFrame::setItemIcon(unsigned position, const image& icon) -> void {
_synchronizeTab(position); _synchronizeTab(position);
} }
@ -239,15 +239,15 @@ auto pTabFrame::_synchronizeTab(unsigned position) -> void {
auto& item = state().items[position]; auto& item = state().items[position];
auto& tab = tabs[position]; auto& tab = tabs[position];
gtk_widget_set_visible(tab.close, item->closable()); gtk_widget_set_visible(tab.close, item->closable());
if(auto& image = item->state.image) { if(auto& icon = item->state.icon) {
unsigned size = pFont::size(self().font(true), " ").height(); uint size = pFont::size(self().font(true), " ").height();
auto pixbuf = CreatePixbuf(image, true); auto pixbuf = CreatePixbuf(icon, true);
gtk_image_set_from_pixbuf(GTK_IMAGE(tab.image), pixbuf); gtk_image_set_from_pixbuf(GTK_IMAGE(tab.image), pixbuf);
} else { } else {
gtk_image_clear(GTK_IMAGE(tab.image)); gtk_image_clear(GTK_IMAGE(tab.image));
} }
string text = { string text = {
item->state.image && item->state.text ? " " : "", item->state.icon && item->state.text ? " " : "",
item->state.text, item->state.text,
item->state.text && item->state.closable ? " " : "" item->state.text && item->state.closable ? " " : ""
}; };

View File

@ -12,7 +12,7 @@ struct pTabFrame : pWidget {
auto setFont(const Font& font) -> void override; auto setFont(const Font& font) -> void override;
auto setGeometry(Geometry geometry) -> void override; auto setGeometry(Geometry geometry) -> void override;
auto setItemClosable(unsigned position, bool closable) -> void; 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 setItemLayout(unsigned position, sLayout layout) -> void;
auto setItemMovable(unsigned position, bool movable) -> void; auto setItemMovable(unsigned position, bool movable) -> void;
auto setItemSelected(unsigned position) -> void; auto setItemSelected(unsigned position) -> void;

View File

@ -10,7 +10,7 @@ auto pTreeViewItem::construct() -> void {
gtk_tree_store_append(parentWidget->gtkTreeStore, &gtkIter, nullptr); gtk_tree_store_append(parentWidget->gtkTreeStore, &gtkIter, nullptr);
} }
setChecked(state().checked); setChecked(state().checked);
setImage(state().image); setIcon(state().icon);
setText(state().text); setText(state().text);
} }
} }
@ -65,10 +65,10 @@ auto pTreeViewItem::setFocused() -> void {
auto pTreeViewItem::setForegroundColor(Color color) -> 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(auto parentWidget = _parentWidget()) {
if(image) { if(icon) {
auto pixbuf = CreatePixbuf(image); auto pixbuf = CreatePixbuf(icon);
gtk_tree_store_set(parentWidget->gtkTreeStore, &gtkIter, 1, pixbuf, -1); gtk_tree_store_set(parentWidget->gtkTreeStore, &gtkIter, 1, pixbuf, -1);
} else { } else {
gtk_tree_store_set(parentWidget->gtkTreeStore, &gtkIter, 1, nullptr, -1); gtk_tree_store_set(parentWidget->gtkTreeStore, &gtkIter, 1, nullptr, -1);

Some files were not shown because too many files have changed in this diff Show More