mirror of https://github.com/bsnes-emu/bsnes.git
Update to v094r25 release.
byuu says: Windows port should run mostly well now, although exiting fullscreen breaks the application in a really bizarre way. (clicking on the window makes it sink to background rather than come to the foreground o_O) I also need to add the doModalChange => audio.clear() thing for the accursed menu stuttering with DirectSound. I also finished porting all of the ruby drivers over to the newer API changes from nall. Since I can't compile the Linux or OS X drivers, I have no idea if there are any typos that will result in compilation errors. If so, please let me know where they're at and I'll try and fix them. If they're simple, please try and fix them on your end to test further if you can. I'm hopeful the udev crash will be gone now that nall::string checks for null char* values passed to its stringify function. Of course, it's a problem it's getting a null value in the first place, so it may not work at all. If you can compile on Linux (or by some miracle, OS X), please test each video/audio/input driver if you don't mind, to make sure there's no "compiles okay but still typos exist" bugs.
This commit is contained in:
parent
f0c17ffc0d
commit
bb3c69a30d
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Emulator {
|
||||
static const char Name[] = "higan";
|
||||
static const char Version[] = "094.24";
|
||||
static const char Version[] = "094.25";
|
||||
static const char Author[] = "byuu";
|
||||
static const char License[] = "GPLv3";
|
||||
static const char Website[] = "http://byuu.org/";
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mMenuCheckItem::doToggle() const -> void {
|
|||
if(state.onToggle) return state.onToggle();
|
||||
}
|
||||
|
||||
auto mMenuCheckItem::onToggle(const function<void ()>& function) -> type& {
|
||||
state.onToggle = function;
|
||||
auto mMenuCheckItem::onToggle(const function<void ()>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mMenuItem::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mMenuItem::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mMenuItem::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ auto mMenuRadioItem::group() const -> sGroup {
|
|||
return state.group;
|
||||
}
|
||||
|
||||
auto mMenuRadioItem::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mMenuRadioItem::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ auto mMenu::remove(sAction action) -> type& {
|
|||
signal(remove, *action);
|
||||
state.actions.remove(action->offset());
|
||||
for(auto n : range(action->offset(), actions())) {
|
||||
state.actions[n]->offset(-1);
|
||||
state.actions[n]->adjustOffset(-1);
|
||||
}
|
||||
action->setParent();
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ auto Application::name() -> string {
|
|||
return state.name;
|
||||
}
|
||||
|
||||
auto Application::onMain(const nall::function<void ()>& function) -> void {
|
||||
state.onMain = function;
|
||||
auto Application::onMain(const function<void ()>& callback) -> void {
|
||||
state.onMain = callback;
|
||||
}
|
||||
|
||||
auto Application::run() -> void {
|
||||
|
@ -50,8 +50,8 @@ auto Application::Windows::doModalChange(bool modal) -> void {
|
|||
if(state.windows.onModalChange) return state.windows.onModalChange(modal);
|
||||
}
|
||||
|
||||
auto Application::Windows::onModalChange(const function<void (bool)>& function) -> void {
|
||||
state.windows.onModalChange = function;
|
||||
auto Application::Windows::onModalChange(const function<void (bool)>& callback) -> void {
|
||||
state.windows.onModalChange = callback;
|
||||
}
|
||||
|
||||
//Cocoa
|
||||
|
@ -73,20 +73,20 @@ auto Application::Cocoa::doQuit() -> void {
|
|||
if(state.cocoa.onQuit) return state.cocoa.onQuit();
|
||||
}
|
||||
|
||||
auto Application::Cocoa::onAbout(const function<void ()>& function) -> void {
|
||||
state.cocoa.onAbout = function;
|
||||
auto Application::Cocoa::onAbout(const function<void ()>& callback) -> void {
|
||||
state.cocoa.onAbout = callback;
|
||||
}
|
||||
|
||||
auto Application::Cocoa::onActivate(const function<void ()>& function) -> void {
|
||||
state.cocoa.onActivate = function;
|
||||
auto Application::Cocoa::onActivate(const function<void ()>& callback) -> void {
|
||||
state.cocoa.onActivate = callback;
|
||||
}
|
||||
|
||||
auto Application::Cocoa::onPreferences(const function<void ()>& function) -> void {
|
||||
state.cocoa.onPreferences = function;
|
||||
auto Application::Cocoa::onPreferences(const function<void ()>& callback) -> void {
|
||||
state.cocoa.onPreferences = callback;
|
||||
}
|
||||
|
||||
auto Application::Cocoa::onQuit(const function<void ()>& function) -> void {
|
||||
state.cocoa.onQuit = function;
|
||||
auto Application::Cocoa::onQuit(const function<void ()>& callback) -> void {
|
||||
state.cocoa.onQuit = callback;
|
||||
}
|
||||
|
||||
//Internal
|
||||
|
|
|
@ -4,12 +4,8 @@ Color::Color() {
|
|||
setColor(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Color::Color(signed red, signed green, signed blue) {
|
||||
setColor(255, red, green, blue);
|
||||
}
|
||||
|
||||
Color::Color(signed alpha, signed red, signed green, signed blue) {
|
||||
setColor(alpha, red, green, blue);
|
||||
Color::Color(signed red, signed green, signed blue, signed alpha) {
|
||||
setColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
Color::operator bool() const {
|
||||
|
@ -17,7 +13,7 @@ Color::operator bool() const {
|
|||
}
|
||||
|
||||
auto Color::operator==(const Color& source) const -> bool {
|
||||
return alpha() == source.alpha() && red() == source.red() && green() == source.green() && blue() == source.blue();
|
||||
return red() == source.red() && green() == source.green() && blue() == source.blue() && alpha() == source.alpha();
|
||||
}
|
||||
|
||||
auto Color::operator!=(const Color& source) const -> bool {
|
||||
|
@ -33,7 +29,7 @@ auto Color::blue() const -> uint8_t {
|
|||
}
|
||||
|
||||
auto Color::empty() const -> bool {
|
||||
return state.alpha == 0 && state.red == 0 && state.green == 0 && state.blue == 0;
|
||||
return state.red == 0 && state.green == 0 && state.blue == 0 && state.alpha == 0;
|
||||
}
|
||||
|
||||
auto Color::green() const -> uint8_t {
|
||||
|
@ -55,18 +51,14 @@ auto Color::setBlue(signed blue) -> type& {
|
|||
}
|
||||
|
||||
auto Color::setColor(Color color) -> type& {
|
||||
return setColor(color.alpha(), color.red(), color.green(), color.blue());
|
||||
return setColor(color.red(), color.green(), color.blue(), color.alpha());
|
||||
}
|
||||
|
||||
auto Color::setColor(signed red, signed green, signed blue) -> type& {
|
||||
return setColor(255, red, green, blue);
|
||||
}
|
||||
|
||||
auto Color::setColor(signed alpha, signed red, signed green, signed blue) -> type& {
|
||||
state.alpha = max(0, min(255, alpha));
|
||||
auto Color::setColor(signed red, signed green, signed blue, signed alpha) -> type& {
|
||||
state.red = max(0, min(255, red ));
|
||||
state.green = max(0, min(255, green));
|
||||
state.blue = max(0, min(255, blue ));
|
||||
state.alpha = max(0, min(255, alpha));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ struct Application {
|
|||
static auto doMain() -> void;
|
||||
static auto font() -> string;
|
||||
static auto name() -> string;
|
||||
static auto onMain(const function<void ()>& function = {}) -> void;
|
||||
static auto onMain(const function<void ()>& callback = {}) -> void;
|
||||
static auto run() -> void;
|
||||
static auto pendingEvents() -> bool;
|
||||
static auto processEvents() -> void;
|
||||
|
@ -102,7 +102,7 @@ struct Application {
|
|||
|
||||
struct Windows {
|
||||
static auto doModalChange(bool modal) -> void;
|
||||
static auto onModalChange(const function<void (bool)>& function = {}) -> void;
|
||||
static auto onModalChange(const function<void (bool)>& callback = {}) -> void;
|
||||
};
|
||||
|
||||
struct Cocoa {
|
||||
|
@ -110,10 +110,10 @@ struct Application {
|
|||
static auto doActivate() -> void;
|
||||
static auto doPreferences() -> void;
|
||||
static auto doQuit() -> void;
|
||||
static auto onAbout(const function<void ()>& function = {}) -> void;
|
||||
static auto onActivate(const function<void ()>& function = {}) -> void;
|
||||
static auto onPreferences(const function<void ()>& function = {}) -> void;
|
||||
static auto onQuit(const function<void ()>& function = {}) -> void;
|
||||
static auto onAbout(const function<void ()>& callback = {}) -> void;
|
||||
static auto onActivate(const function<void ()>& callback = {}) -> void;
|
||||
static auto onPreferences(const function<void ()>& callback = {}) -> void;
|
||||
static auto onQuit(const function<void ()>& callback = {}) -> void;
|
||||
};
|
||||
|
||||
//private:
|
||||
|
@ -144,8 +144,7 @@ struct Color {
|
|||
using type = Color;
|
||||
|
||||
Color();
|
||||
Color(signed red, signed green, signed blue);
|
||||
Color(signed alpha, signed red, signed green, signed blue);
|
||||
Color(signed red, signed green, signed blue, signed alpha = 255);
|
||||
|
||||
explicit operator bool() const;
|
||||
auto operator==(const Color& source) const -> bool;
|
||||
|
@ -159,18 +158,17 @@ struct Color {
|
|||
auto setAlpha(signed alpha) -> type&;
|
||||
auto setBlue(signed blue) -> type&;
|
||||
auto setColor(Color color = {}) -> type&;
|
||||
auto setColor(signed red, signed green, signed blue) -> type&;
|
||||
auto setColor(signed alpha, signed red, signed green, signed blue) -> type&;
|
||||
auto setColor(signed red, signed green, signed blue, signed alpha = 255) -> type&;
|
||||
auto setGreen(signed green) -> type&;
|
||||
auto setRed(signed red) -> type&;
|
||||
auto value() const -> uint32_t;
|
||||
|
||||
//private:
|
||||
struct State {
|
||||
signed alpha;
|
||||
signed red;
|
||||
signed green;
|
||||
signed blue;
|
||||
signed alpha;
|
||||
} state;
|
||||
};
|
||||
#endif
|
||||
|
@ -408,12 +406,12 @@ struct mObject {
|
|||
mObject& operator=(const mObject&) = delete;
|
||||
|
||||
auto abstract() const -> bool;
|
||||
auto adjustOffset(signed displacement) -> type&;
|
||||
auto enabled(bool recursive = false) const -> bool;
|
||||
virtual auto focused() const -> bool;
|
||||
auto font(bool recursive = false) const -> string;
|
||||
virtual auto group() const -> sGroup;
|
||||
auto offset() const -> signed;
|
||||
auto offset(signed displacement) -> type&;
|
||||
auto parent() const -> mObject*;
|
||||
auto parentComboButton(bool recursive = false) const -> mComboButton*;
|
||||
auto parentFrame(bool recursive = false) const -> mFrame*;
|
||||
|
@ -481,8 +479,8 @@ struct mHotkey : mObject {
|
|||
|
||||
auto doPress() const -> void;
|
||||
auto doRelease() const -> void;
|
||||
auto onPress(const function<void ()>& function = {}) -> type&;
|
||||
auto onRelease(const function<void ()>& function = {}) -> type&;
|
||||
auto onPress(const function<void ()>& callback = {}) -> type&;
|
||||
auto onRelease(const function<void ()>& callback = {}) -> type&;
|
||||
auto parent() const -> wObject;
|
||||
auto remove() -> type& override;
|
||||
auto sequence() const -> string;
|
||||
|
@ -507,7 +505,7 @@ struct mTimer : mObject {
|
|||
|
||||
auto doActivate() const -> void;
|
||||
auto interval() const -> unsigned;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto setInterval(unsigned interval = 0) -> type&;
|
||||
|
||||
//private:
|
||||
|
@ -540,20 +538,19 @@ struct mWindow : mObject {
|
|||
auto layout() const -> sLayout;
|
||||
auto menuBar() const -> sMenuBar;
|
||||
auto modal() const -> bool;
|
||||
auto onClose(const function<void ()>& function = {}) -> type&;
|
||||
auto onDrop(const function<void (lstring)>& function = {}) -> type&;
|
||||
auto onKeyPress(const function<void (signed)>& function = {}) -> type&;
|
||||
auto onKeyRelease(const function<void (signed)>& function = {}) -> type&;
|
||||
auto onMove(const function<void ()>& function = {}) -> type&;
|
||||
auto onSize(const function<void ()>& function = {}) -> type&;
|
||||
auto onClose(const function<void ()>& callback = {}) -> type&;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onKeyPress(const function<void (signed)>& callback = {}) -> type&;
|
||||
auto onKeyRelease(const function<void (signed)>& callback = {}) -> type&;
|
||||
auto onMove(const function<void ()>& callback = {}) -> type&;
|
||||
auto onSize(const function<void ()>& callback = {}) -> type&;
|
||||
auto remove(sLayout layout) -> type&;
|
||||
auto remove(sMenuBar menuBar) -> type&;
|
||||
auto remove(sStatusBar statusBar) -> type&;
|
||||
auto reset() -> type& override;
|
||||
auto resizable() const -> bool;
|
||||
auto setBackgroundColor(Color color = {}) -> type&;
|
||||
auto setCentered() -> type&;
|
||||
auto setCentered(sWindow parent) -> type&;
|
||||
auto setCentered(sWindow parent = {}) -> type&;
|
||||
auto setDroppable(bool droppable = true) -> type&;
|
||||
auto setFrameGeometry(Geometry geometry) -> type&;
|
||||
auto setFramePosition(Position position) -> type&;
|
||||
|
@ -706,7 +703,7 @@ struct mMenuItem : mAction {
|
|||
|
||||
auto doActivate() const -> void;
|
||||
auto icon() const -> image;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto setIcon(const image& icon = {}) -> type&;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
auto text() const -> string;
|
||||
|
@ -726,7 +723,7 @@ struct mMenuCheckItem : mAction {
|
|||
|
||||
auto checked() const -> bool;
|
||||
auto doToggle() const -> void;
|
||||
auto onToggle(const function<void ()>& function = {}) -> type&;
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type&;
|
||||
auto setChecked(bool checked = true) -> type&;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
auto text() const -> string;
|
||||
|
@ -747,7 +744,7 @@ struct mMenuRadioItem : mAction {
|
|||
auto checked() const -> bool;
|
||||
auto doActivate() const -> void;
|
||||
auto group() const -> sGroup override;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto setChecked() -> type&;
|
||||
auto setGroup(sGroup group = {}) -> type& override;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
|
@ -804,7 +801,7 @@ struct mWidget : mSizable {
|
|||
Declare(Widget)
|
||||
|
||||
auto doSize() const -> void;
|
||||
auto onSize(const function<void ()>& function = {}) -> type&;
|
||||
auto onSize(const function<void ()>& callback = {}) -> type&;
|
||||
auto remove() -> type& override;
|
||||
|
||||
//private:
|
||||
|
@ -821,7 +818,7 @@ struct mButton : mWidget {
|
|||
auto bordered() const -> bool;
|
||||
auto doActivate() const -> void;
|
||||
auto icon() const -> image;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto orientation() const -> Orientation;
|
||||
auto setBordered(bool bordered = true) -> type&;
|
||||
auto setIcon(const image& icon = {}) -> type&;
|
||||
|
@ -854,11 +851,11 @@ struct mCanvas : mWidget {
|
|||
auto doMouseRelease(Mouse::Button button) const -> void;
|
||||
auto gradient() const -> vector<Color>;
|
||||
auto icon() const -> image;
|
||||
auto onDrop(const function<void (lstring)>& function = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& function = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position)>& function = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& function = {}) -> type&;
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& function = {}) -> type&;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
auto setColor(Color color) -> type&;
|
||||
auto setData(Size size) -> type&;
|
||||
auto setDroppable(bool droppable = true) -> type&;
|
||||
|
@ -894,7 +891,7 @@ struct mCheckButton : mWidget {
|
|||
auto checked() const -> bool;
|
||||
auto doToggle() const -> void;
|
||||
auto icon() const -> image;
|
||||
auto onToggle(const function<void ()>& function = {}) -> type&;
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type&;
|
||||
auto orientation() const -> Orientation;
|
||||
auto setBordered(bool bordered = true) -> type&;
|
||||
auto setChecked(bool checked = true) -> type&;
|
||||
|
@ -921,7 +918,7 @@ struct mCheckLabel : mWidget {
|
|||
|
||||
auto checked() const -> bool;
|
||||
auto doToggle() const -> void;
|
||||
auto onToggle(const function<void ()>& function = {}) -> type&;
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type&;
|
||||
auto setChecked(bool checked = true) -> type&;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
auto text() const -> string;
|
||||
|
@ -944,7 +941,7 @@ struct mComboButton : mWidget {
|
|||
auto doChange() const -> void;
|
||||
auto item(unsigned position) const -> sComboButtonItem;
|
||||
auto items() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto remove(sComboButtonItem item) -> type&;
|
||||
auto reset() -> type&;
|
||||
auto selected() const -> sComboButtonItem;
|
||||
|
@ -988,7 +985,7 @@ struct mConsole : mWidget {
|
|||
auto backgroundColor() const -> Color;
|
||||
auto doActivate(string) const -> void;
|
||||
auto foregroundColor() const -> Color;
|
||||
auto onActivate(const function<void (string)>& function = {}) -> type&;
|
||||
auto onActivate(const function<void (string)>& callback = {}) -> type&;
|
||||
auto print(const string& text) -> type&;
|
||||
auto prompt() const -> string;
|
||||
auto reset() -> type&;
|
||||
|
@ -1040,8 +1037,8 @@ struct mHexEdit : mWidget {
|
|||
auto foregroundColor() const -> Color;
|
||||
auto length() const -> unsigned;
|
||||
auto offset() const -> unsigned;
|
||||
auto onRead(const function<uint8_t (unsigned)>& function = {}) -> type&;
|
||||
auto onWrite(const function<void (unsigned, uint8_t)>& function = {}) -> type&;
|
||||
auto onRead(const function<uint8_t (unsigned)>& callback = {}) -> type&;
|
||||
auto onWrite(const function<void (unsigned, uint8_t)>& callback = {}) -> type&;
|
||||
auto rows() const -> unsigned;
|
||||
auto setBackgroundColor(Color color = {}) -> type&;
|
||||
auto setColumns(unsigned columns = 16) -> type&;
|
||||
|
@ -1071,7 +1068,7 @@ struct mHorizontalScroller : mWidget {
|
|||
|
||||
auto doChange() const -> void;
|
||||
auto length() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto position() const -> unsigned;
|
||||
auto setLength(unsigned length = 101) -> type&;
|
||||
auto setPosition(unsigned position = 0) -> type&;
|
||||
|
@ -1091,7 +1088,7 @@ struct mHorizontalSlider : mWidget {
|
|||
|
||||
auto doChange() const -> void;
|
||||
auto length() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto position() const -> unsigned;
|
||||
auto setLength(unsigned length = 101) -> type&;
|
||||
auto setPosition(unsigned position = 0) -> type&;
|
||||
|
@ -1120,9 +1117,9 @@ struct mIconView : mWidget {
|
|||
auto item(unsigned position) const -> sIconViewItem;
|
||||
auto items() const -> unsigned;
|
||||
auto multiSelect() const -> bool;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onContext(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onContext(const function<void ()>& callback = {}) -> type&;
|
||||
auto orientation() const -> Orientation;
|
||||
auto remove(sIconViewItem item) -> type&;
|
||||
auto reset() -> type&;
|
||||
|
@ -1203,8 +1200,8 @@ struct mLineEdit : mWidget {
|
|||
auto doChange() const -> void;
|
||||
auto editable() const -> bool;
|
||||
auto foregroundColor() const -> Color;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto setBackgroundColor(Color color = {}) -> type&;
|
||||
auto setEditable(bool editable = true) -> type&;
|
||||
auto setForegroundColor(Color color = {}) -> type&;
|
||||
|
@ -1248,12 +1245,12 @@ struct mListView : mWidget {
|
|||
auto headerVisible() const -> bool;
|
||||
auto item(unsigned position) const -> sListViewItem;
|
||||
auto items() const -> unsigned;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onContext(const function<void ()>& function = {}) -> type&;
|
||||
auto onEdit(const function<void (sListViewCell)>& function = {}) -> type&;
|
||||
auto onSort(const function<void (sListViewColumn)>& function = {}) -> type&;
|
||||
auto onToggle(const function<void (sListViewItem)>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onContext(const function<void ()>& callback = {}) -> type&;
|
||||
auto onEdit(const function<void (sListViewCell)>& callback = {}) -> type&;
|
||||
auto onSort(const function<void (sListViewColumn)>& callback = {}) -> type&;
|
||||
auto onToggle(const function<void (sListViewItem)>& callback = {}) -> type&;
|
||||
auto remove(sListViewColumn column) -> type&;
|
||||
auto remove(sListViewItem item) -> type&;
|
||||
auto reset() -> type&;
|
||||
|
@ -1422,7 +1419,7 @@ struct mRadioButton : mWidget {
|
|||
auto doActivate() const -> void;
|
||||
auto group() const -> sGroup override;
|
||||
auto icon() const -> image;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto orientation() const -> Orientation;
|
||||
auto setBordered(bool bordered = true) -> type&;
|
||||
auto setChecked() -> type&;
|
||||
|
@ -1452,7 +1449,7 @@ struct mRadioLabel : mWidget {
|
|||
auto checked() const -> bool;
|
||||
auto doActivate() const -> void;
|
||||
auto group() const -> sGroup override;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto setChecked() -> type&;
|
||||
auto setGroup(sGroup group = {}) -> type& override;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
|
@ -1474,8 +1471,8 @@ struct mSourceEdit : mWidget {
|
|||
|
||||
auto doChange() const -> void;
|
||||
auto doMove() const -> void;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onMove(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMove(const function<void ()>& callback = {}) -> type&;
|
||||
auto position() const -> unsigned;
|
||||
auto setPosition(signed position) -> type&;
|
||||
auto setSelected(Position selected) -> type&;
|
||||
|
@ -1506,9 +1503,9 @@ struct mTabFrame : mWidget {
|
|||
auto edge() const -> Edge;
|
||||
auto item(unsigned position) const -> sTabFrameItem;
|
||||
auto items() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onClose(const function<void (sTabFrameItem)>& function = {}) -> type&;
|
||||
auto onMove(const function<void (sTabFrameItem, sTabFrameItem)>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onClose(const function<void (sTabFrameItem)>& callback = {}) -> type&;
|
||||
auto onMove(const function<void (sTabFrameItem, sTabFrameItem)>& callback = {}) -> type&;
|
||||
auto remove(sTabFrameItem item) -> type&;
|
||||
auto reset() -> type&;
|
||||
auto selected() const -> sTabFrameItem;
|
||||
|
@ -1573,8 +1570,8 @@ struct mTextEdit : mWidget {
|
|||
auto doMove() const -> void;
|
||||
auto editable() const -> bool;
|
||||
auto foregroundColor() const -> Color;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onMove(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMove(const function<void ()>& callback = {}) -> type&;
|
||||
auto setBackgroundColor(Color color = {}) -> type&;
|
||||
auto setCursorPosition(unsigned position) -> type&;
|
||||
auto setEditable(bool editable = true) -> type&;
|
||||
|
@ -1615,10 +1612,10 @@ struct mTreeView : mWidget {
|
|||
auto foregroundColor() const -> Color;
|
||||
auto item(const string& path) const -> sTreeViewItem;
|
||||
auto items() const -> unsigned;
|
||||
auto onActivate(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onContext(const function<void ()>& function = {}) -> type&;
|
||||
auto onToggle(const function<void (sTreeViewItem)>& function = {}) -> type&;
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto onContext(const function<void ()>& callback = {}) -> type&;
|
||||
auto onToggle(const function<void (sTreeViewItem)>& callback = {}) -> type&;
|
||||
auto remove(sTreeViewItem item) -> type&;
|
||||
auto reset() -> type&;
|
||||
auto selected() const -> sTreeViewItem;
|
||||
|
@ -1683,7 +1680,7 @@ struct mVerticalScroller : mWidget {
|
|||
|
||||
auto doChange() const -> void;
|
||||
auto length() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto position() const -> unsigned;
|
||||
auto setLength(unsigned length = 101) -> type&;
|
||||
auto setPosition(unsigned position = 0) -> type&;
|
||||
|
@ -1703,7 +1700,7 @@ struct mVerticalSlider : mWidget {
|
|||
|
||||
auto doChange() const -> void;
|
||||
auto length() const -> unsigned;
|
||||
auto onChange(const function<void ()>& function = {}) -> type&;
|
||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||
auto position() const -> unsigned;
|
||||
auto setLength(unsigned length = 101) -> type&;
|
||||
auto setPosition(unsigned position = 0) -> type&;
|
||||
|
@ -1728,11 +1725,11 @@ struct mViewport : mWidget {
|
|||
auto doMouseRelease(Mouse::Button button) const -> void;
|
||||
auto droppable() const -> bool;
|
||||
auto handle() const -> uintptr_t;
|
||||
auto onDrop(const function<void (lstring)>& function = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& function = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position position)>& function = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& function = {}) -> type&;
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& function = {}) -> type&;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position position)>& callback = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
auto setDroppable(bool droppable = true) -> type&;
|
||||
|
||||
//private:
|
||||
|
|
|
@ -14,13 +14,13 @@ auto mHotkey::doRelease() const -> void {
|
|||
if(state.onRelease) return state.onRelease();
|
||||
}
|
||||
|
||||
auto mHotkey::onPress(const function<void ()>& function) -> type& {
|
||||
state.onPress = function;
|
||||
auto mHotkey::onPress(const function<void ()>& callback) -> type& {
|
||||
state.onPress = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mHotkey::onRelease(const function<void ()>& function) -> type& {
|
||||
state.onRelease = function;
|
||||
auto mHotkey::onRelease(const function<void ()>& callback) -> type& {
|
||||
state.onRelease = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ auto mLayout::remove(shared_pointer<mSizable> sizable) -> type& {
|
|||
sizable->setParent();
|
||||
state.sizables.remove(offset);
|
||||
for(auto n : range(offset, sizables())) {
|
||||
state.sizables[n]->offset(-1);
|
||||
state.sizables[n]->adjustOffset(-1);
|
||||
}
|
||||
setGeometry(geometry());
|
||||
return *this;
|
||||
|
|
|
@ -37,7 +37,7 @@ auto mMenuBar::remove(shared_pointer<mMenu> menu) -> type& {
|
|||
signal(remove, *menu);
|
||||
state.menus.remove(offset);
|
||||
for(auto n : range(offset, menus())) {
|
||||
state.menus[n]->offset(-1);
|
||||
state.menus[n]->adjustOffset(-1);
|
||||
}
|
||||
menu->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -47,6 +47,11 @@ auto mObject::abstract() const -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
auto mObject::adjustOffset(signed displacement) -> type& {
|
||||
state.offset += displacement;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mObject::enabled(bool recursive) const -> bool {
|
||||
if(!recursive || !state.enabled) return state.enabled;
|
||||
if(auto object = parent()) return object->enabled(true);
|
||||
|
@ -72,11 +77,6 @@ auto mObject::offset() const -> signed {
|
|||
return state.offset;
|
||||
}
|
||||
|
||||
auto mObject::offset(signed displacement) -> type& {
|
||||
state.offset += displacement;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mObject::parent() const -> mObject* {
|
||||
return state.parent;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ auto mPopupMenu::remove(sAction action) -> type& {
|
|||
signal(remove, action);
|
||||
state.actions.remove(offset);
|
||||
for(auto n : range(offset, actions())) {
|
||||
state.actions[n]->offset(-1);
|
||||
state.actions[n]->adjustOffset(-1);
|
||||
}
|
||||
action->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mTimer::interval() const -> unsigned {
|
|||
return state.interval;
|
||||
}
|
||||
|
||||
auto mTimer::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mTimer::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ auto mButton::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mButton::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mButton::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,28 +46,28 @@ auto mCanvas::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mCanvas::onDrop(const function<void (lstring)>& function) -> type& {
|
||||
state.onDrop = function;
|
||||
auto mCanvas::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mCanvas::onMouseLeave(const function<void ()>& function) -> type& {
|
||||
state.onMouseLeave = function;
|
||||
auto mCanvas::onMouseLeave(const function<void ()>& callback) -> type& {
|
||||
state.onMouseLeave = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mCanvas::onMouseMove(const function<void (Position)>& function) -> type& {
|
||||
state.onMouseMove = function;
|
||||
auto mCanvas::onMouseMove(const function<void (Position)>& callback) -> type& {
|
||||
state.onMouseMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mCanvas::onMousePress(const function<void (Mouse::Button)>& function) -> type& {
|
||||
state.onMousePress = function;
|
||||
auto mCanvas::onMousePress(const function<void (Mouse::Button)>& callback) -> type& {
|
||||
state.onMousePress = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mCanvas::onMouseRelease(const function<void (Mouse::Button)>& function) -> type& {
|
||||
state.onMouseRelease = function;
|
||||
auto mCanvas::onMouseRelease(const function<void (Mouse::Button)>& callback) -> type& {
|
||||
state.onMouseRelease = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ auto mCheckButton::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mCheckButton::onToggle(const function<void ()>& function) -> type& {
|
||||
state.onToggle = function;
|
||||
auto mCheckButton::onToggle(const function<void ()>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mCheckLabel::doToggle() const -> void {
|
|||
if(state.onToggle) return state.onToggle();
|
||||
}
|
||||
|
||||
auto mCheckLabel::onToggle(const function<void ()>& function) -> type& {
|
||||
state.onToggle = function;
|
||||
auto mCheckLabel::onToggle(const function<void ()>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ auto mComboButton::items() const -> unsigned {
|
|||
return state.items.size();
|
||||
}
|
||||
|
||||
auto mComboButton::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mComboButton::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ auto mComboButton::remove(sComboButtonItem item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
item->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -18,8 +18,8 @@ auto mConsole::foregroundColor() const -> Color {
|
|||
return state.foregroundColor;
|
||||
}
|
||||
|
||||
auto mConsole::onActivate(const function<void (string)>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mConsole::onActivate(const function<void (string)>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ auto mHexEdit::offset() const -> unsigned {
|
|||
return state.offset;
|
||||
}
|
||||
|
||||
auto mHexEdit::onRead(const function<uint8_t (unsigned)>& function) -> type& {
|
||||
state.onRead = function;
|
||||
auto mHexEdit::onRead(const function<uint8_t (unsigned)>& callback) -> type& {
|
||||
state.onRead = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mHexEdit::onWrite(const function<void (unsigned, uint8_t)>& function) -> type& {
|
||||
state.onWrite = function;
|
||||
auto mHexEdit::onWrite(const function<void (unsigned, uint8_t)>& callback) -> type& {
|
||||
state.onWrite = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mHorizontalScroller::length() const -> unsigned {
|
|||
return state.length;
|
||||
}
|
||||
|
||||
auto mHorizontalScroller::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mHorizontalScroller::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mHorizontalSlider::length() const -> unsigned {
|
|||
return state.length;
|
||||
}
|
||||
|
||||
auto mHorizontalSlider::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mHorizontalSlider::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,18 +55,18 @@ auto mIconView::multiSelect() const -> bool {
|
|||
return state.multiSelect;
|
||||
}
|
||||
|
||||
auto mIconView::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mIconView::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mIconView::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mIconView::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mIconView::onContext(const function<void ()>& function) -> type& {
|
||||
state.onContext = function;
|
||||
auto mIconView::onContext(const function<void ()>& callback) -> type& {
|
||||
state.onContext = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ auto mIconView::remove(shared_pointer<mIconViewItem> item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
item->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -26,13 +26,13 @@ auto mLineEdit::foregroundColor() const -> Color {
|
|||
return state.foregroundColor;
|
||||
}
|
||||
|
||||
auto mLineEdit::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mLineEdit::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mLineEdit::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mLineEdit::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ auto mListViewItem::remove(sListViewCell cell) -> type& {
|
|||
signal(remove, cell);
|
||||
state.cells.remove(cell->offset());
|
||||
for(auto n : range(cell->offset(), cells())) {
|
||||
state.cells[n]->offset(-1);
|
||||
state.cells[n]->adjustOffset(-1);
|
||||
}
|
||||
cell->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -106,33 +106,33 @@ auto mListView::items() const -> unsigned {
|
|||
return state.items.size();
|
||||
}
|
||||
|
||||
auto mListView::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mListView::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mListView::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onContext(const function<void ()>& function) -> type& {
|
||||
state.onContext = function;
|
||||
auto mListView::onContext(const function<void ()>& callback) -> type& {
|
||||
state.onContext = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onEdit(const function<void (sListViewCell)>& function) -> type& {
|
||||
state.onEdit = function;
|
||||
auto mListView::onEdit(const function<void (sListViewCell)>& callback) -> type& {
|
||||
state.onEdit = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onSort(const function<void (sListViewColumn)>& function) -> type& {
|
||||
state.onSort = function;
|
||||
auto mListView::onSort(const function<void (sListViewColumn)>& callback) -> type& {
|
||||
state.onSort = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onToggle(const function<void (sListViewItem)>& function) -> type& {
|
||||
state.onToggle = function;
|
||||
auto mListView::onToggle(const function<void (sListViewItem)>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ auto mListView::remove(sListViewColumn column) -> type& {
|
|||
state.items.reset();
|
||||
state.columns.remove(column->offset());
|
||||
for(auto n : range(column->offset(), columns())) {
|
||||
state.columns[n]->offset(-1);
|
||||
state.columns[n]->adjustOffset(-1);
|
||||
}
|
||||
column->setParent();
|
||||
return *this;
|
||||
|
@ -152,7 +152,7 @@ auto mListView::remove(sListViewItem item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
item->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -26,8 +26,8 @@ auto mRadioButton::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mRadioButton::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mRadioButton::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ auto mRadioLabel::group() const -> sGroup {
|
|||
return state.group;
|
||||
}
|
||||
|
||||
auto mRadioLabel::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mRadioLabel::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ auto mSourceEdit::doMove() const -> void {
|
|||
if(state.onMove) return state.onMove();
|
||||
}
|
||||
|
||||
auto mSourceEdit::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mSourceEdit::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mSourceEdit::onMove(const function<void ()>& function) -> type& {
|
||||
state.onMove = function;
|
||||
auto mSourceEdit::onMove(const function<void ()>& callback) -> type& {
|
||||
state.onMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,18 +43,18 @@ auto mTabFrame::items() const -> unsigned {
|
|||
return state.items.size();
|
||||
}
|
||||
|
||||
auto mTabFrame::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mTabFrame::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTabFrame::onClose(const function<void (sTabFrameItem)>& function) -> type& {
|
||||
state.onClose = function;
|
||||
auto mTabFrame::onClose(const function<void (sTabFrameItem)>& callback) -> type& {
|
||||
state.onClose = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTabFrame::onMove(const function<void (sTabFrameItem, sTabFrameItem)>& function) -> type& {
|
||||
state.onMove = function;
|
||||
auto mTabFrame::onMove(const function<void (sTabFrameItem, sTabFrameItem)>& callback) -> type& {
|
||||
state.onMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ auto mTabFrame::remove(sTabFrameItem item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(offset, items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ auto mTextEdit::foregroundColor() const -> Color {
|
|||
return state.foregroundColor;
|
||||
}
|
||||
|
||||
auto mTextEdit::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mTextEdit::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTextEdit::onMove(const function<void ()>& function) -> type& {
|
||||
state.onMove = function;
|
||||
auto mTextEdit::onMove(const function<void ()>& callback) -> type& {
|
||||
state.onMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ auto mTreeViewItem::remove(sTreeViewItem item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
item->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -69,23 +69,23 @@ auto mTreeView::items() const -> unsigned {
|
|||
return state.items.size();
|
||||
}
|
||||
|
||||
auto mTreeView::onActivate(const function<void ()>& function) -> type& {
|
||||
state.onActivate = function;
|
||||
auto mTreeView::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTreeView::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mTreeView::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTreeView::onContext(const function<void ()>& function) -> type& {
|
||||
state.onContext = function;
|
||||
auto mTreeView::onContext(const function<void ()>& callback) -> type& {
|
||||
state.onContext = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mTreeView::onToggle(const function<void (sTreeViewItem)>& function) -> type& {
|
||||
state.onToggle = function;
|
||||
auto mTreeView::onToggle(const function<void (sTreeViewItem)>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ auto mTreeView::remove(sTreeViewItem item) -> type& {
|
|||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), items())) {
|
||||
state.items[n]->offset(-1);
|
||||
state.items[n]->adjustOffset(-1);
|
||||
}
|
||||
item->setParent();
|
||||
return *this;
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mVerticalScroller::length() const -> unsigned {
|
|||
return state.length;
|
||||
}
|
||||
|
||||
auto mVerticalScroller::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mVerticalScroller::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ auto mVerticalSlider::length() const -> unsigned {
|
|||
return state.length;
|
||||
}
|
||||
|
||||
auto mVerticalSlider::onChange(const function<void ()>& function) -> type& {
|
||||
state.onChange = function;
|
||||
auto mVerticalSlider::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,28 +34,28 @@ auto mViewport::handle() const -> uintptr_t {
|
|||
return signal(handle);
|
||||
}
|
||||
|
||||
auto mViewport::onDrop(const function<void (lstring)>& function) -> type& {
|
||||
state.onDrop = function;
|
||||
auto mViewport::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mViewport::onMouseLeave(const function<void ()>& function) -> type& {
|
||||
state.onMouseLeave = function;
|
||||
auto mViewport::onMouseLeave(const function<void ()>& callback) -> type& {
|
||||
state.onMouseLeave = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mViewport::onMouseMove(const function<void (Position)>& function) -> type& {
|
||||
state.onMouseMove = function;
|
||||
auto mViewport::onMouseMove(const function<void (Position)>& callback) -> type& {
|
||||
state.onMouseMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mViewport::onMousePress(const function<void (Mouse::Button)>& function) -> type& {
|
||||
state.onMousePress = function;
|
||||
auto mViewport::onMousePress(const function<void (Mouse::Button)>& callback) -> type& {
|
||||
state.onMousePress = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mViewport::onMouseRelease(const function<void (Mouse::Button)>& function) -> type& {
|
||||
state.onMouseRelease = function;
|
||||
auto mViewport::onMouseRelease(const function<void (Mouse::Button)>& callback) -> type& {
|
||||
state.onMouseRelease = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ auto mWidget::doSize() const -> void {
|
|||
if(state.onSize) return state.onSize();
|
||||
}
|
||||
|
||||
auto mWidget::onSize(const function<void ()>& function) -> type& {
|
||||
state.onSize = function;
|
||||
auto mWidget::onSize(const function<void ()>& callback) -> type& {
|
||||
state.onSize = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ auto mWindow::destruct() -> void {
|
|||
|
||||
//
|
||||
|
||||
auto mWindow::append(shared_pointer<mLayout> layout) -> type& {
|
||||
auto mWindow::append(sLayout layout) -> type& {
|
||||
if(auto& layout = state.layout) remove(layout);
|
||||
state.layout = layout;
|
||||
layout->setGeometry(geometry().setPosition(0, 0));
|
||||
|
@ -23,7 +23,7 @@ auto mWindow::append(shared_pointer<mLayout> layout) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::append(shared_pointer<mMenuBar> menuBar) -> type& {
|
||||
auto mWindow::append(sMenuBar menuBar) -> type& {
|
||||
if(auto& menuBar = state.menuBar) remove(menuBar);
|
||||
menuBar->setParent(this, 0);
|
||||
state.menuBar = menuBar;
|
||||
|
@ -31,7 +31,7 @@ auto mWindow::append(shared_pointer<mMenuBar> menuBar) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::append(shared_pointer<mStatusBar> statusBar) -> type& {
|
||||
auto mWindow::append(sStatusBar statusBar) -> type& {
|
||||
if(auto& statusBar = state.statusBar) remove(statusBar);
|
||||
statusBar->setParent(this, 0);
|
||||
state.statusBar = statusBar;
|
||||
|
@ -99,44 +99,44 @@ auto mWindow::modal() const -> bool {
|
|||
return state.modal;
|
||||
}
|
||||
|
||||
auto mWindow::onClose(const function<void ()>& function) -> type& {
|
||||
state.onClose = function;
|
||||
auto mWindow::onClose(const function<void ()>& callback) -> type& {
|
||||
state.onClose = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onDrop(const function<void (lstring)>& function) -> type& {
|
||||
state.onDrop = function;
|
||||
auto mWindow::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onKeyPress(const function<void (signed)>& function) -> type& {
|
||||
state.onKeyPress = function;
|
||||
auto mWindow::onKeyPress(const function<void (signed)>& callback) -> type& {
|
||||
state.onKeyPress = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onKeyRelease(const function<void (signed)>& function) -> type& {
|
||||
state.onKeyRelease = function;
|
||||
auto mWindow::onKeyRelease(const function<void (signed)>& callback) -> type& {
|
||||
state.onKeyRelease = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onMove(const function<void ()>& function) -> type& {
|
||||
state.onMove = function;
|
||||
auto mWindow::onMove(const function<void ()>& callback) -> type& {
|
||||
state.onMove = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onSize(const function<void ()>& function) -> type& {
|
||||
state.onSize = function;
|
||||
auto mWindow::onSize(const function<void ()>& callback) -> type& {
|
||||
state.onSize = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::remove(shared_pointer<mLayout> layout) -> type& {
|
||||
auto mWindow::remove(sLayout layout) -> type& {
|
||||
signal(remove, layout);
|
||||
layout->setParent();
|
||||
state.layout.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::remove(shared_pointer<mMenuBar> menuBar) -> type& {
|
||||
auto mWindow::remove(sMenuBar menuBar) -> type& {
|
||||
signal(remove, menuBar);
|
||||
menuBar->reset();
|
||||
menuBar->setParent();
|
||||
|
@ -144,7 +144,7 @@ auto mWindow::remove(shared_pointer<mMenuBar> menuBar) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::remove(shared_pointer<mStatusBar> statusBar) -> type& {
|
||||
auto mWindow::remove(sStatusBar statusBar) -> type& {
|
||||
signal(remove, statusBar);
|
||||
statusBar->setParent();
|
||||
state.statusBar.reset();
|
||||
|
@ -168,19 +168,8 @@ auto mWindow::setBackgroundColor(Color color) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::setCentered() -> type& {
|
||||
Geometry workspace = Desktop::workspace();
|
||||
Geometry geometry = frameGeometry();
|
||||
signed x = workspace.x();
|
||||
signed y = workspace.y();
|
||||
if(workspace.width() > geometry.width()) x += (workspace.width() - geometry.width()) / 2;
|
||||
if(workspace.height() > geometry.height()) y += (workspace.height() - geometry.height()) / 2;
|
||||
return setFrameGeometry({x, y, geometry.width(), geometry.height()});
|
||||
}
|
||||
|
||||
auto mWindow::setCentered(shared_pointer<mWindow> parent) -> type& {
|
||||
if(!parent) return setCentered();
|
||||
Geometry workspace = parent->frameGeometry();
|
||||
auto mWindow::setCentered(sWindow parent) -> type& {
|
||||
Geometry workspace = parent ? parent->frameGeometry() : Desktop::workspace();
|
||||
Geometry geometry = frameGeometry();
|
||||
signed x = workspace.x();
|
||||
signed y = workspace.y();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#if defined(Hiro_FixedLayout)
|
||||
|
||||
auto mFixedLayout::append(shared_pointer<mSizable> sizable, Geometry geometry) -> type& {
|
||||
auto mFixedLayout::append(sSizable sizable, Geometry geometry) -> type& {
|
||||
properties.append({geometry});
|
||||
mLayout::append(sizable);
|
||||
sizable->setGeometry(geometry);
|
||||
|
@ -16,7 +16,7 @@ auto mFixedLayout::minimumSize() const -> Size {
|
|||
return {width, height};
|
||||
}
|
||||
|
||||
auto mFixedLayout::remove(shared_pointer<mSizable> sizable) -> type& {
|
||||
auto mFixedLayout::remove(sSizable sizable) -> type& {
|
||||
properties.remove(sizable->offset());
|
||||
mLayout::remove(sizable);
|
||||
return *this;
|
||||
|
|
|
@ -5,18 +5,18 @@ struct mFixedLayout : mLayout {
|
|||
using mLayout::append;
|
||||
using mLayout::remove;
|
||||
|
||||
auto append(nall::shared_pointer<mSizable> sizable, Geometry geometry) -> type&;
|
||||
auto append(sSizable sizable, Geometry geometry) -> type&;
|
||||
auto minimumSize() const -> Size override;
|
||||
auto remove(nall::shared_pointer<mSizable> sizable) -> type& override;
|
||||
auto remove(sSizable sizable) -> type& override;
|
||||
auto reset() -> type& override;
|
||||
auto setEnabled(bool enabled = true) -> type& override;
|
||||
auto setFont(const nall::string& font = "") -> type& override;
|
||||
auto setFont(const string& font = "") -> type& override;
|
||||
auto setVisible(bool visible = true) ->type& override;
|
||||
|
||||
struct Properties {
|
||||
Geometry geometry;
|
||||
};
|
||||
nall::vector<Properties> properties;
|
||||
vector<Properties> properties;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#if defined(Hiro_HorizontalLayout)
|
||||
|
||||
auto mHorizontalLayout::append(shared_pointer<mSizable> sizable, Size size, signed spacing) -> type& {
|
||||
auto mHorizontalLayout::append(sSizable sizable, Size size, signed spacing) -> type& {
|
||||
properties.append({size.width(), size.height(), spacing < 0 ? settings.spacing : spacing});
|
||||
mLayout::append(sizable);
|
||||
return *this;
|
||||
|
@ -31,7 +31,7 @@ auto mHorizontalLayout::minimumSize() const -> Size {
|
|||
return {settings.margin * 2 + width, settings.margin * 2 + height};
|
||||
}
|
||||
|
||||
auto mHorizontalLayout::remove(shared_pointer<mSizable> sizable) -> type& {
|
||||
auto mHorizontalLayout::remove(sSizable sizable) -> type& {
|
||||
properties.remove(sizable->offset());
|
||||
mLayout::remove(sizable);
|
||||
return *this;
|
||||
|
|
|
@ -5,13 +5,13 @@ struct mHorizontalLayout : mLayout {
|
|||
using mLayout::append;
|
||||
using mLayout::remove;
|
||||
|
||||
auto append(nall::shared_pointer<mSizable> sizable, Size size, signed spacing = 5) -> type&;
|
||||
auto append(sSizable sizable, Size size, signed spacing = 5) -> type&;
|
||||
auto minimumSize() const -> Size override;
|
||||
auto remove(nall::shared_pointer<mSizable> sizable) -> type& override;
|
||||
auto remove(sSizable sizable) -> type& override;
|
||||
auto reset() -> type& override;
|
||||
auto setAlignment(double alignment = 0.5) -> type&;
|
||||
auto setEnabled(bool enabled = true) -> type& override;
|
||||
auto setFont(const nall::string& font = "") -> type& override;
|
||||
auto setFont(const string& font = "") -> type& override;
|
||||
auto setGeometry(Geometry geometry) -> type& override;
|
||||
auto setMargin(signed margin = 0) -> type&;
|
||||
auto setSpacing(signed spacing = 5) -> type&;
|
||||
|
@ -28,7 +28,7 @@ struct mHorizontalLayout : mLayout {
|
|||
signed height;
|
||||
signed spacing;
|
||||
};
|
||||
nall::vector<Property> properties;
|
||||
vector<Property> properties;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define DeclareWidget(Name) \
|
||||
DeclareSizable(Name) \
|
||||
auto doSize() const -> void { return self().doSize(); } \
|
||||
auto onSize(const function<void ()>& function = {}) -> type& { return self().onSize(function), *this; } \
|
||||
auto onSize(const function<void ()>& callback = {}) -> type& { return self().onSize(callback), *this; } \
|
||||
|
||||
#if defined(Hiro_Object)
|
||||
struct Object : sObject {
|
||||
|
@ -78,8 +78,8 @@ struct Hotkey : sHotkey {
|
|||
|
||||
auto doPress() const -> void { return self().doPress(); }
|
||||
auto doRelease() const -> void { return self().doRelease(); }
|
||||
auto onPress(const function<void ()>& function = {}) -> type& { return self().onPress(function), *this; }
|
||||
auto onRelease(const function<void ()>& function = {}) -> type& { return self().onRelease(function), *this; }
|
||||
auto onPress(const function<void ()>& callback = {}) -> type& { return self().onPress(callback), *this; }
|
||||
auto onRelease(const function<void ()>& callback = {}) -> type& { return self().onRelease(callback), *this; }
|
||||
auto parent() const -> wObject { return self().parent(); }
|
||||
auto sequence() const -> string { return self().sequence(); }
|
||||
auto setParent(sObject object) -> type& { return self().setParent(object), *this; }
|
||||
|
@ -93,7 +93,7 @@ struct Timer : sTimer {
|
|||
|
||||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto interval() const -> unsigned { return self().interval(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto setInterval(unsigned interval = 0) -> type& { return self().setInterval(interval), *this; }
|
||||
};
|
||||
#endif
|
||||
|
@ -119,20 +119,19 @@ struct Window : sWindow {
|
|||
auto layout() const -> sLayout { return self().layout(); }
|
||||
auto menuBar() const -> sMenuBar { return self().menuBar(); }
|
||||
auto modal() const -> bool { return self().modal(); }
|
||||
auto onClose(const function<void ()>& function = {}) -> type& { return self().onClose(function), *this; }
|
||||
auto onDrop(const function<void (nall::lstring)>& function = {}) -> type& { return self().onDrop(function), *this; }
|
||||
auto onKeyPress(const function<void (signed)>& function = {}) -> type& { return self().onKeyPress(function), *this; }
|
||||
auto onKeyRelease(const function<void (signed)>& function = {}) -> type& { return self().onKeyRelease(function), *this; }
|
||||
auto onMove(const function<void ()>& function = {}) -> type& { return self().onMove(function), *this; }
|
||||
auto onSize(const function<void ()>& function = {}) -> type& { return self().onSize(function), *this; }
|
||||
auto onClose(const function<void ()>& callback = {}) -> type& { return self().onClose(callback), *this; }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type& { return self().onDrop(callback), *this; }
|
||||
auto onKeyPress(const function<void (signed)>& callback = {}) -> type& { return self().onKeyPress(callback), *this; }
|
||||
auto onKeyRelease(const function<void (signed)>& callback = {}) -> type& { return self().onKeyRelease(callback), *this; }
|
||||
auto onMove(const function<void ()>& callback = {}) -> type& { return self().onMove(callback), *this; }
|
||||
auto onSize(const function<void ()>& callback = {}) -> type& { return self().onSize(callback), *this; }
|
||||
auto remove(sLayout layout) -> type& { return self().remove(layout), *this; }
|
||||
auto remove(sMenuBar menuBar) -> type& { return self().remove(menuBar), *this; }
|
||||
auto remove(sStatusBar statusBar) -> type& { return self().remove(statusBar), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
auto resizable() const -> bool { return self().resizable(); }
|
||||
auto setBackgroundColor(Color color = {}) -> type& { return self().setBackgroundColor(color), *this; }
|
||||
auto setCentered() -> type& { return self().setCentered(), *this; }
|
||||
auto setCentered(sWindow parent) -> type& { return self().setCentered(parent), *this; }
|
||||
auto setCentered(sWindow parent = {}) -> type& { return self().setCentered(parent), *this; }
|
||||
auto setDroppable(bool droppable = true) -> type& { return self().setDroppable(droppable), *this; }
|
||||
auto setFrameGeometry(Geometry geometry) -> type& { return self().setFrameGeometry(geometry), *this; }
|
||||
auto setFramePosition(Position position) -> type& { return self().setFramePosition(position), *this; }
|
||||
|
@ -217,7 +216,7 @@ struct MenuItem : sMenuItem {
|
|||
|
||||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto icon() const -> image { return self().icon(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto setIcon(const image& icon = {}) -> type& { return self().setIcon(icon), *this; }
|
||||
auto setText(const string& text = "") -> type& { return self().setText(text), *this; }
|
||||
auto text() const -> string { return self().text(); }
|
||||
|
@ -230,7 +229,7 @@ struct MenuCheckItem : sMenuCheckItem {
|
|||
|
||||
auto checked() const -> bool { return self().checked(); }
|
||||
auto doToggle() const -> void { return self().doToggle(); }
|
||||
auto onToggle(const function<void ()>& function = {}) -> type& { return self().onToggle(function), *this; }
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type& { return self().onToggle(callback), *this; }
|
||||
auto setChecked(bool checked = true) -> type& { return self().setChecked(checked), *this; }
|
||||
auto setText(const string& text = "") -> type& { return self().setText(text), *this; }
|
||||
auto text() const -> string { return self().text(); }
|
||||
|
@ -244,7 +243,7 @@ struct MenuRadioItem : sMenuRadioItem {
|
|||
auto checked() const -> bool { return self().checked(); }
|
||||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto group() const -> sGroup { return self().group(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto setChecked() -> type& { return self().setChecked(), *this; }
|
||||
auto setText(const string& text = "") -> type& { return self().setText(text), *this; }
|
||||
auto text() const -> string { return self().text(); }
|
||||
|
@ -276,7 +275,7 @@ struct Button : sButton {
|
|||
auto bordered() const -> bool { return self().bordered(); }
|
||||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto icon() const -> image { return self().icon(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto orientation() const -> Orientation { return self().orientation(); }
|
||||
auto setBordered(bool bordered = true) -> type& { return self().setBordered(bordered), *this; }
|
||||
auto setIcon(const image& icon = {}) -> type& { return self().setIcon(icon), *this; }
|
||||
|
@ -300,11 +299,11 @@ struct Canvas : sCanvas {
|
|||
auto doMouseRelease(Mouse::Button button) const -> void { return self().doMouseRelease(button); }
|
||||
auto gradient() const -> vector<Color> { return self().gradient(); }
|
||||
auto icon() const -> image { return self().icon(); }
|
||||
auto onDrop(const function<void (lstring)>& function = {}) -> type& { return self().onDrop(function), *this; }
|
||||
auto onMouseLeave(const function<void ()>& function = {}) -> type& { return self().onMouseLeave(function), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& function = {}) -> type& { return self().onMouseMove(function), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& function = {}) -> type& { return self().onMousePress(function), *this; }
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& function = {}) -> type& { return self().onMouseRelease(function), *this; }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type& { return self().onDrop(callback), *this; }
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type& { return self().onMouseLeave(callback), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) -> type& { return self().onMouseMove(callback), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type& { return self().onMousePress(callback), *this; }
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& callback = {}) -> type& { return self().onMouseRelease(callback), *this; }
|
||||
auto setColor(Color color) -> type& { return self().setColor(color), *this; }
|
||||
auto setData(Size size) -> type& { return self().setData(size), *this; }
|
||||
auto setDroppable(bool droppable = true) -> type& { return self().setDroppable(droppable), *this; }
|
||||
|
@ -325,7 +324,7 @@ struct CheckButton : sCheckButton {
|
|||
auto checked() const -> bool { return self().checked(); }
|
||||
auto doToggle() const -> void { return self().doToggle(); }
|
||||
auto icon() const -> image { return self().icon(); }
|
||||
auto onToggle(const function<void ()>& function = {}) -> type& { return self().onToggle(function), *this; }
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type& { return self().onToggle(callback), *this; }
|
||||
auto orientation() const -> Orientation { return self().orientation(); }
|
||||
auto setBordered(bool bordered = true) -> type& { return self().setBordered(bordered), *this; }
|
||||
auto setChecked(bool checked = true) -> type& { return self().setChecked(checked), *this; }
|
||||
|
@ -342,7 +341,7 @@ struct CheckLabel : sCheckLabel {
|
|||
|
||||
auto checked() const -> bool { return self().checked(); }
|
||||
auto doToggle() const -> void { return self().doToggle(); }
|
||||
auto onToggle(const function<void ()>& function = {}) -> type& { return self().onToggle(function), *this; }
|
||||
auto onToggle(const function<void ()>& callback = {}) -> type& { return self().onToggle(callback), *this; }
|
||||
auto setChecked(bool checked = true) -> type& { return self().setChecked(checked), *this; }
|
||||
auto setText(const string& text = "") -> type& { return self().setText(text), *this; }
|
||||
auto text() const -> string { return self().text(); }
|
||||
|
@ -357,7 +356,7 @@ struct ComboButton : sComboButton {
|
|||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto item(unsigned position) const -> sComboButtonItem { return self().item(position); }
|
||||
auto items() const -> unsigned { return self().items(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto remove(sComboButtonItem item) -> type& { return self().remove(item), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
auto selected() const -> sComboButtonItem { return self().selected(); }
|
||||
|
@ -385,7 +384,7 @@ struct Console : sConsole {
|
|||
auto backgroundColor() const -> Color { return self().backgroundColor(); }
|
||||
auto doActivate(string command) const -> void { return self().doActivate(command); }
|
||||
auto foregroundColor() const -> Color { return self().foregroundColor(); }
|
||||
auto onActivate(const function<void (string)>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void (string)>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto print(const string& text) -> type& { return self().print(text), *this; }
|
||||
auto prompt() const -> string { return self().prompt(); }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
|
@ -419,8 +418,8 @@ struct HexEdit : sHexEdit {
|
|||
auto foregroundColor() const -> Color { return self().foregroundColor(); }
|
||||
auto length() const -> unsigned { return self().length(); }
|
||||
auto offset() const -> unsigned { return self().offset(); }
|
||||
auto onRead(const function<uint8_t (unsigned)>& function = {}) -> type& { return self().onRead(function), *this; }
|
||||
auto onWrite(const function<void (unsigned, uint8_t)>& function = {}) -> type& { return self().onWrite(function), *this; }
|
||||
auto onRead(const function<uint8_t (unsigned)>& callback = {}) -> type& { return self().onRead(callback), *this; }
|
||||
auto onWrite(const function<void (unsigned, uint8_t)>& callback = {}) -> type& { return self().onWrite(callback), *this; }
|
||||
auto rows() const -> unsigned { return self().rows(); }
|
||||
auto setBackgroundColor(Color color = {}) -> type& { return self().setBackgroundColor(color), *this; }
|
||||
auto setColumns(unsigned columns = 16) -> type& { return self().setColumns(columns), *this; }
|
||||
|
@ -438,7 +437,7 @@ struct HorizontalScroller : sHorizontalScroller {
|
|||
|
||||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto length() const -> unsigned { return self().length(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto position() const -> unsigned { return self().position(); }
|
||||
auto setLength(unsigned length = 101) -> type& { return self().setLength(length), *this; }
|
||||
auto setPosition(unsigned position = 0) -> type& { return self().setPosition(position), *this; }
|
||||
|
@ -451,7 +450,7 @@ struct HorizontalSlider : sHorizontalSlider {
|
|||
|
||||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto length() const -> unsigned { return self().length(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto position() const -> unsigned { return self().position(); }
|
||||
auto setLength(unsigned length = 101) -> type& { return self().setLength(length), *this; }
|
||||
auto setPosition(unsigned position = 0) -> type& { return self().setPosition(position), *this; }
|
||||
|
@ -472,9 +471,9 @@ struct IconView : sIconView {
|
|||
auto item(unsigned position) const -> sIconViewItem { return self().item(position); }
|
||||
auto items() const -> unsigned { return self().items(); }
|
||||
auto multiSelect() const -> bool { return self().multiSelect(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onContext(const function<void ()>& function = {}) -> type& { return self().onContext(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onContext(const function<void ()>& callback = {}) -> type& { return self().onContext(callback), *this; }
|
||||
auto orientation() const -> Orientation { return self().orientation(); }
|
||||
auto remove(sIconViewItem item) -> type& { return self().remove(item), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
|
@ -524,8 +523,8 @@ struct LineEdit : sLineEdit {
|
|||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto editable() const -> bool { return self().editable(); }
|
||||
auto foregroundColor() const -> Color { return self().foregroundColor(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto setBackgroundColor(Color color = {}) -> type& { return self().setBackgroundColor(color), *this; }
|
||||
auto setEditable(bool editable = true) -> type& { return self().setEditable(editable), *this; }
|
||||
auto setForegroundColor(Color color = {}) -> type& { return self().setForegroundColor(color), *this; }
|
||||
|
@ -558,12 +557,12 @@ struct ListView : sListView {
|
|||
auto headerVisible() const -> bool { return self().headerVisible(); }
|
||||
auto item(unsigned position) -> sListViewItem { return self().item(position); }
|
||||
auto items() const -> unsigned { return self().items(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onContext(const function<void ()>& function = {}) -> type& { return self().onContext(function), *this; }
|
||||
auto onEdit(const function<void (sListViewCell)>& function = {}) -> type& { return self().onEdit(function), *this; }
|
||||
auto onSort(const function<void (sListViewColumn)>& function = {}) -> type& { return self().onSort(function), *this; }
|
||||
auto onToggle(const function<void (sListViewItem)>& function = {}) -> type& { return self().onToggle(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onContext(const function<void ()>& callback = {}) -> type& { return self().onContext(callback), *this; }
|
||||
auto onEdit(const function<void (sListViewCell)>& callback = {}) -> type& { return self().onEdit(callback), *this; }
|
||||
auto onSort(const function<void (sListViewColumn)>& callback = {}) -> type& { return self().onSort(callback), *this; }
|
||||
auto onToggle(const function<void (sListViewItem)>& callback = {}) -> type& { return self().onToggle(callback), *this; }
|
||||
auto remove(sListViewColumn column) -> type& { return self().remove(column), *this; }
|
||||
auto remove(sListViewItem item) -> type& { return self().remove(item), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
|
@ -665,7 +664,7 @@ struct RadioButton : sRadioButton {
|
|||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto group() const -> sGroup { return self().group(); }
|
||||
auto icon() const -> image { return self().icon(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto orientation() const -> Orientation { return self().orientation(); }
|
||||
auto setBordered(bool bordered = true) -> type& { return self().setBordered(bordered), *this; }
|
||||
auto setChecked() -> type& { return self().setChecked(), *this; }
|
||||
|
@ -683,7 +682,7 @@ struct RadioLabel : sRadioLabel {
|
|||
auto checked() const -> bool { return self().checked(); }
|
||||
auto doActivate() const -> void { return self().doActivate(); }
|
||||
auto group() const -> sGroup { return self().group(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto setChecked() -> type& { return self().setChecked(), *this; }
|
||||
auto setText(const string& text = "") -> type& { return self().setText(text), *this; }
|
||||
auto text() const -> string { return self().text(); }
|
||||
|
@ -696,8 +695,8 @@ struct SourceEdit : sSourceEdit {
|
|||
|
||||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto doMove() const -> void { return self().doMove(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onMove(const function<void ()>& function = {}) -> type& { return self().onMove(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onMove(const function<void ()>& callback = {}) -> type& { return self().onMove(callback), *this; }
|
||||
auto position() const -> unsigned { return self().position(); }
|
||||
auto setPosition(signed position) -> type& { return self().setPosition(position), *this; }
|
||||
auto setSelected(Position selected) -> type& { return self().setSelected(selected), *this; }
|
||||
|
@ -717,9 +716,9 @@ struct TabFrame : sTabFrame {
|
|||
auto edge() const -> Edge;
|
||||
auto item(unsigned position) const -> sTabFrameItem { return self().item(position); }
|
||||
auto items() const -> unsigned { return self().items(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onClose(const function<void (sTabFrameItem)>& function = {}) -> type& { return self().onClose(function), *this; }
|
||||
auto onMove(const function<void (sTabFrameItem, sTabFrameItem)>& function = {}) -> type& { return self().onMove(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onClose(const function<void (sTabFrameItem)>& callback = {}) -> type& { return self().onClose(callback), *this; }
|
||||
auto onMove(const function<void (sTabFrameItem, sTabFrameItem)>& callback = {}) -> type& { return self().onMove(callback), *this; }
|
||||
auto remove(sTabFrameItem item) -> type& { return self().remove(item), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
auto selected() const -> sTabFrameItem { return self().selected(); }
|
||||
|
@ -758,8 +757,8 @@ struct TextEdit : sTextEdit {
|
|||
auto doMove() const -> void { return self().doMove(); }
|
||||
auto editable() const -> bool { return self().editable(); }
|
||||
auto foregroundColor() const -> Color { return self().foregroundColor(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onMove(const function<void ()>& function = {}) -> type& { return self().onMove(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onMove(const function<void ()>& callback = {}) -> type& { return self().onMove(callback), *this; }
|
||||
auto setBackgroundColor(Color color = {}) -> type& { return self().setBackgroundColor(color), *this; }
|
||||
auto setCursorPosition(unsigned position) -> type& { return self().setCursorPosition(position), *this; }
|
||||
auto setEditable(bool editable = true) -> type& { return self().setEditable(editable), *this; }
|
||||
|
@ -787,10 +786,10 @@ struct TreeView : sTreeView {
|
|||
auto foregroundColor() const -> Color { return self().foregroundColor(); }
|
||||
auto item(const string& path) const -> sTreeViewItem { return self().item(path); }
|
||||
auto items() const -> unsigned { return self().items(); }
|
||||
auto onActivate(const function<void ()>& function = {}) -> type& { return self().onActivate(function), *this; }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onContext(const function<void ()>& function = {}) -> type& { return self().onContext(function), *this; }
|
||||
auto onToggle(const function<void (sTreeViewItem)>& function = {}) -> type& { return self().onToggle(function), *this; }
|
||||
auto onActivate(const function<void ()>& callback = {}) -> type& { return self().onActivate(callback), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto onContext(const function<void ()>& callback = {}) -> type& { return self().onContext(callback), *this; }
|
||||
auto onToggle(const function<void (sTreeViewItem)>& callback = {}) -> type& { return self().onToggle(callback), *this; }
|
||||
auto remove(sTreeViewItem item) -> type& { return self().remove(item), *this; }
|
||||
auto reset() -> type& { return self().reset(), *this; }
|
||||
auto selected() const -> sTreeViewItem { return self().selected(); }
|
||||
|
@ -826,7 +825,7 @@ struct VerticalScroller : sVerticalScroller {
|
|||
|
||||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto length() const -> unsigned { return self().length(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto position() const -> unsigned { return self().position(); }
|
||||
auto setLength(unsigned length = 101) -> type& { return self().setLength(length), *this; }
|
||||
auto setPosition(unsigned position = 0) -> type& { return self().setPosition(position), *this; }
|
||||
|
@ -839,7 +838,7 @@ struct VerticalSlider : sVerticalSlider {
|
|||
|
||||
auto doChange() const -> void { return self().doChange(); }
|
||||
auto length() const -> unsigned { return self().length(); }
|
||||
auto onChange(const function<void ()>& function = {}) -> type& { return self().onChange(function), *this; }
|
||||
auto onChange(const function<void ()>& callback = {}) -> type& { return self().onChange(callback), *this; }
|
||||
auto position() const -> unsigned { return self().position(); }
|
||||
auto setLength(unsigned length = 101) -> type& { return self().setLength(length), *this; }
|
||||
auto setPosition(unsigned position = 0) -> type& { return self().setPosition(position), *this; }
|
||||
|
@ -857,11 +856,11 @@ struct Viewport : sViewport {
|
|||
auto doMouseRelease(Mouse::Button button) const -> void { return self().doMouseRelease(button); }
|
||||
auto droppable() const -> bool { return self().droppable(); }
|
||||
auto handle() const -> uintptr_t { return self().handle(); }
|
||||
auto onDrop(const function<void (lstring)>& function = {}) -> type& { return self().onDrop(function), *this; }
|
||||
auto onMouseLeave(const function<void ()>& function = {}) -> type& { return self().onMouseLeave(function), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& function = {}) -> type& { return self().onMouseMove(function), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& function = {}) -> type& { return self().onMousePress(function), *this; }
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& function = {}) -> type& { return self().onMouseRelease(function), *this; }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type& { return self().onDrop(callback), *this; }
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type& { return self().onMouseLeave(callback), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) -> type& { return self().onMouseMove(callback), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type& { return self().onMousePress(callback), *this; }
|
||||
auto onMouseRelease(const function<void (Mouse::Button)>& callback = {}) -> type& { return self().onMouseRelease(callback), *this; }
|
||||
auto setDroppable(bool droppable = true) -> type& { return self().setDroppable(droppable), *this; }
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#if defined(Hiro_VerticalLayout)
|
||||
|
||||
auto mVerticalLayout::append(shared_pointer<mSizable> sizable, Size size, signed spacing) -> type& {
|
||||
auto mVerticalLayout::append(sSizable sizable, Size size, signed spacing) -> type& {
|
||||
properties.append({size.width(), size.height(), spacing < 0 ? settings.spacing : spacing});
|
||||
mLayout::append(sizable);
|
||||
return *this;
|
||||
|
@ -31,7 +31,7 @@ auto mVerticalLayout::minimumSize() const -> Size {
|
|||
return {settings.margin * 2 + width, settings.margin * 2 + height};
|
||||
}
|
||||
|
||||
auto mVerticalLayout::remove(shared_pointer<mSizable> sizable) -> type& {
|
||||
auto mVerticalLayout::remove(sSizable sizable) -> type& {
|
||||
properties.remove(sizable->offset());
|
||||
mLayout::remove(sizable);
|
||||
return *this;
|
||||
|
|
|
@ -5,13 +5,13 @@ struct mVerticalLayout : mLayout {
|
|||
using mLayout::append;
|
||||
using mLayout::remove;
|
||||
|
||||
auto append(nall::shared_pointer<mSizable> sizable, Size size, signed spacing = 5) -> type&;
|
||||
auto append(sSizable sizable, Size size, signed spacing = 5) -> type&;
|
||||
auto minimumSize() const -> Size override;
|
||||
auto remove(nall::shared_pointer<mSizable> sizable) -> type& override;
|
||||
auto remove(sSizable sizable) -> type& override;
|
||||
auto reset() -> type& override;
|
||||
auto setAlignment(double alignment = 0.0) -> type&;
|
||||
auto setEnabled(bool enabled = true) -> type& override;
|
||||
auto setFont(const nall::string& font = "") -> type& override;
|
||||
auto setFont(const string& font = "") -> type& override;
|
||||
auto setGeometry(Geometry geometry) -> type& override;
|
||||
auto setMargin(signed margin = 0) -> type&;
|
||||
auto setSpacing(signed spacing = 5) -> type&;
|
||||
|
@ -28,7 +28,7 @@ struct mVerticalLayout : mLayout {
|
|||
signed height;
|
||||
signed spacing;
|
||||
};
|
||||
nall::vector<Properties> properties;
|
||||
vector<Properties> properties;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -136,24 +136,30 @@ auto pApplication::initialize() -> void {
|
|||
static auto Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> bool {
|
||||
if(msg != WM_KEYDOWN && msg != WM_SYSKEYDOWN && msg != WM_KEYUP && msg != WM_SYSKEYUP) return false;
|
||||
|
||||
GUITHREADINFO info;
|
||||
memset(&info, 0, sizeof(GUITHREADINFO));
|
||||
info.cbSize = sizeof(GUITHREADINFO);
|
||||
GUITHREADINFO info{sizeof(GUITHREADINFO)};
|
||||
GetGUIThreadInfo(GetCurrentThreadId(), &info);
|
||||
|
||||
auto object = (mObject*)GetWindowLongPtr(info.hwndFocus, GWLP_USERDATA);
|
||||
if(!object) return false;
|
||||
|
||||
if(auto window = dynamic_cast<mWindow*>(object)) {
|
||||
if(pWindow::modal && !pWindow::modal.find(window->self())) return false;
|
||||
|
||||
if(auto self = window->self()) {
|
||||
if(!self->_modalityDisabled()) {
|
||||
if(auto code = pKeyboard::_translate(wparam, lparam)) {
|
||||
if(msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) window->doKeyPress(code);
|
||||
if(msg == WM_KEYUP || msg == WM_SYSKEYUP) window->doKeyRelease(code);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(auto window = object->parentWindow(true)) {
|
||||
if(auto self = window->self()) {
|
||||
if(self->_modalityDisabled()) return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(msg == WM_KEYDOWN) {
|
||||
if(0);
|
||||
|
||||
|
@ -225,23 +231,26 @@ case WM_GETMINMAXINFO: {
|
|||
*/
|
||||
|
||||
static auto CALLBACK Application_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
if(Application::state.quit) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if(!object) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
auto& window = dynamic_cast<mWindow*>(object) ? (mWindow&)*object : *object->parentWindow(true);
|
||||
auto window = dynamic_cast<mWindow*>(object);
|
||||
if(!window) window = object->parentWindow(true);
|
||||
if(!window) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
auto pWindow = window->self();
|
||||
if(!pWindow) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
bool process = true;
|
||||
if(pWindow::modal && !pWindow::modal.find(window.self())) process = false;
|
||||
if(Application::state.quit) process = false;
|
||||
if(!process) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
if(pWindow->_modalityDisabled()) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
switch(msg) {
|
||||
case WM_CLOSE: window.self()->onClose(); return TRUE;
|
||||
case WM_MOVE: window.self()->onMove(); break;
|
||||
case WM_SIZE: window.self()->onSize(); break;
|
||||
case WM_DROPFILES: window.self()->onDrop(wparam); return FALSE;
|
||||
case WM_ERASEBKGND: if(window.self()->onEraseBackground()) return true; break;
|
||||
case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: window.self()->onModalBegin(); return FALSE;
|
||||
case WM_EXITMENULOOP: case WM_EXITSIZEMOVE: window.self()->onModalEnd(); return FALSE;
|
||||
case WM_CLOSE: pWindow->onClose(); return true;
|
||||
case WM_MOVE: pWindow->onMove(); break;
|
||||
case WM_SIZE: pWindow->onSize(); break;
|
||||
case WM_DROPFILES: pWindow->onDrop(wparam); return false;
|
||||
case WM_ERASEBKGND: if(pWindow->onEraseBackground()) return true; break;
|
||||
case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: pWindow->onModalBegin(); return false;
|
||||
case WM_EXITMENULOOP: case WM_EXITSIZEMOVE: pWindow->onModalEnd(); return false;
|
||||
}
|
||||
|
||||
return Shared_windowProc(DefWindowProc, hwnd, msg, wparam, lparam);
|
||||
|
|
|
@ -17,6 +17,8 @@ struct AppMessage {
|
|||
|
||||
using WindowProc = auto CALLBACK (*)(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
|
||||
|
||||
static vector<wObject> windows;
|
||||
|
||||
}
|
||||
|
||||
#define Declare(Name, Base) \
|
||||
|
|
|
@ -145,16 +145,17 @@ static auto CALLBACK Menu_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
|||
}
|
||||
|
||||
static auto CALLBACK Shared_windowProc(WindowProc windowProc, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
if(Application::state.quit) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if(!object) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
auto window = dynamic_cast<mWindow*>(object);
|
||||
if(!window) window = object->parentWindow(true);
|
||||
if(!window) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
auto pWindow = window->self();
|
||||
if(!pWindow) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
bool process = true;
|
||||
if(pWindow::modal && !pWindow::modal.find(window->self())) process = false;
|
||||
if(Application::state.quit) process = false;
|
||||
if(!process) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
if(pWindow->_modalityDisabled()) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
switch(msg) {
|
||||
case WM_CTLCOLORBTN:
|
||||
|
|
|
@ -2,6 +2,25 @@
|
|||
|
||||
namespace hiro {
|
||||
|
||||
static auto CALLBACK ListView_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
if(auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA)) {
|
||||
if(auto listView = dynamic_cast<mListView*>(object)) {
|
||||
if(auto self = listView->self()) {
|
||||
if(!listView->enabled(true)) {
|
||||
if(msg == WM_KEYDOWN || msg == WM_KEYUP || msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) {
|
||||
//WC_LISTVIEW responds to key messages even when its HWND is disabled
|
||||
//the control should be inactive when disabled; so we intercept the messages here
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return self->windowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
auto pListView::construct() -> void {
|
||||
hwnd = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE, WC_LISTVIEW, L"",
|
||||
|
@ -9,6 +28,8 @@ auto pListView::construct() -> void {
|
|||
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
||||
);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
||||
windowProc = (WindowProc)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)&ListView_windowProc);
|
||||
ListView_SetExtendedListViewStyle(hwnd, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
|
||||
pWidget::_setState();
|
||||
setBackgroundColor(state().backgroundColor);
|
||||
|
|
|
@ -38,6 +38,7 @@ struct pListView : pWidget {
|
|||
auto _setIcons() -> void;
|
||||
auto _width(unsigned column) -> unsigned;
|
||||
|
||||
WindowProc windowProc = nullptr;
|
||||
HIMAGELIST imageList = 0;
|
||||
vector<image> icons;
|
||||
};
|
||||
|
|
|
@ -5,9 +5,12 @@ namespace hiro {
|
|||
static auto CALLBACK TabFrame_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
if(auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA)) {
|
||||
if(auto tabFrame = dynamic_cast<mTabFrame*>(object)) {
|
||||
return Shared_windowProc(tabFrame->self()->windowProc, hwnd, msg, wparam, lparam);
|
||||
if(auto self = tabFrame->self()) {
|
||||
return Shared_windowProc(self->windowProc, hwnd, msg, wparam, lparam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ auto pWidget::destruct() -> void {
|
|||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
auto pWidget::focused() -> bool {
|
||||
return GetFocus() == hwnd;
|
||||
auto pWidget::focused() const -> bool {
|
||||
auto focused = GetFocus();
|
||||
return hwnd == focused || IsChild(hwnd, focused);
|
||||
}
|
||||
|
||||
auto pWidget::minimumSize() -> Size {
|
||||
|
@ -44,11 +45,11 @@ auto pWidget::setFont(const string&) -> void {
|
|||
|
||||
auto pWidget::setGeometry(Geometry geometry) -> void {
|
||||
if(auto parent = _parentWidget()) {
|
||||
Position displacement = parent->geometry().position();
|
||||
auto displacement = parent->self().geometry().position();
|
||||
geometry.setX(geometry.x() - displacement.x());
|
||||
geometry.setY(geometry.y() - displacement.y());
|
||||
}
|
||||
SetWindowPos(hwnd, NULL, geometry.x(), geometry.y(), geometry.width(), geometry.height(), SWP_NOZORDER);
|
||||
SetWindowPos(hwnd, nullptr, geometry.x(), geometry.y(), geometry.width(), geometry.height(), SWP_NOZORDER);
|
||||
self().doSize();
|
||||
}
|
||||
|
||||
|
@ -62,20 +63,24 @@ auto pWidget::setVisible(bool visible) -> void {
|
|||
//
|
||||
|
||||
auto pWidget::_parentHandle() -> HWND {
|
||||
if(auto parent = _parentWidget()) return parent->self()->hwnd;
|
||||
if(auto parent = _parentWindow()) return parent->self()->hwnd;
|
||||
return 0;
|
||||
if(auto parent = _parentWidget()) return parent->hwnd;
|
||||
if(auto parent = _parentWindow()) return parent->hwnd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto pWidget::_parentWidget() -> maybe<mWidget&> {
|
||||
auto pWidget::_parentWidget() -> maybe<pWidget&> {
|
||||
#if defined(Hiro_TabFrame)
|
||||
if(auto parent = self().parentTabFrame(true)) return *parent;
|
||||
if(auto parent = self().parentTabFrame(true)) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
#endif
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pWidget::_parentWindow() -> maybe<mWindow&> {
|
||||
if(auto parent = self().parentWindow(true)) return *parent;
|
||||
auto pWidget::_parentWindow() -> maybe<pWindow&> {
|
||||
if(auto parent = self().parentWindow(true)) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
struct pWidget : pSizable {
|
||||
Declare(Widget, Sizable)
|
||||
|
||||
auto focused() -> bool;
|
||||
auto focused() const -> bool override;
|
||||
virtual auto minimumSize() -> Size;
|
||||
auto setEnabled(bool enabled) -> void override;
|
||||
auto setFocused() -> void;
|
||||
|
@ -14,8 +14,8 @@ struct pWidget : pSizable {
|
|||
auto setVisible(bool visible) -> void override;
|
||||
|
||||
auto _parentHandle() -> HWND;
|
||||
auto _parentWidget() -> maybe<mWidget&>;
|
||||
auto _parentWindow() -> maybe<mWindow&>;
|
||||
auto _parentWidget() -> maybe<pWidget&>;
|
||||
auto _parentWindow() -> maybe<pWindow&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
bool abstract = false;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace hiro {
|
||||
|
||||
vector<pWindow*> pWindow::modal;
|
||||
|
||||
static const unsigned FixedStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_BORDER;
|
||||
static const unsigned ResizableStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME;
|
||||
|
||||
|
@ -12,9 +10,13 @@ auto pWindow::construct() -> void {
|
|||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
||||
setDroppable(state().droppable);
|
||||
setGeometry({128, 128, 256, 256});
|
||||
|
||||
windows.append(self().instance);
|
||||
}
|
||||
|
||||
auto pWindow::destruct() -> void {
|
||||
if(auto position = windows.find(self().instance)) windows.remove(*position);
|
||||
|
||||
if(hbrush) { DeleteObject(hbrush); hbrush = nullptr; }
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
@ -28,7 +30,7 @@ auto pWindow::append(sMenuBar menuBar) -> void {
|
|||
auto pWindow::append(sStatusBar statusBar) -> void {
|
||||
}
|
||||
|
||||
auto pWindow::focused() const -> bool override {
|
||||
auto pWindow::focused() const -> bool {
|
||||
return (GetForegroundWindow() == hwnd);
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,7 @@ auto pWindow::setGeometry(Geometry geometry) -> void {
|
|||
|
||||
auto pWindow::setModal(bool modality) -> void {
|
||||
if(modality) {
|
||||
modal.appendOnce(this);
|
||||
_modalityUpdate();
|
||||
while(state().modal) {
|
||||
Application::processEvents();
|
||||
if(Application::state.onMain) {
|
||||
|
@ -131,7 +133,7 @@ auto pWindow::setModal(bool modality) -> void {
|
|||
usleep(20 * 1000);
|
||||
}
|
||||
}
|
||||
if(auto position = modal.find(this)) modal.remove(position());
|
||||
_modalityUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,6 +227,39 @@ auto pWindow::_geometry() -> Geometry {
|
|||
return {x, y, width, height};
|
||||
}
|
||||
|
||||
auto pWindow::_modalityCount() -> unsigned {
|
||||
unsigned modalWindows = 0;
|
||||
for(auto& weak : windows) {
|
||||
if(auto object = weak.acquire()) {
|
||||
if(auto window = dynamic_cast<mWindow*>(object.data())) {
|
||||
if(window->modal()) modalWindows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return modalWindows;
|
||||
}
|
||||
|
||||
auto pWindow::_modalityDisabled() -> bool {
|
||||
if(_modalityCount() == 0) return false;
|
||||
return !state().modal;
|
||||
}
|
||||
|
||||
auto pWindow::_modalityUpdate() -> void {
|
||||
unsigned modalWindows = _modalityCount();
|
||||
for(auto& weak : windows) {
|
||||
if(auto object = weak.acquire()) {
|
||||
if(auto window = dynamic_cast<mWindow*>(object.data())) {
|
||||
if(auto self = window->self()) {
|
||||
bool enabled = !modalWindows || window->modal();
|
||||
if(IsWindowEnabled(self->hwnd) != enabled) {
|
||||
EnableWindow(self->hwnd, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,13 +33,14 @@ struct pWindow : pObject {
|
|||
auto onSize() -> void;
|
||||
|
||||
auto _geometry() -> Geometry;
|
||||
auto _modalityCount() -> unsigned;
|
||||
auto _modalityDisabled() -> bool;
|
||||
auto _modalityUpdate() -> void;
|
||||
|
||||
HWND hwnd = nullptr;
|
||||
HFONT hstatusfont = nullptr;
|
||||
HBRUSH hbrush = nullptr;
|
||||
COLORREF hbrushColor = 0;
|
||||
|
||||
static vector<pWindow*> modal;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef NALL_HTTP_SERVER_HPP
|
||||
#define NALL_HTTP_SERVER_HPP
|
||||
|
||||
#include <poll.h>
|
||||
#include <atomic>
|
||||
|
||||
#include <nall/service.hpp>
|
||||
#include <nall/http/role.hpp>
|
||||
|
||||
|
|
|
@ -56,13 +56,16 @@ namespace nall {
|
|||
#define PLATFORM_WINDOWS
|
||||
Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::Windows; }
|
||||
#elif defined(__APPLE__)
|
||||
#define PLATFORM_POSIX
|
||||
#define PLATFORM_MACOSX
|
||||
Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::MacOSX; }
|
||||
#elif defined(linux) || defined(__linux__)
|
||||
#define PLATFORM_POSIX
|
||||
#define PLATFORM_LINUX
|
||||
#define PLATFORM_XORG
|
||||
Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::Linux; }
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define PLATFORM_POSIX
|
||||
#define PLATFORM_BSD
|
||||
#define PLATFORM_XORG
|
||||
Intrinsics::Platform Intrinsics::platform() { return Intrinsics::Platform::BSD; }
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace Math {
|
|||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_CL)
|
||||
|
@ -58,17 +59,40 @@ namespace Math {
|
|||
#endif
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
//fight Microsoft's ardent efforts at vendor lock-in
|
||||
|
||||
#undef interface
|
||||
#define dllexport __declspec(dllexport)
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
extern "C" {
|
||||
using pollfd = WSAPOLLFD;
|
||||
}
|
||||
|
||||
inline auto access(const char* path, int amode) -> int { return _waccess(nall::utf16_t(path), amode); }
|
||||
inline auto getcwd(char* buf, size_t size) -> char* { wchar_t wpath[PATH_MAX] = L""; if(!_wgetcwd(wpath, size)) return nullptr; strcpy(buf, nall::utf8_t(wpath)); return buf; }
|
||||
inline auto mkdir(const char* path, int mode) -> int { return _wmkdir(nall::utf16_t(path)); }
|
||||
inline auto poll(struct pollfd fds[], unsigned long nfds, int timeout) -> int { return WSAPoll(fds, nfds, timeout); }
|
||||
inline auto putenv(const char* value) -> int { return _wputenv(nall::utf16_t(value)); }
|
||||
inline auto realpath(const char* file_name, char* resolved_name) -> char* { wchar_t wfile_name[PATH_MAX] = L""; if(!_wfullpath(wfile_name, nall::utf16_t(file_name), PATH_MAX)) return nullptr; strcpy(resolved_name, nall::utf8_t(wfile_name)); return resolved_name; }
|
||||
inline auto rename(const char* oldname, const char* newname) -> int { return _wrename(nall::utf16_t(oldname), nall::utf16_t(newname)); }
|
||||
inline auto usleep(unsigned milliseconds) -> void { Sleep(milliseconds / 1000); }
|
||||
|
||||
namespace nall {
|
||||
//network functions take void*, not char*. this allows them to be used without casting
|
||||
|
||||
inline auto recv(int socket, void* buffer, size_t length, int flags) -> ssize_t {
|
||||
return ::recv(socket, (char*)buffer, length, flags);
|
||||
}
|
||||
|
||||
inline auto send(int socket, const void* buffer, size_t length, int flags) -> ssize_t {
|
||||
return ::send(socket, (const char*)buffer, length, flags);
|
||||
}
|
||||
|
||||
inline auto setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len) -> int {
|
||||
return ::setsockopt(socket, level, option_name, (const char*)option_value, option_len);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define dllexport
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
#ifndef NALL_POSIX_SERVICE_HPP
|
||||
#define NALL_POSIX_SERVICE_HPP
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
namespace nall {
|
||||
|
||||
struct service {
|
||||
inline explicit operator bool() const;
|
||||
inline auto command(const string& name, const string& command) -> bool;
|
||||
inline auto receive() -> string;
|
||||
inline auto name() const -> string;
|
||||
inline auto stop() const -> bool;
|
||||
|
||||
private:
|
||||
shared_memory shared;
|
||||
string _name;
|
||||
bool _stop = false;
|
||||
};
|
||||
|
||||
service::operator bool() const {
|
||||
return (bool)shared;
|
||||
}
|
||||
|
||||
//returns true on new service process creation (false is not necessarily an error)
|
||||
auto service::command(const string& name, const string& command) -> bool {
|
||||
if(!name) return false;
|
||||
if(!command) return print("[{0}] usage: {service} command\n"
|
||||
"commands:\n"
|
||||
" status : query whether service is running\n"
|
||||
" start : start service if it is not running\n"
|
||||
" stop : stop service if it is running\n"
|
||||
" remove : remove semaphore lock if service crashed\n"
|
||||
" {value} : send custom command to service\n"
|
||||
"", format{name}), false;
|
||||
|
||||
if(shared.open(name, 4096)) {
|
||||
if(command == "start") {
|
||||
print("[{0}] already started\n", format{name});
|
||||
} else if(command == "status") {
|
||||
print("[{0}] running\n", format{name});
|
||||
}
|
||||
if(auto data = shared.acquire()) {
|
||||
if(command == "stop") print("[{0}] stopped\n", format{name});
|
||||
memory::copy(data, command.data(), min(command.size(), 4096));
|
||||
shared.release();
|
||||
}
|
||||
if(command == "remove") {
|
||||
shared.remove();
|
||||
print("[{0}] removed\n", format{name});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(command == "start") {
|
||||
if(shared.create(name, 4096)) {
|
||||
print("[{0}] started\n", format{name});
|
||||
auto pid = fork();
|
||||
if(pid == 0) {
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
shared.close();
|
||||
} else {
|
||||
print("[{0}] start failed ({1})\n", format{name, strerror(errno)});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(command == "status") {
|
||||
print("[{0}] stopped\n", format{name});
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto service::receive() -> string {
|
||||
string command;
|
||||
if(shared) {
|
||||
if(auto data = shared.acquire()) {
|
||||
if(*data) {
|
||||
command.resize(4095);
|
||||
memory::copy(command.pointer(), data, 4095);
|
||||
memory::fill(data, 4096);
|
||||
}
|
||||
shared.release();
|
||||
if(command == "remove") {
|
||||
_stop = true;
|
||||
return "";
|
||||
} else if(command == "start") {
|
||||
return "";
|
||||
} else if(command == "status") {
|
||||
return "";
|
||||
} else if(command == "stop") {
|
||||
_stop = true;
|
||||
shared.remove();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
auto service::name() const -> string {
|
||||
return _name;
|
||||
}
|
||||
|
||||
auto service::stop() const -> bool {
|
||||
return _stop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,154 @@
|
|||
#ifndef NALL_POSIX_SHARED_MEMORY_HPP
|
||||
#define NALL_POSIX_SHARED_MEMORY_HPP
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
namespace nall {
|
||||
|
||||
struct shared_memory {
|
||||
shared_memory() = default;
|
||||
shared_memory(const shared_memory&) = delete;
|
||||
auto operator=(const shared_memory&) -> shared_memory& = delete;
|
||||
|
||||
~shared_memory() {
|
||||
reset();
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return _mode != mode::inactive;
|
||||
}
|
||||
|
||||
auto empty() const -> bool {
|
||||
return _mode == mode::inactive;
|
||||
}
|
||||
|
||||
auto size() const -> unsigned {
|
||||
return _size;
|
||||
}
|
||||
|
||||
auto acquired() const -> bool {
|
||||
return _acquired;
|
||||
}
|
||||
|
||||
auto acquire() -> uint8_t* {
|
||||
if(!acquired()) {
|
||||
sem_wait(_semaphore);
|
||||
_acquired = true;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
auto release() -> void {
|
||||
if(acquired()) {
|
||||
sem_post(_semaphore);
|
||||
_acquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto reset() -> void {
|
||||
release();
|
||||
if(_mode == mode::server) return remove();
|
||||
if(_mode == mode::client) return close();
|
||||
}
|
||||
|
||||
auto create(const string& name, unsigned size) -> bool {
|
||||
reset();
|
||||
|
||||
_name = {"/nall::", string{name}.transform("/", ":")};
|
||||
_size = size;
|
||||
|
||||
//O_CREAT | O_EXCL seems to throw ENOENT even when semaphore does not exist ...
|
||||
_semaphore = sem_open(_name, O_CREAT, 0644, 1);
|
||||
if(_semaphore == SEM_FAILED) return remove(), false;
|
||||
|
||||
_descriptor = shm_open(_name, O_CREAT | O_TRUNC | O_RDWR, 0644);
|
||||
if(_descriptor < 0) return remove(), false;
|
||||
|
||||
if(ftruncate(_descriptor, _size) != 0) return remove(), false;
|
||||
|
||||
_data = (uint8_t*)mmap(nullptr, _size, PROT_READ | PROT_WRITE, MAP_SHARED, _descriptor, 0);
|
||||
if(_data == MAP_FAILED) return remove(), false;
|
||||
|
||||
memory::fill(_data, _size);
|
||||
|
||||
_mode = mode::server;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto remove() -> void {
|
||||
if(_data) {
|
||||
munmap(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
if(_descriptor) {
|
||||
::close(_descriptor);
|
||||
shm_unlink(_name);
|
||||
_descriptor = -1;
|
||||
}
|
||||
|
||||
if(_semaphore) {
|
||||
sem_close(_semaphore);
|
||||
sem_unlink(_name);
|
||||
_semaphore = nullptr;
|
||||
}
|
||||
|
||||
_mode = mode::inactive;
|
||||
_name = "";
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
auto open(const string& name, unsigned size) -> bool {
|
||||
reset();
|
||||
|
||||
_name = {"/nall::", string{name}.transform("/", ":")};
|
||||
_size = size;
|
||||
|
||||
_semaphore = sem_open(_name, 0, 0644);
|
||||
if(_semaphore == SEM_FAILED) return close(), false;
|
||||
|
||||
_descriptor = shm_open(_name, O_RDWR, 0644);
|
||||
if(_descriptor < 0) return close(), false;
|
||||
|
||||
_data = (uint8_t*)mmap(nullptr, _size, PROT_READ | PROT_WRITE, MAP_SHARED, _descriptor, 0);
|
||||
if(_data == MAP_FAILED) return close(), false;
|
||||
|
||||
_mode = mode::client;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto close() -> void {
|
||||
if(_data) {
|
||||
munmap(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
if(_descriptor) {
|
||||
::close(_descriptor);
|
||||
_descriptor = -1;
|
||||
}
|
||||
|
||||
if(_semaphore) {
|
||||
sem_close(_semaphore);
|
||||
_semaphore = nullptr;
|
||||
}
|
||||
|
||||
_mode = mode::inactive;
|
||||
_name = "";
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
enum class mode : unsigned { server, client, inactive } _mode = mode::inactive;
|
||||
string _name;
|
||||
sem_t* _semaphore = nullptr;
|
||||
signed _descriptor = -1;
|
||||
uint8_t* _data = nullptr;
|
||||
unsigned _size = 0;
|
||||
bool _acquired = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
116
nall/service.hpp
116
nall/service.hpp
|
@ -3,118 +3,14 @@
|
|||
|
||||
//service model template built on top of shared-memory
|
||||
|
||||
#include <signal.h>
|
||||
#include <nall/shared-memory.hpp>
|
||||
|
||||
namespace nall {
|
||||
#if defined(PLATFORM_POSIX)
|
||||
#include <nall/posix/service.hpp>
|
||||
#endif
|
||||
|
||||
struct service {
|
||||
inline explicit operator bool() const;
|
||||
inline auto command(const string& name, const string& command) -> bool;
|
||||
inline auto receive() -> string;
|
||||
inline auto name() const -> string;
|
||||
inline auto stop() const -> bool;
|
||||
|
||||
private:
|
||||
shared_memory shared;
|
||||
string _name;
|
||||
bool _stop = false;
|
||||
};
|
||||
|
||||
service::operator bool() const {
|
||||
return (bool)shared;
|
||||
}
|
||||
|
||||
//returns true on new service process creation (false is not necessarily an error)
|
||||
auto service::command(const string& name, const string& command) -> bool {
|
||||
if(!name) return false;
|
||||
if(!command) return print("[{0}] usage: {service} command\n"
|
||||
"commands:\n"
|
||||
" status : query whether service is running\n"
|
||||
" start : start service if it is not running\n"
|
||||
" stop : stop service if it is running\n"
|
||||
" remove : remove semaphore lock if service crashed\n"
|
||||
" {value} : send custom command to service\n"
|
||||
"", format{name}), false;
|
||||
|
||||
if(shared.open(name, 4096)) {
|
||||
if(command == "start") {
|
||||
print("[{0}] already started\n", format{name});
|
||||
} else if(command == "status") {
|
||||
print("[{0}] running\n", format{name});
|
||||
}
|
||||
if(auto data = shared.acquire()) {
|
||||
if(command == "stop") print("[{0}] stopped\n", format{name});
|
||||
memory::copy(data, command.data(), min(command.size(), 4096));
|
||||
shared.release();
|
||||
}
|
||||
if(command == "remove") {
|
||||
shared.remove();
|
||||
print("[{0}] removed\n", format{name});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(command == "start") {
|
||||
if(shared.create(name, 4096)) {
|
||||
print("[{0}] started\n", format{name});
|
||||
auto pid = fork();
|
||||
if(pid == 0) {
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
shared.close();
|
||||
} else {
|
||||
print("[{0}] start failed ({1})\n", format{name, strerror(errno)});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(command == "status") {
|
||||
print("[{0}] stopped\n", format{name});
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto service::receive() -> string {
|
||||
string command;
|
||||
if(shared) {
|
||||
if(auto data = shared.acquire()) {
|
||||
if(*data) {
|
||||
command.resize(4095);
|
||||
memory::copy(command.pointer(), data, 4095);
|
||||
memory::fill(data, 4096);
|
||||
}
|
||||
shared.release();
|
||||
if(command == "remove") {
|
||||
_stop = true;
|
||||
return "";
|
||||
} else if(command == "start") {
|
||||
return "";
|
||||
} else if(command == "status") {
|
||||
return "";
|
||||
} else if(command == "stop") {
|
||||
_stop = true;
|
||||
shared.remove();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
auto service::name() const -> string {
|
||||
return _name;
|
||||
}
|
||||
|
||||
auto service::stop() const -> bool {
|
||||
return _stop;
|
||||
}
|
||||
|
||||
}
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include <nall/windows/service.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,154 +4,12 @@
|
|||
#include <nall/memory.hpp>
|
||||
#include <nall/string.hpp>
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <sys/mman.h>
|
||||
#if defined(PLATFORM_POSIX)
|
||||
#include <nall/posix/shared-memory.hpp>
|
||||
#endif
|
||||
|
||||
namespace nall {
|
||||
|
||||
struct shared_memory {
|
||||
shared_memory() = default;
|
||||
shared_memory(const shared_memory&) = delete;
|
||||
shared_memory& operator=(const shared_memory&) = delete;
|
||||
|
||||
~shared_memory() {
|
||||
reset();
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return _mode != mode::inactive;
|
||||
}
|
||||
|
||||
auto empty() const -> bool {
|
||||
return _mode == mode::inactive;
|
||||
}
|
||||
|
||||
auto size() const -> unsigned {
|
||||
return _size;
|
||||
}
|
||||
|
||||
auto acquired() const -> bool {
|
||||
return _acquired;
|
||||
}
|
||||
|
||||
auto acquire() -> uint8_t* {
|
||||
if(!acquired()) {
|
||||
sem_wait(_semaphore);
|
||||
_acquired = true;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
auto release() -> void {
|
||||
if(acquired()) {
|
||||
sem_post(_semaphore);
|
||||
_acquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto reset() -> void {
|
||||
release();
|
||||
if(_mode == mode::server) return remove();
|
||||
if(_mode == mode::client) return close();
|
||||
}
|
||||
|
||||
auto create(const string& name, unsigned size) -> bool {
|
||||
reset();
|
||||
|
||||
_name = {"/nall::", string{name}.transform("/", ":")};
|
||||
_size = size;
|
||||
|
||||
//O_CREAT | O_EXCL seems to throw ENOENT even when semaphore does not exist ...
|
||||
_semaphore = sem_open(_name, O_CREAT, 0644, 1);
|
||||
if(_semaphore == SEM_FAILED) return remove(), false;
|
||||
|
||||
_descriptor = shm_open(_name, O_CREAT | O_TRUNC | O_RDWR, 0644);
|
||||
if(_descriptor < 0) return remove(), false;
|
||||
|
||||
if(ftruncate(_descriptor, _size) != 0) return remove(), false;
|
||||
|
||||
_data = (uint8_t*)mmap(nullptr, _size, PROT_READ | PROT_WRITE, MAP_SHARED, _descriptor, 0);
|
||||
if(_data == MAP_FAILED) return remove(), false;
|
||||
|
||||
memory::fill(_data, _size);
|
||||
|
||||
_mode = mode::server;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto remove() -> void {
|
||||
if(_data) {
|
||||
munmap(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
if(_descriptor) {
|
||||
::close(_descriptor);
|
||||
shm_unlink(_name);
|
||||
_descriptor = -1;
|
||||
}
|
||||
|
||||
if(_semaphore) {
|
||||
sem_close(_semaphore);
|
||||
sem_unlink(_name);
|
||||
_semaphore = nullptr;
|
||||
}
|
||||
|
||||
_mode = mode::inactive;
|
||||
_name = "";
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
auto open(const string& name, unsigned size) -> bool {
|
||||
reset();
|
||||
|
||||
_name = {"/nall::", string{name}.transform("/", ":")};
|
||||
_size = size;
|
||||
|
||||
_semaphore = sem_open(_name, 0, 0644);
|
||||
if(_semaphore == SEM_FAILED) return close(), false;
|
||||
|
||||
_descriptor = shm_open(_name, O_RDWR, 0644);
|
||||
if(_descriptor < 0) return close(), false;
|
||||
|
||||
_data = (uint8_t*)mmap(nullptr, _size, PROT_READ | PROT_WRITE, MAP_SHARED, _descriptor, 0);
|
||||
if(_data == MAP_FAILED) return close(), false;
|
||||
|
||||
_mode = mode::client;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto close() -> void {
|
||||
if(_data) {
|
||||
munmap(_data, _size);
|
||||
_data = nullptr;
|
||||
}
|
||||
|
||||
if(_descriptor) {
|
||||
::close(_descriptor);
|
||||
_descriptor = -1;
|
||||
}
|
||||
|
||||
if(_semaphore) {
|
||||
sem_close(_semaphore);
|
||||
_semaphore = nullptr;
|
||||
}
|
||||
|
||||
_mode = mode::inactive;
|
||||
_name = "";
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
enum class mode : unsigned { server, client, inactive } _mode = mode::inactive;
|
||||
string _name;
|
||||
sem_t* _semaphore = nullptr;
|
||||
signed _descriptor = -1;
|
||||
uint8_t* _data = nullptr;
|
||||
unsigned _size = 0;
|
||||
bool _acquired = false;
|
||||
};
|
||||
|
||||
}
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include <nall/windows/shared-memory.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,7 @@ struct shared_pointer {
|
|||
reset();
|
||||
}
|
||||
|
||||
shared_pointer& operator=(T* source) {
|
||||
auto operator=(T* source) -> shared_pointer& {
|
||||
reset();
|
||||
if(source) {
|
||||
manager = new shared_pointer_manager((void*)source);
|
||||
|
@ -89,7 +89,7 @@ struct shared_pointer {
|
|||
return *this;
|
||||
}
|
||||
|
||||
shared_pointer& operator=(const shared_pointer& source) {
|
||||
auto operator=(const shared_pointer& source) -> shared_pointer& {
|
||||
if(this != &source) {
|
||||
reset();
|
||||
if((bool)source) {
|
||||
|
@ -100,7 +100,7 @@ struct shared_pointer {
|
|||
return *this;
|
||||
}
|
||||
|
||||
shared_pointer& operator=(shared_pointer&& source) {
|
||||
auto operator=(shared_pointer&& source) -> shared_pointer& {
|
||||
if(this != &source) {
|
||||
reset();
|
||||
manager = source.manager;
|
||||
|
@ -110,7 +110,7 @@ struct shared_pointer {
|
|||
}
|
||||
|
||||
template<typename U, typename = enable_if<is_compatible<U>>>
|
||||
shared_pointer& operator=(const shared_pointer<U>& source) {
|
||||
auto operator=(const shared_pointer<U>& source) -> shared_pointer& {
|
||||
if((uintptr_t)this != (uintptr_t)&source) {
|
||||
reset();
|
||||
if((bool)source) {
|
||||
|
@ -122,7 +122,7 @@ struct shared_pointer {
|
|||
}
|
||||
|
||||
template<typename U, typename = enable_if<is_compatible<U>>>
|
||||
shared_pointer& operator=(shared_pointer&& source) {
|
||||
auto operator=(shared_pointer&& source) -> shared_pointer& {
|
||||
if((uintptr_t)this != (uintptr_t)&source) {
|
||||
reset();
|
||||
manager = source.manager;
|
||||
|
@ -132,7 +132,7 @@ struct shared_pointer {
|
|||
}
|
||||
|
||||
template<typename U, typename = enable_if<is_compatible<U>>>
|
||||
shared_pointer& operator=(const shared_pointer_weak<U>& source) {
|
||||
auto operator=(const shared_pointer_weak<U>& source) -> shared_pointer& {
|
||||
reset();
|
||||
if((bool)source) {
|
||||
manager = source.manager;
|
||||
|
@ -141,32 +141,32 @@ struct shared_pointer {
|
|||
return *this;
|
||||
}
|
||||
|
||||
T* data() {
|
||||
auto data() -> T* {
|
||||
if(manager) return (T*)manager->pointer;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const T* data() const {
|
||||
auto data() const -> const T* {
|
||||
if(manager) return (T*)manager->pointer;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
T* operator->() { return data(); }
|
||||
const T* operator->() const { return data(); }
|
||||
auto operator->() -> T* { return data(); }
|
||||
auto operator->() const -> const T* { return data(); }
|
||||
|
||||
T& operator*() { return *data(); }
|
||||
const T& operator*() const { return *data(); }
|
||||
auto operator*() -> T& { return *data(); }
|
||||
auto operator*() const -> const T& { return *data(); }
|
||||
|
||||
T& operator()() { return *data(); }
|
||||
const T& operator()() const { return *data(); }
|
||||
auto operator()() -> T& { return *data(); }
|
||||
auto operator()() const -> const T& { return *data(); }
|
||||
|
||||
template<typename U>
|
||||
bool operator==(const shared_pointer<U>& source) const {
|
||||
auto operator==(const shared_pointer<U>& source) const -> bool {
|
||||
return manager == source.manager;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
bool operator!=(const shared_pointer<U>& source) const {
|
||||
auto operator!=(const shared_pointer<U>& source) const -> bool {
|
||||
return manager != source.manager;
|
||||
}
|
||||
|
||||
|
@ -174,15 +174,15 @@ struct shared_pointer {
|
|||
return !empty();
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
auto empty() const -> bool {
|
||||
return !manager || !manager->strong;
|
||||
}
|
||||
|
||||
bool unique() const {
|
||||
auto unique() const -> bool {
|
||||
return manager && manager->strong == 1;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
auto reset() -> void {
|
||||
if(manager && manager->strong) {
|
||||
//pointer may contain weak references; if strong==0 it may destroy manager
|
||||
//as such, we must destroy strong before decrementing it to zero
|
||||
|
@ -204,7 +204,7 @@ struct shared_pointer {
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
shared_pointer<U> cast() {
|
||||
auto cast() -> shared_pointer<U> {
|
||||
if(auto pointer = dynamic_cast<U*>(data())) {
|
||||
return {*this, pointer};
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ struct shared_pointer_weak {
|
|||
operator=(source);
|
||||
}
|
||||
|
||||
shared_pointer_weak& operator=(const shared_pointer<T>& source) {
|
||||
auto operator=(const shared_pointer<T>& source) -> shared_pointer_weak& {
|
||||
reset();
|
||||
if(manager = source.manager) manager->weak++;
|
||||
return *this;
|
||||
|
@ -234,19 +234,27 @@ struct shared_pointer_weak {
|
|||
reset();
|
||||
}
|
||||
|
||||
auto operator==(const shared_pointer_weak& source) const -> bool {
|
||||
return manager == source.manager;
|
||||
}
|
||||
|
||||
auto operator!=(const shared_pointer_weak& source) const -> bool {
|
||||
return manager != source.manager;
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return !empty();
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
auto empty() const -> bool {
|
||||
return !manager || !manager->strong;
|
||||
}
|
||||
|
||||
shared_pointer<T> acquire() const {
|
||||
auto acquire() const -> shared_pointer<T> {
|
||||
return shared_pointer<T>(*this);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
auto reset() -> void {
|
||||
if(manager && --manager->weak == 0) {
|
||||
if(manager->strong == 0) {
|
||||
delete manager;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef NALL_WINDOWS_SERVICE_HPP
|
||||
#define NALL_WINDOWS_SERVICE_HPP
|
||||
|
||||
namespace nall {
|
||||
|
||||
struct service {
|
||||
explicit operator bool() const { return false; }
|
||||
auto command(const string& name, const string& command) -> bool { return false; }
|
||||
auto receive() -> string { return ""; }
|
||||
auto name() const -> string { return ""; }
|
||||
auto stop() const -> bool { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef NALL_WINDOWS_SHARED_MEMORY_HPP
|
||||
#define NALL_WINDOWS_SHARED_MEMORY_HPP
|
||||
|
||||
namespace nall {
|
||||
|
||||
struct shared_memory {
|
||||
shared_memory() = default;
|
||||
shared_memory(const shared_memory&) = delete;
|
||||
auto operator=(const shared_memory&) -> shared_memory& = delete;
|
||||
|
||||
~shared_memory() {
|
||||
reset();
|
||||
}
|
||||
|
||||
explicit operator bool() const { return false; }
|
||||
auto empty() const -> bool { return true; }
|
||||
auto size() const -> unsigned { return 0; }
|
||||
auto acquired() const -> bool { return false; }
|
||||
auto acquire() -> uint8_t* { return nullptr; }
|
||||
auto release() -> void {}
|
||||
auto reset() -> void {}
|
||||
auto create(const string& name, unsigned size) -> bool { return false; }
|
||||
auto remove() -> void {}
|
||||
auto open(const string& name, unsigned size) -> bool { return false; }
|
||||
auto close() -> void {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,66 +1,66 @@
|
|||
//audio.alsa (2009-11-30)
|
||||
//authors: BearOso, byuu, Nach, RedDwarf
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pAudioALSA {
|
||||
public:
|
||||
struct pAudioALSA {
|
||||
struct {
|
||||
snd_pcm_t* handle;
|
||||
snd_pcm_format_t format;
|
||||
snd_pcm_t* handle = nullptr;
|
||||
snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
snd_pcm_uframes_t period_size;
|
||||
int channels;
|
||||
const char* name;
|
||||
int channels = 2;
|
||||
const char* name = "default";
|
||||
} device;
|
||||
|
||||
struct {
|
||||
uint32_t* data;
|
||||
unsigned length;
|
||||
uint32_t* data = nullptr;
|
||||
unsigned length = 0;
|
||||
} buffer;
|
||||
|
||||
struct {
|
||||
bool synchronize;
|
||||
unsigned frequency;
|
||||
unsigned latency;
|
||||
bool synchronize = false;
|
||||
unsigned frequency = 22050;
|
||||
unsigned latency = 60;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
~pAudioALSA() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Audio::Synchronize) return true;
|
||||
if(name == Audio::Frequency) return true;
|
||||
if(name == Audio::Latency) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Audio::Synchronize) return settings.synchronize;
|
||||
if(name == Audio::Frequency) return settings.frequency;
|
||||
if(name == Audio::Latency) return settings.latency;
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Audio::Synchronize) {
|
||||
if(settings.synchronize != any_cast<bool>(value)) {
|
||||
settings.synchronize = any_cast<bool>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Audio::Synchronize && value.is<bool>()) {
|
||||
if(settings.synchronize != value.get<bool>()) {
|
||||
settings.synchronize = value.get<bool>();
|
||||
if(device.handle) init();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Frequency) {
|
||||
if(settings.frequency != any_cast<unsigned>(value)) {
|
||||
settings.frequency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Frequency && value.is<unsigned>()) {
|
||||
if(settings.frequency != value.get<unsigned>()) {
|
||||
settings.frequency = value.get<unsigned>();
|
||||
if(device.handle) init();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Latency) {
|
||||
if(settings.latency != any_cast<unsigned>(value)) {
|
||||
settings.latency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Latency && value.is<unsigned>()) {
|
||||
if(settings.latency != value.get<unsigned>()) {
|
||||
settings.latency = value.get<unsigned>();
|
||||
if(device.handle) init();
|
||||
}
|
||||
return true;
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void sample(uint16_t left, uint16_t right) {
|
||||
auto sample(uint16_t left, uint16_t right) -> void {
|
||||
if(!device.handle) return;
|
||||
|
||||
buffer.data[buffer.length++] = left + (right << 16);
|
||||
|
@ -123,10 +123,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
term();
|
||||
|
||||
if(snd_pcm_open(&device.handle, device.name, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) {
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(device.handle) {
|
||||
//snd_pcm_drain(device.handle); //prevents popping noise; but causes multi-second lag
|
||||
snd_pcm_close(device.handle);
|
||||
|
@ -215,24 +215,6 @@ public:
|
|||
buffer.data = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pAudioALSA() {
|
||||
device.handle = 0;
|
||||
device.format = SND_PCM_FORMAT_S16_LE;
|
||||
device.channels = 2;
|
||||
device.name = "default";
|
||||
|
||||
buffer.data = 0;
|
||||
buffer.length = 0;
|
||||
|
||||
settings.synchronize = false;
|
||||
settings.frequency = 22050;
|
||||
settings.latency = 60;
|
||||
}
|
||||
|
||||
~pAudioALSA() {
|
||||
term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareAudio(ALSA)
|
||||
|
|
|
@ -1,35 +1,38 @@
|
|||
/*
|
||||
audio.ao (2008-06-01)
|
||||
authors: Nach, RedDwarf
|
||||
*/
|
||||
|
||||
#include <ao/ao.h>
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pAudioAO {
|
||||
public:
|
||||
struct pAudioAO {
|
||||
int driver_id;
|
||||
ao_sample_format driver_format;
|
||||
ao_device* audio_device;
|
||||
ao_device* audio_device = nullptr;
|
||||
|
||||
struct {
|
||||
unsigned frequency;
|
||||
unsigned frequency = 22050;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
pAudioAO() {
|
||||
ao_initialize();
|
||||
}
|
||||
|
||||
~pAudioAO() {
|
||||
term();
|
||||
//ao_shutdown(); //FIXME: this is causing a segfault for some reason when called ...
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Audio::Frequency) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Audio::Frequency) return settings.frequency;
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Audio::Frequency) {
|
||||
settings.frequency = any_cast<unsigned>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Audio::Frequency && value.is<unsigned>()) {
|
||||
settings.frequency = value.get<unsigned>();
|
||||
if(audio_device) init();
|
||||
return true;
|
||||
}
|
||||
|
@ -37,15 +40,15 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void sample(uint16_t l_sample, uint16_t r_sample) {
|
||||
auto sample(uint16_t l_sample, uint16_t r_sample) -> void {
|
||||
uint32_t samp = (l_sample << 0) + (r_sample << 16);
|
||||
ao_play(audio_device, (char*)&samp, 4); //This may need to be byte swapped for Big Endian
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
term();
|
||||
|
||||
driver_id = ao_default_driver_id(); //ao_driver_id((const char*)driver)
|
||||
|
@ -69,24 +72,12 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(audio_device) {
|
||||
ao_close(audio_device);
|
||||
audio_device = 0;
|
||||
audio_device = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
pAudioAO() {
|
||||
audio_device = 0;
|
||||
ao_initialize();
|
||||
|
||||
settings.frequency = 22050;
|
||||
}
|
||||
|
||||
~pAudioAO() {
|
||||
term();
|
||||
//ao_shutdown(); //FIXME: this is causing a segfault for some reason when called ...
|
||||
}
|
||||
};
|
||||
|
||||
DeclareAudio(AO)
|
||||
|
|
|
@ -1,70 +1,74 @@
|
|||
//audio.pulseaudio (2010-01-05)
|
||||
//author: RedDwarf
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pAudioPulseAudio {
|
||||
public:
|
||||
struct pAudioPulseAudio {
|
||||
struct {
|
||||
pa_mainloop* mainloop;
|
||||
pa_context* context;
|
||||
pa_stream* stream;
|
||||
pa_mainloop* mainloop = nullptr;
|
||||
pa_context* context = nullptr;
|
||||
pa_stream* stream = nullptr;
|
||||
pa_sample_spec spec;
|
||||
pa_buffer_attr buffer_attr;
|
||||
bool first;
|
||||
} device;
|
||||
|
||||
struct {
|
||||
uint32_t* data;
|
||||
uint32_t* data = nullptr;
|
||||
size_t size;
|
||||
unsigned offset;
|
||||
} buffer;
|
||||
|
||||
struct {
|
||||
bool synchronize;
|
||||
unsigned frequency;
|
||||
unsigned latency;
|
||||
bool synchronize = false;
|
||||
unsigned frequency = 22050;
|
||||
unsigned latency = 60;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
~pAudioPulseAudio() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Audio::Synchronize) return true;
|
||||
if(name == Audio::Frequency) return true;
|
||||
if(name == Audio::Latency) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Audio::Synchronize) return settings.synchronize;
|
||||
if(name == Audio::Frequency) return settings.frequency;
|
||||
if(name == Audio::Latency) return settings.latency;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Audio::Synchronize) {
|
||||
settings.synchronize = any_cast<bool>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Audio::Synchronize && value.is<bool>()) {
|
||||
settings.synchronize = value.get<bool>();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Frequency) {
|
||||
settings.frequency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Frequency && value.is<unsigned>()) {
|
||||
settings.frequency = value.get<unsigned>();
|
||||
if(device.stream) {
|
||||
pa_operation_unref(pa_stream_update_sample_rate(device.stream, settings.frequency, NULL, NULL));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Latency) {
|
||||
settings.latency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Latency && value.is<unsigned>()) {
|
||||
settings.latency = value.get<unsigned>();
|
||||
if(device.stream) {
|
||||
device.buffer_attr.tlength = pa_usec_to_bytes(settings.latency * PA_USEC_PER_MSEC, &device.spec);
|
||||
pa_stream_set_buffer_attr(device.stream, &device.buffer_attr, NULL, NULL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void sample(uint16_t left, uint16_t right) {
|
||||
auto sample(uint16_t left, uint16_t right) -> void {
|
||||
pa_stream_begin_write(device.stream, (void**)&buffer.data, &buffer.size);
|
||||
buffer.data[buffer.offset++] = left + (right << 16);
|
||||
if((buffer.offset + 1) * pa_frame_size(&device.spec) <= buffer.size) return;
|
||||
|
@ -89,10 +93,10 @@ public:
|
|||
buffer.offset = 0;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
device.mainloop = pa_mainloop_new();
|
||||
|
||||
device.context = pa_context_new(pa_mainloop_get_api(device.mainloop), "ruby::pulseaudio");
|
||||
|
@ -133,43 +137,29 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(buffer.data) {
|
||||
pa_stream_cancel_write(device.stream);
|
||||
buffer.data = 0;
|
||||
buffer.data = nullptr;
|
||||
}
|
||||
|
||||
if(device.stream) {
|
||||
pa_stream_disconnect(device.stream);
|
||||
pa_stream_unref(device.stream);
|
||||
device.stream = 0;
|
||||
device.stream = nullptr;
|
||||
}
|
||||
|
||||
if(device.context) {
|
||||
pa_context_disconnect(device.context);
|
||||
pa_context_unref(device.context);
|
||||
device.context = 0;
|
||||
device.context = nullptr;
|
||||
}
|
||||
|
||||
if(device.mainloop) {
|
||||
pa_mainloop_free(device.mainloop);
|
||||
device.mainloop = 0;
|
||||
device.mainloop = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
pAudioPulseAudio() {
|
||||
device.mainloop = 0;
|
||||
device.context = 0;
|
||||
device.stream = 0;
|
||||
buffer.data = 0;
|
||||
settings.synchronize = false;
|
||||
settings.frequency = 22050;
|
||||
settings.latency = 60;
|
||||
}
|
||||
|
||||
~pAudioPulseAudio() {
|
||||
term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareAudio(PulseAudio)
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
//audio.pulseaudiosimple (2010-01-05)
|
||||
//author: byuu
|
||||
|
||||
#include <pulse/simple.h>
|
||||
#include <pulse/error.h>
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pAudioPulseAudioSimple {
|
||||
public:
|
||||
struct pAudioPulseAudioSimple {
|
||||
struct {
|
||||
pa_simple* handle;
|
||||
pa_simple* handle = nullptr;
|
||||
pa_sample_spec spec;
|
||||
} device;
|
||||
|
||||
struct {
|
||||
uint32_t* data;
|
||||
unsigned offset;
|
||||
uint32_t* data = nullptr;
|
||||
unsigned offset = 0;
|
||||
} buffer;
|
||||
|
||||
struct {
|
||||
unsigned frequency;
|
||||
unsigned frequency = 22050;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
~pAudioPulseAudioSimple() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Audio::Frequency) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Audio::Frequency) return settings.frequency;
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Audio::Frequency) {
|
||||
settings.frequency = any_cast<unsigned>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Audio::Frequency && value.is<unsigned>()) {
|
||||
settings.frequency = value.get<unsigned>();
|
||||
if(device.handle) init();
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void sample(uint16_t left, uint16_t right) {
|
||||
auto sample(uint16_t left, uint16_t right) -> void {
|
||||
if(!device.handle) return;
|
||||
|
||||
buffer.data[buffer.offset++] = left + (right << 16);
|
||||
|
@ -53,10 +53,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
term();
|
||||
|
||||
device.spec.format = PA_SAMPLE_S16LE;
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(device.handle) {
|
||||
int error;
|
||||
pa_simple_flush(device.handle, &error);
|
||||
|
@ -98,16 +98,6 @@ public:
|
|||
buffer.data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
pAudioPulseAudioSimple() {
|
||||
device.handle = nullptr;
|
||||
buffer.data = nullptr;
|
||||
settings.frequency = 22050;
|
||||
}
|
||||
|
||||
~pAudioPulseAudioSimple() {
|
||||
term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareAudio(PulseAudioSimple)
|
||||
|
|
|
@ -8,39 +8,39 @@ struct pInputCarbon {
|
|||
vector<Key> keys;
|
||||
|
||||
struct Keyboard {
|
||||
HID::Keyboard hid;
|
||||
shared_pointer<HID::Keyboard> hid{new HID::Keyboard};
|
||||
} kb;
|
||||
|
||||
bool cap(const string& name) {
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Input::KeyboardSupport) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
return false;
|
||||
auto acquire() -> bool { return false; }
|
||||
auto unacquire() -> bool { return false; }
|
||||
auto acquired() -> bool { return false; }
|
||||
|
||||
auto assign(shared_pointer<HID::Device> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
bool acquire() { return false; }
|
||||
bool unacquire() { return false; }
|
||||
bool acquired() { return false; }
|
||||
|
||||
void assign(HID::Device& hid, unsigned groupID, unsigned inputID, int16_t value) {
|
||||
auto& group = hid.group[groupID];
|
||||
if(group.input[inputID].value == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input[inputID].value, value);
|
||||
group.input[inputID].value = value;
|
||||
}
|
||||
|
||||
vector<HID::Device*> poll() {
|
||||
vector<HID::Device*> devices;
|
||||
auto poll() -> vector<shared_pointer<HID::Device>> {
|
||||
vector<shared_pointer<HID::Device>> devices;
|
||||
|
||||
KeyMap keymap;
|
||||
GetKeys(keymap);
|
||||
uint8_t* buffer = (uint8_t*)keymap;
|
||||
auto buffer = (uint8_t*)keymap;
|
||||
|
||||
unsigned inputID = 0;
|
||||
for(auto& key : keys) {
|
||||
|
@ -48,15 +48,15 @@ struct pInputCarbon {
|
|||
assign(kb.hid, HID::Keyboard::GroupID::Button, inputID++, value);
|
||||
}
|
||||
|
||||
devices.append(&kb.hid);
|
||||
devices.append(kb.hid);
|
||||
return devices;
|
||||
}
|
||||
|
||||
bool rumble(uint64_t id, bool enable) {
|
||||
auto rumble(uint64_t id, bool enable) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
keys.append({0x35, "Escape"});
|
||||
keys.append({0x7a, "F1"});
|
||||
keys.append({0x78, "F2"});
|
||||
|
@ -170,13 +170,13 @@ struct pInputCarbon {
|
|||
keys.append({0x3a, "Alt"});
|
||||
keys.append({0x37, "Super"});
|
||||
|
||||
kb.hid.id = 1;
|
||||
for(auto& key : keys) kb.hid.button().append({key.name});
|
||||
kb.hid->setID(1);
|
||||
for(auto& key : keys) kb.hid->buttons().append(key.name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ struct InputJoypadUdev {
|
|||
};
|
||||
|
||||
struct Joypad {
|
||||
HID::Joypad hid;
|
||||
shared_pointer<HID::Joypad> hid{new HID::Joypad};
|
||||
|
||||
int fd = -1;
|
||||
dev_t device = 0;
|
||||
|
@ -52,14 +52,14 @@ struct InputJoypadUdev {
|
|||
};
|
||||
vector<Joypad> joypads;
|
||||
|
||||
void assign(HID::Joypad& hid, unsigned groupID, unsigned inputID, int16_t value) {
|
||||
auto& group = hid.group[groupID];
|
||||
if(group.input[inputID].value == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input[inputID].value, value);
|
||||
group.input[inputID].value = value;
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
if(input.onChange) input.onChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
group.input(inputID).setValue(value);
|
||||
}
|
||||
|
||||
void poll(vector<HID::Device*>& devices) {
|
||||
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
|
||||
while(hotplugDevicesAvailable()) hotplugDevice();
|
||||
|
||||
for(auto& jp : joypads) {
|
||||
|
@ -92,14 +92,14 @@ struct InputJoypadUdev {
|
|||
}
|
||||
}
|
||||
|
||||
devices.append(&jp.hid);
|
||||
devices.append(jp.hid);
|
||||
}
|
||||
}
|
||||
|
||||
bool rumble(uint64_t id, bool enable) {
|
||||
auto rumble(uint64_t id, bool enable) -> bool {
|
||||
for(auto& jp : joypads) {
|
||||
if(jp.hid.id != id) continue;
|
||||
if(jp.hid.rumble == false) continue;
|
||||
if(jp.hid->id() != id) continue;
|
||||
if(!jp.hid->rumble()) continue;
|
||||
|
||||
input_event play;
|
||||
memset(&play, 0, sizeof(input_event));
|
||||
|
@ -113,7 +113,7 @@ struct InputJoypadUdev {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
context = udev_new();
|
||||
if(context == nullptr) return false;
|
||||
|
||||
|
@ -140,19 +140,19 @@ struct InputJoypadUdev {
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(enumerator) { udev_enumerate_unref(enumerator); enumerator = nullptr; }
|
||||
}
|
||||
|
||||
private:
|
||||
bool hotplugDevicesAvailable() {
|
||||
auto hotplugDevicesAvailable() -> bool {
|
||||
pollfd fd = {0};
|
||||
fd.fd = udev_monitor_get_fd(monitor);
|
||||
fd.events = POLLIN;
|
||||
return (::poll(&fd, 1, 0) == 1) && (fd.revents & POLLIN);
|
||||
}
|
||||
|
||||
void hotplugDevice() {
|
||||
auto hotplugDevice() -> void {
|
||||
udev_device* device = udev_monitor_receive_device(monitor);
|
||||
if(device == nullptr) return;
|
||||
|
||||
|
@ -169,7 +169,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void createJoypad(udev_device* device, const string& deviceNode) {
|
||||
auto createJoypad(udev_device* device, const string& deviceNode) -> void {
|
||||
Joypad jp;
|
||||
jp.deviceNode = deviceNode;
|
||||
|
||||
|
@ -254,17 +254,17 @@ private:
|
|||
#undef testBit
|
||||
}
|
||||
|
||||
void createJoypadHID(Joypad& jp) {
|
||||
auto createJoypadHID(Joypad& jp) -> void {
|
||||
uint64_t pathID = Hash::CRC32(jp.deviceName.data(), jp.deviceName.size()).value();
|
||||
jp.hid.id = pathID << 32 | hex(jp.vendorID) << 16 | hex(jp.productID) << 0;
|
||||
jp.hid->setID(pathID << 32 | hex(jp.vendorID) << 16 | hex(jp.productID) << 0);
|
||||
|
||||
for(unsigned n = 0; n < jp.axes.size(); n++) jp.hid.axis().append({n});
|
||||
for(unsigned n = 0; n < jp.hats.size(); n++) jp.hid.hat().append({n});
|
||||
for(unsigned n = 0; n < jp.buttons.size(); n++) jp.hid.button().append({n});
|
||||
jp.hid.rumble = jp.rumble;
|
||||
for(unsigned n = 0; n < jp.axes.size(); n++) jp.hid->axes().append(n);
|
||||
for(unsigned n = 0; n < jp.hats.size(); n++) jp.hid->hats().append(n);
|
||||
for(unsigned n = 0; n < jp.buttons.size(); n++) jp.hid->buttons().append(n);
|
||||
jp.hid->setRumble(jp.rumble);
|
||||
}
|
||||
|
||||
void removeJoypad(udev_device* device, const string& deviceNode) {
|
||||
auto removeJoypad(udev_device* device, const string& deviceNode) -> void {
|
||||
for(unsigned n = 0; n < joypads.size(); n++) {
|
||||
if(joypads[n].deviceNode == deviceNode) {
|
||||
close(joypads[n].fd);
|
||||
|
|
|
@ -23,7 +23,7 @@ struct pInputUdev {
|
|||
uintptr_t handle = 0;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Input::Handle) return true;
|
||||
if(name == Input::KeyboardSupport) return true;
|
||||
if(name == Input::MouseSupport) return true;
|
||||
|
@ -32,51 +32,51 @@ struct pInputUdev {
|
|||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
if(name == Input::Handle) return (uintptr_t)settings.handle;
|
||||
return false;
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Input::Handle) return settings.handle;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Input::Handle) {
|
||||
settings.handle = any_cast<uintptr_t>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Input::Handle && value.is<uintptr_t>()) {
|
||||
settings.handle = value.get<uintptr_t>();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool acquire() {
|
||||
auto acquire() -> bool {
|
||||
return xlibMouse.acquire();
|
||||
}
|
||||
|
||||
bool unacquire() {
|
||||
auto unacquire() -> bool {
|
||||
return xlibMouse.unacquire();
|
||||
}
|
||||
|
||||
bool acquired() {
|
||||
auto acquired() -> bool {
|
||||
return xlibMouse.acquired();
|
||||
}
|
||||
|
||||
vector<HID::Device*> poll() {
|
||||
vector<HID::Device*> devices;
|
||||
auto poll() -> vector<shared_pointer<HID::Device>> {
|
||||
vector<shared_pointer<HID::Device>> devices;
|
||||
xlibKeyboard.poll(devices);
|
||||
xlibMouse.poll(devices);
|
||||
udev.poll(devices);
|
||||
return devices;
|
||||
}
|
||||
|
||||
bool rumble(uint64_t id, bool enable) {
|
||||
auto rumble(uint64_t id, bool enable) -> bool {
|
||||
return udev.rumble(id, enable);
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
if(xlibKeyboard.init() == false) return false;
|
||||
if(xlibMouse.init(settings.handle) == false) return false;
|
||||
if(udev.init() == false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
xlibKeyboard.term();
|
||||
xlibMouse.term();
|
||||
udev.term();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "opengl/opengl.hpp"
|
||||
|
||||
namespace ruby {
|
||||
class pVideoCGL;
|
||||
struct pVideoCGL;
|
||||
}
|
||||
|
||||
@interface RubyVideoCGL : NSOpenGLView {
|
||||
|
@ -20,11 +20,15 @@ struct pVideoCGL : OpenGL {
|
|||
struct {
|
||||
NSView* handle = nullptr;
|
||||
bool synchronize = false;
|
||||
unsigned filter = 0;
|
||||
unsigned filter = Video::FilterNearest;
|
||||
string shader;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
~pVideoCGL() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Video::Handle) return true;
|
||||
if(name == Video::Synchronize) return true;
|
||||
if(name == Video::Filter) return true;
|
||||
|
@ -32,22 +36,22 @@ struct pVideoCGL : OpenGL {
|
|||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Video::Handle) return (uintptr_t)settings.handle;
|
||||
if(name == Video::Synchronize) return settings.synchronize;
|
||||
if(name == Video::Filter) return settings.filter;
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Video::Handle) {
|
||||
settings.handle = (NSView*)any_cast<uintptr_t>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Video::Handle && value.is<uintptr_t>()) {
|
||||
settings.handle = (NSView*)value.get<uintptr_t>();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::Synchronize) {
|
||||
if(settings.synchronize != any_cast<bool>(value)) {
|
||||
settings.synchronize = any_cast<bool>(value);
|
||||
if(name == Video::Synchronize && value.is<bool>()) {
|
||||
if(settings.synchronize != value.get<bool>()) {
|
||||
settings.synchronize = value.get<bool>();
|
||||
|
||||
if(view) {
|
||||
@autoreleasepool {
|
||||
|
@ -60,34 +64,34 @@ struct pVideoCGL : OpenGL {
|
|||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::Filter) {
|
||||
settings.filter = any_cast<unsigned>(value);
|
||||
if(settings.shader.empty()) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
||||
if(name == Video::Filter && value.is<unsigned>()) {
|
||||
settings.filter = value.get<unsigned>();
|
||||
if(!settings.shader) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Video::Shader) {
|
||||
settings.shader = any_cast<const char*>(value);
|
||||
if(name == Video::Shader && value.is<string>()) {
|
||||
settings.shader = value.get<string>();
|
||||
@autoreleasepool {
|
||||
[[view openGLContext] makeCurrentContext];
|
||||
}
|
||||
OpenGL::shader(settings.shader);
|
||||
if(settings.shader.empty()) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
||||
if(!settings.shader) OpenGL::filter = settings.filter ? GL_LINEAR : GL_NEAREST;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) {
|
||||
auto lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) -> bool {
|
||||
OpenGL::size(width, height);
|
||||
return OpenGL::lock(data, pitch);
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
auto unlock() -> void {
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
@autoreleasepool {
|
||||
[view lockFocus];
|
||||
OpenGL::clear();
|
||||
|
@ -96,7 +100,7 @@ struct pVideoCGL : OpenGL {
|
|||
}
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
auto refresh() -> void {
|
||||
@autoreleasepool {
|
||||
if([view lockFocusIfCanDraw]) {
|
||||
auto area = [view frame];
|
||||
|
@ -108,7 +112,7 @@ struct pVideoCGL : OpenGL {
|
|||
}
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
term();
|
||||
|
||||
@autoreleasepool {
|
||||
|
@ -146,7 +150,7 @@ struct pVideoCGL : OpenGL {
|
|||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
OpenGL::term();
|
||||
|
||||
@autoreleasepool {
|
||||
|
@ -155,10 +159,6 @@ struct pVideoCGL : OpenGL {
|
|||
view = nil;
|
||||
}
|
||||
}
|
||||
|
||||
~pVideoCGL() {
|
||||
term();
|
||||
}
|
||||
};
|
||||
|
||||
DeclareVideo(CGL)
|
||||
|
|
|
@ -25,7 +25,7 @@ else ifeq ($(platform),macosx)
|
|||
else ifeq ($(platform),linux)
|
||||
ruby += video.glx video.xv video.xshm video.sdl
|
||||
ruby += audio.alsa audio.openal audio.oss audio.pulseaudio audio.pulseaudiosimple audio.ao
|
||||
ruby += input.sdl input.xlib #input.udev
|
||||
ruby += input.udev input.sdl input.xlib
|
||||
else ifeq ($(platform),bsd)
|
||||
ruby += video.glx video.xv video.xshm video.sdl
|
||||
ruby += audio.openal audio.oss
|
||||
|
|
Loading…
Reference in New Issue