mirror of https://github.com/bsnes-emu/bsnes.git
Update to 20160106 OS X Preview for Developers release.
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
This commit is contained in:
parent
4d193d7d94
commit
0b923489dd
|
@ -1,5 +1,5 @@
|
|||
AdvancedSettings::AdvancedSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Action::Settings);
|
||||
setIcon(Icon::Action::Settings);
|
||||
setText("Advanced");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Device::Speaker);
|
||||
setIcon(Icon::Device::Speaker);
|
||||
setText("Audio");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Device::Keyboard);
|
||||
setIcon(Icon::Device::Keyboard);
|
||||
setText("Hotkeys");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Device::Joypad);
|
||||
setIcon(Icon::Device::Joypad);
|
||||
setText("Input");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TimingSettings::TimingSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Device::Clock);
|
||||
setIcon(Icon::Device::Clock);
|
||||
setText("Timing");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
VideoSettings::VideoSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Device::Display);
|
||||
setIcon(Icon::Device::Display);
|
||||
setText("Video");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CheatEditor::CheatEditor(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Edit::Replace);
|
||||
setIcon(Icon::Edit::Replace);
|
||||
setText("Cheat Editor");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
ManifestViewer::ManifestViewer(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Emblem::Text);
|
||||
setIcon(Icon::Emblem::Text);
|
||||
setText("Manifest Viewer");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setImage(Icon::Application::FileManager);
|
||||
setIcon(Icon::Application::FileManager);
|
||||
setText("State Manager");
|
||||
|
||||
layout.setMargin(5);
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<NSDraggingInfo> sender) -> NSDragOperation {
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ auto pCheckLabel::construct() -> void {
|
|||
|
||||
auto pCheckLabel::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ auto pComboButton::construct() -> void {
|
|||
|
||||
auto pComboButton::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ void pConsole::constructor() {
|
|||
|
||||
void pConsole::destructor() {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ auto pFrame::construct() -> void {
|
|||
|
||||
auto pFrame::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ void pHexEdit::constructor() {
|
|||
|
||||
void pHexEdit::destructor() {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ auto pHorizontalScrollBar::construct() -> void {
|
|||
|
||||
auto pHorizontalScrollBar::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ auto pHorizontalSlider::construct() -> void {
|
|||
|
||||
auto pHorizontalSlider::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ auto pLabel::construct() -> void {
|
|||
|
||||
auto pLabel::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ auto pLineEdit::construct() -> void {
|
|||
|
||||
auto pLineEdit::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -10,7 +10,7 @@ struct pListViewCell : pObject {
|
|||
auto setCheckable(bool checkable) -> void;
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -28,6 +28,7 @@ auto pProgressBar::construct() -> void {
|
|||
|
||||
auto pProgressBar::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ auto pRadioLabel::construct() -> void {
|
|||
|
||||
auto pRadioLabel::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ auto pTextEdit::construct() -> void {
|
|||
|
||||
auto pTextEdit::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ auto pVerticalScrollBar::construct() -> void {
|
|||
|
||||
auto pVerticalScrollBar::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ auto pVerticalSlider::construct() -> void {
|
|||
|
||||
auto pVerticalSlider::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ auto pViewport::construct() -> void {
|
|||
|
||||
auto pViewport::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define Hiro_Size
|
||||
#define Hiro_Geometry
|
||||
#define Hiro_Font
|
||||
#define Hiro_Image
|
||||
|
||||
#define Hiro_Application
|
||||
#define Hiro_Desktop
|
||||
|
|
|
@ -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<void ()>& callback) -> type& {
|
||||
|
@ -19,9 +19,9 @@ auto mMenuItem::onActivate(const function<void ()>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace hiro {
|
|||
#include "size.cpp"
|
||||
#include "geometry.cpp"
|
||||
#include "font.cpp"
|
||||
#include "image.cpp"
|
||||
|
||||
#include "application.cpp"
|
||||
#include "desktop.cpp"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <nall/vector.hpp>
|
||||
|
||||
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<uint8_t>& source);
|
||||
Image(const uint32_t* data, Size size);
|
||||
~Image();
|
||||
|
||||
explicit operator bool() const;
|
||||
auto operator=(const Image& source) -> type&;
|
||||
|
||||
auto data() const -> uint32_t*;
|
||||
auto height() const -> signed;
|
||||
auto reset() -> type&;
|
||||
auto setImage(const uint32_t* data, Size size) -> type&;
|
||||
auto setSize(Size size = {}) -> type&;
|
||||
auto size() const -> Size;
|
||||
auto width() const -> signed;
|
||||
|
||||
//private:
|
||||
struct State {
|
||||
uint32_t* data = nullptr;
|
||||
Size size;
|
||||
} state;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_Hotkey)
|
||||
struct Hotkey {
|
||||
using type = Hotkey;
|
||||
|
@ -837,10 +808,10 @@ struct mMenu : mAction {
|
|||
auto actionCount() const -> unsigned;
|
||||
auto actions() const -> vector<Action>;
|
||||
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<sAction> 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<void ()>& 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<void ()> 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<void ()>& 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<void ()> 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<void (lstring)>& callback = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position)>& 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<void (lstring)> onDrop;
|
||||
function<void ()> onMouseLeave;
|
||||
function<void (Position)> 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<void ()>& 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<void ()> 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<void ()>& 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<void ()> 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<TreeViewItem>;
|
||||
|
@ -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<sTreeViewItem> items;
|
||||
string text;
|
||||
} state;
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
#if defined(Hiro_Image)
|
||||
|
||||
Image::Image() {
|
||||
}
|
||||
|
||||
Image::Image(const Image& source) {
|
||||
operator=(source);
|
||||
}
|
||||
|
||||
Image::Image(const string& source) {
|
||||
nall::image image{source};
|
||||
image.transform();
|
||||
setImage((const uint32_t*)image.data(), Size{(signed)image.width(), (signed)image.height()});
|
||||
}
|
||||
|
||||
Image::Image(const vector<uint8_t>& source) {
|
||||
nall::image image{source};
|
||||
image.transform();
|
||||
setImage((const uint32_t*)image.data(), Size{(signed)image.width(), (signed)image.height()});
|
||||
}
|
||||
|
||||
Image::Image(const uint32_t* data, Size size) {
|
||||
setImage(data, size);
|
||||
}
|
||||
|
||||
Image::~Image() {
|
||||
reset();
|
||||
}
|
||||
|
||||
Image::operator bool() const {
|
||||
return state.data;
|
||||
}
|
||||
|
||||
auto Image::operator=(const Image& source) -> type& {
|
||||
reset();
|
||||
if(state.size = source.state.size) {
|
||||
state.data = new uint32_t[state.size.width() * state.size.height()];
|
||||
memory::copy(state.data, source.state.data, state.size.width() * state.size.height() * sizeof(uint32_t));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto Image::data() const -> uint32_t* {
|
||||
return state.data;
|
||||
}
|
||||
|
||||
auto Image::height() const -> signed {
|
||||
return state.size.height();
|
||||
}
|
||||
|
||||
auto Image::reset() -> type& {
|
||||
if(state.data) delete[] state.data;
|
||||
state.data = nullptr;
|
||||
state.size = {};
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto Image::setImage(const uint32_t* data, Size size) -> type& {
|
||||
reset();
|
||||
if(data && size) {
|
||||
state.size = size;
|
||||
state.data = new uint32_t[size.width() * size.height()];
|
||||
memory::copy(state.data, data, size.width() * size.height() * sizeof(uint32_t));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto Image::setSize(Size size) -> type& {
|
||||
state.size = size;
|
||||
if(state.data) delete[] state.data;
|
||||
if(state.size) state.data = new uint32_t[size.width() * size.height()];
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto Image::size() const -> Size {
|
||||
return state.size;
|
||||
}
|
||||
|
||||
auto Image::width() const -> signed {
|
||||
return state.size.width();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -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<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
||||
auto setImage(const Image& image = {}) { return self().setImage(image), *this; }
|
||||
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||
auto 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<void ()>& 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<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) { return self().onMouseLeave(callback), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) { return self().onMouseMove(callback), *this; }
|
||||
|
@ -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<void ()>& 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<void ()>& 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(); }
|
||||
|
|
|
@ -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<void ()>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<void (lstring)>& 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& {
|
||||
|
|
|
@ -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<void ()>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<void ()>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -15,7 +15,7 @@ struct MessageDialog {
|
|||
private:
|
||||
struct State {
|
||||
lstring buttons;
|
||||
vector<uint8_t> image;
|
||||
vector<uint8> icon;
|
||||
sWindow parent;
|
||||
string response;
|
||||
string text;
|
||||
|
|
|
@ -9,7 +9,7 @@ static auto MenuItem_activate(GtkMenuItem*, pMenuItem* p) -> void {
|
|||
auto pMenuItem::construct() -> void {
|
||||
widget = gtk_image_menu_item_new_with_mnemonic("");
|
||||
g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(MenuItem_activate), (gpointer)this);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ auto pMenuItem::destruct() -> void {
|
|||
if(widget) gtk_widget_destroy(widget), widget = nullptr;
|
||||
}
|
||||
|
||||
auto pMenuItem::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image, true);
|
||||
auto pMenuItem::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon, true);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
struct pMenuItem : pAction {
|
||||
Declare(MenuItem, Action)
|
||||
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ auto pMenu::construct() -> void {
|
|||
gtkMenu = gtk_menu_new();
|
||||
widget = gtk_image_menu_item_new_with_mnemonic("");
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
|
||||
for(auto& action : state().actions) append(*action);
|
||||
|
@ -35,9 +35,9 @@ auto pMenu::setFont(const Font& font) -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto pMenu::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image, true);
|
||||
auto pMenu::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon, true);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
|
||||
|
|
|
@ -8,7 +8,7 @@ struct pMenu : pAction {
|
|||
auto append(sAction action) -> void;
|
||||
auto remove(sAction action) -> void;
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
GtkWidget* gtkMenu = nullptr;
|
||||
|
|
|
@ -29,40 +29,11 @@ static auto CreatePixbuf(image icon, bool scale = false) -> GdkPixbuf* {
|
|||
return pixbuf;
|
||||
}
|
||||
|
||||
static auto CreatePixbuf(const Image& image, bool scale = false) -> GdkPixbuf* {
|
||||
if(!image.state.data) return nullptr;
|
||||
|
||||
auto pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, image.width(), image.height());
|
||||
|
||||
//ARGB -> ABGR conversion
|
||||
const uint32_t* source = image.data();
|
||||
uint32_t* target = (uint32_t*)gdk_pixbuf_get_pixels(pixbuf);
|
||||
for(auto n : range(image.width() * image.height())) {
|
||||
uint32_t pixel = *source++;
|
||||
*target++ = (pixel & 0x00ff0000) >> 16 | (pixel & 0xff00ff00) | (pixel & 0x000000ff) << 16;
|
||||
}
|
||||
|
||||
if(scale) {
|
||||
auto scaled = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR);
|
||||
g_object_unref(pixbuf);
|
||||
pixbuf = scaled;
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static auto CreateImage(const nall::image& image, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(image, scale);
|
||||
auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
static auto CreateImage(const image& icon, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(icon, scale);
|
||||
auto gtkIcon = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
return gtkImage;
|
||||
}
|
||||
|
||||
static auto CreateImage(const Image& image, bool scale = false) -> GtkImage* {
|
||||
auto pixbuf = CreatePixbuf(image, scale);
|
||||
auto gtkImage = (GtkImage*)gtk_image_new_from_pixbuf(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
return gtkImage;
|
||||
return gtkIcon;
|
||||
}
|
||||
|
||||
static auto DropPaths(GtkSelectionData* data) -> lstring {
|
||||
|
|
|
@ -9,7 +9,7 @@ auto pButton::construct() -> void {
|
|||
gtkButton = GTK_BUTTON(gtkWidget);
|
||||
|
||||
setBordered(state().bordered);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
|
@ -26,13 +26,13 @@ auto pButton::minimumSize() const -> Size {
|
|||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + (state().text ? 24 : 12), size.height() + 12};
|
||||
|
@ -42,9 +42,9 @@ auto pButton::setBordered(bool bordered) -> void {
|
|||
gtk_button_set_relief(gtkButton, bordered ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE);
|
||||
}
|
||||
|
||||
auto pButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
auto gtkImage = CreateImage(image);
|
||||
auto pButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
auto gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(gtkButton, (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(gtkButton, nullptr);
|
||||
|
|
|
@ -7,7 +7,7 @@ struct pButton : pWidget {
|
|||
|
||||
auto minimumSize() const -> Size override;
|
||||
auto setBordered(bool bordered) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ auto pCanvas::destruct() -> void {
|
|||
}
|
||||
|
||||
auto pCanvas::minimumSize() const -> Size {
|
||||
if(auto& image = state().image) return image.size();
|
||||
if(auto& icon = state().icon) return {(int)icon.width(), (int)icon.height()};
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ auto pCanvas::setGradient(Gradient gradient) -> void {
|
|||
update();
|
||||
}
|
||||
|
||||
auto pCanvas::setImage(const Image& image) -> void {
|
||||
auto pCanvas::setIcon(const image& icon) -> void {
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -109,9 +109,9 @@ auto pCanvas::update() -> void {
|
|||
auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
|
||||
if(surface == nullptr) return;
|
||||
|
||||
signed sx = 0, sy = 0, dx = 0, dy = 0;
|
||||
signed width = surfaceWidth;
|
||||
signed height = surfaceHeight;
|
||||
int sx = 0, sy = 0, dx = 0, dy = 0;
|
||||
int width = surfaceWidth;
|
||||
int height = surfaceHeight;
|
||||
auto geometry = pSizable::state().geometry;
|
||||
|
||||
if(width <= geometry.width()) {
|
||||
|
@ -136,12 +136,12 @@ auto pCanvas::_onExpose(GdkEventExpose* expose) -> void {
|
|||
}
|
||||
|
||||
auto pCanvas::_rasterize() -> void {
|
||||
signed width = 0;
|
||||
signed height = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
if(auto& image = state().image) {
|
||||
width = image.width();
|
||||
height = image.height();
|
||||
if(auto& icon = state().icon) {
|
||||
width = icon.width();
|
||||
height = icon.height();
|
||||
} else {
|
||||
width = pSizable::state().geometry.width();
|
||||
height = pSizable::state().geometry.height();
|
||||
|
@ -155,22 +155,22 @@ auto pCanvas::_rasterize() -> void {
|
|||
if(!surface) surface = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, width, height);
|
||||
auto buffer = (uint32_t*)gdk_pixbuf_get_pixels(surface);
|
||||
|
||||
if(auto& image = state().image) {
|
||||
memory::copy(buffer, state().image.data(), width * height * sizeof(uint32_t));
|
||||
if(auto& icon = state().icon) {
|
||||
memory::copy(buffer, state().icon.data(), width * height * sizeof(uint32));
|
||||
} else if(auto& gradient = state().gradient) {
|
||||
auto& colors = gradient.state.colors;
|
||||
nall::image fill;
|
||||
image fill;
|
||||
fill.allocate(width, height);
|
||||
fill.gradient(colors[0].value(), colors[1].value(), colors[2].value(), colors[3].value());
|
||||
memory::copy(buffer, fill.data(), fill.size());
|
||||
} else {
|
||||
uint32_t color = state().color.value();
|
||||
uint32 color = state().color.value();
|
||||
for(auto n : range(width * height)) buffer[n] = color;
|
||||
}
|
||||
|
||||
//ARGB -> ABGR conversion
|
||||
for(auto n : range(width * height)) {
|
||||
uint32_t color = *buffer;
|
||||
uint32 color = *buffer;
|
||||
color = (color & 0xff00ff00) | ((color & 0xff0000) >> 16) | ((color & 0x0000ff) << 16);
|
||||
*buffer++ = color;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ struct pCanvas : pWidget {
|
|||
auto setDroppable(bool droppable) -> void;
|
||||
auto setGeometry(Geometry geometry) -> void override;
|
||||
auto setGradient(Gradient gradient) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto update() -> void;
|
||||
|
||||
auto _onExpose(GdkEventExpose* event) -> void;
|
||||
|
@ -19,8 +19,8 @@ struct pCanvas : pWidget {
|
|||
auto _release() -> void;
|
||||
|
||||
GdkPixbuf* surface = nullptr;
|
||||
unsigned surfaceWidth = 0;
|
||||
unsigned surfaceHeight = 0;
|
||||
uint surfaceWidth = 0;
|
||||
uint surfaceHeight = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ auto pCheckButton::construct() -> void {
|
|||
|
||||
setBordered(state().bordered);
|
||||
setChecked(state().checked);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
|
@ -29,13 +29,13 @@ auto pCheckButton::minimumSize() const -> Size {
|
|||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + 24, size.height() + 12};
|
||||
|
@ -51,9 +51,9 @@ auto pCheckButton::setChecked(bool checked) -> void {
|
|||
unlock();
|
||||
}
|
||||
|
||||
auto pCheckButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image);
|
||||
auto pCheckButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);
|
||||
|
|
|
@ -8,7 +8,7 @@ struct pCheckButton : pWidget {
|
|||
auto minimumSize() const -> Size override;
|
||||
auto setBordered(bool bordered) -> void;
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
};
|
||||
|
|
|
@ -8,10 +8,10 @@ auto pComboButtonItem::construct() -> void {
|
|||
auto pComboButtonItem::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pComboButtonItem::setImage(const Image& image) -> void {
|
||||
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
auto size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(image, true);
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
struct pComboButtonItem : pObject {
|
||||
Declare(ComboButtonItem, Object)
|
||||
|
||||
auto setImage(const Image& icon) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ auto pComboButton::append(sComboButtonItem item) -> void {
|
|||
lock();
|
||||
if(auto self = item->self()) {
|
||||
gtk_list_store_append(gtkListStore, &self->gtkIter);
|
||||
self->setImage(item->state.image);
|
||||
self->setIcon(item->state.icon);
|
||||
if(item->state.selected) self->setSelected();
|
||||
self->setText(item->state.text);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ auto pComboButton::minimumSize() const -> Size {
|
|||
signed maximumWidth = 0;
|
||||
for(auto& item : state().items) {
|
||||
maximumWidth = max(maximumWidth,
|
||||
(item->state.image ? pFont::size(font, " ").height() + 2 : 0)
|
||||
(item->state.icon ? pFont::size(font, " ").height() + 2 : 0)
|
||||
+ pFont::size(font, item->state.text).width()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ auto pIconViewItem::construct() -> void {
|
|||
auto pIconViewItem::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pIconViewItem::setImage(const Image& image) -> void {
|
||||
auto pIconViewItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->setItemImage(self().offset(), image);
|
||||
parent->setItemIcon(self().offset(), icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
struct pIconViewItem : pObject {
|
||||
Declare(IconViewItem, Object)
|
||||
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setSelected(bool selected) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ auto pIconView::destruct() -> void {
|
|||
auto pIconView::append(sIconViewItem item) -> void {
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(store, &iter);
|
||||
setItemImage(item->offset(), item->state.image);
|
||||
setItemIcon(item->offset(), item->state.icon);
|
||||
setItemSelected(item->offset(), item->state.selected);
|
||||
setItemText(item->offset(), item->state.text);
|
||||
}
|
||||
|
@ -121,12 +121,12 @@ auto pIconView::setGeometry(Geometry geometry) -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto pIconView::setItemImage(unsigned position, const Image& image) -> void {
|
||||
auto pIconView::setItemIcon(unsigned position, const image& icon) -> void {
|
||||
if(position >= self().itemCount()) return;
|
||||
GtkTreeIter iter;
|
||||
if(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, string{position})) {
|
||||
if(image) {
|
||||
GdkPixbuf* pixbuf = CreatePixbuf(image);
|
||||
if(icon) {
|
||||
GdkPixbuf* pixbuf = CreatePixbuf(icon);
|
||||
gtk_list_store_set(store, &iter, 0, pixbuf, -1);
|
||||
} else {
|
||||
gtk_list_store_set(store, &iter, 0, nullptr, -1);
|
||||
|
|
|
@ -13,7 +13,7 @@ struct pIconView : pWidget {
|
|||
auto setFlow(Orientation flow) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setGeometry(Geometry geometry) -> void;
|
||||
auto setItemImage(unsigned position, const Image& image) -> void;
|
||||
auto setItemIcon(unsigned position, const image& icon) -> void;
|
||||
auto setItemSelected(unsigned position, bool selected) -> void;
|
||||
auto setItemSelected(const vector<signed>& selections) -> void;
|
||||
auto setItemSelectedAll() -> void;
|
||||
|
|
|
@ -25,7 +25,7 @@ auto pListViewCell::setChecked(bool checked) -> void {
|
|||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewCell::setImage(const Image& image) -> void {
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ auto pListViewCell::_setState() -> void {
|
|||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 0, state().checked, -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().image), -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 1, CreatePixbuf(state().icon), -1);
|
||||
gtk_list_store_set(grandparent->gtkListStore, &parent->gtkIter, 3 * self().offset() + 2, state().text.data(), -1);
|
||||
grandparent->unlock();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ struct pListViewCell : pObject {
|
|||
auto setCheckable(bool checkable) -> void;
|
||||
auto setChecked(bool checked) -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
|
|
|
@ -81,9 +81,9 @@ auto pListViewColumn::setFont(const Font& font) -> void {
|
|||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(image));
|
||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
||||
} else {
|
||||
gtk_image_clear(GTK_IMAGE(gtkHeaderIcon));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct pListViewColumn : pObject {
|
|||
auto setFont(const Font& font) -> void override;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setHorizontalAlignment(double) -> void {}
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setResizable(bool resizable) -> void;
|
||||
auto setSortable(bool sortable) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
|
|
@ -155,8 +155,8 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
|||
if(cell->state.checkable) {
|
||||
width += 24;
|
||||
}
|
||||
if(auto& image = cell->state.image) {
|
||||
width += image.width() + 2;
|
||||
if(auto& icon = cell->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = cell->state.text) {
|
||||
width += pFont::size(cell->font(true), text).width();
|
||||
|
@ -170,8 +170,8 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
|||
unsigned width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto column = header->column(_column)) {
|
||||
if(auto& image = column->state.image) {
|
||||
width += image.width() + 2;
|
||||
if(auto& icon = column->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = column->state.text) {
|
||||
width += pFont::size(column->font(true), text).width();
|
||||
|
|
|
@ -13,7 +13,7 @@ auto pRadioButton::construct() -> void {
|
|||
gtkWidget = gtk_toggle_button_new();
|
||||
|
||||
setBordered(state().bordered);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setOrientation(state().orientation);
|
||||
setText(state().text);
|
||||
|
||||
|
@ -30,13 +30,13 @@ auto pRadioButton::minimumSize() const -> Size {
|
|||
Size size = pFont::size(self().font(true), state().text);
|
||||
|
||||
if(state().orientation == Orientation::Horizontal) {
|
||||
size.setWidth(size.width() + state().image.width());
|
||||
size.setHeight(max(size.height(), state().image.height()));
|
||||
size.setWidth(size.width() + state().icon.width());
|
||||
size.setHeight(max(size.height(), state().icon.height()));
|
||||
}
|
||||
|
||||
if(state().orientation == Orientation::Vertical) {
|
||||
size.setWidth(max(size.width(), state().image.width()));
|
||||
size.setHeight(size.height() + state().image.height());
|
||||
size.setWidth(max(size.width(), state().icon.width()));
|
||||
size.setHeight(size.height() + state().icon.height());
|
||||
}
|
||||
|
||||
return {size.width() + 24, size.height() + 12};
|
||||
|
@ -76,9 +76,9 @@ auto pRadioButton::setGroup(sGroup group) -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto pRadioButton::setImage(const Image& image) -> void {
|
||||
if(image) {
|
||||
GtkImage* gtkImage = CreateImage(image);
|
||||
auto pRadioButton::setIcon(const image& icon) -> void {
|
||||
if(icon) {
|
||||
GtkImage* gtkImage = CreateImage(icon);
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), (GtkWidget*)gtkImage);
|
||||
} else {
|
||||
gtk_button_set_image(GTK_BUTTON(gtkWidget), nullptr);
|
||||
|
|
|
@ -9,7 +9,7 @@ struct pRadioButton : pWidget {
|
|||
auto setBordered(bool bordered) -> void;
|
||||
auto setChecked() -> void;
|
||||
auto setGroup(sGroup group) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setOrientation(Orientation orientation) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ auto pTabFrameItem::setClosable(bool closable) -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto pTabFrameItem::setImage(const Image& image) -> void {
|
||||
auto pTabFrameItem::setIcon(const image& icon) -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->setItemImage(self().offset(), image);
|
||||
parent->setItemIcon(self().offset(), icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ struct pTabFrameItem : pObject {
|
|||
auto append(sLayout layout) -> void;
|
||||
auto remove(sLayout layout) -> void;
|
||||
auto setClosable(bool closable) -> void;
|
||||
auto setImage(const Image& image) -> void;
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setMovable(bool movable) -> void;
|
||||
auto setSelected() -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
|
|
@ -178,7 +178,7 @@ auto pTabFrame::setItemClosable(unsigned position, bool closable) -> void {
|
|||
_synchronizeTab(position);
|
||||
}
|
||||
|
||||
auto pTabFrame::setItemImage(unsigned position, const Image& image) -> void {
|
||||
auto pTabFrame::setItemIcon(unsigned position, const image& icon) -> void {
|
||||
_synchronizeTab(position);
|
||||
}
|
||||
|
||||
|
@ -239,15 +239,15 @@ auto pTabFrame::_synchronizeTab(unsigned position) -> void {
|
|||
auto& item = state().items[position];
|
||||
auto& tab = tabs[position];
|
||||
gtk_widget_set_visible(tab.close, item->closable());
|
||||
if(auto& image = item->state.image) {
|
||||
unsigned size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(image, true);
|
||||
if(auto& icon = item->state.icon) {
|
||||
uint size = pFont::size(self().font(true), " ").height();
|
||||
auto pixbuf = CreatePixbuf(icon, true);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(tab.image), pixbuf);
|
||||
} else {
|
||||
gtk_image_clear(GTK_IMAGE(tab.image));
|
||||
}
|
||||
string text = {
|
||||
item->state.image && item->state.text ? " " : "",
|
||||
item->state.icon && item->state.text ? " " : "",
|
||||
item->state.text,
|
||||
item->state.text && item->state.closable ? " " : ""
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ struct pTabFrame : pWidget {
|
|||
auto setFont(const Font& font) -> void override;
|
||||
auto setGeometry(Geometry geometry) -> void override;
|
||||
auto setItemClosable(unsigned position, bool closable) -> void;
|
||||
auto setItemImage(unsigned position, const Image& image) -> void;
|
||||
auto setItemIcon(unsigned position, const image& icon) -> void;
|
||||
auto setItemLayout(unsigned position, sLayout layout) -> void;
|
||||
auto setItemMovable(unsigned position, bool movable) -> void;
|
||||
auto setItemSelected(unsigned position) -> void;
|
||||
|
|
|
@ -10,7 +10,7 @@ auto pTreeViewItem::construct() -> void {
|
|||
gtk_tree_store_append(parentWidget->gtkTreeStore, >kIter, nullptr);
|
||||
}
|
||||
setChecked(state().checked);
|
||||
setImage(state().image);
|
||||
setIcon(state().icon);
|
||||
setText(state().text);
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ auto pTreeViewItem::setFocused() -> void {
|
|||
auto pTreeViewItem::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pTreeViewItem::setImage(const Image& image) -> void {
|
||||
auto pTreeViewItem::setIcon(const image& icon) -> void {
|
||||
if(auto parentWidget = _parentWidget()) {
|
||||
if(image) {
|
||||
auto pixbuf = CreatePixbuf(image);
|
||||
if(icon) {
|
||||
auto pixbuf = CreatePixbuf(icon);
|
||||
gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, pixbuf, -1);
|
||||
} else {
|
||||
gtk_tree_store_set(parentWidget->gtkTreeStore, >kIter, 1, nullptr, -1);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue