Update to v106r47 release.

byuu says:

This is probably the largest code-change diff I've done in years.

I spent four days working 10-16 hours a day reworking layouts in hiro
completely.

The result is we now have TableLayout, which will allow for better
horizontal+vertical combined alignment.

Windows, GTK2, and now GTK3 are fully supported.

Windows is getting the initial window geometry wrong by a bit.

GTK2 and GTK3 work perfectly. I basically abandoned trying to detect
resize signals, and instead keep a list of all hiro windows that are
allocated, and every time the main loop runs, it will query all of them
to see if they've been resized. I'm disgusted that I have to do this,
but after fighting with GTK for years, I'm about sick of it. GTK was
doing this crazy thing where it would trigger another size-allocate
inside of a previous size-allocate, and so my layouts would be halfway
through resizing all the widgets, and then the size-allocate would kick
off another one. That would end up leaving the rest of the first layout
loop with bad widget sizes. And if I detected a second re-entry and
blocked it, then the entire window would end up with the older geometry.
I started trying to build a message queue system to allow the second
layout resize to occur after the first one completed, but this was just
too much madness, so I went with the simpler solution.

Qt4 has some geometry problems, and doesn't show tab frame layouts
properly yet.

Qt5 causes an ICE error and tanks my entire Xorg display server, so ...
something is seriously wrong there, and it's not hiro's fault. Creating
a dummy Qt5 application without even using hiro, just int main() {
TestObject object; } with object performing a dynamic\_cast to a derived
type segfaults. Memory is getting corrupted where GCC allocates the
vtables for classes, just by linking in Qt. Could be somehow related to
the -fPIC requirement that only Qt5 has ... could just be that FreeBSD
10.1 has a buggy implementation of Qt5. I don't know. It's beyond my
ability to debug, so this one's going to stay broken.

The Cocoa port is busted. I'll fix it up to compile again, but that's
about all I'm going to do.

Many optimizations mean bsnes and higan open faster. GTK2 and GTK3 both
resize windows very quickly now.

higan crashes when you load a game, so that's not good. bsnes works
though.

bsnes also has the start of a localization engine now. Still a long way
to go.

The makefiles received a rather substantial restructuring. Including the
ruby and hiro makefiles will add the necessary compilation rules for
you, which also means that moc will run for the qt4 and qt5 targets, and
windres will run for the Windows targets.
This commit is contained in:
Tim Allen
2018-07-14 13:59:29 +10:00
parent 0c55796060
commit 6090c63958
207 changed files with 2864 additions and 1667 deletions

View File

@@ -1,31 +0,0 @@
#if defined(Hiro_Layout)
namespace hiro {
auto pLayout::construct() -> void {
}
auto pLayout::destruct() -> void {
}
auto pLayout::setEnabled(bool enabled) -> void {
for(auto& sizable : state().sizables) {
if(auto self = sizable->self()) self->setEnabled(sizable->enabled(true));
}
}
auto pLayout::setFont(const Font& font) -> void {
for(auto& sizable : state().sizables) {
if(auto self = sizable->self()) self->setFont(sizable->font(true));
}
}
auto pLayout::setVisible(bool visible) -> void {
for(auto& sizable : state().sizables) {
if(auto self = sizable->self()) self->setVisible(sizable->visible(true));
}
}
}
#endif

View File

@@ -1,15 +0,0 @@
#if defined(Hiro_Layout)
namespace hiro {
struct pLayout : pSizable {
Declare(Layout, Sizable)
auto setEnabled(bool enabled) -> void override;
auto setFont(const Font& font) -> void override;
auto setVisible(bool visible) -> void override;
};
}
#endif

View File

@@ -1,5 +1,7 @@
#if defined(Hiro_Monitor)
//per-monitor API is only on Windows 10+
namespace hiro {
struct MonitorInfo {
@@ -49,6 +51,10 @@ auto pMonitor::primary() -> uint {
return info.primary;
}
auto pMonitor::workspace(uint monitor) -> Geometry {
return pDesktop::workspace();
}
}
#endif

View File

@@ -7,6 +7,7 @@ struct pMonitor {
static auto dpi(uint monitor) -> Position;
static auto geometry(uint monitor) -> Geometry;
static auto primary() -> uint;
static auto workspace(uint monitor) -> Geometry;
};
}

View File

@@ -33,6 +33,9 @@ auto pObject::setFont(const Font& font) -> void {
auto pObject::setGroup(sGroup group) -> void {
}
auto pObject::setParent(mObject* parent, int offset) -> void {
}
auto pObject::setVisible(bool visible) -> void {
}

View File

@@ -2,7 +2,7 @@
namespace hiro {
struct pObject {
struct pObject : mLock {
pObject(mObject& reference) : reference(reference) {}
virtual ~pObject() = default;
virtual auto construct() -> void;
@@ -16,14 +16,10 @@ struct pObject {
virtual auto setFocused() -> void;
virtual auto setFont(const Font& font) -> void;
virtual auto setGroup(sGroup group) -> void;
virtual auto setParent(mObject* parent, int offset) -> void;
virtual auto setVisible(bool visible) -> void;
auto locked() const -> bool { return locks != 0 || Application::state.quit; }
auto lock() -> void { ++locks; }
auto unlock() -> void { --locks; }
mObject& reference;
signed locks = 0;
};
}

View File

@@ -26,7 +26,6 @@
#include "action/menu-radio-item.cpp"
#include "sizable.cpp"
#include "layout.cpp"
#include "widget/widget.cpp"
#include "widget/button.cpp"

View File

@@ -8,7 +8,7 @@ struct pLayout;
struct pWidget;
struct AppMessage {
enum : unsigned {
enum : uint {
None = WM_APP,
TableView_doPaint,
TableView_onActivate,
@@ -55,7 +55,6 @@ static vector<wObject> windows;
#include "action/menu-radio-item.hpp"
#include "sizable.hpp"
#include "layout.hpp"
#include "widget/widget.hpp"
#include "widget/button.hpp"

View File

@@ -15,14 +15,14 @@ auto pFrame::destruct() -> void {
DestroyWindow(hwnd);
}
auto pFrame::append(sLayout layout) -> void {
auto pFrame::append(sSizable sizable) -> void {
}
auto pFrame::remove(sLayout layout) -> void {
auto pFrame::remove(sSizable sizable) -> void {
}
auto pFrame::setEnabled(bool enabled) -> void {
if(auto layout = state().layout) layout->setEnabled(layout->enabled());
if(auto& sizable = state().sizable) sizable->setEnabled(sizable->enabled());
pWidget::setEnabled(enabled);
}
@@ -35,9 +35,9 @@ auto pFrame::setGeometry(Geometry geometry) -> void {
geometry.width(),
geometry.height() + (empty ? size.height() / 2 : 0)
});
if(auto layout = state().layout) {
if(auto& sizable = state().sizable) {
if(empty) size.setHeight(1);
layout->setGeometry({
sizable->setGeometry({
geometry.x() + 1,
geometry.y() + size.height(),
geometry.width() - 2,
@@ -51,7 +51,7 @@ auto pFrame::setText(const string& text) -> void {
}
auto pFrame::setVisible(bool visible) -> void {
if(auto layout = state().layout) layout->setVisible(layout->visible());
if(auto& sizable = state().sizable) sizable->setVisible(sizable->visible());
pWidget::setVisible(visible);
}

View File

@@ -5,8 +5,8 @@ namespace hiro {
struct pFrame : pWidget {
Declare(Frame, Widget)
auto append(sLayout layout) -> void;
auto remove(sLayout layout) -> void;
auto append(sSizable sizable) -> void;
auto remove(sSizable sizable) -> void;
auto setEnabled(bool enabled) -> void override;
auto setGeometry(Geometry geometry) -> void override;
auto setText(const string& text) -> void;

View File

@@ -8,15 +8,15 @@ auto pTabFrameItem::construct() -> void {
auto pTabFrameItem::destruct() -> void {
}
auto pTabFrameItem::append(sLayout layout) -> void {
auto pTabFrameItem::append(sSizable sizable) -> void {
if(auto parent = _parent()) {
parent->_synchronizeLayout();
parent->_synchronizeSizable();
}
}
auto pTabFrameItem::remove(sLayout layout) -> void {
auto pTabFrameItem::remove(sSizable sizable) -> void {
if(auto parent = _parent()) {
parent->_synchronizeLayout();
parent->_synchronizeSizable();
}
}
@@ -37,7 +37,7 @@ auto pTabFrameItem::setMovable(bool movable) -> void {
auto pTabFrameItem::setSelected() -> void {
if(auto parent = _parent()) {
TabCtrl_SetCurSel(parent->hwnd, self().offset());
parent->_synchronizeLayout();
parent->_synchronizeSizable();
}
}

View File

@@ -5,8 +5,8 @@ namespace hiro {
struct pTabFrameItem : pObject {
Declare(TabFrameItem, Object)
auto append(sLayout layout) -> void;
auto remove(sLayout layout) -> void;
auto append(sSizable sizable) -> void;
auto remove(sSizable sizable) -> void;
auto setClosable(bool closable) -> void;
auto setIcon(const image& icon) -> void;
auto setMovable(bool movable) -> void;

View File

@@ -45,7 +45,7 @@ auto pTabFrame::append(sTabFrameItem item) -> void {
if(item->selected()) self->setSelected();
}
_buildImageList();
_synchronizeLayout();
_synchronizeSizable();
}
auto pTabFrame::remove(sTabFrameItem item) -> void {
@@ -56,8 +56,8 @@ auto pTabFrame::remove(sTabFrameItem item) -> void {
auto pTabFrame::setEnabled(bool enabled) -> void {
pWidget::setEnabled(enabled);
for(auto& item : state().items) {
if(auto layout = item->state.layout) {
if(auto self = layout->self()) self->setEnabled(layout->enabled(true));
if(auto& sizable = item->state.sizable) {
if(auto self = sizable->self()) self->setEnabled(sizable->enabled());
}
}
}
@@ -69,8 +69,8 @@ auto pTabFrame::setGeometry(Geometry geometry) -> void {
geometry.setWidth(geometry.width() - 4);
geometry.setHeight(geometry.height() - 23);
for(auto& item : state().items) {
if(auto layout = item->state.layout) {
layout->setGeometry(geometry);
if(auto& sizable = item->state.sizable) {
sizable->setGeometry(geometry);
}
}
}
@@ -82,8 +82,8 @@ auto pTabFrame::setNavigation(Navigation navigation) -> void {
auto pTabFrame::setVisible(bool visible) -> void {
pWidget::setVisible(visible);
for(auto& item : state().items) {
if(auto layout = item->state.layout) {
if(auto self = layout->self()) self->setVisible(layout->visible(true));
if(auto& sizable = item->state.sizable) {
if(auto self = sizable->self()) self->setVisible(sizable->visible(true));
}
}
}
@@ -97,7 +97,7 @@ auto pTabFrame::_buildImageList() -> void {
ImageList_Append(imageList, item->state.icon, size);
}
TabCtrl_SetImageList(hwnd, imageList);
for(auto offset : range(state().items)) {
for(auto offset : range(state().items.size())) {
TCITEM tcItem;
tcItem.mask = TCIF_IMAGE;
tcItem.iImage = state().items[offset]->state.icon ? offset : -1;
@@ -105,10 +105,10 @@ auto pTabFrame::_buildImageList() -> void {
}
}
auto pTabFrame::_synchronizeLayout() -> void {
auto pTabFrame::_synchronizeSizable() -> void {
for(auto& item : state().items) {
if(auto layout = item->state.layout) {
layout->setVisible(item->selected());
if(auto& sizable = item->state.sizable) {
sizable->setVisible(item->selected());
}
}
}
@@ -117,7 +117,7 @@ auto pTabFrame::onChange() -> void {
unsigned selected = TabCtrl_GetCurSel(hwnd);
for(auto& item : state().items) item->state.selected = false;
if(auto item = self().item(selected)) item->state.selected = true;
_synchronizeLayout();
_synchronizeSizable();
self().doChange();
}

View File

@@ -16,7 +16,7 @@ struct pTabFrame : pWidget {
auto onDrawItem(LPARAM lparam) -> void;
auto _buildImageList() -> void;
auto _synchronizeLayout() -> void;
auto _synchronizeSizable() -> void;
WindowProc windowProc = nullptr;
HIMAGELIST imageList = nullptr;

View File

@@ -428,7 +428,7 @@ auto pTableView::_width(unsigned column) -> unsigned {
if(auto width = header->state.columns[column]->width()) return width;
unsigned width = 1;
if(header->visible()) width = max(width, _columnWidth(column));
for(auto row : range(state().items)) {
for(auto row : range(state().items.size())) {
width = max(width, _cellWidth(row, column));
}
return width;

View File

@@ -2,8 +2,8 @@
namespace hiro {
static const unsigned FixedStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_BORDER | WS_CLIPCHILDREN;
static const unsigned ResizableStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPCHILDREN;
static const uint FixedStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_BORDER | WS_CLIPCHILDREN;
static const uint ResizableStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPCHILDREN;
auto pWindow::construct() -> void {
hwnd = CreateWindow(L"hiroWindow", L"", ResizableStyle, 128, 128, 256, 256, 0, 0, GetModuleHandle(0), 0);
@@ -21,10 +21,10 @@ auto pWindow::destruct() -> void {
DestroyWindow(hwnd);
}
auto pWindow::append(sLayout layout) -> void {
auto pWindow::append(sMenuBar menuBar) -> void {
}
auto pWindow::append(sMenuBar menuBar) -> void {
auto pWindow::append(sSizable sizable) -> void {
}
auto pWindow::append(sStatusBar statusBar) -> void {
@@ -40,7 +40,7 @@ auto pWindow::frameMargin() const -> Geometry {
RECT rc{0, 0, 640, 480};
AdjustWindowRect(&rc, style, (bool)GetMenu(hwnd));
signed statusHeight = 0;
if(auto statusBar = state().statusBar) {
if(auto& statusBar = state().statusBar) {
if(auto self = statusBar->self()) {
if(statusBar->visible()) {
RECT src;
@@ -52,10 +52,10 @@ auto pWindow::frameMargin() const -> Geometry {
return {abs(rc.left), abs(rc.top), (rc.right - rc.left) - 640, (rc.bottom - rc.top) + statusHeight - 480};
}
auto pWindow::remove(sLayout layout) -> void {
auto pWindow::remove(sMenuBar menuBar) -> void {
}
auto pWindow::remove(sMenuBar menuBar) -> void {
auto pWindow::remove(sSizable sizable) -> void {
}
auto pWindow::remove(sStatusBar statusBar) -> void {
@@ -75,8 +75,8 @@ auto pWindow::setDroppable(bool droppable) -> void {
}
auto pWindow::setEnabled(bool enabled) -> void {
if(auto layout = state().layout) {
if(auto self = layout->self()) self->setEnabled(layout->enabled(true));
if(auto& sizable = state().sizable) {
if(auto self = sizable->self()) self->setEnabled(sizable->enabled(true));
}
}
@@ -86,8 +86,8 @@ auto pWindow::setFocused() -> void {
}
auto pWindow::setFont(const Font& font) -> void {
if(auto layout = state().layout) {
if(auto self = layout->self()) self->setFont(layout->font(true));
if(auto& sizable = state().sizable) {
if(auto self = sizable->self()) self->setFont(sizable->font(true));
}
}
@@ -125,13 +125,13 @@ auto pWindow::setGeometry(Geometry geometry) -> void {
geometry.width() + margin.width(), geometry.height() + margin.height(),
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
);
if(auto statusBar = state().statusBar) {
if(auto& statusBar = state().statusBar) {
if(auto self = statusBar->self()) {
SetWindowPos(self->hwnd, nullptr, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
}
if(auto layout = state().layout) {
layout->setGeometry(geometry.setPosition(0, 0));
if(auto& sizable = state().sizable) {
sizable->setGeometry(geometry.setPosition());
}
unlock();
}
@@ -139,7 +139,7 @@ auto pWindow::setGeometry(Geometry geometry) -> void {
auto pWindow::setMaximized(bool maximized) -> void {
if(state().minimized) return;
lock();
ShowWindow(hwnd, maximized ? SW_MAXIMIZED : SW_SHOWNOACTIVATE);
ShowWindow(hwnd, maximized ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
unlock();
}
@@ -149,7 +149,7 @@ auto pWindow::setMaximumSize(Size size) -> void {
auto pWindow::setMinimized(bool minimized) -> void {
lock();
ShowWindow(hwnd, minimized ? SW_MINIMIZED : state().maximized ? SW_MAXIMIZED : SW_SHOWNOACTIVATE);
ShowWindow(hwnd, minimized ? SW_MINIMIZE : state().maximized ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
unlock();
}
@@ -187,8 +187,8 @@ auto pWindow::setVisible(bool visible) -> void {
ShowWindow(hwnd, visible ? SW_SHOWNORMAL : SW_HIDE);
if(!visible) setModal(false);
if(auto layout = state().layout) {
if(auto self = layout->self()) self->setVisible(layout->visible(true));
if(auto& sizable = state().sizable) {
if(auto self = sizable->self()) self->setVisible(sizable->visible(true));
}
unlock();
}
@@ -239,8 +239,8 @@ auto pWindow::onSize() -> void {
}
}
state().geometry.setSize(_geometry().size());
if(auto layout = state().layout) {
layout->setGeometry(_geometry().setPosition(0, 0));
if(auto& sizable = state().sizable) {
sizable->setGeometry(_geometry().setPosition());
}
self().doSize();
}

View File

@@ -5,13 +5,13 @@ namespace hiro {
struct pWindow : pObject {
Declare(Window, Object)
auto append(sLayout layout) -> void;
auto append(sMenuBar menuBar) -> void;
auto append(sSizable sizable) -> void;
auto append(sStatusBar statusBar) -> void;
auto focused() const -> bool override;
auto frameMargin() const -> Geometry;
auto remove(sLayout layout) -> void;
auto remove(sMenuBar menuBar) -> void;
auto remove(sSizable sizable) -> void;
auto remove(sStatusBar statusBar) -> void;
auto setBackgroundColor(Color color) -> void;
auto setDismissable(bool dismissable) -> void;