bsnes/hiro/qt/action/menu.cpp

60 lines
1.2 KiB
C++
Raw Normal View History

#if defined(Hiro_Menu)
namespace hiro {
auto pMenu::construct() -> void {
qtMenu = new QMenu;
if(auto parent = _parentMenu()) {
parent->qtMenu->addMenu(qtMenu);
Update to v075r11 release. byuu says: Rewrote the way menus are attached, they act like layouts/widgets now. All three phoenix targets once again work with both radio menu items and radio widgets. Both GTK+ and Qt have built-in group controls right inside the widgets, so I don't have to keep my own groups around anymore. They do act screwy at widget creation though, have to jump through some hoops to get it to work right. All I can say is, definitely set all child widgets to the parent before trying to check any of them. My long-term goal for the main window is to honor the fullscreen video setting as a generic setting, and let the window scale auto-fit the best possible size that matches your scale preference into the output window, centered just like fullscreen. For now, I've just set it to a fixed window size until I finish working on phoenix. The scale X settings will just be to snap the window to an exact size in case you don't want any black borders, they won't be radio items and the bsnes-geometry.cfg file will save width/height information as well. Simplified the sizing requirements for creating layouts and updated all bsnes windows to support the new system. Layouts also expose their minimum width/height values, which I use to create perfectly sized windows on all three platforms. This will fix cut-off heights on the last Windows WIP. Qt is being annoying though and forcing a minimum window size of 300,100 despite me telling it to use a smaller window size. Always have to fight with Qt, I swear to god.
2011-02-10 10:08:12 +00:00
}
if(auto parent = _parentMenuBar()) {
if(auto window = parent->_parent()) {
window->qtMenuBar->addMenu(qtMenu);
}
}
if(auto parent = _parentPopupMenu()) {
parent->qtPopupMenu->addMenu(qtMenu);
}
_setState();
}
auto pMenu::destruct() -> void {
if(Application::state().quit) return; //TODO: hack
delete qtMenu;
qtMenu = nullptr;
}
auto pMenu::append(sAction action) -> void {
}
auto pMenu::remove(sAction action) -> void {
}
auto pMenu::setIcon(const image& icon) -> void {
_setState();
Update to v075r11 release. byuu says: Rewrote the way menus are attached, they act like layouts/widgets now. All three phoenix targets once again work with both radio menu items and radio widgets. Both GTK+ and Qt have built-in group controls right inside the widgets, so I don't have to keep my own groups around anymore. They do act screwy at widget creation though, have to jump through some hoops to get it to work right. All I can say is, definitely set all child widgets to the parent before trying to check any of them. My long-term goal for the main window is to honor the fullscreen video setting as a generic setting, and let the window scale auto-fit the best possible size that matches your scale preference into the output window, centered just like fullscreen. For now, I've just set it to a fixed window size until I finish working on phoenix. The scale X settings will just be to snap the window to an exact size in case you don't want any black borders, they won't be radio items and the bsnes-geometry.cfg file will save width/height information as well. Simplified the sizing requirements for creating layouts and updated all bsnes windows to support the new system. Layouts also expose their minimum width/height values, which I use to create perfectly sized windows on all three platforms. This will fix cut-off heights on the last Windows WIP. Qt is being annoying though and forcing a minimum window size of 300,100 despite me telling it to use a smaller window size. Always have to fight with Qt, I swear to god.
2011-02-10 10:08:12 +00:00
}
auto pMenu::setText(const string& text) -> void {
_setState();
}
auto pMenu::_setState() -> void {
qtMenu->setEnabled(self().enabled());
qtMenu->setFont(pFont::create(self().font(true)));
qtMenu->setIcon(CreateIcon(state().icon));
qtMenu->setTitle(QString::fromUtf8(state().text));
qtMenu->menuAction()->setVisible(self().visible());
for(auto& action : state().actions) {
if(auto self = action->self()) self->setFont(action->font(true));
}
}
}
#endif