diff --git a/higan/target-tomoko/settings/advanced.cpp b/higan/target-tomoko/settings/advanced.cpp index 7b28b1d1..56ff1244 100644 --- a/higan/target-tomoko/settings/advanced.cpp +++ b/higan/target-tomoko/settings/advanced.cpp @@ -1,5 +1,5 @@ AdvancedSettings::AdvancedSettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Action::Settings); + setIcon(Icon::Action::Settings); setText("Advanced"); layout.setMargin(5); diff --git a/higan/target-tomoko/settings/audio.cpp b/higan/target-tomoko/settings/audio.cpp index 3a805db8..6df614b6 100644 --- a/higan/target-tomoko/settings/audio.cpp +++ b/higan/target-tomoko/settings/audio.cpp @@ -1,5 +1,5 @@ AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Device::Speaker); + setIcon(Icon::Device::Speaker); setText("Audio"); layout.setMargin(5); diff --git a/higan/target-tomoko/settings/hotkeys.cpp b/higan/target-tomoko/settings/hotkeys.cpp index b4ea6c47..5aeeec7f 100644 --- a/higan/target-tomoko/settings/hotkeys.cpp +++ b/higan/target-tomoko/settings/hotkeys.cpp @@ -1,5 +1,5 @@ HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Device::Keyboard); + setIcon(Icon::Device::Keyboard); setText("Hotkeys"); layout.setMargin(5); diff --git a/higan/target-tomoko/settings/input.cpp b/higan/target-tomoko/settings/input.cpp index 2763db56..aa3a4581 100644 --- a/higan/target-tomoko/settings/input.cpp +++ b/higan/target-tomoko/settings/input.cpp @@ -1,5 +1,5 @@ InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Device::Joypad); + setIcon(Icon::Device::Joypad); setText("Input"); layout.setMargin(5); diff --git a/higan/target-tomoko/settings/timing.cpp b/higan/target-tomoko/settings/timing.cpp index 92bc719d..4a9c7f24 100644 --- a/higan/target-tomoko/settings/timing.cpp +++ b/higan/target-tomoko/settings/timing.cpp @@ -1,5 +1,5 @@ TimingSettings::TimingSettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Device::Clock); + setIcon(Icon::Device::Clock); setText("Timing"); layout.setMargin(5); diff --git a/higan/target-tomoko/settings/video.cpp b/higan/target-tomoko/settings/video.cpp index d0ed0c63..5ca392fa 100644 --- a/higan/target-tomoko/settings/video.cpp +++ b/higan/target-tomoko/settings/video.cpp @@ -1,5 +1,5 @@ VideoSettings::VideoSettings(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Device::Display); + setIcon(Icon::Device::Display); setText("Video"); layout.setMargin(5); diff --git a/higan/target-tomoko/tools/cheat-editor.cpp b/higan/target-tomoko/tools/cheat-editor.cpp index fdf32116..4678e959 100644 --- a/higan/target-tomoko/tools/cheat-editor.cpp +++ b/higan/target-tomoko/tools/cheat-editor.cpp @@ -1,5 +1,5 @@ CheatEditor::CheatEditor(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Edit::Replace); + setIcon(Icon::Edit::Replace); setText("Cheat Editor"); layout.setMargin(5); diff --git a/higan/target-tomoko/tools/manifest-viewer.cpp b/higan/target-tomoko/tools/manifest-viewer.cpp index 177ccb86..1458c086 100644 --- a/higan/target-tomoko/tools/manifest-viewer.cpp +++ b/higan/target-tomoko/tools/manifest-viewer.cpp @@ -1,5 +1,5 @@ ManifestViewer::ManifestViewer(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Emblem::Text); + setIcon(Icon::Emblem::Text); setText("Manifest Viewer"); layout.setMargin(5); diff --git a/higan/target-tomoko/tools/state-manager.cpp b/higan/target-tomoko/tools/state-manager.cpp index 87b12627..0c8912f8 100644 --- a/higan/target-tomoko/tools/state-manager.cpp +++ b/higan/target-tomoko/tools/state-manager.cpp @@ -1,5 +1,5 @@ StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) { - setImage(Icon::Application::FileManager); + setIcon(Icon::Application::FileManager); setText("State Manager"); layout.setMargin(5); diff --git a/hiro/cocoa/action/menu-item.cpp b/hiro/cocoa/action/menu-item.cpp index e02cfe7b..10335e63 100644 --- a/hiro/cocoa/action/menu-item.cpp +++ b/hiro/cocoa/action/menu-item.cpp @@ -24,7 +24,7 @@ auto pMenuItem::construct() -> void { cocoaAction = cocoaMenuItem = [[CocoaMenuItem alloc] initWith:self()]; pAction::construct(); - setImage(state().image); + setIcon(state().icon); 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 { uint size = 15; //there is no API to retrieve the optimal size - [cocoaAction setImage:NSMakeImage(image, size, size)]; + [cocoaAction setImage:NSMakeImage(icon, size, size)]; } } diff --git a/hiro/cocoa/action/menu-item.hpp b/hiro/cocoa/action/menu-item.hpp index 2e4aaa97..12dba029 100644 --- a/hiro/cocoa/action/menu-item.hpp +++ b/hiro/cocoa/action/menu-item.hpp @@ -13,7 +13,7 @@ namespace hiro { struct pMenuItem : pAction { Declare(MenuItem, Action) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; CocoaMenuItem* cocoaMenuItem = nullptr; diff --git a/hiro/cocoa/action/menu.cpp b/hiro/cocoa/action/menu.cpp index d914171d..7f23b19d 100644 --- a/hiro/cocoa/action/menu.cpp +++ b/hiro/cocoa/action/menu.cpp @@ -25,7 +25,7 @@ auto pMenu::construct() -> void { cocoaAction = cocoaMenu = [[CocoaMenu alloc] initWith:self()]; pAction::construct(); - setImage(state().image); + setIcon(state().icon); 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 { uint size = 15; //there is no API to retrieve the optimal size - [cocoaAction setImage:NSMakeImage(image, size, size)]; + [cocoaAction setImage:NSMakeImage(icon, size, size)]; } } diff --git a/hiro/cocoa/action/menu.hpp b/hiro/cocoa/action/menu.hpp index e7021ec0..d608062b 100644 --- a/hiro/cocoa/action/menu.hpp +++ b/hiro/cocoa/action/menu.hpp @@ -16,7 +16,7 @@ struct pMenu : pAction { auto append(sAction action) -> void; auto remove(sAction action) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; CocoaMenu* cocoaMenu = nullptr; diff --git a/hiro/cocoa/status-bar.cpp b/hiro/cocoa/status-bar.cpp index 964af900..b2678dfb 100644 --- a/hiro/cocoa/status-bar.cpp +++ b/hiro/cocoa/status-bar.cpp @@ -36,6 +36,7 @@ auto pStatusBar::setVisible(bool visible) -> void { @autoreleasepool { if(auto parent = _parent()) { [[parent->cocoaWindow statusBar] setHidden:!visible]; + parent->setGeometry(parent->state().geometry); } } } diff --git a/hiro/cocoa/utility.cpp b/hiro/cocoa/utility.cpp index 184105a1..cc35dbdc 100644 --- a/hiro/cocoa/utility.cpp +++ b/hiro/cocoa/utility.cpp @@ -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)]; } -auto NSMakeImage(hiro::Image image, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* { - if(!image.state.data) return nil; +auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* { + if(!icon) return nil; - //convert ARGB8888 to ABGR8888 - auto p = image.data(); - for(auto n : range(image.width() * image.height())) { - uint32 color = *p; - color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16); - *p++ = color; - } + if(scaleWidth && scaleHeight) icon.scale(scaleWidth, scaleHeight); + icon.transform(0, 32, 255u << 24, 255u << 0, 255u << 8, 255u << 16); //Cocoa stores images in ABGR format //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] initWithBitmapDataPlanes:nil - pixelsWide:image.width() pixelsHigh:image.height() + pixelsWide:icon.width() pixelsHigh:icon.height() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bitmapFormat:NSAlphaNonpremultipliedBitmapFormat - bytesPerRow:4*image.width() bitsPerPixel:32 + bytesPerRow:(4 * icon.width()) bitsPerPixel:32 ] 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]; - if(!scaleWidth || !scaleHeight) 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; + return cocoaImage; } auto DropPathsOperation(id sender) -> NSDragOperation { diff --git a/hiro/cocoa/widget/button.cpp b/hiro/cocoa/widget/button.cpp index 527829fb..9b82e978 100644 --- a/hiro/cocoa/widget/button.cpp +++ b/hiro/cocoa/widget/button.cpp @@ -27,7 +27,7 @@ auto pButton::construct() -> void { pWidget::construct(); setBordered(state().bordered); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); } @@ -35,6 +35,7 @@ auto pButton::construct() -> void { auto pButton::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } @@ -43,16 +44,16 @@ auto pButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } - return {size.width() + (state().text ? 20 : 4), size.height() + 4}; + return {size.width() + (state().text ? 20 : 8), size.height() + 8}; } 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 { - if(!image) { - [cocoaView setImage:nil]; - return; - } - - [cocoaView setImage:NSMakeImage(image)]; + [cocoaView setImage:NSMakeImage(icon)]; } } diff --git a/hiro/cocoa/widget/button.hpp b/hiro/cocoa/widget/button.hpp index 2b2177d9..98028e8a 100644 --- a/hiro/cocoa/widget/button.hpp +++ b/hiro/cocoa/widget/button.hpp @@ -16,7 +16,7 @@ struct pButton : pWidget { auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; auto setGeometry(Geometry geometry) -> void override; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/canvas.cpp b/hiro/cocoa/widget/canvas.cpp index 7ba3993a..1588ede3 100644 --- a/hiro/cocoa/widget/canvas.cpp +++ b/hiro/cocoa/widget/canvas.cpp @@ -99,6 +99,7 @@ auto pCanvas::construct() -> void { auto pCanvas::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } @@ -146,7 +147,7 @@ auto pCanvas::setGeometry(Geometry geometry) -> 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 { diff --git a/hiro/cocoa/widget/canvas.hpp b/hiro/cocoa/widget/canvas.hpp index 414f458a..bc4774f3 100644 --- a/hiro/cocoa/widget/canvas.hpp +++ b/hiro/cocoa/widget/canvas.hpp @@ -31,7 +31,7 @@ struct pCanvas : pWidget { auto setDroppable(bool droppable) -> void; auto setGeometry(Geometry geometry) -> void override; auto setGradient(Gradient gradient) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto update() -> void; auto _rasterize() -> void; diff --git a/hiro/cocoa/widget/check-button.cpp b/hiro/cocoa/widget/check-button.cpp index 0cecdacb..96a3edc8 100644 --- a/hiro/cocoa/widget/check-button.cpp +++ b/hiro/cocoa/widget/check-button.cpp @@ -30,7 +30,7 @@ auto pCheckButton::construct() -> void { setBordered(state().bordered); setChecked(state().checked); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); } @@ -38,6 +38,7 @@ auto pCheckButton::construct() -> void { auto pCheckButton::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } @@ -46,16 +47,16 @@ auto pCheckButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } - return {size.width() + 20, size.height() + 4}; + return {size.width() + (state().text ? 20 : 8), size.height() + 8}; } 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 { - if(!image) { - [cocoaView setImage:nil]; - return; - } - - [cocoaView setImage:NSMakeImage(image)]; + [cocoaView setImage:NSMakeImage(icon)]; } } diff --git a/hiro/cocoa/widget/check-button.hpp b/hiro/cocoa/widget/check-button.hpp index ae74bfb3..6c3d478f 100644 --- a/hiro/cocoa/widget/check-button.hpp +++ b/hiro/cocoa/widget/check-button.hpp @@ -17,7 +17,7 @@ struct pCheckButton : pWidget { auto setBordered(bool bordered) -> void; auto setChecked(bool checked) -> void; auto setGeometry(Geometry geometry) -> void override; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/check-label.cpp b/hiro/cocoa/widget/check-label.cpp index 3378e646..2810216a 100644 --- a/hiro/cocoa/widget/check-label.cpp +++ b/hiro/cocoa/widget/check-label.cpp @@ -34,6 +34,7 @@ auto pCheckLabel::construct() -> void { auto pCheckLabel::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/combo-button-item.cpp b/hiro/cocoa/widget/combo-button-item.cpp index 97d72210..881f9960 100644 --- a/hiro/cocoa/widget/combo-button-item.cpp +++ b/hiro/cocoa/widget/combo-button-item.cpp @@ -8,7 +8,7 @@ auto pComboButtonItem::construct() -> void { auto pComboButtonItem::destruct() -> void { } -auto pComboButtonItem::setImage(const Image& icon) -> void { +auto pComboButtonItem::setIcon(const image& icon) -> void { } auto pComboButtonItem::setSelected() -> void { diff --git a/hiro/cocoa/widget/combo-button-item.hpp b/hiro/cocoa/widget/combo-button-item.hpp index 1a3c0965..335e489a 100644 --- a/hiro/cocoa/widget/combo-button-item.hpp +++ b/hiro/cocoa/widget/combo-button-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pComboButtonItem : pObject { Declare(ComboButtonItem, Object) - auto setImage(const Image& icon) -> void; + auto setIcon(const image& icon) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/combo-button.cpp b/hiro/cocoa/widget/combo-button.cpp index 70ee2e5b..b6ac1d49 100644 --- a/hiro/cocoa/widget/combo-button.cpp +++ b/hiro/cocoa/widget/combo-button.cpp @@ -30,6 +30,7 @@ auto pComboButton::construct() -> void { auto pComboButton::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/console.cpp b/hiro/cocoa/widget/console.cpp index 5b363045..4a5f186e 100644 --- a/hiro/cocoa/widget/console.cpp +++ b/hiro/cocoa/widget/console.cpp @@ -36,6 +36,7 @@ void pConsole::constructor() { void pConsole::destructor() { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/frame.cpp b/hiro/cocoa/widget/frame.cpp index e8d77de9..6460e1b9 100644 --- a/hiro/cocoa/widget/frame.cpp +++ b/hiro/cocoa/widget/frame.cpp @@ -26,6 +26,7 @@ auto pFrame::construct() -> void { auto pFrame::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/hex-edit.cpp b/hiro/cocoa/widget/hex-edit.cpp index 5cea6256..22f772f6 100644 --- a/hiro/cocoa/widget/hex-edit.cpp +++ b/hiro/cocoa/widget/hex-edit.cpp @@ -42,6 +42,7 @@ void pHexEdit::constructor() { void pHexEdit::destructor() { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/horizontal-scroll-bar.cpp b/hiro/cocoa/widget/horizontal-scroll-bar.cpp index 41585b88..f1672f57 100644 --- a/hiro/cocoa/widget/horizontal-scroll-bar.cpp +++ b/hiro/cocoa/widget/horizontal-scroll-bar.cpp @@ -66,6 +66,7 @@ auto pHorizontalScrollBar::construct() -> void { auto pHorizontalScrollBar::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/horizontal-slider.cpp b/hiro/cocoa/widget/horizontal-slider.cpp index d0c90f8c..7878d6f7 100644 --- a/hiro/cocoa/widget/horizontal-slider.cpp +++ b/hiro/cocoa/widget/horizontal-slider.cpp @@ -34,6 +34,7 @@ auto pHorizontalSlider::construct() -> void { auto pHorizontalSlider::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/label.cpp b/hiro/cocoa/widget/label.cpp index c1c338b8..7f2ebf77 100644 --- a/hiro/cocoa/widget/label.cpp +++ b/hiro/cocoa/widget/label.cpp @@ -29,6 +29,7 @@ auto pLabel::construct() -> void { auto pLabel::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/line-edit.cpp b/hiro/cocoa/widget/line-edit.cpp index e41621fc..145bdfea 100644 --- a/hiro/cocoa/widget/line-edit.cpp +++ b/hiro/cocoa/widget/line-edit.cpp @@ -42,6 +42,7 @@ auto pLineEdit::construct() -> void { auto pLineEdit::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/list-view-cell.cpp b/hiro/cocoa/widget/list-view-cell.cpp index a1a47a44..ef43cedc 100644 --- a/hiro/cocoa/widget/list-view-cell.cpp +++ b/hiro/cocoa/widget/list-view-cell.cpp @@ -23,7 +23,7 @@ auto pListViewCell::setChecked(bool checked) -> void { auto pListViewCell::setForegroundColor(Color color) -> void { } -auto pListViewCell::setImage(const Image& image) -> void { +auto pListViewCell::setIcon(const image& icon) -> void { } auto pListViewCell::setText(const string& text) -> void { diff --git a/hiro/cocoa/widget/list-view-cell.hpp b/hiro/cocoa/widget/list-view-cell.hpp index 4c82d27d..33b33f39 100644 --- a/hiro/cocoa/widget/list-view-cell.hpp +++ b/hiro/cocoa/widget/list-view-cell.hpp @@ -10,7 +10,7 @@ struct pListViewCell : pObject { auto setCheckable(bool checkable) -> void; auto setChecked(bool checked) -> void; auto setForegroundColor(Color color) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _grandparent() -> maybe; diff --git a/hiro/cocoa/widget/list-view-column.cpp b/hiro/cocoa/widget/list-view-column.cpp index d1f99be6..a2016c14 100644 --- a/hiro/cocoa/widget/list-view-column.cpp +++ b/hiro/cocoa/widget/list-view-column.cpp @@ -42,7 +42,7 @@ auto pListViewColumn::setForegroundColor(Color color) -> 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 { diff --git a/hiro/cocoa/widget/list-view-column.hpp b/hiro/cocoa/widget/list-view-column.hpp index 7507f3a2..59b45288 100644 --- a/hiro/cocoa/widget/list-view-column.hpp +++ b/hiro/cocoa/widget/list-view-column.hpp @@ -13,7 +13,7 @@ struct pListViewColumn : pObject { auto setFont(const Font& font) -> void override; auto setForegroundColor(Color color) -> void; auto setHorizontalAlignment(double) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setResizable(bool resizable) -> void; auto setSortable(bool sortable) -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/list-view.cpp b/hiro/cocoa/widget/list-view.cpp index 27fcb3c9..56a995e4 100644 --- a/hiro/cocoa/widget/list-view.cpp +++ b/hiro/cocoa/widget/list-view.cpp @@ -177,8 +177,8 @@ frame.size.width -= frame.size.height + 2; } - if(listViewCell->state.image) { - NSImage* image = NSMakeImage(listViewCell->state.image, frame.size.height, frame.size.height); + if(listViewCell->state.icon) { + NSImage* image = NSMakeImage(listViewCell->state.icon, frame.size.height, frame.size.height); [[NSGraphicsContext currentContext] saveGraphicsState]; 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); @@ -269,6 +269,7 @@ auto pListView::construct() -> void { auto pListView::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } @@ -361,8 +362,8 @@ auto pListView::_cellWidth(uint row, uint column) -> uint { if(pListViewCell->state.checkable) { width += 24; } - if(auto& image = pListViewCell->state.image) { - width += image.width() + 2; + if(auto& icon = pListViewCell->state.icon) { + width += icon.width() + 2; } if(auto& text = pListViewCell->state.text) { width += pFont::size(pListViewCell->font(true), text).width(); @@ -376,8 +377,8 @@ auto pListView::_columnWidth(uint column) -> uint { uint width = 8; if(auto& header = state().header) { if(auto pListViewColumn = header->column(column)) { - if(auto& image = pListViewColumn->state.image) { - width += image.width() + 2; + if(auto& icon = pListViewColumn->state.icon) { + width += icon.width() + 2; } if(auto& text = pListViewColumn->state.text) { width += pFont::size(pListViewColumn->font(true), text).width(); diff --git a/hiro/cocoa/widget/progress-bar.cpp b/hiro/cocoa/widget/progress-bar.cpp index 731188c0..4afe7ed6 100644 --- a/hiro/cocoa/widget/progress-bar.cpp +++ b/hiro/cocoa/widget/progress-bar.cpp @@ -28,6 +28,7 @@ auto pProgressBar::construct() -> void { auto pProgressBar::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/radio-button.cpp b/hiro/cocoa/widget/radio-button.cpp index cf3a234c..e60ab37b 100644 --- a/hiro/cocoa/widget/radio-button.cpp +++ b/hiro/cocoa/widget/radio-button.cpp @@ -31,7 +31,7 @@ auto pRadioButton::construct() -> void { setBordered(state().bordered); if(state().checked) setChecked(); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); } @@ -39,6 +39,7 @@ auto pRadioButton::construct() -> void { auto pRadioButton::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } @@ -47,16 +48,16 @@ auto pRadioButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } - return {size.width() + 20, size.height() + 4}; + return {size.width() + (state().text ? 20 : 8), size.height() + 8}; } auto pRadioButton::setBordered(bool bordered) -> void { @@ -89,14 +90,9 @@ auto pRadioButton::setGeometry(Geometry geometry) -> void { auto pRadioButton::setGroup(sGroup group) -> void { } -auto pRadioButton::setImage(const Image& image) -> void { +auto pRadioButton::setIcon(const image& icon) -> void { @autoreleasepool { - if(!image) { - [cocoaView setImage:nil]; - return; - } - - [cocoaView setImage:NSMakeImage(image)]; + [cocoaView setImage:NSMakeImage(icon)]; } } diff --git a/hiro/cocoa/widget/radio-button.hpp b/hiro/cocoa/widget/radio-button.hpp index 76c04335..30848e30 100644 --- a/hiro/cocoa/widget/radio-button.hpp +++ b/hiro/cocoa/widget/radio-button.hpp @@ -18,7 +18,7 @@ struct pRadioButton : pWidget { auto setChecked() -> void; auto setGeometry(Geometry geometry) -> void override; auto setGroup(sGroup group) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/radio-label.cpp b/hiro/cocoa/widget/radio-label.cpp index 80d62e6f..aa5dd94a 100644 --- a/hiro/cocoa/widget/radio-label.cpp +++ b/hiro/cocoa/widget/radio-label.cpp @@ -34,6 +34,7 @@ auto pRadioLabel::construct() -> void { auto pRadioLabel::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/tab-frame-item.cpp b/hiro/cocoa/widget/tab-frame-item.cpp index 474ff4f1..96616a8f 100644 --- a/hiro/cocoa/widget/tab-frame-item.cpp +++ b/hiro/cocoa/widget/tab-frame-item.cpp @@ -17,7 +17,7 @@ auto pTabFrameItem::remove(sLayout layout) -> 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 { diff --git a/hiro/cocoa/widget/tab-frame-item.hpp b/hiro/cocoa/widget/tab-frame-item.hpp index a8c96b18..ede2333d 100644 --- a/hiro/cocoa/widget/tab-frame-item.hpp +++ b/hiro/cocoa/widget/tab-frame-item.hpp @@ -8,7 +8,7 @@ struct pTabFrameItem : pObject { auto append(sLayout layout) -> void; auto remove(sLayout layout) -> void; auto setClosable(bool closable) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setMovable(bool movable) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/cocoa/widget/tab-frame.cpp b/hiro/cocoa/widget/tab-frame.cpp index a1f680cc..34490512 100644 --- a/hiro/cocoa/widget/tab-frame.cpp +++ b/hiro/cocoa/widget/tab-frame.cpp @@ -33,7 +33,7 @@ int selection = [cocoaTabFrame indexOfTabViewItem:self]; if(selection >= 0) { if(auto item = tabFrame->item(selection)) { - if(item->state.image) { + if(item->state.icon) { uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height(); sizeOfLabel.width += iconSize + 2; } @@ -46,9 +46,9 @@ int selection = [cocoaTabFrame indexOfTabViewItem:self]; if(selection >= 0) { if(auto item = tabFrame->item(selection)) { - if(item->state.image) { + if(item->state.icon) { uint iconSize = hiro::pFont::size(tabFrame->font(true), " ").height(); - NSImage* image = NSMakeImage(item->state.image); + NSImage* image = NSMakeImage(item->state.icon); [[NSGraphicsContext currentContext] saveGraphicsState]; NSRect targetRect = NSMakeRect(tabRect.origin.x, tabRect.origin.y + 2, iconSize, iconSize); @@ -78,6 +78,7 @@ auto pTabFrame::construct() -> void { auto pTabFrame::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/text-edit.cpp b/hiro/cocoa/widget/text-edit.cpp index ac7ce82d..862a12b6 100644 --- a/hiro/cocoa/widget/text-edit.cpp +++ b/hiro/cocoa/widget/text-edit.cpp @@ -59,6 +59,7 @@ auto pTextEdit::construct() -> void { auto pTextEdit::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/vertical-scroll-bar.cpp b/hiro/cocoa/widget/vertical-scroll-bar.cpp index fcbda93c..db8bc416 100644 --- a/hiro/cocoa/widget/vertical-scroll-bar.cpp +++ b/hiro/cocoa/widget/vertical-scroll-bar.cpp @@ -66,6 +66,7 @@ auto pVerticalScrollBar::construct() -> void { auto pVerticalScrollBar::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/vertical-slider.cpp b/hiro/cocoa/widget/vertical-slider.cpp index 89d0fa98..12cd4010 100644 --- a/hiro/cocoa/widget/vertical-slider.cpp +++ b/hiro/cocoa/widget/vertical-slider.cpp @@ -34,6 +34,7 @@ auto pVerticalSlider::construct() -> void { auto pVerticalSlider::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/viewport.cpp b/hiro/cocoa/widget/viewport.cpp index cb788cc1..c03202d3 100644 --- a/hiro/cocoa/widget/viewport.cpp +++ b/hiro/cocoa/widget/viewport.cpp @@ -48,6 +48,7 @@ auto pViewport::construct() -> void { auto pViewport::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } diff --git a/hiro/cocoa/widget/widget.cpp b/hiro/cocoa/widget/widget.cpp index 56529310..bb8d82e6 100644 --- a/hiro/cocoa/widget/widget.cpp +++ b/hiro/cocoa/widget/widget.cpp @@ -21,18 +21,11 @@ auto pWidget::construct() -> void { auto pWidget::destruct() -> void { @autoreleasepool { + [cocoaView removeFromSuperview]; [cocoaView release]; } } -/* -bool pWidget::enabled() { - @autoreleasepool { - return [cocoaView respondsToSelector:@selector(enabled)] && [cocoaView enabled]; - } -} -*/ - auto pWidget::focused() const -> bool { @autoreleasepool { 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 diff --git a/hiro/cocoa/window.cpp b/hiro/cocoa/window.cpp index b54ae171..a95cd801 100644 --- a/hiro/cocoa/window.cpp +++ b/hiro/cocoa/window.cpp @@ -337,7 +337,9 @@ auto pWindow::sizeEvent() -> void { auto pWindow::statusBarHeight() -> uint { if(auto& statusBar = state().statusBar) { - return pFont::size(statusBar->font(true), " ").height() + 6; + if(statusBar->visible()) { + return pFont::size(statusBar->font(true), " ").height() + 6; + } } return 0; } diff --git a/hiro/components.hpp b/hiro/components.hpp index bfb9a8d3..cd48b86c 100644 --- a/hiro/components.hpp +++ b/hiro/components.hpp @@ -17,7 +17,6 @@ #define Hiro_Size #define Hiro_Geometry #define Hiro_Font -#define Hiro_Image #define Hiro_Application #define Hiro_Desktop diff --git a/hiro/core/action/menu-item.cpp b/hiro/core/action/menu-item.cpp index 3b09a8c4..8f5ce5fe 100644 --- a/hiro/core/action/menu-item.cpp +++ b/hiro/core/action/menu-item.cpp @@ -10,8 +10,8 @@ auto mMenuItem::doActivate() const -> void { if(state.onActivate) return state.onActivate(); } -auto mMenuItem::image() const -> Image { - return state.image; +auto mMenuItem::icon() const -> image { + return state.icon; } auto mMenuItem::onActivate(const function& callback) -> type& { @@ -19,9 +19,9 @@ auto mMenuItem::onActivate(const function& callback) -> type& { return *this; } -auto mMenuItem::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mMenuItem::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/action/menu.cpp b/hiro/core/action/menu.cpp index 76640b62..45bea2eb 100644 --- a/hiro/core/action/menu.cpp +++ b/hiro/core/action/menu.cpp @@ -33,8 +33,8 @@ auto mMenu::append(sAction action) -> type& { return *this; } -auto mMenu::image() const -> Image { - return state.image; +auto mMenu::icon() const -> image { + return state.icon; } auto mMenu::remove(sAction action) -> type& { @@ -52,9 +52,9 @@ auto mMenu::reset() -> type& { return *this; } -auto mMenu::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mMenu::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/core.cpp b/hiro/core/core.cpp index 32259398..d6fd5e17 100644 --- a/hiro/core/core.cpp +++ b/hiro/core/core.cpp @@ -39,7 +39,6 @@ namespace hiro { #include "size.cpp" #include "geometry.cpp" #include "font.cpp" - #include "image.cpp" #include "application.cpp" #include "desktop.cpp" diff --git a/hiro/core/core.hpp b/hiro/core/core.hpp index b1c3a6f5..c33f9d59 100644 --- a/hiro/core/core.hpp +++ b/hiro/core/core.hpp @@ -14,6 +14,7 @@ #include using nall::function; +using nall::image; using nall::lstring; using nall::maybe; using nall::nothing; @@ -327,36 +328,6 @@ struct Font { }; #endif -#if defined(Hiro_Image) -struct Image { - using type = Image; - - Image(); - Image(const Image& source); - Image(const string& source); - Image(const vector& 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) struct Hotkey { using type = Hotkey; @@ -837,10 +808,10 @@ struct mMenu : mAction { auto actionCount() const -> unsigned; auto actions() const -> vector; auto append(sAction action) -> type&; - auto image() const -> Image; + auto icon() const -> image; auto remove(sAction action) -> 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 setText(const string& text = "") -> type&; auto text() const -> string; @@ -848,7 +819,7 @@ struct mMenu : mAction { //private: struct State { vector actions; - Image image; + image icon; string text; } state; @@ -871,15 +842,15 @@ struct mMenuItem : mAction { Declare(MenuItem) auto doActivate() const -> void; - auto image() const -> Image; + auto icon() const -> image; auto onActivate(const function& callback = {}) -> type&; - auto setImage(const Image& image = {}) -> type&; + auto setIcon(const image& icon = {}) -> type&; auto setText(const string& text = "") -> type&; auto text() const -> string; //private: struct State { - Image image; + image icon; function onActivate; string text; } state; @@ -987,11 +958,11 @@ struct mButton : mWidget { auto bordered() const -> bool; auto doActivate() const -> void; - auto image() const -> Image; + auto icon() const -> image; auto onActivate(const function& callback = {}) -> type&; auto orientation() const -> Orientation; 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 setText(const string& text = "") -> type&; auto text() const -> string; @@ -999,7 +970,7 @@ struct mButton : mWidget { //private: struct State { bool bordered = true; - Image image; + image icon; function onActivate; Orientation orientation = Orientation::Horizontal; string text; @@ -1020,7 +991,7 @@ struct mCanvas : mWidget { auto doMousePress(Mouse::Button button) const -> void; auto doMouseRelease(Mouse::Button button) const -> void; auto gradient() const -> Gradient; - auto image() const -> Image; + auto icon() const -> image; auto onDrop(const function& callback = {}) -> type&; auto onMouseLeave(const function& callback = {}) -> type&; auto onMouseMove(const function& callback = {}) -> type&; @@ -1029,7 +1000,7 @@ struct mCanvas : mWidget { auto setColor(Color color = {}) -> type&; auto setDroppable(bool droppable = true) -> type&; auto setGradient(Gradient gradient = {}) -> type&; - auto setImage(const Image& image = {}) -> type&; + auto setIcon(const image& icon = {}) -> type&; auto setSize(Size size = {}) -> type&; auto size() const -> Size; auto update() -> type&; @@ -1039,7 +1010,7 @@ struct mCanvas : mWidget { Color color; bool droppable = false; Gradient gradient; - Image image; + image icon; function onDrop; function onMouseLeave; function onMouseMove; @@ -1056,12 +1027,12 @@ struct mCheckButton : mWidget { auto bordered() const -> bool; auto checked() const -> bool; auto doToggle() const -> void; - auto image() const -> Image; + auto icon() const -> image; auto onToggle(const function& callback = {}) -> type&; auto orientation() const -> Orientation; auto setBordered(bool bordered = 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 setText(const string& text = "") -> type&; auto text() const -> string; @@ -1070,7 +1041,7 @@ struct mCheckButton : mWidget { struct State { bool bordered = true; bool checked = false; - Image image; + image icon; function onToggle; Orientation orientation = Orientation::Horizontal; string text; @@ -1128,17 +1099,17 @@ struct mComboButton : mWidget { struct mComboButtonItem : mObject { Declare(ComboButtonItem) - auto image() const -> Image; + auto icon() const -> image; auto remove() -> type& override; auto selected() const -> bool; - auto setImage(const Image& image = {}) -> type&; + auto setIcon(const image& icon = {}) -> type&; auto setSelected() -> type&; auto setText(const string& text = "") -> type&; auto text() const -> string; //private: struct State { - Image image; + image icon; bool selected = false; string text; } state; @@ -1322,17 +1293,17 @@ struct mIconView : mWidget { struct mIconViewItem : mObject { Declare(IconViewItem) - auto image() const -> Image; + auto icon() const -> image; auto remove() -> type& override; auto selected() const -> bool; - auto setImage(const Image& image = {}) -> type&; + auto setIcon(const image& icon = {}) -> type&; auto setSelected(bool selected = true) -> type&; auto setText(const string& text = "") -> type&; auto text() const -> string; //private: struct State { - Image image; + image icon; bool selected = false; string text; } state; @@ -1478,7 +1449,7 @@ struct mListViewColumn : mObject { auto expandable() const -> bool; auto foregroundColor() const -> Color; auto horizontalAlignment() const -> double; - auto image() const -> Image; + auto icon() const -> image; auto remove() -> type& override; auto resizable() const -> bool; auto setActive() -> type&; @@ -1488,7 +1459,7 @@ struct mListViewColumn : mObject { auto setExpandable(bool expandable = true) -> type&; auto setForegroundColor(Color color = {}) -> 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 setSortable(bool sortable = true) -> type&; auto setText(const string& text = "") -> type&; @@ -1508,7 +1479,7 @@ struct mListViewColumn : mObject { bool expandable = false; Color foregroundColor; double horizontalAlignment = 0.0; - Image image; + image icon; bool resizable = true; bool sortable = false; string text; @@ -1561,13 +1532,13 @@ struct mListViewCell : mObject { auto checked() const -> bool; auto font(bool recursive = false) const -> Font; auto foregroundColor(bool recursive = false) const -> Color; - auto image() const -> Image; + auto icon() const -> image; auto setAlignment(Alignment alignment = {}) -> type&; auto setBackgroundColor(Color color = {}) -> type&; auto setCheckable(bool checkable = true) -> type&; auto setChecked(bool checked = true) -> 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 text() const -> string; @@ -1578,7 +1549,7 @@ struct mListViewCell : mObject { bool checkable = false; bool checked = false; Color foregroundColor; - Image image; + image icon; string text; } state; }; @@ -1606,13 +1577,13 @@ struct mRadioButton : mWidget { auto checked() const -> bool; auto doActivate() const -> void; auto group() const -> Group override; - auto image() const -> Image; + auto icon() const -> image; auto onActivate(const function& callback = {}) -> type&; auto orientation() const -> Orientation; auto setBordered(bool bordered = true) -> type&; auto setChecked() -> type&; 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 setText(const string& text = "") -> type&; auto text() const -> string; @@ -1622,7 +1593,7 @@ struct mRadioButton : mWidget { bool bordered = true; bool checked = false; sGroup group; - Image image; + image icon; function onActivate; Orientation orientation = Orientation::Horizontal; string text; @@ -1718,7 +1689,7 @@ struct mTabFrameItem : mObject { auto append(sLayout layout) -> type&; auto closable() const -> bool; - auto image() const -> Image; + auto icon() const -> image; auto layout() const -> Layout; auto movable() const -> bool; auto remove() -> type& override; @@ -1726,7 +1697,7 @@ struct mTabFrameItem : mObject { auto reset() -> type&; auto selected() const -> bool; 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 setParent(mObject* object = nullptr, signed offset = -1) -> type& override; auto setSelected() -> type&; @@ -1736,7 +1707,7 @@ struct mTabFrameItem : mObject { //private: struct State { bool closable = false; - Image image; + image icon; sLayout layout; bool movable = false; bool selected = false; @@ -1833,7 +1804,7 @@ struct mTreeViewItem : mObject { auto checkable() const -> bool; auto checked() const -> bool; auto foregroundColor(bool recursive = false) const -> Color; - auto image() const -> Image; + auto icon() const -> image; auto item(const string& path) const -> TreeViewItem; auto itemCount() const -> unsigned; auto items() const -> vector; @@ -1847,7 +1818,7 @@ struct mTreeViewItem : mObject { auto setExpanded(bool expanded = true) -> type&; auto setFocused() -> type& override; 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 setSelected() -> type&; auto setText(const string& text = "") -> type&; @@ -1859,7 +1830,7 @@ struct mTreeViewItem : mObject { bool checkable = false; bool checked = false; Color foregroundColor; - Image image; + image icon; vector items; string text; } state; diff --git a/hiro/core/image.cpp b/hiro/core/image.cpp deleted file mode 100644 index 503530e1..00000000 --- a/hiro/core/image.cpp +++ /dev/null @@ -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& 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 diff --git a/hiro/core/shared.hpp b/hiro/core/shared.hpp index 1160c334..947e091c 100644 --- a/hiro/core/shared.hpp +++ b/hiro/core/shared.hpp @@ -128,10 +128,10 @@ struct Menu : sMenu { auto actionCount() const { return self().actionCount(); } auto actions() const { return self().actions(); } 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 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 text() const { return self().text(); } }; @@ -150,9 +150,9 @@ struct MenuItem : sMenuItem { using internalType = mMenuItem; auto doActivate() const { return self().doActivate(); } - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } auto onActivate(const function& 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 text() const { return self().text(); } }; @@ -215,11 +215,11 @@ struct Button : sButton { auto bordered() const { return self().bordered(); } auto doActivate() const { return self().doActivate(); } - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } auto onActivate(const function& callback = {}) { return self().onActivate(callback), *this; } auto orientation() const { return self().orientation(); } 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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } @@ -240,7 +240,7 @@ struct Canvas : sCanvas { auto doMousePress(Mouse::Button button) const { return self().doMousePress(button); } auto doMouseRelease(Mouse::Button button) const { return self().doMouseRelease(button); } auto gradient() const { return self().gradient(); } - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } auto onDrop(const function& callback = {}) { return self().onDrop(callback), *this; } auto onMouseLeave(const function& callback = {}) { return self().onMouseLeave(callback), *this; } auto onMouseMove(const function& callback = {}) { return self().onMouseMove(callback), *this; } @@ -249,7 +249,7 @@ struct Canvas : sCanvas { auto setColor(Color color) { return self().setColor(color), *this; } auto setDroppable(bool droppable = true) { return self().setDroppable(droppable), *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 update() { return self().update(), *this; } }; @@ -263,12 +263,12 @@ struct CheckButton : sCheckButton { auto bordered() const { return self().bordered(); } auto checked() const { return self().checked(); } auto doToggle() const { return self().doToggle(); } - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } auto onToggle(const function& callback = {}) { return self().onToggle(callback), *this; } auto orientation() const { return self().orientation(); } auto setBordered(bool bordered = true) { return self().setBordered(bordered), *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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } @@ -294,9 +294,9 @@ struct ComboButtonItem : sComboButtonItem { DeclareSharedObject(ComboButtonItem) using internalType = mComboButtonItem; - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } 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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } @@ -411,9 +411,9 @@ struct IconViewItem : sIconViewItem { DeclareSharedObject(IconViewItem) using internalType = mIconViewItem; - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } 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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } @@ -497,7 +497,7 @@ struct ListViewColumn : sListViewColumn { auto expandable() const { return self().expandable(); } auto foregroundColor() const { return self().foregroundColor(); } 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 setActive() { return self().setActive(), *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 setExpandable(bool expandable = true) { return self().setExpandable(expandable), *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 setSortable(bool sortable = true) { return self().setSortable(sortable), *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 checked() const { return self().checked(); } 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 setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; } auto setCheckable(bool checkable = true) const { return self().setCheckable(checkable), *this; } auto setChecked(bool checked = true) const { return self().setChecked(checked), *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 text() const { return self().text(); } }; @@ -634,12 +634,12 @@ struct RadioButton : sRadioButton { auto checked() const { return self().checked(); } auto doActivate() const { return self().doActivate(); } auto group() const { return self().group(); } - auto image() const { return self().image(); } + auto icon() const { return self().icon(); } auto onActivate(const function& callback = {}) { return self().onActivate(callback), *this; } auto orientation() const { return self().orientation(); } auto setBordered(bool bordered = true) { return self().setBordered(bordered), *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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } @@ -684,14 +684,14 @@ struct TabFrameItem : sTabFrameItem { auto append(sLayout layout) { return self().append(layout), *this; } 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 movable() const { return self().movable(); } auto remove(sLayout layout) { return self().remove(layout), *this; } auto reset() { return self().reset(), *this; } auto selected() const { return self().selected(); } 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 setSelected() { return self().setSelected(), *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 checked() const { return self().checked(); } 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 itemCount() const { return self().itemCount(); } auto items() const { return self().items(); } @@ -768,7 +768,7 @@ struct TreeViewItem : sTreeViewItem { auto setChecked(bool checked = true) { return self().setChecked(checked), *this; } auto setExpanded(bool expanded = true) { return self().setExpanded(expanded), *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 setText(const string& text = "") { return self().setText(text), *this; } auto text() const { return self().text(); } diff --git a/hiro/core/widget/button.cpp b/hiro/core/widget/button.cpp index 07f7f344..d754ba03 100644 --- a/hiro/core/widget/button.cpp +++ b/hiro/core/widget/button.cpp @@ -14,8 +14,8 @@ auto mButton::doActivate() const -> void { if(state.onActivate) return state.onActivate(); } -auto mButton::image() const -> Image { - return state.image; +auto mButton::icon() const -> image { + return state.icon; } auto mButton::onActivate(const function& callback) -> type& { @@ -33,9 +33,9 @@ auto mButton::setBordered(bool bordered) -> type& { return *this; } -auto mButton::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mButton::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/canvas.cpp b/hiro/core/widget/canvas.cpp index 0dfd405b..55df58aa 100644 --- a/hiro/core/widget/canvas.cpp +++ b/hiro/core/widget/canvas.cpp @@ -10,8 +10,8 @@ auto mCanvas::color() const -> Color { return state.color; } -auto mCanvas::data() -> uint32_t* { - return state.image.data(); +auto mCanvas::data() -> uint32* { + return (uint32*)state.icon.data(); } auto mCanvas::droppable() const -> bool { @@ -42,8 +42,8 @@ auto mCanvas::gradient() const -> Gradient { return state.gradient; } -auto mCanvas::image() const -> Image { - return state.image; +auto mCanvas::icon() const -> image { + return state.icon; } auto mCanvas::onDrop(const function& callback) -> type& { @@ -89,21 +89,20 @@ auto mCanvas::setGradient(Gradient gradient) -> type& { return *this; } -auto mCanvas::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mCanvas::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } auto mCanvas::setSize(Size size) -> type& { - Image image; - image.setSize(size); - memory::fill(image.data(), size.width() * size.height() * sizeof(uint32_t), 0x00); - return setImage(image); + image icon; + icon.allocate(size.width(), size.height()); + return setIcon(icon); } auto mCanvas::size() const -> Size { - return state.image.size(); + return {(int)state.icon.width(), (int)state.icon.height()}; } auto mCanvas::update() -> type& { diff --git a/hiro/core/widget/check-button.cpp b/hiro/core/widget/check-button.cpp index a72db387..e67bf17d 100644 --- a/hiro/core/widget/check-button.cpp +++ b/hiro/core/widget/check-button.cpp @@ -18,8 +18,8 @@ auto mCheckButton::doToggle() const -> void { if(state.onToggle) return state.onToggle(); } -auto mCheckButton::image() const -> Image { - return state.image; +auto mCheckButton::icon() const -> image { + return state.icon; } auto mCheckButton::onToggle(const function& callback) -> type& { @@ -43,9 +43,9 @@ auto mCheckButton::setChecked(bool checked) -> type& { return *this; } -auto mCheckButton::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mCheckButton::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/combo-button-item.cpp b/hiro/core/widget/combo-button-item.cpp index 9d006aea..ff836d36 100644 --- a/hiro/core/widget/combo-button-item.cpp +++ b/hiro/core/widget/combo-button-item.cpp @@ -6,8 +6,8 @@ auto mComboButtonItem::allocate() -> pObject* { // -auto mComboButtonItem::image() const -> Image { - return state.image; +auto mComboButtonItem::icon() const -> image { + return state.icon; } auto mComboButtonItem::remove() -> type& { @@ -19,9 +19,9 @@ auto mComboButtonItem::selected() const -> bool { return state.selected; } -auto mComboButtonItem::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mComboButtonItem::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/icon-view-item.cpp b/hiro/core/widget/icon-view-item.cpp index 61fc4031..bff5694e 100644 --- a/hiro/core/widget/icon-view-item.cpp +++ b/hiro/core/widget/icon-view-item.cpp @@ -6,8 +6,8 @@ auto mIconViewItem::allocate() -> pObject* { // -auto mIconViewItem::image() const -> Image { - return state.image; +auto mIconViewItem::icon() const -> image { + return state.icon; } auto mIconViewItem::remove() -> type& { @@ -19,9 +19,9 @@ auto mIconViewItem::selected() const -> bool { return state.selected; } -auto mIconViewItem::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mIconViewItem::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/list-view-cell.cpp b/hiro/core/widget/list-view-cell.cpp index bd4b699f..f9c4d01b 100644 --- a/hiro/core/widget/list-view-cell.cpp +++ b/hiro/core/widget/list-view-cell.cpp @@ -94,8 +94,8 @@ auto mListViewCell::foregroundColor(bool recursive) const -> Color { return state.foregroundColor; } -auto mListViewCell::image() const -> Image { - return state.image; +auto mListViewCell::icon() const -> image { + return state.icon; } auto mListViewCell::setAlignment(Alignment alignment) -> type& { @@ -129,9 +129,9 @@ auto mListViewCell::setForegroundColor(Color color) -> type& { return *this; } -auto mListViewCell::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mListViewCell::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/list-view-column.cpp b/hiro/core/widget/list-view-column.cpp index a9223da9..e23e67df 100644 --- a/hiro/core/widget/list-view-column.cpp +++ b/hiro/core/widget/list-view-column.cpp @@ -35,8 +35,8 @@ auto mListViewColumn::horizontalAlignment() const -> double { return state.horizontalAlignment; } -auto mListViewColumn::image() const -> Image { - return state.image; +auto mListViewColumn::icon() const -> image { + return state.icon; } auto mListViewColumn::remove() -> type& { @@ -91,9 +91,9 @@ auto mListViewColumn::setHorizontalAlignment(double alignment) -> type& { return *this; } -auto mListViewColumn::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mListViewColumn::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/radio-button.cpp b/hiro/core/widget/radio-button.cpp index b95e7066..7cd47f47 100644 --- a/hiro/core/widget/radio-button.cpp +++ b/hiro/core/widget/radio-button.cpp @@ -22,8 +22,8 @@ auto mRadioButton::group() const -> Group { return state.group; } -auto mRadioButton::image() const -> Image { - return state.image; +auto mRadioButton::icon() const -> image { + return state.icon; } auto mRadioButton::onActivate(const function& callback) -> type& { @@ -62,9 +62,9 @@ auto mRadioButton::setGroup(sGroup group) -> type& { return *this; } -auto mRadioButton::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mRadioButton::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/tab-frame-item.cpp b/hiro/core/widget/tab-frame-item.cpp index 3a7d1cff..2c6998f4 100644 --- a/hiro/core/widget/tab-frame-item.cpp +++ b/hiro/core/widget/tab-frame-item.cpp @@ -23,8 +23,8 @@ auto mTabFrameItem::closable() const -> bool { return state.closable; } -auto mTabFrameItem::image() const -> Image { - return state.image; +auto mTabFrameItem::icon() const -> image { + return state.icon; } auto mTabFrameItem::layout() const -> Layout { @@ -62,9 +62,9 @@ auto mTabFrameItem::setClosable(bool closable) -> type& { return *this; } -auto mTabFrameItem::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mTabFrameItem::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/core/widget/tree-view-item.cpp b/hiro/core/widget/tree-view-item.cpp index c6656a61..75724a01 100644 --- a/hiro/core/widget/tree-view-item.cpp +++ b/hiro/core/widget/tree-view-item.cpp @@ -52,8 +52,8 @@ auto mTreeViewItem::foregroundColor(bool recursive) const -> Color { return {}; } -auto mTreeViewItem::image() const -> Image { - return state.image; +auto mTreeViewItem::icon() const -> image { + return state.icon; } auto mTreeViewItem::item(const string& path) const -> TreeViewItem { @@ -137,9 +137,9 @@ auto mTreeViewItem::setForegroundColor(Color color) -> type& { return *this; } -auto mTreeViewItem::setImage(const Image& image) -> type& { - state.image = image; - signal(setImage, image); +auto mTreeViewItem::setIcon(const image& icon) -> type& { + state.icon = icon; + signal(setIcon, icon); return *this; } diff --git a/hiro/extension/browser-dialog.cpp b/hiro/extension/browser-dialog.cpp index 9be90006..56a784a8 100644 --- a/hiro/extension/browser-dialog.cpp +++ b/hiro/extension/browser-dialog.cpp @@ -118,9 +118,9 @@ auto BrowserDialogWindow::run() -> lstring { layout.setMargin(5); pathName.onActivate([&] { setPath(pathName.text()); }); - pathRefresh.setBordered(false).setImage(Icon::Action::Refresh).onActivate([&] { setPath(state.path); }); - pathHome.setBordered(false).setImage(Icon::Go::Home).onActivate([&] { setPath(userpath()); }); - pathUp.setBordered(false).setImage(Icon::Go::Up).onActivate([&] { setPath(dirname(state.path)); }); + pathRefresh.setBordered(false).setIcon(Icon::Action::Refresh).onActivate([&] { setPath(state.path); }); + pathHome.setBordered(false).setIcon(Icon::Go::Home).onActivate([&] { setPath(userpath()); }); + pathUp.setBordered(false).setIcon(Icon::Go::Up).onActivate([&] { setPath(dirname(state.path)); }); view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); }); filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); }); for(auto& filter : state.filters) { @@ -175,7 +175,7 @@ auto BrowserDialogWindow::setPath(string path) -> void { if(folderMode && isMatch(content)) continue; 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; 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)) ); } diff --git a/hiro/extension/message-dialog.cpp b/hiro/extension/message-dialog.cpp index 31a4c894..d9e379d2 100644 --- a/hiro/extension/message-dialog.cpp +++ b/hiro/extension/message-dialog.cpp @@ -6,19 +6,19 @@ MessageDialog::MessageDialog(const string& text) { auto MessageDialog::error(const lstring& buttons) -> string { state.buttons = buttons; - state.image = Icon::Prompt::Error; + state.icon = Icon::Prompt::Error; return _run(); } auto MessageDialog::information(const lstring& buttons) -> string { state.buttons = buttons; - state.image = Icon::Prompt::Information; + state.icon = Icon::Prompt::Information; return _run(); } auto MessageDialog::question(const lstring& buttons) -> string { state.buttons = buttons; - state.image = Icon::Prompt::Question; + state.icon = Icon::Prompt::Question; return _run(); } @@ -39,7 +39,7 @@ auto MessageDialog::setTitle(const string& title) -> type& { auto MessageDialog::warning(const lstring& buttons) -> string { state.buttons = buttons; - state.image = Icon::Prompt::Warning; + state.icon = Icon::Prompt::Warning; return _run(); } @@ -53,7 +53,7 @@ auto MessageDialog::_run() -> string { Widget controlSpacer{&controlLayout, Size{~0, 0}}; layout.setMargin(5); - messageIcon.setImage(state.image); + messageIcon.setIcon(state.icon); messageText.setText(state.text); for(auto n : range(state.buttons)) { Button button{&controlLayout, Size{80, 0}, 5}; diff --git a/hiro/extension/message-dialog.hpp b/hiro/extension/message-dialog.hpp index 480beedb..cd53ae69 100644 --- a/hiro/extension/message-dialog.hpp +++ b/hiro/extension/message-dialog.hpp @@ -15,7 +15,7 @@ struct MessageDialog { private: struct State { lstring buttons; - vector image; + vector icon; sWindow parent; string response; string text; diff --git a/hiro/gtk/action/menu-item.cpp b/hiro/gtk/action/menu-item.cpp index 92ae2b92..7451b747 100644 --- a/hiro/gtk/action/menu-item.cpp +++ b/hiro/gtk/action/menu-item.cpp @@ -9,7 +9,7 @@ static auto MenuItem_activate(GtkMenuItem*, pMenuItem* p) -> void { auto pMenuItem::construct() -> void { widget = gtk_image_menu_item_new_with_mnemonic(""); g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(MenuItem_activate), (gpointer)this); - setImage(state().image); + setIcon(state().icon); setText(state().text); } @@ -17,9 +17,9 @@ auto pMenuItem::destruct() -> void { if(widget) gtk_widget_destroy(widget), widget = nullptr; } -auto pMenuItem::setImage(const Image& image) -> void { - if(image) { - GtkImage* gtkImage = CreateImage(image, true); +auto pMenuItem::setIcon(const image& icon) -> void { + if(icon) { + GtkImage* gtkImage = CreateImage(icon, true); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage); } else { gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr); diff --git a/hiro/gtk/action/menu-item.hpp b/hiro/gtk/action/menu-item.hpp index 263b3bb4..8d980c34 100644 --- a/hiro/gtk/action/menu-item.hpp +++ b/hiro/gtk/action/menu-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pMenuItem : pAction { Declare(MenuItem, Action) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; }; diff --git a/hiro/gtk/action/menu.cpp b/hiro/gtk/action/menu.cpp index 34c95572..652853ad 100644 --- a/hiro/gtk/action/menu.cpp +++ b/hiro/gtk/action/menu.cpp @@ -6,7 +6,7 @@ auto pMenu::construct() -> void { gtkMenu = gtk_menu_new(); widget = gtk_image_menu_item_new_with_mnemonic(""); gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu); - setImage(state().image); + setIcon(state().icon); setText(state().text); for(auto& action : state().actions) append(*action); @@ -35,9 +35,9 @@ auto pMenu::setFont(const Font& font) -> void { } } -auto pMenu::setImage(const Image& image) -> void { - if(image) { - GtkImage* gtkImage = CreateImage(image, true); +auto pMenu::setIcon(const image& icon) -> void { + if(icon) { + GtkImage* gtkImage = CreateImage(icon, true); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage); } else { gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr); diff --git a/hiro/gtk/action/menu.hpp b/hiro/gtk/action/menu.hpp index 34f0b8de..d99cd752 100644 --- a/hiro/gtk/action/menu.hpp +++ b/hiro/gtk/action/menu.hpp @@ -8,7 +8,7 @@ struct pMenu : pAction { auto append(sAction action) -> void; auto remove(sAction action) -> void; auto setFont(const Font& font) -> void override; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; GtkWidget* gtkMenu = nullptr; diff --git a/hiro/gtk/utility.cpp b/hiro/gtk/utility.cpp index 41d5db38..c30286f9 100644 --- a/hiro/gtk/utility.cpp +++ b/hiro/gtk/utility.cpp @@ -29,40 +29,11 @@ static auto CreatePixbuf(image icon, bool scale = false) -> GdkPixbuf* { return pixbuf; } -static auto CreatePixbuf(const Image& image, bool scale = false) -> GdkPixbuf* { - if(!image.state.data) return nullptr; - - auto pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, image.width(), image.height()); - - //ARGB -> ABGR conversion - const uint32_t* source = image.data(); - uint32_t* target = (uint32_t*)gdk_pixbuf_get_pixels(pixbuf); - for(auto n : range(image.width() * image.height())) { - uint32_t pixel = *source++; - *target++ = (pixel & 0x00ff0000) >> 16 | (pixel & 0xff00ff00) | (pixel & 0x000000ff) << 16; - } - - if(scale) { - auto scaled = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - pixbuf = scaled; - } - - return pixbuf; -} - -static auto CreateImage(const nall::image& image, bool scale = false) -> GtkImage* { - auto pixbuf = CreatePixbuf(image, scale); - auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf); +static auto CreateImage(const image& icon, bool scale = false) -> GtkImage* { + auto pixbuf = CreatePixbuf(icon, scale); + auto gtkIcon = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); - return gtkImage; -} - -static auto CreateImage(const Image& image, bool scale = false) -> GtkImage* { - auto pixbuf = CreatePixbuf(image, scale); - auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - return gtkImage; + return gtkIcon; } static auto DropPaths(GtkSelectionData* data) -> lstring { diff --git a/hiro/gtk/widget/button.cpp b/hiro/gtk/widget/button.cpp index 63a28c6e..764af857 100644 --- a/hiro/gtk/widget/button.cpp +++ b/hiro/gtk/widget/button.cpp @@ -9,7 +9,7 @@ auto pButton::construct() -> void { gtkButton = GTK_BUTTON(gtkWidget); setBordered(state().bordered); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); @@ -26,13 +26,13 @@ auto pButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + (state().text ? 24 : 12), size.height() + 12}; @@ -42,9 +42,9 @@ auto pButton::setBordered(bool bordered) -> void { gtk_button_set_relief(gtkButton, bordered ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE); } -auto pButton::setImage(const Image& image) -> void { - if(image) { - auto gtkImage = CreateImage(image); +auto pButton::setIcon(const image& icon) -> void { + if(icon) { + auto gtkImage = CreateImage(icon); gtk_button_set_image(gtkButton, (GtkWidget*)gtkImage); } else { gtk_button_set_image(gtkButton, nullptr); diff --git a/hiro/gtk/widget/button.hpp b/hiro/gtk/widget/button.hpp index 3a769248..76108e67 100644 --- a/hiro/gtk/widget/button.hpp +++ b/hiro/gtk/widget/button.hpp @@ -7,7 +7,7 @@ struct pButton : pWidget { auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/canvas.cpp b/hiro/gtk/widget/canvas.cpp index d92beb73..9b14efa0 100644 --- a/hiro/gtk/widget/canvas.cpp +++ b/hiro/gtk/widget/canvas.cpp @@ -73,7 +73,7 @@ auto pCanvas::destruct() -> void { } auto pCanvas::minimumSize() const -> Size { - if(auto& image = state().image) return image.size(); + if(auto& icon = state().icon) return {(int)icon.width(), (int)icon.height()}; return {0, 0}; } @@ -97,7 +97,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void { update(); } -auto pCanvas::setImage(const Image& image) -> void { +auto pCanvas::setIcon(const image& icon) -> void { update(); } @@ -109,9 +109,9 @@ auto pCanvas::update() -> void { auto pCanvas::_onExpose(GdkEventExpose* expose) -> void { if(surface == nullptr) return; - signed sx = 0, sy = 0, dx = 0, dy = 0; - signed width = surfaceWidth; - signed height = surfaceHeight; + int sx = 0, sy = 0, dx = 0, dy = 0; + int width = surfaceWidth; + int height = surfaceHeight; auto geometry = pSizable::state().geometry; if(width <= geometry.width()) { @@ -136,12 +136,12 @@ auto pCanvas::_onExpose(GdkEventExpose* expose) -> void { } auto pCanvas::_rasterize() -> void { - signed width = 0; - signed height = 0; + int width = 0; + int height = 0; - if(auto& image = state().image) { - width = image.width(); - height = image.height(); + if(auto& icon = state().icon) { + width = icon.width(); + height = icon.height(); } else { width = pSizable::state().geometry.width(); height = pSizable::state().geometry.height(); @@ -155,22 +155,22 @@ auto pCanvas::_rasterize() -> void { if(!surface) surface = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, width, height); auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface); - if(auto& image = state().image) { - memory::copy(buffer, state().image.data(), width * height * sizeof(uint32_t)); + if(auto& icon = state().icon) { + memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32)); } else if(auto& gradient = state().gradient) { auto& colors = gradient.state.colors; - nall::image fill; + image fill; fill.allocate(width, height); fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value()); memory::copy(buffer, fill.data(), fill.size()); } else { - uint32_t color = state().color.value(); + uint32 color = state().color.value(); for(auto n : range(width * height)) buffer[n] = color; } //ARGB -> ABGR conversion for(auto n : range(width * height)) { - uint32_t color = *buffer; + uint32 color = *buffer; color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16); *buffer++ = color; } diff --git a/hiro/gtk/widget/canvas.hpp b/hiro/gtk/widget/canvas.hpp index 9b6a93ad..3a9c61a7 100644 --- a/hiro/gtk/widget/canvas.hpp +++ b/hiro/gtk/widget/canvas.hpp @@ -10,7 +10,7 @@ struct pCanvas : pWidget { auto setDroppable(bool droppable) -> void; auto setGeometry(Geometry geometry) -> void override; auto setGradient(Gradient gradient) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto update() -> void; auto _onExpose(GdkEventExpose* event) -> void; @@ -19,8 +19,8 @@ struct pCanvas : pWidget { auto _release() -> void; GdkPixbuf* surface = nullptr; - unsigned surfaceWidth = 0; - unsigned surfaceHeight = 0; + uint surfaceWidth = 0; + uint surfaceHeight = 0; }; } diff --git a/hiro/gtk/widget/check-button.cpp b/hiro/gtk/widget/check-button.cpp index 903b3c21..3ff37aa9 100644 --- a/hiro/gtk/widget/check-button.cpp +++ b/hiro/gtk/widget/check-button.cpp @@ -12,7 +12,7 @@ auto pCheckButton::construct() -> void { setBordered(state().bordered); setChecked(state().checked); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); @@ -29,13 +29,13 @@ auto pCheckButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + 24, size.height() + 12}; @@ -51,9 +51,9 @@ auto pCheckButton::setChecked(bool checked) -> void { unlock(); } -auto pCheckButton::setImage(const Image& image) -> void { - if(image) { - GtkImage* gtkImage = CreateImage(image); +auto pCheckButton::setIcon(const image& icon) -> void { + if(icon) { + GtkImage* gtkImage = CreateImage(icon); gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage); } else { gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr); diff --git a/hiro/gtk/widget/check-button.hpp b/hiro/gtk/widget/check-button.hpp index 1b6cdf7b..886f4e56 100644 --- a/hiro/gtk/widget/check-button.hpp +++ b/hiro/gtk/widget/check-button.hpp @@ -8,7 +8,7 @@ struct pCheckButton : pWidget { auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; auto setChecked(bool checked) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; }; diff --git a/hiro/gtk/widget/combo-button-item.cpp b/hiro/gtk/widget/combo-button-item.cpp index b475be36..01ca947b 100644 --- a/hiro/gtk/widget/combo-button-item.cpp +++ b/hiro/gtk/widget/combo-button-item.cpp @@ -8,10 +8,10 @@ auto pComboButtonItem::construct() -> void { auto pComboButtonItem::destruct() -> void { } -auto pComboButtonItem::setImage(const Image& image) -> void { +auto pComboButtonItem::setIcon(const image& icon) -> void { if(auto parent = _parent()) { auto size = pFont::size(self().font(true), " ").height(); - auto pixbuf = CreatePixbuf(image, true); + auto pixbuf = CreatePixbuf(icon, true); gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1); } } diff --git a/hiro/gtk/widget/combo-button-item.hpp b/hiro/gtk/widget/combo-button-item.hpp index f0c3c5d0..3afd541f 100644 --- a/hiro/gtk/widget/combo-button-item.hpp +++ b/hiro/gtk/widget/combo-button-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pComboButtonItem : pObject { Declare(ComboButtonItem, Object) - auto setImage(const Image& icon) -> void; + auto setIcon(const image& icon) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/combo-button.cpp b/hiro/gtk/widget/combo-button.cpp index 1a93f2be..1959e274 100644 --- a/hiro/gtk/widget/combo-button.cpp +++ b/hiro/gtk/widget/combo-button.cpp @@ -32,7 +32,7 @@ auto pComboButton::append(sComboButtonItem item) -> void { lock(); if(auto self = item->self()) { gtk_list_store_append(gtkListStore, &self->gtkIter); - self->setImage(item->state.image); + self->setIcon(item->state.icon); if(item->state.selected) self->setSelected(); self->setText(item->state.text); } @@ -45,7 +45,7 @@ auto pComboButton::minimumSize() const -> Size { signed maximumWidth = 0; for(auto& item : state().items) { maximumWidth = max(maximumWidth, - (item->state.image ? pFont::size(font, " ").height() + 2 : 0) + (item->state.icon ? pFont::size(font, " ").height() + 2 : 0) + pFont::size(font, item->state.text).width() ); } diff --git a/hiro/gtk/widget/icon-view-item.cpp b/hiro/gtk/widget/icon-view-item.cpp index 2b766efc..48081e86 100644 --- a/hiro/gtk/widget/icon-view-item.cpp +++ b/hiro/gtk/widget/icon-view-item.cpp @@ -8,9 +8,9 @@ auto pIconViewItem::construct() -> void { auto pIconViewItem::destruct() -> void { } -auto pIconViewItem::setImage(const Image& image) -> void { +auto pIconViewItem::setIcon(const image& icon) -> void { if(auto parent = _parent()) { - parent->setItemImage(self().offset(), image); + parent->setItemIcon(self().offset(), icon); } } diff --git a/hiro/gtk/widget/icon-view-item.hpp b/hiro/gtk/widget/icon-view-item.hpp index a386069a..e4060110 100644 --- a/hiro/gtk/widget/icon-view-item.hpp +++ b/hiro/gtk/widget/icon-view-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pIconViewItem : pObject { Declare(IconViewItem, Object) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setSelected(bool selected) -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/icon-view.cpp b/hiro/gtk/widget/icon-view.cpp index 3a472d10..eb8c3ea9 100644 --- a/hiro/gtk/widget/icon-view.cpp +++ b/hiro/gtk/widget/icon-view.cpp @@ -65,7 +65,7 @@ auto pIconView::destruct() -> void { auto pIconView::append(sIconViewItem item) -> void { GtkTreeIter iter; gtk_list_store_append(store, &iter); - setItemImage(item->offset(), item->state.image); + setItemIcon(item->offset(), item->state.icon); setItemSelected(item->offset(), item->state.selected); setItemText(item->offset(), item->state.text); } @@ -121,12 +121,12 @@ auto pIconView::setGeometry(Geometry geometry) -> void { } } -auto pIconView::setItemImage(unsigned position, const Image& image) -> void { +auto pIconView::setItemIcon(unsigned position, const image& icon) -> void { if(position >= self().itemCount()) return; GtkTreeIter iter; if(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, string{position})) { - if(image) { - GdkPixbuf* pixbuf = CreatePixbuf(image); + if(icon) { + GdkPixbuf* pixbuf = CreatePixbuf(icon); gtk_list_store_set(store, &iter, 0, pixbuf, -1); } else { gtk_list_store_set(store, &iter, 0, nullptr, -1); diff --git a/hiro/gtk/widget/icon-view.hpp b/hiro/gtk/widget/icon-view.hpp index 58923c21..6b48359f 100644 --- a/hiro/gtk/widget/icon-view.hpp +++ b/hiro/gtk/widget/icon-view.hpp @@ -13,7 +13,7 @@ struct pIconView : pWidget { auto setFlow(Orientation flow) -> void; auto setForegroundColor(Color color) -> void; auto setGeometry(Geometry geometry) -> void; - auto setItemImage(unsigned position, const Image& image) -> void; + auto setItemIcon(unsigned position, const image& icon) -> void; auto setItemSelected(unsigned position, bool selected) -> void; auto setItemSelected(const vector& selections) -> void; auto setItemSelectedAll() -> void; diff --git a/hiro/gtk/widget/list-view-cell.cpp b/hiro/gtk/widget/list-view-cell.cpp index 507d0341..94e22bcc 100644 --- a/hiro/gtk/widget/list-view-cell.cpp +++ b/hiro/gtk/widget/list-view-cell.cpp @@ -25,7 +25,7 @@ auto pListViewCell::setChecked(bool checked) -> void { auto pListViewCell::setForegroundColor(Color color) -> void { } -auto pListViewCell::setImage(const Image& image) -> void { +auto pListViewCell::setIcon(const image& icon) -> void { _setState(); } @@ -50,7 +50,7 @@ auto pListViewCell::_setState() -> void { if(auto grandparent = _grandparent()) { grandparent->lock(); gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 0, state().checked, -1); - gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().image), -1); + gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().icon), -1); gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 2, state().text.data(), -1); grandparent->unlock(); } diff --git a/hiro/gtk/widget/list-view-cell.hpp b/hiro/gtk/widget/list-view-cell.hpp index 3587d44f..2fd00821 100644 --- a/hiro/gtk/widget/list-view-cell.hpp +++ b/hiro/gtk/widget/list-view-cell.hpp @@ -10,7 +10,7 @@ struct pListViewCell : pObject { auto setCheckable(bool checkable) -> void; auto setChecked(bool checked) -> void; auto setForegroundColor(Color color) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _grandparent() -> maybe; diff --git a/hiro/gtk/widget/list-view-column.cpp b/hiro/gtk/widget/list-view-column.cpp index 8a984495..05842074 100644 --- a/hiro/gtk/widget/list-view-column.cpp +++ b/hiro/gtk/widget/list-view-column.cpp @@ -81,9 +81,9 @@ auto pListViewColumn::setFont(const Font& font) -> void { auto pListViewColumn::setForegroundColor(Color color) -> void { } -auto pListViewColumn::setImage(const Image& image) -> void { - if(image) { - gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(image)); +auto pListViewColumn::setIcon(const image& icon) -> void { + if(icon) { + gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon)); } else { gtk_image_clear(GTK_IMAGE(gtkHeaderIcon)); } diff --git a/hiro/gtk/widget/list-view-column.hpp b/hiro/gtk/widget/list-view-column.hpp index 1c58fb85..1cc4b182 100644 --- a/hiro/gtk/widget/list-view-column.hpp +++ b/hiro/gtk/widget/list-view-column.hpp @@ -13,7 +13,7 @@ struct pListViewColumn : pObject { auto setFont(const Font& font) -> void override; auto setForegroundColor(Color color) -> void; auto setHorizontalAlignment(double) -> void {} - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setResizable(bool resizable) -> void; auto setSortable(bool sortable) -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/list-view.cpp b/hiro/gtk/widget/list-view.cpp index 8e9539bb..5947a37f 100644 --- a/hiro/gtk/widget/list-view.cpp +++ b/hiro/gtk/widget/list-view.cpp @@ -155,8 +155,8 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned { if(cell->state.checkable) { width += 24; } - if(auto& image = cell->state.image) { - width += image.width() + 2; + if(auto& icon = cell->state.icon) { + width += icon.width() + 2; } if(auto& text = cell->state.text) { width += pFont::size(cell->font(true), text).width(); @@ -170,8 +170,8 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned { unsigned width = 8; if(auto& header = state().header) { if(auto column = header->column(_column)) { - if(auto& image = column->state.image) { - width += image.width() + 2; + if(auto& icon = column->state.icon) { + width += icon.width() + 2; } if(auto& text = column->state.text) { width += pFont::size(column->font(true), text).width(); diff --git a/hiro/gtk/widget/radio-button.cpp b/hiro/gtk/widget/radio-button.cpp index 9cdd8063..53605d09 100644 --- a/hiro/gtk/widget/radio-button.cpp +++ b/hiro/gtk/widget/radio-button.cpp @@ -13,7 +13,7 @@ auto pRadioButton::construct() -> void { gtkWidget = gtk_toggle_button_new(); setBordered(state().bordered); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); @@ -30,13 +30,13 @@ auto pRadioButton::minimumSize() const -> Size { Size size = pFont::size(self().font(true), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(size.height(), state().image.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(size.width(), state().image.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + 24, size.height() + 12}; @@ -76,9 +76,9 @@ auto pRadioButton::setGroup(sGroup group) -> void { } } -auto pRadioButton::setImage(const Image& image) -> void { - if(image) { - GtkImage* gtkImage = CreateImage(image); +auto pRadioButton::setIcon(const image& icon) -> void { + if(icon) { + GtkImage* gtkImage = CreateImage(icon); gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage); } else { gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr); diff --git a/hiro/gtk/widget/radio-button.hpp b/hiro/gtk/widget/radio-button.hpp index f1e77ead..2be014dd 100644 --- a/hiro/gtk/widget/radio-button.hpp +++ b/hiro/gtk/widget/radio-button.hpp @@ -9,7 +9,7 @@ struct pRadioButton : pWidget { auto setBordered(bool bordered) -> void; auto setChecked() -> void; auto setGroup(sGroup group) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/tab-frame-item.cpp b/hiro/gtk/widget/tab-frame-item.cpp index f9ae429b..3b8f548b 100644 --- a/hiro/gtk/widget/tab-frame-item.cpp +++ b/hiro/gtk/widget/tab-frame-item.cpp @@ -22,9 +22,9 @@ auto pTabFrameItem::setClosable(bool closable) -> void { } } -auto pTabFrameItem::setImage(const Image& image) -> void { +auto pTabFrameItem::setIcon(const image& icon) -> void { if(auto parent = _parent()) { - parent->setItemImage(self().offset(), image); + parent->setItemIcon(self().offset(), icon); } } diff --git a/hiro/gtk/widget/tab-frame-item.hpp b/hiro/gtk/widget/tab-frame-item.hpp index b2cb4417..495555b0 100644 --- a/hiro/gtk/widget/tab-frame-item.hpp +++ b/hiro/gtk/widget/tab-frame-item.hpp @@ -8,7 +8,7 @@ struct pTabFrameItem : pObject { auto append(sLayout layout) -> void; auto remove(sLayout layout) -> void; auto setClosable(bool closable) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setMovable(bool movable) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/tab-frame.cpp b/hiro/gtk/widget/tab-frame.cpp index 2cdbfd0b..5b5e5396 100644 --- a/hiro/gtk/widget/tab-frame.cpp +++ b/hiro/gtk/widget/tab-frame.cpp @@ -178,7 +178,7 @@ auto pTabFrame::setItemClosable(unsigned position, bool closable) -> void { _synchronizeTab(position); } -auto pTabFrame::setItemImage(unsigned position, const Image& image) -> void { +auto pTabFrame::setItemIcon(unsigned position, const image& icon) -> void { _synchronizeTab(position); } @@ -239,15 +239,15 @@ auto pTabFrame::_synchronizeTab(unsigned position) -> void { auto& item = state().items[position]; auto& tab = tabs[position]; gtk_widget_set_visible(tab.close, item->closable()); - if(auto& image = item->state.image) { - unsigned size = pFont::size(self().font(true), " ").height(); - auto pixbuf = CreatePixbuf(image, true); + if(auto& icon = item->state.icon) { + uint size = pFont::size(self().font(true), " ").height(); + auto pixbuf = CreatePixbuf(icon, true); gtk_image_set_from_pixbuf(GTK_IMAGE(tab.image), pixbuf); } else { gtk_image_clear(GTK_IMAGE(tab.image)); } string text = { - item->state.image && item->state.text ? " " : "", + item->state.icon && item->state.text ? " " : "", item->state.text, item->state.text && item->state.closable ? " " : "" }; diff --git a/hiro/gtk/widget/tab-frame.hpp b/hiro/gtk/widget/tab-frame.hpp index 07d41d3f..a0cf067c 100644 --- a/hiro/gtk/widget/tab-frame.hpp +++ b/hiro/gtk/widget/tab-frame.hpp @@ -12,7 +12,7 @@ struct pTabFrame : pWidget { auto setFont(const Font& font) -> void override; auto setGeometry(Geometry geometry) -> void override; auto setItemClosable(unsigned position, bool closable) -> void; - auto setItemImage(unsigned position, const Image& image) -> void; + auto setItemIcon(unsigned position, const image& icon) -> void; auto setItemLayout(unsigned position, sLayout layout) -> void; auto setItemMovable(unsigned position, bool movable) -> void; auto setItemSelected(unsigned position) -> void; diff --git a/hiro/gtk/widget/tree-view-item.cpp b/hiro/gtk/widget/tree-view-item.cpp index 00042970..db199879 100644 --- a/hiro/gtk/widget/tree-view-item.cpp +++ b/hiro/gtk/widget/tree-view-item.cpp @@ -10,7 +10,7 @@ auto pTreeViewItem::construct() -> void { gtk_tree_store_append(parentWidget->gtkTreeStore, >kIter, nullptr); } setChecked(state().checked); - setImage(state().image); + setIcon(state().icon); setText(state().text); } } @@ -65,10 +65,10 @@ auto pTreeViewItem::setFocused() -> void { auto pTreeViewItem::setForegroundColor(Color color) -> void { } -auto pTreeViewItem::setImage(const Image& image) -> void { +auto pTreeViewItem::setIcon(const image& icon) -> void { if(auto parentWidget = _parentWidget()) { - if(image) { - auto pixbuf = CreatePixbuf(image); + if(icon) { + auto pixbuf = CreatePixbuf(icon); gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, pixbuf, -1); } else { gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, nullptr, -1); diff --git a/hiro/gtk/widget/tree-view-item.hpp b/hiro/gtk/widget/tree-view-item.hpp index 775f4bc5..7633a489 100644 --- a/hiro/gtk/widget/tree-view-item.hpp +++ b/hiro/gtk/widget/tree-view-item.hpp @@ -13,7 +13,7 @@ struct pTreeViewItem : pObject { auto setExpanded(bool expanded) -> void; auto setFocused() -> void; auto setForegroundColor(Color color) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/gtk/widget/tree-view.cpp b/hiro/gtk/widget/tree-view.cpp index 8061a03e..44e2fa52 100644 --- a/hiro/gtk/widget/tree-view.cpp +++ b/hiro/gtk/widget/tree-view.cpp @@ -143,7 +143,7 @@ auto pTreeView::_doDataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer if(renderer == GTK_CELL_RENDERER(gtkCellToggle)) { gtk_cell_renderer_set_visible(renderer, item->state.checkable); } else if(renderer == GTK_CELL_RENDERER(gtkCellPixbuf)) { - gtk_cell_renderer_set_visible(renderer, (bool)item->state.image); + gtk_cell_renderer_set_visible(renderer, (bool)item->state.icon); } else if(renderer == GTK_CELL_RENDERER(gtkCellText)) { auto font = pFont::create(item->font(true)); g_object_set(G_OBJECT(renderer), "font-desc", font, nullptr); diff --git a/hiro/hiro.hpp b/hiro/hiro.hpp index 3f122a6f..e9be057a 100644 --- a/hiro/hiro.hpp +++ b/hiro/hiro.hpp @@ -1,3 +1,5 @@ +#pragma once + /* hiro * author: byuu * license: ISC @@ -7,9 +9,6 @@ * it also provides a reference wrapper for terminal applications with optional UIs */ -#ifndef HIRO_HPP -#define HIRO_HPP - #include "components.hpp" #include "core/core.hpp" #include "extension/extension.hpp" @@ -20,5 +19,3 @@ #undef DeclareSharedSizable #undef DeclareSharedLayout #undef DeclareSharedWidget - -#endif diff --git a/hiro/qt/action/menu-item.cpp b/hiro/qt/action/menu-item.cpp index ceec8c32..000cdceb 100644 --- a/hiro/qt/action/menu-item.cpp +++ b/hiro/qt/action/menu-item.cpp @@ -22,7 +22,7 @@ auto pMenuItem::destruct() -> void { qtMenuItem = nullptr; } -auto pMenuItem::setImage(const Image& icon) -> void { +auto pMenuItem::setIcon(const image& icon) -> void { _setState(); } @@ -31,7 +31,7 @@ auto pMenuItem::setText(const string& text) -> void { } auto pMenuItem::_setState() -> void { - qtMenuItem->setIcon(CreateImage(state().image)); + qtMenuItem->setIcon(CreateIcon(state().icon)); qtMenuItem->setText(QString::fromUtf8(state().text)); } diff --git a/hiro/qt/action/menu-item.hpp b/hiro/qt/action/menu-item.hpp index 4da61c42..35d815f7 100644 --- a/hiro/qt/action/menu-item.hpp +++ b/hiro/qt/action/menu-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pMenuItem : pAction { Declare(MenuItem, Action) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _setState() -> void override; diff --git a/hiro/qt/action/menu.cpp b/hiro/qt/action/menu.cpp index eaf4c2a6..001444bd 100644 --- a/hiro/qt/action/menu.cpp +++ b/hiro/qt/action/menu.cpp @@ -33,7 +33,7 @@ auto pMenu::append(sAction action) -> void { auto pMenu::remove(sAction action) -> void { } -auto pMenu::setImage(const Image& image) -> void { +auto pMenu::setIcon(const image& icon) -> void { _setState(); } @@ -44,7 +44,7 @@ auto pMenu::setText(const string& text) -> void { auto pMenu::_setState() -> void { qtMenu->setEnabled(self().enabled()); qtMenu->setFont(pFont::create(self().font(true))); - qtMenu->setIcon(CreateImage(state().image)); + qtMenu->setIcon(CreateIcon(state().icon)); qtMenu->setTitle(QString::fromUtf8(state().text)); qtMenu->menuAction()->setVisible(self().visible()); diff --git a/hiro/qt/action/menu.hpp b/hiro/qt/action/menu.hpp index 44cf3d05..f09ca43d 100644 --- a/hiro/qt/action/menu.hpp +++ b/hiro/qt/action/menu.hpp @@ -7,7 +7,7 @@ struct pMenu : public pAction { auto append(sAction action) -> void; auto remove(sAction action) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _setState() -> void override; diff --git a/hiro/qt/utility.cpp b/hiro/qt/utility.cpp index d8739c0e..885fd648 100644 --- a/hiro/qt/utility.cpp +++ b/hiro/qt/utility.cpp @@ -15,7 +15,7 @@ static auto CreateBrush(Color color) -> QBrush { return color ? QColor(color.red(), color.green(), color.blue()) : QBrush(); } -static auto CreateIcon(const nall::image& icon, bool scale = false) -> QIcon { +static auto CreateIcon(const image& icon, bool scale = false) -> QIcon { if(!icon) return QIcon(); auto qtBuffer = icon; qtBuffer.transform(); @@ -24,12 +24,6 @@ static auto CreateIcon(const nall::image& icon, bool scale = false) -> QIcon { return QIcon(QPixmap::fromImage(qtImage)); } -static auto CreateImage(const Image& image, bool scale = false) -> QIcon { - if(!image) return QIcon(); - QImage qtImage((const uint8_t*)image.data(), image.width(), image.height(), QImage::Format_ARGB32); - return QIcon(QPixmap::fromImage(qtImage)); -} - static auto DropPaths(QDropEvent* event) -> lstring { QList urls = event->mimeData()->urls(); if(urls.size() == 0) return {}; diff --git a/hiro/qt/widget/button.cpp b/hiro/qt/widget/button.cpp index 168292ad..1bfb50b5 100644 --- a/hiro/qt/widget/button.cpp +++ b/hiro/qt/widget/button.cpp @@ -8,7 +8,7 @@ auto pButton::construct() -> void { qtButton->connect(qtButton, SIGNAL(released()), SLOT(onActivate())); setBordered(state().bordered); - setImage(state().image); + setIcon(state().icon); setOrientation(state().orientation); setText(state().text); @@ -24,13 +24,13 @@ auto pButton::minimumSize() const -> Size { auto size = pFont::size(qtWidget->font(), state().text ? state().text : " "); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(state().image.height(), size.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(state().image.width(), size.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + (state().text ? 20 : 12), size.height() + 12}; @@ -40,9 +40,9 @@ auto pButton::setBordered(bool bordered) -> void { qtButton->setAutoRaise(!bordered); } -auto pButton::setImage(const Image& image) -> void { - qtButton->setIconSize(QSize(image.width(), image.height())); - qtButton->setIcon(CreateImage(image)); +auto pButton::setIcon(const image& icon) -> void { + qtButton->setIconSize(QSize(icon.width(), icon.height())); + qtButton->setIcon(CreateIcon(icon)); qtButton->setStyleSheet("text-align: top;"); } diff --git a/hiro/qt/widget/button.hpp b/hiro/qt/widget/button.hpp index 215383e6..2cc25b0d 100644 --- a/hiro/qt/widget/button.hpp +++ b/hiro/qt/widget/button.hpp @@ -7,7 +7,7 @@ struct pButton : pWidget { auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/canvas.cpp b/hiro/qt/widget/canvas.cpp index 0dcd1995..8a82c651 100644 --- a/hiro/qt/widget/canvas.cpp +++ b/hiro/qt/widget/canvas.cpp @@ -18,7 +18,7 @@ auto pCanvas::destruct() -> void { } auto pCanvas::minimumSize() const -> Size { - if(auto& image = state().image) return image.size(); + if(auto& icon = state().icon) return {(int)icon.width(), (int)icon.height()}; return {0, 0}; } @@ -39,7 +39,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void { update(); } -auto pCanvas::setImage(const Image& image) -> void { +auto pCanvas::setIcon(const image& icon) -> void { update(); } @@ -52,9 +52,9 @@ auto pCanvas::_rasterize() -> void { signed width = 0; signed height = 0; - if(auto& image = state().image) { - width = image.width(); - height = image.height(); + if(auto& icon = state().icon) { + width = icon.width(); + height = icon.height(); } else { width = pSizable::state().geometry.width(); height = pSizable::state().geometry.height(); @@ -66,18 +66,18 @@ auto pCanvas::_rasterize() -> void { qtImageHeight = height; if(!qtImage) qtImage = new QImage(width, height, QImage::Format_ARGB32); - auto buffer = (uint32_t*)qtImage->bits(); + auto buffer = (uint32*)qtImage->bits(); - if(auto& image = state().image) { - memory::copy(buffer, state().image.data(), width * height * sizeof(uint32_t)); + if(auto& icon = state().icon) { + memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32)); } else if(auto& gradient = state().gradient) { auto& colors = gradient.state.colors; - nall::image fill; + image fill; fill.allocate(width, height); fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value()); memory::copy(buffer, fill.data(), fill.size()); } else { - uint32_t color = state().color.value(); + uint32 color = state().color.value(); for(auto n : range(width * height)) buffer[n] = color; } } diff --git a/hiro/qt/widget/canvas.hpp b/hiro/qt/widget/canvas.hpp index de30b602..347d9075 100644 --- a/hiro/qt/widget/canvas.hpp +++ b/hiro/qt/widget/canvas.hpp @@ -10,7 +10,7 @@ struct pCanvas : pWidget { auto setDroppable(bool droppable) -> void; auto setGeometry(Geometry geometry) -> void; auto setGradient(Gradient gradient) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto update() -> void; auto _rasterize() -> void; diff --git a/hiro/qt/widget/check-button.cpp b/hiro/qt/widget/check-button.cpp index 9cf20fbd..6c4e87b3 100644 --- a/hiro/qt/widget/check-button.cpp +++ b/hiro/qt/widget/check-button.cpp @@ -21,13 +21,13 @@ auto pCheckButton::minimumSize() const -> Size { auto size = pFont::size(qtWidget->font(), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(state().image.height(), size.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(state().image.width(), size.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + 20, size.height() + 12}; @@ -41,7 +41,7 @@ auto pCheckButton::setChecked(bool checked) -> void { _setState(); } -auto pCheckButton::setImage(const Image& image) -> void { +auto pCheckButton::setIcon(const image& icon) -> void { _setState(); } @@ -57,8 +57,8 @@ auto pCheckButton::_setState() -> void { lock(); qtCheckButton->setAutoRaise(!state().bordered); qtCheckButton->setChecked(state().checked); - qtCheckButton->setIconSize(QSize(state().image.width(), state().image.height())); - qtCheckButton->setIcon(CreateImage(state().image)); + qtCheckButton->setIconSize(QSize(state().icon.width(), state().icon.height())); + qtCheckButton->setIcon(CreateIcon(state().icon)); qtCheckButton->setStyleSheet("text-align: top;"); switch(state().orientation) { case Orientation::Horizontal: qtCheckButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break; diff --git a/hiro/qt/widget/check-button.hpp b/hiro/qt/widget/check-button.hpp index 49493a6e..092c8024 100644 --- a/hiro/qt/widget/check-button.hpp +++ b/hiro/qt/widget/check-button.hpp @@ -8,7 +8,7 @@ struct pCheckButton : pWidget { auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; auto setChecked(bool checked) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/combo-button-item.cpp b/hiro/qt/widget/combo-button-item.cpp index 64cf12a6..a38266a4 100644 --- a/hiro/qt/widget/combo-button-item.cpp +++ b/hiro/qt/widget/combo-button-item.cpp @@ -19,7 +19,7 @@ auto pComboButtonItem::destruct() -> void { } } -auto pComboButtonItem::setImage(const Image& image) -> void { +auto pComboButtonItem::setIcon(const image& icon) -> void { _setState(); } @@ -40,7 +40,7 @@ auto pComboButtonItem::_parent() -> maybe { auto pComboButtonItem::_setState() -> void { if(auto parent = _parent()) { - parent->qtComboButton->setItemIcon(self().offset(), CreateImage(state().image)); + parent->qtComboButton->setItemIcon(self().offset(), CreateIcon(state().icon)); if(state().selected) parent->qtComboButton->setCurrentIndex(self().offset()); parent->qtComboButton->setItemText(self().offset(), QString::fromUtf8(state().text)); } diff --git a/hiro/qt/widget/combo-button-item.hpp b/hiro/qt/widget/combo-button-item.hpp index 5918b19a..11e65a4e 100644 --- a/hiro/qt/widget/combo-button-item.hpp +++ b/hiro/qt/widget/combo-button-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pComboButtonItem : pObject { Declare(ComboButtonItem, Object) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/frame.cpp b/hiro/qt/widget/frame.cpp index 8fb42335..2ffd8075 100644 --- a/hiro/qt/widget/frame.cpp +++ b/hiro/qt/widget/frame.cpp @@ -22,6 +22,12 @@ auto pFrame::destruct() -> void { qtWidget = qtFrame = nullptr; } +auto pFrame::append(sLayout layout) -> void { +} + +auto pFrame::remove(sLayout layout) -> void { +} + auto pFrame::setEnabled(bool enabled) -> void { if(auto layout = state().layout) layout->setEnabled(layout->enabled(true)); pWidget::setEnabled(enabled); diff --git a/hiro/qt/widget/frame.hpp b/hiro/qt/widget/frame.hpp index 6faf26cd..b58e3044 100644 --- a/hiro/qt/widget/frame.hpp +++ b/hiro/qt/widget/frame.hpp @@ -5,6 +5,8 @@ namespace hiro { struct pFrame : pWidget { Declare(Frame, Widget) + auto append(sLayout layout) -> void; + auto remove(sLayout layout) -> void; auto setEnabled(bool enabled) -> void override; auto setGeometry(Geometry geometry) -> void override; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/list-view-cell.cpp b/hiro/qt/widget/list-view-cell.cpp index d9125044..6469ca64 100644 --- a/hiro/qt/widget/list-view-cell.cpp +++ b/hiro/qt/widget/list-view-cell.cpp @@ -32,7 +32,7 @@ auto pListViewCell::setForegroundColor(Color color) -> void { _setState(); } -auto pListViewCell::setImage(const Image& image) -> void { +auto pListViewCell::setIcon(const image& icon) -> void { _setState(); } @@ -60,7 +60,7 @@ auto pListViewCell::_setState() -> void { } parent->qtItem->setFont(self().offset(), pFont::create(self().font(true))); parent->qtItem->setForeground(self().offset(), CreateBrush(self().foregroundColor(true))); - parent->qtItem->setIcon(self().offset(), CreateImage(state().image)); + parent->qtItem->setIcon(self().offset(), CreateIcon(state().icon)); parent->qtItem->setText(self().offset(), QString::fromUtf8(state().text)); parent->qtItem->setTextAlignment(self().offset(), CalculateAlignment(self().alignment(true))); grandparent->unlock(); diff --git a/hiro/qt/widget/list-view-cell.hpp b/hiro/qt/widget/list-view-cell.hpp index 14f89ee2..4eddcc5e 100644 --- a/hiro/qt/widget/list-view-cell.hpp +++ b/hiro/qt/widget/list-view-cell.hpp @@ -11,7 +11,7 @@ struct pListViewCell : pObject { auto setChecked(bool checked) -> void; auto setFont(const string& font) -> void; auto setForegroundColor(Color color) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _parent() -> maybe; diff --git a/hiro/qt/widget/list-view-column.cpp b/hiro/qt/widget/list-view-column.cpp index aac67854..1ba29f20 100644 --- a/hiro/qt/widget/list-view-column.cpp +++ b/hiro/qt/widget/list-view-column.cpp @@ -40,7 +40,7 @@ auto pListViewColumn::setHorizontalAlignment(double alignment) -> void { _setState(); } -auto pListViewColumn::setImage(const Image& image) -> void { +auto pListViewColumn::setIcon(const image& icon) -> void { //unsupported } diff --git a/hiro/qt/widget/list-view-column.hpp b/hiro/qt/widget/list-view-column.hpp index b5d1eec5..f130ea41 100644 --- a/hiro/qt/widget/list-view-column.hpp +++ b/hiro/qt/widget/list-view-column.hpp @@ -13,7 +13,7 @@ struct pListViewColumn : pObject { auto setFont(const Font& font) -> void override; auto setForegroundColor(Color color) -> void; auto setHorizontalAlignment(double alignment) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setResizable(bool resizable) -> void; auto setSortable(bool sortable) -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/list-view.cpp b/hiro/qt/widget/list-view.cpp index 1a51d5cb..3bd27a34 100644 --- a/hiro/qt/widget/list-view.cpp +++ b/hiro/qt/widget/list-view.cpp @@ -154,8 +154,8 @@ auto pListView::_widthOfColumn(unsigned _column) -> unsigned { unsigned width = 8; if(auto& header = state().header) { if(auto column = header->column(_column)) { - if(auto& image = column->state.image) { - width += image.width() + 2; + if(auto& icon = column->state.icon) { + width += icon.width() + 2; } if(auto& text = column->state.text) { width += pFont::size(column->font(true), text).width(); @@ -172,8 +172,8 @@ auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned { if(cell->state.checkable) { width += 16 + 2; } - if(auto& image = cell->state.image) { - width += image.width() + 2; + if(auto& icon = cell->state.icon) { + width += icon.width() + 2; } if(auto& text = cell->state.text) { width += pFont::size(cell->font(true), text).width(); diff --git a/hiro/qt/widget/radio-button.cpp b/hiro/qt/widget/radio-button.cpp index 0e7a9f55..9ec2f677 100644 --- a/hiro/qt/widget/radio-button.cpp +++ b/hiro/qt/widget/radio-button.cpp @@ -22,13 +22,13 @@ auto pRadioButton::minimumSize() const -> Size { auto size = pFont::size(qtWidget->font(), state().text); if(state().orientation == Orientation::Horizontal) { - size.setWidth(size.width() + state().image.width()); - size.setHeight(max(state().image.height(), size.height())); + size.setWidth(size.width() + state().icon.width()); + size.setHeight(max(size.height(), state().icon.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(state().image.width(), size.width())); - size.setHeight(size.height() + state().image.height()); + size.setWidth(max(size.width(), state().icon.width())); + size.setHeight(size.height() + state().icon.height()); } return {size.width() + 20, size.height() + 12}; @@ -59,7 +59,7 @@ auto pRadioButton::setGroup(sGroup group) -> void { } } -auto pRadioButton::setImage(const Image& image) -> void { +auto pRadioButton::setIcon(const image& icon) -> void { _setState(); } @@ -85,8 +85,8 @@ auto pRadioButton::_setState() -> void { } group->self()->unlock(); } - qtRadioButton->setIconSize(QSize(state().image.width(), state().image.height())); - qtRadioButton->setIcon(CreateImage(state().image)); + qtRadioButton->setIconSize(QSize(state().icon.width(), state().icon.height())); + qtRadioButton->setIcon(CreateIcon(state().icon)); qtRadioButton->setStyleSheet("text-align: top;"); switch(state().orientation) { case Orientation::Horizontal: qtRadioButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break; diff --git a/hiro/qt/widget/radio-button.hpp b/hiro/qt/widget/radio-button.hpp index 1ebe7a7e..2aec616b 100644 --- a/hiro/qt/widget/radio-button.hpp +++ b/hiro/qt/widget/radio-button.hpp @@ -9,7 +9,7 @@ struct pRadioButton : pWidget { auto setBordered(bool bordered) -> void; auto setChecked() -> void; auto setGroup(sGroup group) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/widget/tab-frame-item.cpp b/hiro/qt/widget/tab-frame-item.cpp index fa0b4f54..72d8ca73 100644 --- a/hiro/qt/widget/tab-frame-item.cpp +++ b/hiro/qt/widget/tab-frame-item.cpp @@ -34,7 +34,7 @@ auto pTabFrameItem::setGeometry(Geometry geometry) -> void { } } -auto pTabFrameItem::setImage(const Image& image) -> void { +auto pTabFrameItem::setIcon(const image& icon) -> void { _setState(); } @@ -62,7 +62,7 @@ auto pTabFrameItem::_parent() -> maybe { auto pTabFrameItem::_setState() -> void { if(auto parent = _parent()) { - parent->qtTabFrame->setTabIcon(self().offset(), CreateImage(state().image)); + parent->qtTabFrame->setTabIcon(self().offset(), CreateIcon(state().icon)); if(state().selected) parent->qtTabFrame->setCurrentIndex(self().offset()); parent->qtTabFrame->setTabText(self().offset(), QString::fromUtf8(state().text)); if(auto layout = state().layout) { diff --git a/hiro/qt/widget/tab-frame-item.hpp b/hiro/qt/widget/tab-frame-item.hpp index cb383b6e..4b8d59c8 100644 --- a/hiro/qt/widget/tab-frame-item.hpp +++ b/hiro/qt/widget/tab-frame-item.hpp @@ -8,7 +8,7 @@ struct pTabFrameItem : pObject { auto append(sLayout layout) -> void; auto remove(sLayout layout) -> void; auto setClosable(bool closable) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setGeometry(Geometry geometry) -> void; auto setMovable(bool movable) -> void; auto setSelected() -> void; diff --git a/hiro/windows/action/menu-item.cpp b/hiro/windows/action/menu-item.cpp index df2bbeb5..f87dc66e 100644 --- a/hiro/windows/action/menu-item.cpp +++ b/hiro/windows/action/menu-item.cpp @@ -10,7 +10,7 @@ auto pMenuItem::destruct() -> void { if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; } } -auto pMenuItem::setImage(const Image& image) -> void { +auto pMenuItem::setIcon(const image& icon) -> void { _createBitmap(); _synchronize(); } @@ -26,10 +26,7 @@ auto pMenuItem::onActivate() -> void { auto pMenuItem::_createBitmap() -> void { if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; } - if(auto& image = state().image) { - nall::image icon; - icon.allocate(image.width(), image.height()); - memory::copy(icon.data(), image.data(), icon.size()); + if(auto icon = state().icon) { icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline) icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear); hbitmap = CreateBitmap(icon); diff --git a/hiro/windows/action/menu-item.hpp b/hiro/windows/action/menu-item.hpp index 8f94950a..636eef4a 100644 --- a/hiro/windows/action/menu-item.hpp +++ b/hiro/windows/action/menu-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pMenuItem : pAction { Declare(MenuItem, Action) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto onActivate() -> void; diff --git a/hiro/windows/action/menu.cpp b/hiro/windows/action/menu.cpp index 56f2e03b..791d863a 100644 --- a/hiro/windows/action/menu.cpp +++ b/hiro/windows/action/menu.cpp @@ -19,7 +19,7 @@ auto pMenu::remove(sAction action) -> void { _synchronize(); } -auto pMenu::setImage(const Image& image) -> void { +auto pMenu::setIcon(const image& icon) -> void { _createBitmap(); _synchronize(); } @@ -31,10 +31,7 @@ auto pMenu::setText(const string& text) -> void { auto pMenu::_createBitmap() -> void { if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; } - if(auto& image = state().image) { - nall::image icon; - icon.allocate(image.width(), image.height()); - memory::copy(icon.data(), image.data(), icon.size()); + if(auto icon = state().icon) { icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline) icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear); hbitmap = CreateBitmap(icon); diff --git a/hiro/windows/action/menu.hpp b/hiro/windows/action/menu.hpp index 63aea704..b8caee56 100644 --- a/hiro/windows/action/menu.hpp +++ b/hiro/windows/action/menu.hpp @@ -7,7 +7,7 @@ struct pMenu : pAction { auto append(sAction action) -> void; auto remove(sAction action) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _createBitmap() -> void; diff --git a/hiro/windows/utility.cpp b/hiro/windows/utility.cpp index 41c7d477..ff1b77e8 100644 --- a/hiro/windows/utility.cpp +++ b/hiro/windows/utility.cpp @@ -1,11 +1,11 @@ namespace hiro { -static const unsigned Windows2000 = 0x0500; -static const unsigned WindowsXP = 0x0501; -static const unsigned WindowsVista = 0x0600; -static const unsigned Windows7 = 0x0601; +static const uint Windows2000 = 0x0500; +static const uint WindowsXP = 0x0501; +static const uint WindowsVista = 0x0600; +static const uint Windows7 = 0x0601; -static auto Button_CustomDraw(HWND, PAINTSTRUCT&, bool, bool, bool, unsigned, const Font&, const Image&, Orientation, const string&) -> void; +static auto Button_CustomDraw(HWND, PAINTSTRUCT&, bool, bool, bool, unsigned, const Font&, const image&, Orientation, const string&) -> void; static auto OsVersion() -> unsigned { OSVERSIONINFO versionInfo{0}; @@ -34,33 +34,6 @@ static auto CreateBitmap(image icon) -> HBITMAP { return hbitmap; } -static auto CreateBitmap(const Image& image) -> HBITMAP { - HDC hdc = GetDC(0); - BITMAPINFO bitmapInfo{0}; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = image.width(); - bitmapInfo.bmiHeader.biHeight = -image.height(); //bitmaps are stored upside down unless we negate height - bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; - bitmapInfo.bmiHeader.biCompression = BI_RGB; - bitmapInfo.bmiHeader.biSizeImage = image.width() * image.height() * sizeof(uint32_t); - void* bits = nullptr; - HBITMAP hbitmap = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &bits, nullptr, 0); - if(bits) { - auto source = (const uint8_t*)image.data(); - auto target = (uint8_t*)bits; - for(auto n : range(image.width() * image.height())) { - target[0] = (source[0] * source[3]) / 255; - target[1] = (source[1] * source[3]) / 255; - target[2] = (source[2] * source[3]) / 255; - target[3] = (source[3]); - source += 4, target += 4; - } - } - ReleaseDC(0, hdc); - return hbitmap; -} - static auto CreateRGB(const Color& color) -> COLORREF { return RGB(color.red(), color.green(), color.blue()); } @@ -93,11 +66,8 @@ static auto GetWindowZOrder(HWND hwnd) -> unsigned { return z; } -static auto ImageList_Append(HIMAGELIST imageList, const Image& image, unsigned scale) -> void { - nall::image icon; - if(image) { - icon.allocate(image.width(), image.height()); - memory::copy(icon.data(), image.data(), icon.size()); +static auto ImageList_Append(HIMAGELIST imageList, image icon, unsigned scale) -> void { + if(icon) { icon.scale(scale, scale); } else { icon.allocate(scale, scale); diff --git a/hiro/windows/widget/button.cpp b/hiro/windows/widget/button.cpp index 5c2c30e8..4a2b8edf 100644 --- a/hiro/windows/widget/button.cpp +++ b/hiro/windows/widget/button.cpp @@ -3,13 +3,13 @@ namespace hiro { static auto Button_paintProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, - bool bordered, bool checked, bool enabled, const Font& font, const Image& image, Orientation orientation, const string& text + bool bordered, bool checked, bool enabled, const Font& font, const image& icon, Orientation orientation, const string& text ) -> LRESULT { if(msg == WM_PAINT) { PAINTSTRUCT ps; BeginPaint(hwnd, &ps); auto state = Button_GetState(hwnd); - Button_CustomDraw(hwnd, ps, bordered, checked, enabled, state, font, image, orientation, text); + Button_CustomDraw(hwnd, ps, bordered, checked, enabled, state, font, icon, orientation, text); EndPaint(hwnd, &ps); } return DefWindowProc(hwnd, msg, wparam, lparam); @@ -27,7 +27,7 @@ static auto CALLBACK Button_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARA if(msg == WM_ERASEBKGND) return DefWindowProc(hwnd, msg, wparam, lparam); if(msg == WM_PAINT) return Button_paintProc(hwnd, msg, wparam, lparam, button->state.bordered, false, button->enabled(true), button->font(true), - button->state.image, button->state.orientation, button->state.text + button->state.icon, button->state.orientation, button->state.text ); return self->windowProc(hwnd, msg, wparam, lparam); } @@ -53,16 +53,16 @@ auto pButton::destruct() -> void { } auto pButton::minimumSize() const -> Size { - Size image = state().image.size(); + Size icon = {(int)state().icon.width(), (int)state().icon.height()}; Size text = state().text ? pFont::size(self().font(true), state().text) : Size{}; Size size; if(state().orientation == Orientation::Horizontal) { - size.setWidth(image.width() + (image && text ? 5 : 0) + text.width()); - size.setHeight(max(image.height(), text.height())); + size.setWidth(icon.width() + (icon && text ? 5 : 0) + text.width()); + size.setHeight(max(icon.height(), text.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(image.width(), text.width())); - size.setHeight(image.height() + (image && text ? 5 : 0) + text.height()); + size.setWidth(max(icon.width(), text.width())); + size.setHeight(icon.height() + (icon && text ? 5 : 0) + text.height()); } size.setHeight(max(size.height(), pFont::size(self().font(true), " ").height())); return {size.width() + (state().bordered && text ? 20 : 10), size.height() + 10}; @@ -82,7 +82,7 @@ auto pButton::setFont(const Font& font) -> void { _setState(); } -auto pButton::setImage(const Image& image) -> void { +auto pButton::setIcon(const image& icon) -> void { _setState(); } @@ -108,11 +108,11 @@ auto pButton::_setState() -> void { } //this function is designed to be used with Button, CheckButton, and RadioButton -auto Button_CustomDraw(HWND hwnd, PAINTSTRUCT& ps, bool bordered, bool checked, bool enabled, unsigned state, const Font& font, const Image& image, Orientation orientation, const string& text) -> void { +auto Button_CustomDraw(HWND hwnd, PAINTSTRUCT& ps, bool bordered, bool checked, bool enabled, unsigned state, const Font& font, const image& icon, Orientation orientation, const string& text) -> void { RECT rc; GetClientRect(hwnd, &rc); - Geometry geometry{rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top}, imageGeometry, textGeometry; - if(image) imageGeometry.setSize(image.size()); + Geometry geometry{rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top}, iconGeometry, textGeometry; + if(icon) iconGeometry.setSize({(int)icon.width(), (int)icon.height()}); if(text) textGeometry.setSize(pFont::size(font, text)); Position position; @@ -120,15 +120,15 @@ auto Button_CustomDraw(HWND hwnd, PAINTSTRUCT& ps, bool bordered, bool checked, switch(orientation) { case Orientation::Horizontal: - size = {imageGeometry.width() + (image && text ? 5 : 0) + textGeometry.width(), max(imageGeometry.height(), textGeometry.height())}; + size = {iconGeometry.width() + (icon && text ? 5 : 0) + textGeometry.width(), max(iconGeometry.height(), textGeometry.height())}; position = {(geometry.width() - size.width()) / 2, (geometry.height() - size.height()) / 2}; - imageGeometry.setPosition({position.x(), position.y() + (size.height() - imageGeometry.height()) / 2}); + iconGeometry.setPosition({position.x(), position.y() + (size.height() - iconGeometry.height()) / 2}); textGeometry.setPosition({position.x() + size.width() - textGeometry.width(), position.y() + (size.height() - textGeometry.height()) / 2}); break; case Orientation::Vertical: - size = {max(imageGeometry.width(), textGeometry.width()), imageGeometry.height() + (image && text ? 5 : 0) + textGeometry.height()}; + size = {max(iconGeometry.width(), textGeometry.width()), iconGeometry.height() + (icon && text ? 5 : 0) + textGeometry.height()}; position = {(geometry.width() - size.width()) / 2, (geometry.height() - size.height()) / 2}; - imageGeometry.setPosition({position.x() + (size.width() - imageGeometry.width()) / 2, position.y()}); + iconGeometry.setPosition({position.x() + (size.width() - iconGeometry.width()) / 2, position.y()}); textGeometry.setPosition({position.x() + (size.width() - textGeometry.width()) / 2, position.y() + size.height() - textGeometry.height()}); break; } @@ -154,14 +154,14 @@ auto Button_CustomDraw(HWND hwnd, PAINTSTRUCT& ps, bool bordered, bool checked, if(!(state & BST_PUSHED) && !(state & BST_HOT)) DrawFocusRect(ps.hdc, &rcFocus); } - if(image) { + if(icon) { HDC hdcSource = CreateCompatibleDC(ps.hdc); - auto bitmap = CreateBitmap(image); + auto bitmap = CreateBitmap(icon); SelectBitmap(hdcSource, bitmap); BLENDFUNCTION blend{AC_SRC_OVER, 0, (BYTE)(IsWindowEnabled(hwnd) ? 255 : 128), AC_SRC_ALPHA}; AlphaBlend( - ps.hdc, imageGeometry.x(), imageGeometry.y(), image.width(), image.height(), - hdcSource, 0, 0, image.width(), image.height(), blend + ps.hdc, iconGeometry.x(), iconGeometry.y(), icon.width(), icon.height(), + hdcSource, 0, 0, icon.width(), icon.height(), blend ); DeleteObject(bitmap); DeleteDC(hdcSource); diff --git a/hiro/windows/widget/button.hpp b/hiro/windows/widget/button.hpp index 3ff16470..44bd313b 100644 --- a/hiro/windows/widget/button.hpp +++ b/hiro/windows/widget/button.hpp @@ -9,7 +9,7 @@ struct pButton : pWidget { auto setBordered(bool bordered) -> void; auto setEnabled(bool enabled) -> void override; auto setFont(const Font& font) -> void override; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; auto setVisible(bool visible) -> void override; diff --git a/hiro/windows/widget/canvas.cpp b/hiro/windows/widget/canvas.cpp index 6118e6e4..f4f23127 100644 --- a/hiro/windows/widget/canvas.cpp +++ b/hiro/windows/widget/canvas.cpp @@ -69,7 +69,7 @@ auto pCanvas::destruct() -> void { } auto pCanvas::minimumSize() const -> Size { - if(auto& image = state().image) return image.size(); + if(auto& icon = state().icon) return {(int)icon.width(), (int)icon.height()}; return {0, 0}; } @@ -90,7 +90,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void { update(); } -auto pCanvas::setImage(const Image& image) -> void { +auto pCanvas::setIcon(const image& icon) -> void { update(); } @@ -112,12 +112,12 @@ auto pCanvas::_paint() -> void { bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biHeight = -height; //GDI stores bitmaps upside now; negative height flips bitmap - bmi.bmiHeader.biSizeImage = pixels.size() * sizeof(uint32_t); + bmi.bmiHeader.biSizeImage = pixels.size() * sizeof(uint32); void* bits = nullptr; HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &bits, nullptr, 0); if(bits) { - auto source = (const uint8_t*)pixels.data(); - auto target = (uint8_t*)bits; + auto source = (const uint8*)pixels.data(); + auto target = (uint8*)bits; for(auto n : range(width * height)) { target[0] = (source[0] * source[3]) / 255; target[1] = (source[1] * source[3]) / 255; @@ -142,9 +142,9 @@ auto pCanvas::_paint() -> void { } auto pCanvas::_rasterize() -> void { - if(auto& image = state().image) { - width = image.width(); - height = image.height(); + if(auto& icon = state().icon) { + width = icon.width(); + height = icon.height(); } else { width = self().geometry().width(); height = self().geometry().height(); @@ -153,16 +153,16 @@ auto pCanvas::_rasterize() -> void { pixels.reallocate(width * height); - if(auto& image = state().image) { - memory::copy(pixels.data(), image.data(), width * height * sizeof(uint32_t)); + if(auto& icon = state().icon) { + memory::copy(pixels.data(), icon.data(), width * height * sizeof(uint32)); } else if(auto& gradient = state().gradient) { auto& colors = gradient.state.colors; - nall::image fill; + image fill; fill.allocate(width, height); fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value()); memory::copy(pixels.data(), fill.data(), fill.size()); } else { - uint32_t color = state().color.value(); + uint32 color = state().color.value(); for(auto& pixel : pixels) pixel = color; } } diff --git a/hiro/windows/widget/canvas.hpp b/hiro/windows/widget/canvas.hpp index a76f5cfb..1adcd9a7 100644 --- a/hiro/windows/widget/canvas.hpp +++ b/hiro/windows/widget/canvas.hpp @@ -10,7 +10,7 @@ struct pCanvas : pWidget { auto setDroppable(bool droppable) -> void; auto setGeometry(Geometry geometry) -> void override; auto setGradient(Gradient gradient) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto update() -> void; auto _paint() -> void; diff --git a/hiro/windows/widget/check-button.cpp b/hiro/windows/widget/check-button.cpp index 7da36753..ef5e93b5 100644 --- a/hiro/windows/widget/check-button.cpp +++ b/hiro/windows/widget/check-button.cpp @@ -9,7 +9,7 @@ static auto CALLBACK CheckButton_windowProc(HWND hwnd, UINT msg, WPARAM wparam, if(msg == WM_ERASEBKGND) return DefWindowProc(hwnd, msg, wparam, lparam); if(msg == WM_PAINT) return Button_paintProc(hwnd, msg, wparam, lparam, button->state.bordered, button->state.checked, button->enabled(true), button->font(true), - button->state.image, button->state.orientation, button->state.text + button->state.icon, button->state.orientation, button->state.text ); return self->windowProc(hwnd, msg, wparam, lparam); } @@ -35,16 +35,16 @@ auto pCheckButton::destruct() -> void { } auto pCheckButton::minimumSize() const -> Size { - Size image = state().image.size(); + Size icon = {(int)state().icon.width(), (int)state().icon.height()}; Size text = state().text ? pFont::size(self().font(true), state().text) : Size{}; Size size; if(state().orientation == Orientation::Horizontal) { - size.setWidth(image.width() + (image && text ? 5 : 0) + text.width()); - size.setHeight(max(image.height(), text.height())); + size.setWidth(icon.width() + (icon && text ? 5 : 0) + text.width()); + size.setHeight(max(icon.height(), text.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(image.width(), text.width())); - size.setHeight(image.height() + (image && text ? 5 : 0) + text.height()); + size.setWidth(max(icon.width(), text.width())); + size.setHeight(icon.height() + (icon && text ? 5 : 0) + text.height()); } size.setHeight(max(size.height(), pFont::size(self().font(true), " ").height())); return {size.width() + (state().bordered && text ? 20 : 10), size.height() + 10}; @@ -68,7 +68,7 @@ auto pCheckButton::setFont(const Font& font) -> void { _setState(); } -auto pCheckButton::setImage(const Image& image) -> void { +auto pCheckButton::setIcon(const image& icon) -> void { _setState(); } diff --git a/hiro/windows/widget/check-button.hpp b/hiro/windows/widget/check-button.hpp index 62ab9a82..1de6eed5 100644 --- a/hiro/windows/widget/check-button.hpp +++ b/hiro/windows/widget/check-button.hpp @@ -10,7 +10,7 @@ struct pCheckButton : pWidget { auto setEnabled(bool enabled) -> void override; auto setFont(const Font& font) -> void override; auto setChecked(bool checked) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; auto setVisible(bool visible) -> void override; diff --git a/hiro/windows/widget/combo-button-item.cpp b/hiro/windows/widget/combo-button-item.cpp index dc802202..0b8b1a0e 100644 --- a/hiro/windows/widget/combo-button-item.cpp +++ b/hiro/windows/widget/combo-button-item.cpp @@ -8,7 +8,7 @@ auto pComboButtonItem::construct() -> void { auto pComboButtonItem::destruct() -> void { } -auto pComboButtonItem::setImage(const Image& image) -> void { +auto pComboButtonItem::setIcon(const image& icon) -> void { //unsupported } diff --git a/hiro/windows/widget/combo-button-item.hpp b/hiro/windows/widget/combo-button-item.hpp index 045996ab..335e489a 100644 --- a/hiro/windows/widget/combo-button-item.hpp +++ b/hiro/windows/widget/combo-button-item.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pComboButtonItem : pObject { Declare(ComboButtonItem, Object) - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/windows/widget/frame.cpp b/hiro/windows/widget/frame.cpp index 9e5a961d..e844c118 100644 --- a/hiro/windows/widget/frame.cpp +++ b/hiro/windows/widget/frame.cpp @@ -15,6 +15,12 @@ auto pFrame::destruct() -> void { DestroyWindow(hwnd); } +auto pFrame::append(sLayout layout) -> void { +} + +auto pFrame::remove(sLayout layout) -> void { +} + auto pFrame::setEnabled(bool enabled) -> void { if(auto layout = state().layout) layout->setEnabled(layout->enabled()); pWidget::setEnabled(enabled); diff --git a/hiro/windows/widget/frame.hpp b/hiro/windows/widget/frame.hpp index 32e2c92f..7587893e 100644 --- a/hiro/windows/widget/frame.hpp +++ b/hiro/windows/widget/frame.hpp @@ -5,6 +5,8 @@ namespace hiro { struct pFrame : pWidget { Declare(Frame, Widget) + auto append(sLayout layout) -> void; + auto remove(sLayout layout) -> void; auto setEnabled(bool enabled) -> void override; auto setGeometry(Geometry geometry) -> void override; auto setText(const string& text) -> void; diff --git a/hiro/windows/widget/list-view-cell.cpp b/hiro/windows/widget/list-view-cell.cpp index f37b62b6..0b912aae 100644 --- a/hiro/windows/widget/list-view-cell.cpp +++ b/hiro/windows/widget/list-view-cell.cpp @@ -27,7 +27,7 @@ auto pListViewCell::setForegroundColor(Color color) -> void { _repaint(); } -auto pListViewCell::setImage(const Image& icon) -> void { +auto pListViewCell::setIcon(const image& icon) -> void { _repaint(); } diff --git a/hiro/windows/widget/list-view-cell.hpp b/hiro/windows/widget/list-view-cell.hpp index 4cc0e0d0..d5c62923 100644 --- a/hiro/windows/widget/list-view-cell.hpp +++ b/hiro/windows/widget/list-view-cell.hpp @@ -10,7 +10,7 @@ struct pListViewCell : pObject { auto setCheckable(bool checkable) -> void; auto setChecked(bool checked) -> void; auto setForegroundColor(Color color) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; auto _parent() -> maybe; diff --git a/hiro/windows/widget/list-view-column.cpp b/hiro/windows/widget/list-view-column.cpp index 06a1b26c..ef2871b3 100644 --- a/hiro/windows/widget/list-view-column.cpp +++ b/hiro/windows/widget/list-view-column.cpp @@ -49,7 +49,7 @@ auto pListViewColumn::setHorizontalAlignment(double alignment) -> void { _setState(); } -auto pListViewColumn::setImage(const Image& image) -> void { +auto pListViewColumn::setIcon(const image& icon) -> void { _setState(); } @@ -97,7 +97,7 @@ auto pListViewColumn::_setState() -> void { lvColumn.cx = _width; if(state().horizontalAlignment < 0.333) lvColumn.fmt = LVCFMT_LEFT; if(state().horizontalAlignment > 0.666) lvColumn.fmt = LVCFMT_RIGHT; - if(state().image) lvColumn.mask |= LVCF_IMAGE; + if(state().icon) lvColumn.mask |= LVCF_IMAGE; if(!state().resizable) lvColumn.fmt |= LVCFMT_FIXED_WIDTH; ListView_SetColumn(grandparent->hwnd, self().offset(), &lvColumn); grandparent->unlock(); diff --git a/hiro/windows/widget/list-view-column.hpp b/hiro/windows/widget/list-view-column.hpp index bf13aeac..2c00c654 100644 --- a/hiro/windows/widget/list-view-column.hpp +++ b/hiro/windows/widget/list-view-column.hpp @@ -12,7 +12,7 @@ struct pListViewColumn : pObject { auto setExpandable(bool expandable) -> void; auto setForegroundColor(Color color) -> void; auto setHorizontalAlignment(double alignment) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setResizable(bool resizable) -> void; auto setSortable(bool sortable) -> void; auto setText(const string& text) -> void; diff --git a/hiro/windows/widget/list-view.cpp b/hiro/windows/widget/list-view.cpp index be4bb980..fa561b20 100644 --- a/hiro/windows/widget/list-view.cpp +++ b/hiro/windows/widget/list-view.cpp @@ -218,11 +218,11 @@ auto pListView::onCustomDraw(LPARAM lparam) -> LRESULT { rc.left += 2; } - if(auto& image = cell->state.image) { - auto bitmap = CreateBitmap(image); + if(auto& icon = cell->state.icon) { + auto bitmap = CreateBitmap(icon); SelectBitmap(hdcSource, bitmap); BLENDFUNCTION blend{AC_SRC_OVER, 0, (BYTE)(selected ? 128 : 255), AC_SRC_ALPHA}; - AlphaBlend(hdc, rc.left, rc.top, iconSize, iconSize, hdcSource, 0, 0, image.width(), image.height(), blend); + AlphaBlend(hdc, rc.left, rc.top, iconSize, iconSize, hdcSource, 0, 0, icon.width(), icon.height(), blend); DeleteObject(bitmap); rc.left += iconSize + 2; } @@ -322,7 +322,7 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned { if(cell->state.checkable) { width += 16 + 2; } - if(auto& image = cell->state.image) { + if(auto& icon = cell->state.icon) { width += 16 + 2; } if(auto& text = cell->state.text) { @@ -337,7 +337,7 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned { unsigned width = 12; if(auto header = state().header) { if(auto column = header->column(_column)) { - if(auto& image = column->state.image) { + if(auto& icon = column->state.icon) { width += 16 + 12; //yes; icon spacing in column headers is excessive } if(auto& text = column->state.text) { @@ -384,10 +384,10 @@ auto pListView::_setIcons() -> void { if(auto& header = state().header) { for(auto column : range(header->columnCount())) { - nall::image icon; - if(auto& image = header->state.columns[column]->state.image) { - icon.allocate(image.width(), image.height()); - memory::copy(icon.data(), image.data(), icon.size()); + image icon; + if(auto& sourceIcon = header->state.columns[column]->state.icon) { + icon.allocate(sourceIcon.width(), sourceIcon.height()); + memory::copy(icon.data(), sourceIcon.data(), icon.size()); icon.scale(16, 16); } else { icon.allocate(16, 16); @@ -400,7 +400,7 @@ auto pListView::_setIcons() -> void { } //empty icon used for ListViewItems (drawn manually via onCustomDraw) - nall::image icon; + image icon; icon.allocate(16, 16); icon.fill(0x00ffffff); auto bitmap = CreateBitmap(icon); diff --git a/hiro/windows/widget/radio-button.cpp b/hiro/windows/widget/radio-button.cpp index fabba761..d0840483 100644 --- a/hiro/windows/widget/radio-button.cpp +++ b/hiro/windows/widget/radio-button.cpp @@ -9,7 +9,7 @@ static auto CALLBACK RadioButton_windowProc(HWND hwnd, UINT msg, WPARAM wparam, if(msg == WM_ERASEBKGND) return DefWindowProc(hwnd, msg, wparam, lparam); if(msg == WM_PAINT) return Button_paintProc(hwnd, msg, wparam, lparam, button->state.bordered, button->state.checked, button->enabled(true), button->font(true), - button->state.image, button->state.orientation, button->state.text + button->state.icon, button->state.orientation, button->state.text ); return self->windowProc(hwnd, msg, wparam, lparam); } @@ -35,16 +35,16 @@ auto pRadioButton::destruct() -> void { } auto pRadioButton::minimumSize() const -> Size { - Size image = state().image.size(); + Size icon = {(int)state().icon.width(), (int)state().icon.height()}; Size text = state().text ? pFont::size(self().font(true), state().text) : Size{}; Size size; if(state().orientation == Orientation::Horizontal) { - size.setWidth(image.width() + (image && text ? 5 : 0) + text.width()); - size.setHeight(max(image.height(), text.height())); + size.setWidth(icon.width() + (icon && text ? 5 : 0) + text.width()); + size.setHeight(max(icon.height(), text.height())); } if(state().orientation == Orientation::Vertical) { - size.setWidth(max(image.width(), text.width())); - size.setHeight(image.height() + (image && text ? 5 : 0) + text.height()); + size.setWidth(max(icon.width(), text.width())); + size.setHeight(icon.height() + (icon && text ? 5 : 0) + text.height()); } size.setHeight(max(size.height(), pFont::size(self().font(true), " ").height())); return {size.width() + (state().bordered && text ? 20 : 10), size.height() + 10}; @@ -94,7 +94,7 @@ auto pRadioButton::setGroup(sGroup group) -> void { } } -auto pRadioButton::setImage(const Image& image) -> void { +auto pRadioButton::setIcon(const image& icon) -> void { _setState(); } diff --git a/hiro/windows/widget/radio-button.hpp b/hiro/windows/widget/radio-button.hpp index 2a94db2f..dc0c5b3a 100644 --- a/hiro/windows/widget/radio-button.hpp +++ b/hiro/windows/widget/radio-button.hpp @@ -11,7 +11,7 @@ struct pRadioButton : pWidget { auto setEnabled(bool enabled) -> void override; auto setFont(const Font& font) -> void override; auto setGroup(sGroup group) -> void override; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setOrientation(Orientation orientation) -> void; auto setText(const string& text) -> void; auto setVisible(bool visible) -> void override; diff --git a/hiro/windows/widget/tab-frame-item.cpp b/hiro/windows/widget/tab-frame-item.cpp index e9615d50..2583d648 100644 --- a/hiro/windows/widget/tab-frame-item.cpp +++ b/hiro/windows/widget/tab-frame-item.cpp @@ -24,7 +24,7 @@ auto pTabFrameItem::setClosable(bool closable) -> void { //unsupported } -auto pTabFrameItem::setImage(const Image& image) -> void { +auto pTabFrameItem::setIcon(const image& icon) -> void { if(auto parent = _parent()) { parent->_buildImageList(); } diff --git a/hiro/windows/widget/tab-frame-item.hpp b/hiro/windows/widget/tab-frame-item.hpp index 37bef59d..d08a2696 100644 --- a/hiro/windows/widget/tab-frame-item.hpp +++ b/hiro/windows/widget/tab-frame-item.hpp @@ -8,7 +8,7 @@ struct pTabFrameItem : pObject { auto append(sLayout layout) -> void; auto remove(sLayout layout) -> void; auto setClosable(bool closable) -> void; - auto setImage(const Image& image) -> void; + auto setIcon(const image& icon) -> void; auto setMovable(bool movable) -> void; auto setSelected() -> void; auto setText(const string& text) -> void; diff --git a/hiro/windows/widget/tab-frame.cpp b/hiro/windows/widget/tab-frame.cpp index 3c320e71..09c246d6 100644 --- a/hiro/windows/widget/tab-frame.cpp +++ b/hiro/windows/widget/tab-frame.cpp @@ -39,7 +39,7 @@ auto pTabFrame::append(sTabFrameItem item) -> void { TabCtrl_InsertItem(hwnd, item->offset(), &tcItem); if(auto self = item->self()) { self->setClosable(item->state.closable); - self->setImage(item->state.image); + self->setIcon(item->state.icon); self->setMovable(item->state.movable); self->setText(item->state.text); if(item->selected()) self->setSelected(); @@ -94,13 +94,13 @@ auto pTabFrame::_buildImageList() -> void { if(imageList) { ImageList_Destroy(imageList); imageList = nullptr; } imageList = ImageList_Create(size, size, ILC_COLOR32, 1, 0); for(auto& item : state().items) { - ImageList_Append(imageList, item->state.image, size); + ImageList_Append(imageList, item->state.icon, size); } TabCtrl_SetImageList(hwnd, imageList); for(auto offset : range(state().items)) { TCITEM tcItem; tcItem.mask = TCIF_IMAGE; - tcItem.iImage = state().items[offset]->state.image ? offset : -1; + tcItem.iImage = state().items[offset]->state.icon ? offset : -1; TabCtrl_SetItem(hwnd, offset, &tcItem); } } diff --git a/icarus/ui/scan-dialog.cpp b/icarus/ui/scan-dialog.cpp index 4d0e917f..342be290 100644 --- a/icarus/ui/scan-dialog.cpp +++ b/icarus/ui/scan-dialog.cpp @@ -4,15 +4,15 @@ ScanDialog::ScanDialog() { onClose(&Application::quit); layout.setMargin(5); pathEdit.onActivate([&] { refresh(); }); - refreshButton.setImage(Icon::Action::Refresh).setBordered(false).onActivate([&] { + refreshButton.setIcon(Icon::Action::Refresh).setBordered(false).onActivate([&] { pathEdit.setText(settings["icarus/Path"].text()); refresh(); }); - homeButton.setImage(Icon::Go::Home).setBordered(false).onActivate([&] { + homeButton.setIcon(Icon::Go::Home).setBordered(false).onActivate([&] { pathEdit.setText(userpath()); refresh(); }); - upButton.setImage(Icon::Go::Up).setBordered(false).onActivate([&] { + upButton.setIcon(Icon::Go::Up).setBordered(false).onActivate([&] { pathEdit.setText(dirname(settings["icarus/Path"].text())); refresh(); }); @@ -59,13 +59,13 @@ auto ScanDialog::refresh() -> void { for(auto& name : contents) { if(!name.endsWith("/")) continue; if(gamePakType(suffixname(name))) continue; - scanList.append(ListViewItem().append(ListViewCell().setImage(Icon::Emblem::Folder).setText(name.rtrim("/")))); + scanList.append(ListViewItem().append(ListViewCell().setIcon(Icon::Emblem::Folder).setText(name.rtrim("/")))); } for(auto& name : contents) { if(name.endsWith("/")) continue; if(!gameRomType(suffixname(name).downcase())) continue; - scanList.append(ListViewItem().append(ListViewCell().setCheckable().setImage(Icon::Emblem::File).setText(name))); + scanList.append(ListViewItem().append(ListViewCell().setCheckable().setIcon(Icon::Emblem::File).setText(name))); } Application::processEvents(); diff --git a/nall/algorithm.hpp b/nall/algorithm.hpp index 89fec57d..612b2556 100644 --- a/nall/algorithm.hpp +++ b/nall/algorithm.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ALGORITHM_HPP -#define NALL_ALGORITHM_HPP +#pragma once #include @@ -25,5 +24,3 @@ template auto max(const T& t, const U& u, } }} - -#endif diff --git a/nall/any.hpp b/nall/any.hpp index 9ee09fea..ed1971e6 100644 --- a/nall/any.hpp +++ b/nall/any.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ANY_HPP -#define NALL_ANY_HPP +#pragma once #include #include @@ -83,5 +82,3 @@ private: }; } - -#endif diff --git a/nall/atoi.hpp b/nall/atoi.hpp index b07ca4b9..4fc639ee 100644 --- a/nall/atoi.hpp +++ b/nall/atoi.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ATOI_HPP -#define NALL_ATOI_HPP +#pragma once #include @@ -86,5 +85,3 @@ inline auto real(const char* s) -> double { } } - -#endif diff --git a/nall/beat/archive.hpp b/nall/beat/archive.hpp index a515ef5d..fab11225 100644 --- a/nall/beat/archive.hpp +++ b/nall/beat/archive.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_ARCHIVE_HPP -#define NALL_BEAT_ARCHIVE_HPP +#pragma once #include @@ -130,5 +129,3 @@ auto Archive::scan(lstring& result, const string& basename, const string& pathna } }} - -#endif diff --git a/nall/beat/delta.hpp b/nall/beat/delta.hpp index b1f4fe91..12482682 100644 --- a/nall/beat/delta.hpp +++ b/nall/beat/delta.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_DELTA_HPP -#define NALL_BEAT_DELTA_HPP +#pragma once #include #include @@ -209,5 +208,3 @@ auto bpsdelta::create(const string& filename, const string& metadata) -> bool { } } - -#endif diff --git a/nall/beat/file.hpp b/nall/beat/file.hpp index 37593900..f3f4f496 100644 --- a/nall/beat/file.hpp +++ b/nall/beat/file.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_FILE_HPP -#define NALL_BEAT_FILE_HPP +#pragma once namespace nall { namespace Beat { @@ -22,5 +21,3 @@ auto File::write(uint8_t data) -> void { } }} - -#endif diff --git a/nall/beat/linear.hpp b/nall/beat/linear.hpp index 5a3a2cc7..0f677671 100644 --- a/nall/beat/linear.hpp +++ b/nall/beat/linear.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_LINEAR_HPP -#define NALL_BEAT_LINEAR_HPP +#pragma once #include #include @@ -147,5 +146,3 @@ auto bpslinear::create(const string& filename, const string& metadata) -> bool { } } - -#endif diff --git a/nall/beat/metadata.hpp b/nall/beat/metadata.hpp index aa9161ce..d924a349 100644 --- a/nall/beat/metadata.hpp +++ b/nall/beat/metadata.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_METADATA_HPP -#define NALL_BEAT_METADATA_HPP +#pragma once #include #include @@ -116,5 +115,3 @@ auto bpsmetadata::metadata() const -> string { } } - -#endif diff --git a/nall/beat/multi.hpp b/nall/beat/multi.hpp index 6174e964..f6f9be6a 100644 --- a/nall/beat/multi.hpp +++ b/nall/beat/multi.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_MULTI_HPP -#define NALL_BEAT_MULTI_HPP +#pragma once #include #include @@ -238,5 +237,3 @@ protected: }; } - -#endif diff --git a/nall/beat/patch.hpp b/nall/beat/patch.hpp index 82f9759f..f8f01058 100644 --- a/nall/beat/patch.hpp +++ b/nall/beat/patch.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BEAT_PATCH_HPP -#define NALL_BEAT_PATCH_HPP +#pragma once #include #include @@ -213,5 +212,3 @@ auto bpspatch::apply() -> result { } } - -#endif diff --git a/nall/bit.hpp b/nall/bit.hpp index 818313e4..e182104a 100644 --- a/nall/bit.hpp +++ b/nall/bit.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BIT_HPP -#define NALL_BIT_HPP +#pragma once #include @@ -84,5 +83,3 @@ namespace bit { } } - -#endif diff --git a/nall/bitvector.hpp b/nall/bitvector.hpp index aa218a39..77b5955b 100644 --- a/nall/bitvector.hpp +++ b/nall/bitvector.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_BITVECTOR_HPP -#define NALL_BITVECTOR_HPP +#pragma once #include @@ -115,5 +114,3 @@ protected: }; } - -#endif diff --git a/nall/config.hpp b/nall/config.hpp index 3c560a38..3201cfe9 100644 --- a/nall/config.hpp +++ b/nall/config.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_CONFIG_HPP -#define NALL_CONFIG_HPP +#pragma once #include #include @@ -111,5 +110,3 @@ struct Document : Node { } } - -#endif diff --git a/nall/database/odbc.hpp b/nall/database/odbc.hpp index 423be10e..a714c6ac 100644 --- a/nall/database/odbc.hpp +++ b/nall/database/odbc.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DATABASE_ODBC_HPP -#define NALL_DATABASE_ODBC_HPP +#pragma once #include @@ -296,5 +295,3 @@ private: }; }} - -#endif diff --git a/nall/database/sqlite3.hpp b/nall/database/sqlite3.hpp index a1b5d0d2..b78cf41f 100644 --- a/nall/database/sqlite3.hpp +++ b/nall/database/sqlite3.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DATABASE_SQLITE3_HPP -#define NALL_DATABASE_SQLITE3_HPP +#pragma once /* SQLite3 C++ RAII wrapper for nall * @@ -202,5 +201,3 @@ protected: }; }} - -#endif diff --git a/nall/decode/base64.hpp b/nall/decode/base64.hpp index bbf1df36..48661dd9 100644 --- a/nall/decode/base64.hpp +++ b/nall/decode/base64.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_BASE64_HPP -#define NALL_DECODE_BASE64_HPP +#pragma once namespace nall { namespace Decode { @@ -45,5 +44,3 @@ inline auto Base64(const string& text) -> vector { } }} - -#endif diff --git a/nall/decode/bmp.hpp b/nall/decode/bmp.hpp index 2d7a0436..17b094cc 100644 --- a/nall/decode/bmp.hpp +++ b/nall/decode/bmp.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_BMP_HPP -#define NALL_DECODE_BMP_HPP +#pragma once namespace nall { namespace Decode { @@ -75,5 +74,3 @@ private: }; }} - -#endif diff --git a/nall/decode/gzip.hpp b/nall/decode/gzip.hpp index 4a46a0e7..75985e9a 100644 --- a/nall/decode/gzip.hpp +++ b/nall/decode/gzip.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_GZIP_HPP -#define NALL_DECODE_GZIP_HPP +#pragma once #include #include @@ -77,5 +76,3 @@ auto GZIP::decompress(const uint8* data, uint size) -> bool { } }} - -#endif diff --git a/nall/decode/inflate.hpp b/nall/decode/inflate.hpp index 13c11d14..884358f2 100644 --- a/nall/decode/inflate.hpp +++ b/nall/decode/inflate.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_INFLATE_HPP -#define NALL_DECODE_INFLATE_HPP +#pragma once #include @@ -345,5 +344,3 @@ inline auto puff( } }} - -#endif diff --git a/nall/decode/png.hpp b/nall/decode/png.hpp index c215ec6b..e68736e9 100644 --- a/nall/decode/png.hpp +++ b/nall/decode/png.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_PNG_HPP -#define NALL_DECODE_PNG_HPP +#pragma once #include #include @@ -331,5 +330,3 @@ auto PNG::readbits(const uint8*& data) -> uint { } }} - -#endif diff --git a/nall/decode/url.hpp b/nall/decode/url.hpp index 45df16d8..9bbfdfde 100644 --- a/nall/decode/url.hpp +++ b/nall/decode/url.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_URL_HPP -#define NALL_DECODE_URL_HPP +#pragma once namespace nall { namespace Decode { @@ -32,5 +31,3 @@ inline auto URL(const string& input) -> string { } }} - -#endif diff --git a/nall/decode/zip.hpp b/nall/decode/zip.hpp index c7445144..637ec395 100644 --- a/nall/decode/zip.hpp +++ b/nall/decode/zip.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DECODE_ZIP_HPP -#define NALL_DECODE_ZIP_HPP +#pragma once #include #include @@ -122,5 +121,3 @@ public: }; }} - -#endif diff --git a/nall/directory.hpp b/nall/directory.hpp index ead023eb..3246324f 100644 --- a/nall/directory.hpp +++ b/nall/directory.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DIRECTORY_HPP -#define NALL_DIRECTORY_HPP +#pragma once #include #include @@ -234,5 +233,3 @@ private: #endif } - -#endif diff --git a/nall/dl.hpp b/nall/dl.hpp index b7b1e653..46d6a10f 100644 --- a/nall/dl.hpp +++ b/nall/dl.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DL_HPP -#define NALL_DL_HPP +#pragma once //dynamic linking support @@ -125,5 +124,3 @@ inline auto library::close() -> void {} #endif } - -#endif diff --git a/nall/dsp.hpp b/nall/dsp.hpp index 3f12a22a..4a3ffc08 100644 --- a/nall/dsp.hpp +++ b/nall/dsp.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_DSP_HPP -#define NALL_DSP_HPP +#pragma once #include @@ -8,8 +7,4 @@ #include #endif -#define NALL_DSP_INTERNAL_HPP #include -#undef NALL_DSP_INTERNAL_HPP - -#endif diff --git a/nall/dsp/buffer.hpp b/nall/dsp/buffer.hpp index 27bcef99..f488c647 100644 --- a/nall/dsp/buffer.hpp +++ b/nall/dsp/buffer.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct Buffer { Buffer() { @@ -48,5 +48,3 @@ struct Buffer { uint16 wroffset = 0; uint channels = 0; }; - -#endif diff --git a/nall/dsp/core.hpp b/nall/dsp/core.hpp index 73aa89a3..f2735783 100644 --- a/nall/dsp/core.hpp +++ b/nall/dsp/core.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once #include #include @@ -162,5 +162,3 @@ auto DSP::clear() -> void { } } - -#endif diff --git a/nall/dsp/resample/average.hpp b/nall/dsp/resample/average.hpp index 2051fe8c..c98b7fef 100644 --- a/nall/dsp/resample/average.hpp +++ b/nall/dsp/resample/average.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleAverage : Resampler { ResampleAverage(DSP& dsp) : Resampler(dsp) {} @@ -70,5 +70,3 @@ auto ResampleAverage::sampleLinear() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/cosine.hpp b/nall/dsp/resample/cosine.hpp index 40665284..68c0a445 100644 --- a/nall/dsp/resample/cosine.hpp +++ b/nall/dsp/resample/cosine.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleCosine : Resampler { ResampleCosine(DSP& dsp) : Resampler(dsp) {} @@ -42,5 +42,3 @@ auto ResampleCosine::sample() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/cubic.hpp b/nall/dsp/resample/cubic.hpp index 90039e71..1b297d93 100644 --- a/nall/dsp/resample/cubic.hpp +++ b/nall/dsp/resample/cubic.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleCubic : Resampler { ResampleCubic(DSP& dsp) : Resampler(dsp) {} @@ -48,5 +48,3 @@ auto ResampleCubic::sample() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/hermite.hpp b/nall/dsp/resample/hermite.hpp index 0a79bf4f..a6215e01 100644 --- a/nall/dsp/resample/hermite.hpp +++ b/nall/dsp/resample/hermite.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleHermite : Resampler { ResampleHermite(DSP& dsp) : Resampler(dsp) {} @@ -60,5 +60,3 @@ auto ResampleHermite::sample() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/linear.hpp b/nall/dsp/resample/linear.hpp index 03f010c6..b7aa7ece 100644 --- a/nall/dsp/resample/linear.hpp +++ b/nall/dsp/resample/linear.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleLinear : Resampler { ResampleLinear(DSP& dsp) : Resampler(dsp) {} @@ -41,5 +41,3 @@ auto ResampleLinear::sample() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/nearest.hpp b/nall/dsp/resample/nearest.hpp index a110679e..50d6da71 100644 --- a/nall/dsp/resample/nearest.hpp +++ b/nall/dsp/resample/nearest.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once struct ResampleNearest : Resampler { ResampleNearest(DSP& dsp) : Resampler(dsp) {} @@ -41,5 +41,3 @@ auto ResampleNearest::sample() -> void { dsp.buffer.rdoffset++; fraction -= 1.0; } - -#endif diff --git a/nall/dsp/resample/sinc.hpp b/nall/dsp/resample/sinc.hpp index 65ca10f3..e39e9fe1 100644 --- a/nall/dsp/resample/sinc.hpp +++ b/nall/dsp/resample/sinc.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once #include "lib/sinc.hpp" @@ -60,5 +60,3 @@ auto ResampleSinc::remakeSinc() -> void { sincResampler[c] = new SincResample(dsp.settings.frequency, frequency, 0.85, SincResample::QUALITY_HIGH); } } - -#endif diff --git a/nall/dsp/settings.hpp b/nall/dsp/settings.hpp index a7b766dd..3254c147 100644 --- a/nall/dsp/settings.hpp +++ b/nall/dsp/settings.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_DSP_INTERNAL_HPP +#pragma once auto DSP::setChannels(uint channels) -> void { channels = max(1u, channels); @@ -44,5 +44,3 @@ auto DSP::setResamplerFrequency(double frequency) -> void { resampler->frequency = frequency; resampler->setFrequency(); } - -#endif diff --git a/nall/emulation/super-famicom-usart.hpp b/nall/emulation/super-famicom-usart.hpp index 92c5c7a0..0dbc87ba 100644 --- a/nall/emulation/super-famicom-usart.hpp +++ b/nall/emulation/super-famicom-usart.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_EMULATION_SUPER_FAMICOM_USART_HPP -#define NALL_EMULATION_SUPER_FAMICOM_USART_HPP +#pragma once #include #include @@ -11,20 +10,20 @@ using namespace nall; #define usartproc dllexport -static function usart_quit; -static function usart_usleep; -static function usart_readable; -static function usart_read; -static function usart_writable; -static function usart_write; +static function bool> usart_quit; +static function void> usart_usleep; +static function bool> usart_readable; +static function uint8> usart_read; +static function bool> usart_writable; +static function void> usart_write; extern "C" usartproc auto usart_init( - function quit, - function usleep, - function readable, - function read, - function writable, - function write + function bool> quit, + function void> usleep, + function bool> readable, + function uint8> read, + function bool> writable, + function void> write ) -> void { usart_quit = quit; usart_usleep = usleep; @@ -96,5 +95,3 @@ auto nall::main(lstring args) -> void { usart_main(args); usart.close(); } - -#endif diff --git a/nall/encode/base64.hpp b/nall/encode/base64.hpp index fb130a34..46fa5f5f 100644 --- a/nall/encode/base64.hpp +++ b/nall/encode/base64.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ENCODE_BASE64_HPP -#define NALL_ENCODE_BASE64_HPP +#pragma once namespace nall { namespace Encode { @@ -66,5 +65,3 @@ inline auto Base64(const string& text, const string& format = "MIME") -> string } }} - -#endif diff --git a/nall/encode/bmp.hpp b/nall/encode/bmp.hpp index 7e22bbf5..2aa037ff 100644 --- a/nall/encode/bmp.hpp +++ b/nall/encode/bmp.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ENCODE_BMP_HPP -#define NALL_ENCODE_BMP_HPP +#pragma once namespace nall { namespace Encode { @@ -45,5 +44,3 @@ struct BMP { }; }} - -#endif diff --git a/nall/encode/url.hpp b/nall/encode/url.hpp index 57fc6602..7a95921d 100644 --- a/nall/encode/url.hpp +++ b/nall/encode/url.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ENCODE_URL_HPP -#define NALL_ENCODE_URL_HPP +#pragma once namespace nall { namespace Encode { @@ -21,5 +20,3 @@ inline auto URL(const string& input) -> string { } }} - -#endif diff --git a/nall/encode/zip.hpp b/nall/encode/zip.hpp index a927ab5b..c6beae2a 100644 --- a/nall/encode/zip.hpp +++ b/nall/encode/zip.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ENCODE_ZIP_HPP -#define NALL_ENCODE_ZIP_HPP +#pragma once //creates uncompressed ZIP archives @@ -91,5 +90,3 @@ protected: }; }} - -#endif diff --git a/nall/endian.hpp b/nall/endian.hpp index 1f834b5b..f08a7427 100644 --- a/nall/endian.hpp +++ b/nall/endian.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_ENDIAN_HPP -#define NALL_ENDIAN_HPP +#pragma once #include @@ -38,5 +37,3 @@ #else #error "Unknown endian. Please specify in nall/intrinsics.hpp" #endif - -#endif diff --git a/nall/file-system-object.hpp b/nall/file-system-object.hpp index f9114b56..a418cc6a 100644 --- a/nall/file-system-object.hpp +++ b/nall/file-system-object.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STORAGE_HPP -#define NALL_STORAGE_HPP +#pragma once //generic abstraction layer for common storage operations against both files and directories //these functions are not recursive; use directory::create() and directory::remove() for recursion @@ -77,5 +76,3 @@ struct file_system_object { }; } - -#endif diff --git a/nall/file.hpp b/nall/file.hpp index 9e6a65c7..b659a245 100644 --- a/nall/file.hpp +++ b/nall/file.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_FILE_HPP -#define NALL_FILE_HPP +#pragma once #include #include @@ -330,5 +329,3 @@ private: }; } - -#endif diff --git a/nall/filemap.hpp b/nall/filemap.hpp index 5020ccfe..2a2870ce 100644 --- a/nall/filemap.hpp +++ b/nall/filemap.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_FILEMAP_HPP -#define NALL_FILEMAP_HPP +#pragma once #include #include @@ -213,5 +212,3 @@ private: }; } - -#endif diff --git a/nall/function.hpp b/nall/function.hpp index 1f4e74a1..14eebb49 100644 --- a/nall/function.hpp +++ b/nall/function.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_FUNCTION_HPP -#define NALL_FUNCTION_HPP +#pragma once #include @@ -69,5 +68,3 @@ private: }; } - -#endif diff --git a/nall/hash/crc16.hpp b/nall/hash/crc16.hpp index 12c582f4..63d3c47e 100644 --- a/nall/hash/crc16.hpp +++ b/nall/hash/crc16.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HASH_CRC16_HPP -#define NALL_HASH_CRC16_HPP +#pragma once #include @@ -39,5 +38,3 @@ private: }; }} - -#endif diff --git a/nall/hash/crc32.hpp b/nall/hash/crc32.hpp index 3ecdd64f..73ded1ae 100644 --- a/nall/hash/crc32.hpp +++ b/nall/hash/crc32.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HASH_CRC32_HPP -#define NALL_HASH_CRC32_HPP +#pragma once #include @@ -81,5 +80,3 @@ private: }; }} - -#endif diff --git a/nall/hash/sha256.hpp b/nall/hash/sha256.hpp index 27105407..0e71f727 100644 --- a/nall/hash/sha256.hpp +++ b/nall/hash/sha256.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HASH_SHA256_HPP -#define NALL_HASH_SHA256_HPP +#pragma once #include @@ -107,5 +106,3 @@ private: }; }} - -#endif diff --git a/nall/hashset.hpp b/nall/hashset.hpp index 2dc6367d..7efd057c 100644 --- a/nall/hashset.hpp +++ b/nall/hashset.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HASHSET_HPP -#define NALL_HASHSET_HPP +#pragma once //hashset // @@ -132,5 +131,3 @@ protected: }; } - -#endif diff --git a/nall/hid.hpp b/nall/hid.hpp index 41a73be6..fbbe06c3 100644 --- a/nall/hid.hpp +++ b/nall/hid.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HID_HPP -#define NALL_HID_HPP +#pragma once namespace nall { namespace HID { @@ -106,5 +105,3 @@ private: }; }} - -#endif diff --git a/nall/http/client.hpp b/nall/http/client.hpp index 8a590fdc..716d4e94 100644 --- a/nall/http/client.hpp +++ b/nall/http/client.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_CLIENT_HPP -#define NALL_HTTP_CLIENT_HPP +#pragma once #include @@ -55,5 +54,3 @@ auto Client::close() -> void { } }} - -#endif diff --git a/nall/http/message.hpp b/nall/http/message.hpp index 385c607b..0bb7c6b7 100644 --- a/nall/http/message.hpp +++ b/nall/http/message.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_MESSAGE_HPP -#define NALL_HTTP_MESSAGE_HPP +#pragma once //httpMessage: base class for httpRequest and httpResponse //provides shared functionality @@ -98,5 +97,3 @@ struct Message { }; }} - -#endif diff --git a/nall/http/request.hpp b/nall/http/request.hpp index 01910cbb..a9afe8d9 100644 --- a/nall/http/request.hpp +++ b/nall/http/request.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_REQUEST_HPP -#define NALL_HTTP_REQUEST_HPP +#pragma once #include #include @@ -183,5 +182,3 @@ auto Request::setBody() -> bool { } }} - -#endif diff --git a/nall/http/response.hpp b/nall/http/response.hpp index 19479ce8..9b00f998 100644 --- a/nall/http/response.hpp +++ b/nall/http/response.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_RESPONSE_HPP -#define NALL_HTTP_RESPONSE_HPP +#pragma once #include @@ -245,5 +244,3 @@ auto Response::setText(const string& value) -> type& { } }} - -#endif diff --git a/nall/http/role.hpp b/nall/http/role.hpp index 6ccb5b02..29eaea8b 100644 --- a/nall/http/role.hpp +++ b/nall/http/role.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_ROLE_HPP -#define NALL_HTTP_ROLE_HPP +#pragma once //Role: base class for Client and Server //provides shared functionality @@ -157,5 +156,3 @@ auto Role::upload(signed fd, const Message& message) -> bool { } }} - -#endif diff --git a/nall/http/server.hpp b/nall/http/server.hpp index d9e1f176..a2e04224 100644 --- a/nall/http/server.hpp +++ b/nall/http/server.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_HTTP_SERVER_HPP -#define NALL_HTTP_SERVER_HPP +#pragma once #include #include @@ -225,5 +224,3 @@ auto Server::close() -> void { } }} - -#endif diff --git a/nall/image.hpp b/nall/image.hpp index c39f356f..03e54845 100644 --- a/nall/image.hpp +++ b/nall/image.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_HPP -#define NALL_IMAGE_HPP +#pragma once #include @@ -17,5 +16,3 @@ #include #include #include - -#endif diff --git a/nall/image/base.hpp b/nall/image/base.hpp index 42244ee9..83742e9f 100644 --- a/nall/image/base.hpp +++ b/nall/image/base.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_BASE_HPP -#define NALL_IMAGE_BASE_HPP +#pragma once namespace nall { @@ -149,5 +148,3 @@ private: }; } - -#endif diff --git a/nall/image/blend.hpp b/nall/image/blend.hpp index 0f6b153a..13d2ba3c 100644 --- a/nall/image/blend.hpp +++ b/nall/image/blend.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_BLEND_HPP -#define NALL_IMAGE_BLEND_HPP +#pragma once namespace nall { @@ -71,5 +70,3 @@ auto image::impose(blend mode, unsigned targetX, unsigned targetY, image source, } } - -#endif diff --git a/nall/image/core.hpp b/nall/image/core.hpp index 92a28743..e0189359 100644 --- a/nall/image/core.hpp +++ b/nall/image/core.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_CORE_HPP -#define NALL_IMAGE_CORE_HPP +#pragma once namespace nall { @@ -166,5 +165,3 @@ auto image::allocate(unsigned width, unsigned height, unsigned stride) -> uint8_ } } - -#endif diff --git a/nall/image/fill.hpp b/nall/image/fill.hpp index 860f16e0..8ff1f886 100644 --- a/nall/image/fill.hpp +++ b/nall/image/fill.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_FILL_HPP -#define NALL_IMAGE_FILL_HPP +#pragma once namespace nall { @@ -83,5 +82,3 @@ auto image::verticalGradient(uint64_t a, uint64_t b, signed radiusX, signed radi } } - -#endif diff --git a/nall/image/interpolation.hpp b/nall/image/interpolation.hpp index 7350bffe..c839f6cb 100644 --- a/nall/image/interpolation.hpp +++ b/nall/image/interpolation.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_INTERPOLATION_HPP -#define NALL_IMAGE_INTERPOLATION_HPP +#pragma once namespace nall { @@ -61,5 +60,3 @@ auto image::interpolate4i(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint32 } } - -#endif diff --git a/nall/image/load.hpp b/nall/image/load.hpp index f783c5ba..6edefe1e 100644 --- a/nall/image/load.hpp +++ b/nall/image/load.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_LOAD_HPP -#define NALL_IMAGE_LOAD_HPP +#pragma once namespace nall { @@ -96,5 +95,3 @@ auto image::loadPNG(const uint8_t* pngData, unsigned pngSize) -> bool { } } - -#endif diff --git a/nall/image/scale.hpp b/nall/image/scale.hpp index 44bfa69f..451acd3d 100644 --- a/nall/image/scale.hpp +++ b/nall/image/scale.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_SCALE_HPP -#define NALL_IMAGE_SCALE_HPP +#pragma once namespace nall { @@ -180,5 +179,3 @@ auto image::scaleNearest(unsigned outputWidth, unsigned outputHeight) -> void { } } - -#endif diff --git a/nall/image/static.hpp b/nall/image/static.hpp index 301a0982..7dc0d842 100644 --- a/nall/image/static.hpp +++ b/nall/image/static.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_STATIC_HPP -#define NALL_IMAGE_STATIC_HPP +#pragma once namespace nall { @@ -27,5 +26,3 @@ auto image::normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth } } - -#endif diff --git a/nall/image/utility.hpp b/nall/image/utility.hpp index bb6e7454..50278c70 100644 --- a/nall/image/utility.hpp +++ b/nall/image/utility.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_IMAGE_UTILITY_HPP -#define NALL_IMAGE_UTILITY_HPP +#pragma once namespace nall { @@ -117,5 +116,3 @@ auto image::transform(bool outputEndian, unsigned outputDepth, uint64_t outputAl } } - -#endif diff --git a/nall/interpolation.hpp b/nall/interpolation.hpp index 39a3c501..587a9b2b 100644 --- a/nall/interpolation.hpp +++ b/nall/interpolation.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_INTERPOLATION_HPP -#define NALL_INTERPOLATION_HPP +#pragma once namespace nall { @@ -55,5 +54,3 @@ struct Interpolation { }; } - -#endif diff --git a/nall/intrinsics.hpp b/nall/intrinsics.hpp index aba93a5f..8f5ad9c7 100644 --- a/nall/intrinsics.hpp +++ b/nall/intrinsics.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_INTRINSICS_HPP -#define NALL_INTRINSICS_HPP +#pragma once namespace nall { struct Intrinsics { @@ -155,5 +154,3 @@ namespace nall { #endif } - -#endif diff --git a/nall/main.hpp b/nall/main.hpp index 70795dbf..925e8f48 100644 --- a/nall/main.hpp +++ b/nall/main.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_MAIN_HPP -#define NALL_MAIN_HPP +#pragma once #include #include @@ -25,5 +24,3 @@ namespace nall { auto main(int argc, char** argv) -> int { return nall::main(argc, argv); } - -#endif diff --git a/nall/map.hpp b/nall/map.hpp index a35f94d0..58b1e11b 100644 --- a/nall/map.hpp +++ b/nall/map.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_MAP_HPP -#define NALL_MAP_HPP +#pragma once #include @@ -57,5 +56,3 @@ protected: }; } - -#endif diff --git a/nall/matrix.hpp b/nall/matrix.hpp index a1705335..fd796869 100644 --- a/nall/matrix.hpp +++ b/nall/matrix.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_MATRIX_HPP -#define NALL_MATRIX_HPP +#pragma once namespace nall { @@ -29,5 +28,3 @@ template inline auto Multiply(const T* xdata, unsigned xrows, unsign } } - -#endif diff --git a/nall/maybe.hpp b/nall/maybe.hpp index f1ac3675..6ebd2ab5 100644 --- a/nall/maybe.hpp +++ b/nall/maybe.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_MAYBE_HPP -#define NALL_MAYBE_HPP +#pragma once namespace nall { @@ -90,5 +89,3 @@ private: }; } - -#endif diff --git a/nall/memory.hpp b/nall/memory.hpp index 17dc6180..7331dd22 100644 --- a/nall/memory.hpp +++ b/nall/memory.hpp @@ -1,8 +1,3 @@ -#ifndef NALL_MEMORY_HPP -#define NALL_MEMORY_HPP +#pragma once -#define NALL_MEMORY_INTERNAL_HPP #include -#undef NALL_MEMORY_INTERNAL_HPP - -#endif diff --git a/nall/memory/memory.hpp b/nall/memory/memory.hpp index 3df31894..f73297db 100644 --- a/nall/memory/memory.hpp +++ b/nall/memory/memory.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_MEMORY_INTERNAL_HPP +#pragma once #include @@ -127,5 +127,3 @@ auto memory::fill(void* target, unsigned capacity, uint8_t data) -> void* { } } - -#endif diff --git a/nall/memory/pool.hpp b/nall/memory/pool.hpp index 8d162886..17d11f74 100644 --- a/nall/memory/pool.hpp +++ b/nall/memory/pool.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_MEMORY_INTERNAL_HPP +#pragma once namespace nall { namespace memory { @@ -60,5 +60,3 @@ struct pool_spsc { } } - -#endif diff --git a/nall/mosaic.hpp b/nall/mosaic.hpp index 16fd0bfd..ac6e6f2a 100644 --- a/nall/mosaic.hpp +++ b/nall/mosaic.hpp @@ -1,10 +1,5 @@ -#ifndef NALL_MOSAIC_HPP -#define NALL_MOSAIC_HPP +#pragma once -#define NALL_MOSAIC_INTERNAL_HPP #include #include #include -#undef NALL_MOSAIC_INTERNAL_HPP - -#endif diff --git a/nall/mosaic/bitstream.hpp b/nall/mosaic/bitstream.hpp index 138f77ff..98fa0598 100644 --- a/nall/mosaic/bitstream.hpp +++ b/nall/mosaic/bitstream.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_MOSAIC_INTERNAL_HPP +#pragma once -namespace nall { -namespace mosaic { +namespace nall { namespace mosaic { struct bitstream { ~bitstream() { @@ -46,7 +45,4 @@ struct bitstream { bool endian = 1; }; -} -} - -#endif +}} diff --git a/nall/mosaic/context.hpp b/nall/mosaic/context.hpp index 396cd447..32950db8 100644 --- a/nall/mosaic/context.hpp +++ b/nall/mosaic/context.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_MOSAIC_INTERNAL_HPP +#pragma once -namespace nall { -namespace mosaic { +namespace nall { namespace mosaic { struct context { context() { @@ -219,7 +218,4 @@ struct context { vector palette; }; -} -} - -#endif +}} diff --git a/nall/mosaic/parser.hpp b/nall/mosaic/parser.hpp index c753f76a..47765c7e 100644 --- a/nall/mosaic/parser.hpp +++ b/nall/mosaic/parser.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_MOSAIC_INTERNAL_HPP +#pragma once -namespace nall { -namespace mosaic { +namespace nall { namespace mosaic { struct parser { //export from bitstream to canvas @@ -117,7 +116,4 @@ private: image canvas; }; -} -} - -#endif +}} diff --git a/nall/nall.hpp b/nall/nall.hpp index 645bfed1..f9f30d79 100644 --- a/nall/nall.hpp +++ b/nall/nall.hpp @@ -1,3 +1,5 @@ +#pragma once + /* nall * author: byuu * license: ISC @@ -6,9 +8,6 @@ * its goals are portability, consistency, minimalism and reusability */ -#ifndef NALL_HPP -#define NALL_HPP - //include the most common nall headers with one statement //does not include the most obscure components with high cost and low usage @@ -74,5 +73,3 @@ #if defined(API_POSIX) #include #endif - -#endif diff --git a/nall/platform.hpp b/nall/platform.hpp index fe48bccf..a8e6aed3 100644 --- a/nall/platform.hpp +++ b/nall/platform.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_PLATFORM_HPP -#define NALL_PLATFORM_HPP +#pragma once #include @@ -132,5 +131,3 @@ namespace Math { //in order to compile code correctly with both compilers, we disable the override keyword for GCC #define override #endif - -#endif diff --git a/nall/posix/service.hpp b/nall/posix/service.hpp index 36cbe110..a8e1ed4f 100644 --- a/nall/posix/service.hpp +++ b/nall/posix/service.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_POSIX_SERVICE_HPP -#define NALL_POSIX_SERVICE_HPP +#pragma once #include @@ -113,5 +112,3 @@ auto service::stop() const -> bool { } } - -#endif diff --git a/nall/posix/shared-memory.hpp b/nall/posix/shared-memory.hpp index 8a50294e..c5e2756f 100644 --- a/nall/posix/shared-memory.hpp +++ b/nall/posix/shared-memory.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_POSIX_SHARED_MEMORY_HPP -#define NALL_POSIX_SHARED_MEMORY_HPP +#pragma once #include #include @@ -150,5 +149,3 @@ private: }; } - -#endif diff --git a/nall/primitives.hpp b/nall/primitives.hpp index 4171bbe4..cf37f67a 100644 --- a/nall/primitives.hpp +++ b/nall/primitives.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_PRIMITIVES_HPP -#define NALL_PRIMITIVES_HPP +#pragma once #include #include @@ -212,5 +211,3 @@ template struct Real { }; } - -#endif diff --git a/nall/priority-queue.hpp b/nall/priority-queue.hpp index 35eaf1d3..49b5fa94 100644 --- a/nall/priority-queue.hpp +++ b/nall/priority-queue.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_PRIORITY_QUEUE_HPP -#define NALL_PRIORITY_QUEUE_HPP +#pragma once #include #include @@ -105,5 +104,3 @@ private: }; } - -#endif diff --git a/nall/property.hpp b/nall/property.hpp index 17e9352c..e6c076b7 100644 --- a/nall/property.hpp +++ b/nall/property.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_PROPERTY_HPP -#define NALL_PROPERTY_HPP +#pragma once namespace nall { @@ -40,5 +39,3 @@ template struct property { }; } - -#endif diff --git a/nall/random.hpp b/nall/random.hpp index 7cfce97b..4187eab5 100644 --- a/nall/random.hpp +++ b/nall/random.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_RANDOM_HPP -#define NALL_RANDOM_HPP +#pragma once #include #include @@ -39,5 +38,3 @@ inline auto random() -> uint64_t { } } - -#endif diff --git a/nall/range.hpp b/nall/range.hpp index 6be51468..f29a838d 100644 --- a/nall/range.hpp +++ b/nall/range.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_RANGE_HPP -#define NALL_RANGE_HPP +#pragma once namespace nall { @@ -49,5 +48,3 @@ template inline auto rrange(const vector& container) { } } - -#endif diff --git a/nall/run.hpp b/nall/run.hpp index 51d8e138..01867a71 100644 --- a/nall/run.hpp +++ b/nall/run.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_RUN_HPP -#define NALL_RUN_HPP +#pragma once //auto execute(const string& name, const string& args...) -> string; //[[synchronous]] @@ -159,5 +158,3 @@ template inline auto invoke(const string& name, P&&... p) -> void #endif } - -#endif diff --git a/nall/serial.hpp b/nall/serial.hpp index c6b65370..4d580dc9 100644 --- a/nall/serial.hpp +++ b/nall/serial.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SERIAL_HPP -#define NALL_SERIAL_HPP +#pragma once #include #include @@ -114,5 +113,3 @@ private: }; } - -#endif diff --git a/nall/serializer.hpp b/nall/serializer.hpp index 91f8fdd5..68be2c87 100644 --- a/nall/serializer.hpp +++ b/nall/serializer.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SERIALIZER_HPP -#define NALL_SERIALIZER_HPP +#pragma once //serializer: a class designed to save and restore the state of classes. // @@ -145,5 +144,3 @@ private: }; }; - -#endif diff --git a/nall/service.hpp b/nall/service.hpp index 86bd2a75..3d3c9024 100644 --- a/nall/service.hpp +++ b/nall/service.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SERVICE_HPP -#define NALL_SERVICE_HPP +#pragma once //service model template built on top of shared-memory @@ -12,5 +11,3 @@ #if defined(API_WINDOWS) #include #endif - -#endif diff --git a/nall/set.hpp b/nall/set.hpp index 828e5e0b..2c3a405b 100644 --- a/nall/set.hpp +++ b/nall/set.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SET_HPP -#define NALL_SET_HPP +#pragma once //set //implementation: red-black tree @@ -263,5 +262,3 @@ private: }; } - -#endif diff --git a/nall/shared-memory.hpp b/nall/shared-memory.hpp index f973a764..9d40bca6 100644 --- a/nall/shared-memory.hpp +++ b/nall/shared-memory.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SHARED_MEMORY_HPP -#define NALL_SHARED_MEMORY_HPP +#pragma once #include #include @@ -11,5 +10,3 @@ #if defined(API_WINDOWS) #include #endif - -#endif diff --git a/nall/shared-pointer.hpp b/nall/shared-pointer.hpp index 13706e8e..ed1a153d 100644 --- a/nall/shared-pointer.hpp +++ b/nall/shared-pointer.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SHARED_POINTER_HPP -#define NALL_SHARED_POINTER_HPP +#pragma once #include #include @@ -272,5 +271,3 @@ struct shared_pointer_new : shared_pointer { }; } - -#endif diff --git a/nall/smtp.hpp b/nall/smtp.hpp index 17d78624..f1f60dea 100644 --- a/nall/smtp.hpp +++ b/nall/smtp.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SMTP_HPP -#define NALL_SMTP_HPP +#pragma once #include #include @@ -314,5 +313,3 @@ SMTP::SMTP() { #endif } - -#endif diff --git a/nall/sort.hpp b/nall/sort.hpp index 1eaec2fe..1f74aa92 100644 --- a/nall/sort.hpp +++ b/nall/sort.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_SORT_HPP -#define NALL_SORT_HPP +#pragma once #include #include @@ -73,5 +72,3 @@ template auto sort(T list[], unsigned size) -> void { } } - -#endif diff --git a/nall/stdint.hpp b/nall/stdint.hpp index 97a35d01..39e5ec1b 100644 --- a/nall/stdint.hpp +++ b/nall/stdint.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STDINT_HPP -#define NALL_STDINT_HPP +#pragma once #if defined(_MSC_VER) typedef signed char int8_t; @@ -69,5 +68,3 @@ using uintptr = uintptr_t; using int128 = int128_t; using uint128 = uint128_t; #endif - -#endif diff --git a/nall/stream.hpp b/nall/stream.hpp index b43ae41e..3ea0c2ce 100644 --- a/nall/stream.hpp +++ b/nall/stream.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_HPP -#define NALL_STREAM_HPP +#pragma once #include #include @@ -11,7 +10,6 @@ #include #include -#define NALL_STREAM_INTERNAL_HPP #include #include #include @@ -19,6 +17,3 @@ #include #include #include -#undef NALL_STREAM_INTERNAL_HPP - -#endif diff --git a/nall/stream/auto.hpp b/nall/stream/auto.hpp index f0f51c42..25a2dc5a 100644 --- a/nall/stream/auto.hpp +++ b/nall/stream/auto.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_AUTO_HPP -#define NALL_STREAM_AUTO_HPP +#pragma once namespace nall { @@ -20,5 +19,3 @@ inline auto makestream(const uint8* data, uint size) -> std::unique_ptr } } - -#endif diff --git a/nall/stream/file.hpp b/nall/stream/file.hpp index 338201ca..043992ee 100644 --- a/nall/stream/file.hpp +++ b/nall/stream/file.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_FILE_HPP -#define NALL_STREAM_FILE_HPP +#pragma once #include @@ -38,5 +37,3 @@ private: }; } - -#endif diff --git a/nall/stream/gzip.hpp b/nall/stream/gzip.hpp index 8d0db283..abc0a5a8 100644 --- a/nall/stream/gzip.hpp +++ b/nall/stream/gzip.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_GZIP_HPP -#define NALL_STREAM_GZIP_HPP +#pragma once #include @@ -30,5 +29,3 @@ struct gzipstream : memorystream { }; } - -#endif diff --git a/nall/stream/memory.hpp b/nall/stream/memory.hpp index 6acc15ca..92f4ab1f 100644 --- a/nall/stream/memory.hpp +++ b/nall/stream/memory.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_MEMORY_HPP -#define NALL_STREAM_MEMORY_HPP +#pragma once #include @@ -47,5 +46,3 @@ protected: }; } - -#endif diff --git a/nall/stream/mmap.hpp b/nall/stream/mmap.hpp index 1f8e4004..a1afc351 100644 --- a/nall/stream/mmap.hpp +++ b/nall/stream/mmap.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_MMAP_HPP -#define NALL_STREAM_MMAP_HPP +#pragma once #include @@ -40,5 +39,3 @@ private: }; } - -#endif diff --git a/nall/stream/stream.hpp b/nall/stream/stream.hpp index 7daff7fb..6a6cc4b8 100644 --- a/nall/stream/stream.hpp +++ b/nall/stream/stream.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_STREAM_HPP -#define NALL_STREAM_STREAM_HPP +#pragma once namespace nall { @@ -97,5 +96,3 @@ struct stream { }; } - -#endif diff --git a/nall/stream/vector.hpp b/nall/stream/vector.hpp index d68df1c7..540501cf 100644 --- a/nall/stream/vector.hpp +++ b/nall/stream/vector.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_VECTOR_HPP -#define NALL_STREAM_VECTOR_HPP +#pragma once #include #include @@ -36,5 +35,3 @@ protected: }; } - -#endif diff --git a/nall/stream/zip.hpp b/nall/stream/zip.hpp index 97d32e22..b2ee11f8 100644 --- a/nall/stream/zip.hpp +++ b/nall/stream/zip.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STREAM_ZIP_HPP -#define NALL_STREAM_ZIP_HPP +#pragma once #include @@ -34,5 +33,3 @@ struct zipstream : memorystream { }; } - -#endif diff --git a/nall/string.hpp b/nall/string.hpp index 716b76a0..a774fdc2 100644 --- a/nall/string.hpp +++ b/nall/string.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_STRING_HPP -#define NALL_STRING_HPP +#pragma once #include #include @@ -25,7 +24,6 @@ #include #include -#define NALL_STRING_INTERNAL_HPP #include #include #include @@ -55,6 +53,3 @@ #include #include #include -#undef NALL_STRING_INTERNAL_HPP - -#endif diff --git a/nall/string/allocator/adaptive.hpp b/nall/string/allocator/adaptive.hpp index 924202fc..224cc154 100644 --- a/nall/string/allocator/adaptive.hpp +++ b/nall/string/allocator/adaptive.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once /***** adaptive allocator @@ -119,5 +119,3 @@ auto string::_resize() -> void { } } - -#endif diff --git a/nall/string/allocator/copy-on-write.hpp b/nall/string/allocator/copy-on-write.hpp index 7b435244..36b96cd6 100644 --- a/nall/string/allocator/copy-on-write.hpp +++ b/nall/string/allocator/copy-on-write.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -88,5 +88,3 @@ auto string::_copy() -> char* { } } - -#endif diff --git a/nall/string/allocator/small-string-optimization.hpp b/nall/string/allocator/small-string-optimization.hpp index 22a56e9c..29e825b8 100644 --- a/nall/string/allocator/small-string-optimization.hpp +++ b/nall/string/allocator/small-string-optimization.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once /* small string optimization (SSO) allocator @@ -91,5 +91,3 @@ auto string::operator=(string&& source) -> type& { } } - -#endif diff --git a/nall/string/allocator/vector.hpp b/nall/string/allocator/vector.hpp index d27cdd5b..f43f15ca 100644 --- a/nall/string/allocator/vector.hpp +++ b/nall/string/allocator/vector.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once /* vector allocator @@ -80,5 +80,3 @@ string::string() { } } - -#endif diff --git a/nall/string/atoi.hpp b/nall/string/atoi.hpp index bbf99c38..7ee5de52 100644 --- a/nall/string/atoi.hpp +++ b/nall/string/atoi.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -15,5 +15,3 @@ auto string::real() const -> double { } } - -#endif diff --git a/nall/string/base.hpp b/nall/string/base.hpp index 61a33334..cdffb29d 100644 --- a/nall/string/base.hpp +++ b/nall/string/base.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -290,5 +290,3 @@ struct format : vector { }; } - -#endif diff --git a/nall/string/cast.hpp b/nall/string/cast.hpp index eaf385ab..2574eca4 100644 --- a/nall/string/cast.hpp +++ b/nall/string/cast.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once //convert any (supported) type to a const char* without constructing a new nall::string //this is used inside string{...} to build nall::string values @@ -223,5 +223,3 @@ template auto make_string(T value) -> stringify { } } - -#endif diff --git a/nall/string/compare.hpp b/nall/string/compare.hpp index 4f34db5c..0fb933dc 100644 --- a/nall/string/compare.hpp +++ b/nall/string/compare.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -56,5 +56,3 @@ auto string::iendsWith(rstring source) const -> bool { } } - -#endif diff --git a/nall/string/convert.hpp b/nall/string/convert.hpp index 00876a8e..2b177f44 100644 --- a/nall/string/convert.hpp +++ b/nall/string/convert.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -51,5 +51,3 @@ auto string::transform(rstring from, rstring to) -> string& { } } - -#endif diff --git a/nall/string/core.hpp b/nall/string/core.hpp index a9267044..da8c166e 100644 --- a/nall/string/core.hpp +++ b/nall/string/core.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once //only allocators may access _data or modify _size and _capacity //all other functions must use data(), size(), capacity() @@ -54,5 +54,3 @@ auto string::length() const -> uint { } } - -#endif diff --git a/nall/string/datetime.hpp b/nall/string/datetime.hpp index f03ad291..8469699f 100644 --- a/nall/string/datetime.hpp +++ b/nall/string/datetime.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -28,5 +28,3 @@ auto string::datetime(time_t timestamp) -> string { } } - -#endif diff --git a/nall/string/eval/evaluator.hpp b/nall/string/eval/evaluator.hpp index 3cfd4180..2261d046 100644 --- a/nall/string/eval/evaluator.hpp +++ b/nall/string/eval/evaluator.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Eval { +namespace nall { namespace Eval { inline auto evaluateExpression(Node* node) -> string { #define p(n) evaluateExpression(node->link[n]) @@ -144,7 +143,4 @@ inline auto real(const string& expression) -> maybe { } } -} -} - -#endif +}} diff --git a/nall/string/eval/literal.hpp b/nall/string/eval/literal.hpp index 11f08796..f56078ad 100644 --- a/nall/string/eval/literal.hpp +++ b/nall/string/eval/literal.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Eval { +namespace nall { namespace Eval { inline auto isLiteral(const char*& s) -> bool { char n = s[0]; @@ -97,7 +96,4 @@ inline auto literal(const char*& s) -> string { throw "invalid literal"; } -} -} - -#endif +}} diff --git a/nall/string/eval/node.hpp b/nall/string/eval/node.hpp index cb88ff5a..54f7e7a0 100644 --- a/nall/string/eval/node.hpp +++ b/nall/string/eval/node.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Eval { +namespace nall { namespace Eval { struct Node { enum class Type : uint { @@ -35,7 +34,4 @@ struct Node { ~Node() { for(auto& node : link) delete node; } }; -} -} - -#endif +}} diff --git a/nall/string/eval/parser.hpp b/nall/string/eval/parser.hpp index 3f5c4d22..1cae0d97 100644 --- a/nall/string/eval/parser.hpp +++ b/nall/string/eval/parser.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Eval { +namespace nall { namespace Eval { inline auto whitespace(char n) -> bool { return n == ' ' || n == '\t' || n == '\r' || n == '\n'; @@ -162,7 +161,4 @@ inline auto parse(const string& expression) -> Node* { return result; } -} -} - -#endif +}} diff --git a/nall/string/find.hpp b/nall/string/find.hpp index 35960239..872fece5 100644 --- a/nall/string/find.hpp +++ b/nall/string/find.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -24,5 +24,3 @@ auto string::findFrom(int offset, rstring source) const -> maybe { return auto string::ifindFrom(int offset, rstring source) const -> maybe { return _find<1, 0>(offset, source); } } - -#endif diff --git a/nall/string/format.hpp b/nall/string/format.hpp index 4c3ab21d..8f8c463e 100644 --- a/nall/string/format.hpp +++ b/nall/string/format.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -175,5 +175,3 @@ auto real(long double value) -> string { } } - -#endif diff --git a/nall/string/hash.hpp b/nall/string/hash.hpp index 81abe3e8..11371a3d 100644 --- a/nall/string/hash.hpp +++ b/nall/string/hash.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -31,5 +31,3 @@ auto sha256(rstring self) -> string { } } - -#endif diff --git a/nall/string/list.hpp b/nall/string/list.hpp index 1aaf2271..cbdc3754 100644 --- a/nall/string/list.hpp +++ b/nall/string/list.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -71,5 +71,3 @@ auto lstring::strip() -> lstring& { } } - -#endif diff --git a/nall/string/markup/bml.hpp b/nall/string/markup/bml.hpp index 371482c8..d170d194 100644 --- a/nall/string/markup/bml.hpp +++ b/nall/string/markup/bml.hpp @@ -1,10 +1,9 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once //BML v1.0 parser //revision 0.04 -namespace nall { -namespace BML { +namespace nall { namespace BML { //metadata is used to store nesting level @@ -187,7 +186,4 @@ inline auto serialize(const Markup::Node& node, uint depth = 0) -> string { return result; } -} -} - -#endif +}} diff --git a/nall/string/markup/find.hpp b/nall/string/markup/find.hpp index dea945b3..9767bfdb 100644 --- a/nall/string/markup/find.hpp +++ b/nall/string/markup/find.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Markup { +namespace nall { namespace Markup { auto ManagedNode::_evaluate(string query) const -> bool { if(!query) return true; @@ -129,7 +128,4 @@ auto ManagedNode::_create(const string& path) -> Node { return _children.last(); } -} -} - -#endif +}} diff --git a/nall/string/markup/node.hpp b/nall/string/markup/node.hpp index 337f4a4b..875e5769 100644 --- a/nall/string/markup/node.hpp +++ b/nall/string/markup/node.hpp @@ -1,7 +1,6 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once -namespace nall { -namespace Markup { +namespace nall { namespace Markup { struct Node; struct ManagedNode; @@ -131,8 +130,7 @@ protected: SharedNode shared; }; -} -} +}} namespace nall { @@ -141,5 +139,3 @@ inline range_t range(const Markup::Node& node) { } } - -#endif diff --git a/nall/string/markup/xml.hpp b/nall/string/markup/xml.hpp index 111cdfb1..f53090e0 100644 --- a/nall/string/markup/xml.hpp +++ b/nall/string/markup/xml.hpp @@ -1,10 +1,9 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once //XML v1.0 subset parser //revision 0.04 -namespace nall { -namespace XML { +namespace nall { namespace XML { //metadata: // 0 = element @@ -215,7 +214,4 @@ inline auto unserialize(const string& markup) -> Markup::SharedNode { return node; } -} -} - -#endif +}} diff --git a/nall/string/match.hpp b/nall/string/match.hpp index b35ee7c2..80ff7c1c 100644 --- a/nall/string/match.hpp +++ b/nall/string/match.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -88,5 +88,3 @@ auto tokenize(lstring& list, const char* s, const char* p) -> bool { } } - -#endif diff --git a/nall/string/path.hpp b/nall/string/path.hpp index d0e6a63b..8672fe71 100644 --- a/nall/string/path.hpp +++ b/nall/string/path.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -70,5 +70,3 @@ auto suffixname(rstring self) -> string { } } - -#endif diff --git a/nall/string/platform.hpp b/nall/string/platform.hpp index 41d15ad5..d327c219 100644 --- a/nall/string/platform.hpp +++ b/nall/string/platform.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -126,5 +126,3 @@ auto temppath() -> string { } } - -#endif diff --git a/nall/string/replace.hpp b/nall/string/replace.hpp index 3b5d3a7d..0744caf3 100644 --- a/nall/string/replace.hpp +++ b/nall/string/replace.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -92,5 +92,3 @@ auto string::qreplace(rstring from, rstring to, long limit) -> string& { return auto string::iqreplace(rstring from, rstring to, long limit) -> string& { return _replace<1, 1>(from, to, limit); } }; - -#endif diff --git a/nall/string/split.hpp b/nall/string/split.hpp index d48d1ef2..b236e373 100644 --- a/nall/string/split.hpp +++ b/nall/string/split.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -39,5 +39,3 @@ auto string::qsplit(rstring on, long limit) const -> lstring { return lstring(). auto string::iqsplit(rstring on, long limit) const -> lstring { return lstring()._split<1, 1>(*this, on, limit); } } - -#endif diff --git a/nall/string/transform/cml.hpp b/nall/string/transform/cml.hpp index 3a091c46..0b99669c 100644 --- a/nall/string/transform/cml.hpp +++ b/nall/string/transform/cml.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once /* CSS Markup Language (CML) v1.0 parser * revision 0.02 @@ -101,5 +101,3 @@ auto CML::parseDocument(const string& filedata, const string& pathname, uint dep } }} - -#endif diff --git a/nall/string/transform/dml.hpp b/nall/string/transform/dml.hpp index 47df98e8..9c6f915e 100644 --- a/nall/string/transform/dml.hpp +++ b/nall/string/transform/dml.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once /* Document Markup Language (DML) v1.0 parser * revision 0.03 @@ -265,5 +265,3 @@ auto DML::markup(const string& text) -> string { } }} - -#endif diff --git a/nall/string/trim.hpp b/nall/string/trim.hpp index 2f6f00c1..35c5ecec 100644 --- a/nall/string/trim.hpp +++ b/nall/string/trim.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -100,5 +100,3 @@ auto string::rstrip() -> string& { } } - -#endif diff --git a/nall/string/utility.hpp b/nall/string/utility.hpp index bd541e94..0faa2be8 100644 --- a/nall/string/utility.hpp +++ b/nall/string/utility.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -156,5 +156,3 @@ auto real(char* result, long double value) -> uint { } } - -#endif diff --git a/nall/string/view.hpp b/nall/string/view.hpp index d90ca144..2f72337c 100644 --- a/nall/string/view.hpp +++ b/nall/string/view.hpp @@ -1,4 +1,4 @@ -#ifdef NALL_STRING_INTERNAL_HPP +#pragma once namespace nall { @@ -86,5 +86,3 @@ protected: }; } - -#endif diff --git a/nall/thread.hpp b/nall/thread.hpp index ecbf7700..a01624b7 100644 --- a/nall/thread.hpp +++ b/nall/thread.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_THREAD_HPP -#define NALL_THREAD_HPP +#pragma once //simple thread library //primary rationale is that std::thread does not support custom stack sizes @@ -136,5 +135,3 @@ auto thread::exit() -> void { } #endif - -#endif diff --git a/nall/traits.hpp b/nall/traits.hpp index 53ec263c..900df0dc 100644 --- a/nall/traits.hpp +++ b/nall/traits.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_TRAITS_HPP -#define NALL_TRAITS_HPP +#pragma once #include #include @@ -52,5 +51,3 @@ namespace nall { template using type_if = typename traits::type_if::type; } - -#endif diff --git a/nall/utility.hpp b/nall/utility.hpp index 35eed247..ac1d13e0 100644 --- a/nall/utility.hpp +++ b/nall/utility.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_UTILITY_HPP -#define NALL_UTILITY_HPP +#pragma once #include @@ -17,5 +16,3 @@ template inline auto allocate(unsigned size, const T& value) -> T* { } } - -#endif diff --git a/nall/varint.hpp b/nall/varint.hpp index 577fc229..461f4bd9 100644 --- a/nall/varint.hpp +++ b/nall/varint.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_VARINT_HPP -#define NALL_VARINT_HPP +#pragma once #include #include @@ -209,5 +208,3 @@ using uint61 = nall::Natural<61>; using uint62 = nall::Natural<62>; using uint63 = nall::Natural<63>; //using uint64 = nall::Natural<64>; - -#endif diff --git a/nall/vector.hpp b/nall/vector.hpp index c07f11fe..73c7d36a 100644 --- a/nall/vector.hpp +++ b/nall/vector.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_VECTOR_HPP -#define NALL_VECTOR_HPP +#pragma once #include #include @@ -281,5 +280,3 @@ protected: }; } - -#endif diff --git a/nall/windows/detour.hpp b/nall/windows/detour.hpp index 99475e90..6e57a590 100644 --- a/nall/windows/detour.hpp +++ b/nall/windows/detour.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_DETOUR_HPP -#define NALL_WINDOWS_DETOUR_HPP +#pragma once #include #include @@ -188,5 +187,3 @@ auto detour::mirror(uint8* target, const uint8* source) -> uint { #undef RelNear } - -#endif diff --git a/nall/windows/guid.hpp b/nall/windows/guid.hpp index 1278dd68..056c7ae0 100644 --- a/nall/windows/guid.hpp +++ b/nall/windows/guid.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_GUID_HPP -#define NALL_WINDOWS_GUID_HPP +#pragma once #include #include @@ -26,5 +25,3 @@ inline auto guid() -> string { } } - -#endif diff --git a/nall/windows/launcher.hpp b/nall/windows/launcher.hpp index 1583dfd9..1ae13c3d 100644 --- a/nall/windows/launcher.hpp +++ b/nall/windows/launcher.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_LAUNCHER_HPP -#define NALL_WINDOWS_LAUNCHER_HPP +#pragma once namespace nall { @@ -90,5 +89,3 @@ auto launch(const char* applicationName, const char* libraryName, uint32 entryPo } } - -#endif diff --git a/nall/windows/registry.hpp b/nall/windows/registry.hpp index d3855157..cd5767d8 100644 --- a/nall/windows/registry.hpp +++ b/nall/windows/registry.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_REGISTRY_HPP -#define NALL_WINDOWS_REGISTRY_HPP +#pragma once #include #include @@ -117,5 +116,3 @@ private: }; } - -#endif diff --git a/nall/windows/service.hpp b/nall/windows/service.hpp index 905bd7a8..fa5d87f9 100644 --- a/nall/windows/service.hpp +++ b/nall/windows/service.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_SERVICE_HPP -#define NALL_WINDOWS_SERVICE_HPP +#pragma once namespace nall { @@ -12,5 +11,3 @@ struct service { }; } - -#endif diff --git a/nall/windows/shared-memory.hpp b/nall/windows/shared-memory.hpp index 0b74f0e2..aa45938a 100644 --- a/nall/windows/shared-memory.hpp +++ b/nall/windows/shared-memory.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_WINDOWS_SHARED_MEMORY_HPP -#define NALL_WINDOWS_SHARED_MEMORY_HPP +#pragma once namespace nall { @@ -26,5 +25,3 @@ struct shared_memory { }; } - -#endif diff --git a/nall/windows/utf8.hpp b/nall/windows/utf8.hpp index 7416d861..04db9757 100644 --- a/nall/windows/utf8.hpp +++ b/nall/windows/utf8.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_UTF8_HPP -#define NALL_UTF8_HPP +#pragma once //UTF-8 <> UTF-16 conversion //used only for Win32; every other OS uses UTF-8 internally @@ -85,5 +84,3 @@ namespace nall { } #endif //if defined(_WIN32) - -#endif diff --git a/nall/xorg/xorg.hpp b/nall/xorg/xorg.hpp index bcf48b46..56ff3163 100644 --- a/nall/xorg/xorg.hpp +++ b/nall/xorg/xorg.hpp @@ -1,5 +1,4 @@ -#ifndef NALL_XORG_XORG_HPP -#define NALL_XORG_XORG_HPP +#pragma once #include #include @@ -8,5 +7,3 @@ #include #include #include - -#endif diff --git a/ruby/ruby.hpp b/ruby/ruby.hpp index 30d5cf81..51a5200e 100644 --- a/ruby/ruby.hpp +++ b/ruby/ruby.hpp @@ -1,3 +1,5 @@ +#pragma once + /* ruby * author: byuu * license: ISC @@ -7,9 +9,6 @@ * it provides a common interface to video, audio and input devices */ -#ifndef RUBY_HPP -#define RUBY_HPP - #include namespace ruby { @@ -107,5 +106,3 @@ private: }; } - -#endif