Update to v075r07 release.

byuu says:

This has the phoenix changes applied. Instead of widgets attaching
directly to windows, you now attach them to layouts, which can then be
attached to windows. Layouts are widgets themselves, so adding layouts
to layouts is trivial. It also allows for multi-widget show/hide, etc.

Right now there is only FixedLayout, but of course the plan is to
support a BoxLayout, that lets you add HorizontalLayout and
VerticalLayout containers to it, thus enabling auto-resize and simpler
form layout.

So far only phoenix/Qt is 100% moved over. phoenix/GTK+ has about 1/3rd
ported, and phoenix/Windows only has one control ported over as
a proof-of-concept.

On the user side, bsnes, bgameboy, snespurify and curse have been moved
to this new layout system. All of bsnes works great with it, as far as
I can tell. Fullscreen, debugger, etc are good.
This commit is contained in:
Tim Allen 2011-02-07 20:14:14 +11:00
parent b433838e9f
commit 133d568f76
73 changed files with 832 additions and 402 deletions

View File

@ -2,7 +2,7 @@ include nall/Makefile
snes := snes
gameboy := gameboy
profile := compatibility
ui := ui
ui := ui-gameboy
# compiler
c := $(compiler) -std=gnu99

View File

@ -39,6 +39,7 @@ void APU::Master::run() {
case 4: left = (left >> 1) + (left >> 3); break; // 62.5%
case 5: left -= (left >> 2); break; // 75.0%
case 6: left -= (left >> 3); break; // 87.5%
//case 7: break; //100.0%
}
if(left_enable == false) left = 0;
@ -59,6 +60,7 @@ void APU::Master::run() {
case 4: right = (right >> 1) + (right >> 3); break; // 62.5%
case 5: right -= (right >> 2); break; // 75.0%
case 6: right -= (right >> 3); break; // 87.5%
//case 7: break; //100.0%
}
if(right_enable == false) right = 0;
}

View File

@ -2,12 +2,14 @@ static void Button_tick(Button *self) {
if(self->onTick) self->onTick();
}
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_button_new_with_label(text);
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);
g_signal_connect_swapped(G_OBJECT(object->widget), "clicked", G_CALLBACK(Button_tick), (gpointer)this);
if(parent.window->defaultFont) setFont(*parent.window->defaultFont);
gtk_fixed_put(GTK_FIXED(parent.object->formContainer), object->widget, x, y);
gtk_widget_show(object->widget);
void Button::setParent(Layout &parent) {
}
void Button::setText(const string &text) {
gtk_button_set_label(GTK_BUTTON(object->widget), text);
}
Button::Button() {
object->widget = gtk_button_new();
g_signal_connect_swapped(G_OBJECT(object->widget), "clicked", G_CALLBACK(Button_tick), (gpointer)this);
}

View File

@ -2,14 +2,11 @@ static void CheckBox_tick(CheckBox *self) {
if(self->onTick && self->object->locked == false) self->onTick();
}
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_check_button_new_with_label(text);
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(CheckBox_tick), (gpointer)this);
if(parent.window->defaultFont) setFont(*parent.window->defaultFont);
gtk_fixed_put(GTK_FIXED(parent.object->formContainer), object->widget, x, y);
gtk_widget_show(object->widget);
void CheckBox::setParent(Layout &parent) {
}
void CheckBox::setText(const string &text) {
gtk_button_set_label(GTK_BUTTON(object->widget), text);
}
bool CheckBox::checked() {
@ -21,3 +18,8 @@ void CheckBox::setChecked(bool checked) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object->widget), checked);
object->locked = false;
}
CheckBox::CheckBox() {
object->widget = gtk_check_button_new_with_label("");
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(CheckBox_tick), (gpointer)this);
}

View File

@ -0,0 +1,21 @@
void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height) {
fixedLayout->widgets.append({ &widget, x, y, width, height });
}
void FixedLayout::create(Window &parent) {
gtk_fixed_put(GTK_FIXED(parent.object->formContainer), fixedLayout->container, 0, 0);
gtk_widget_set_size_request(fixedLayout->container, 640, 480);
foreach(widget, fixedLayout->widgets) {
gtk_widget_set_size_request(widget.widget->object->widget, widget.width, widget.height);
gtk_fixed_put(GTK_FIXED(fixedLayout->container), widget.widget->object->widget, widget.x, widget.y);
gtk_widget_show(widget.widget->object->widget);
}
gtk_widget_show(fixedLayout->container);
}
FixedLayout::FixedLayout() {
fixedLayout = new FixedLayout::Data;
fixedLayout->container = gtk_fixed_new();
}

View File

@ -22,6 +22,8 @@ namespace phoenix {
#include "menu.cpp"
#include "widget.cpp"
#include "window.cpp"
#include "layout.cpp"
#include "fixed-layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"

View File

@ -78,7 +78,13 @@ private:
MenuRadioItem *first;
};
struct Window;
struct Layout;
struct Widget : Object {
virtual void setParent(Layout &parent) {}
virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
virtual void setFont(Font &font);
bool visible();
void setVisible(bool visible = true);
@ -86,7 +92,6 @@ struct Widget : Object {
void setEnabled(bool enabled = true);
virtual bool focused();
virtual void setFocused();
virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
Widget();
//private:
struct Data;
@ -96,6 +101,7 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setLayout(Layout &layout);
bool focused();
void setFocused();
Geometry geometry();
@ -116,9 +122,28 @@ struct Window : Widget {
static Window None;
};
struct Layout : Widget {
virtual void create(Window &parent) = 0;
Layout();
//private:
struct Data;
Data *layout;
};
struct FixedLayout : Layout {
void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height);
void create(Window &parent);
FixedLayout();
//private:
struct Data;
Data *fixedLayout;
};
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
Button();
};
struct Canvas : Widget {
@ -134,9 +159,11 @@ struct Canvas : Widget {
struct CheckBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
bool checked();
void setChecked(bool checked = true);
CheckBox();
};
struct ComboBox : Widget {
@ -191,8 +218,9 @@ struct HorizontalSlider : Widget {
};
struct Label : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
Label();
};
struct ListBox : Widget {
@ -225,10 +253,12 @@ struct ProgressBar : Widget {
struct RadioBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setParent(RadioBox &parent);
void setText(const nall::string &text);
bool checked();
void setChecked();
RadioBox();
private:
RadioBox *first;
};

View File

@ -1,13 +1,11 @@
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_label_new(text);
widget->parent = &parent;
gtk_misc_set_alignment(GTK_MISC(object->widget), 0.0, 0.5);
gtk_widget_set_size_request(object->widget, width, height);
if(parent.window->defaultFont) setFont(*parent.window->defaultFont);
gtk_fixed_put(GTK_FIXED(parent.object->formContainer), object->widget, x, y);
gtk_widget_show(object->widget);
void Label::setParent(Layout &parent) {
}
void Label::setText(const string &text) {
gtk_label_set_text(GTK_LABEL(object->widget), text);
}
Label::Label() {
object->widget = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(object->widget), 0.0, 0.5);
}

3
bsnes/phoenix/gtk/layout.cpp Executable file
View File

@ -0,0 +1,3 @@
Layout::Layout() {
layout = new Layout::Data;
}

View File

@ -21,10 +21,6 @@ struct Action::Data {
Font *font;
};
struct Widget::Data {
Window *parent;
};
struct Window::Data {
Font *defaultFont;
bool isFullscreen;
@ -34,6 +30,25 @@ struct Window::Data {
unsigned height;
};
struct Widget::Data {
Window *parent;
};
struct Layout::Data {
};
struct FixedLayout::Data {
Window *parent;
GtkWidget *container;
struct Widgets {
Widget *widget;
unsigned x, y;
unsigned width, height;
};
linear_vector<Widgets> widgets;
};
struct Canvas::Data {
uint32_t *bufferRGB;
uint32_t *bufferBGR;

View File

@ -2,27 +2,16 @@ static void RadioBox_tick(RadioBox *self) {
if(self->onTick && self->checked() && self->object->locked == false) self->onTick();
}
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
void RadioBox::setParent(Layout &parent) {
first = this;
object->parentWindow = &parent;
object->widget = gtk_radio_button_new_with_label(0, text);
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(RadioBox_tick), (gpointer)this);
if(parent.window->defaultFont) setFont(*parent.window->defaultFont);
gtk_fixed_put(GTK_FIXED(parent.object->formContainer), object->widget, x, y);
gtk_widget_show(object->widget);
}
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
void RadioBox::setParent(RadioBox &parent) {
first = parent.first;
object->parentWindow = parent.object->parentWindow;
object->widget = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(parent.object->widget), text);
gtk_widget_set_size_request(object->widget, width, height);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(RadioBox_tick), (gpointer)this);
if(object->parentWindow->window->defaultFont) setFont(*object->parentWindow->window->defaultFont);
gtk_fixed_put(GTK_FIXED(object->parentWindow->object->formContainer), object->widget, x, y);
gtk_widget_show(object->widget);
}
void RadioBox::setText(const string &text) {
gtk_button_set_label(GTK_BUTTON(object->widget), text);
}
bool RadioBox::checked() {
@ -34,3 +23,8 @@ void RadioBox::setChecked() {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object->widget), true);
object->locked = false;
}
RadioBox::RadioBox() {
object->widget = gtk_radio_button_new_with_label(0, "");
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(RadioBox_tick), (gpointer)this);
}

View File

@ -44,6 +44,10 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con
gtk_widget_realize(object->widget);
}
void Window::setLayout(Layout &layout) {
layout.create(*this);
}
bool Window::focused() {
return gtk_window_is_active(GTK_WINDOW(object->widget));
}

View File

@ -1,13 +1,14 @@
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
button->setParent(parent.window->container);
button->setGeometry(x, y, width, height);
button->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) button->setFont(*parent.window->defaultFont);
void Button::setParent(Layout &parent) {
button->setParent(parent.widget->widget);
button->show();
button->connect(button, SIGNAL(released()), SLOT(onTick()));
}
void Button::setText(const string &text) {
button->setText(QString::fromUtf8(text));
}
Button::Button() {
button = new Button::Data(*this);
widget->widget = button;
button->connect(button, SIGNAL(released()), SLOT(onTick()));
}

View File

@ -1,8 +1,5 @@
void Canvas::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
canvas->image = new QImage(width, height, QImage::Format_RGB32);
canvas->image->fill(0);
canvas->setParent(parent.window->container);
canvas->setGeometry(x, y, width, height);
void Canvas::setParent(Layout &parent) {
canvas->setParent(parent.widget->widget);
canvas->show();
}
@ -26,6 +23,8 @@ Canvas::Canvas() {
canvas = new Canvas::Data(*this);
canvas->image = 0;
widget->widget = canvas;
canvas->image = new QImage(64, 64, QImage::Format_RGB32);
canvas->image->fill(0);
}
Canvas::~Canvas() {

View File

@ -1,10 +1,10 @@
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
checkBox->setParent(parent.window->container);
checkBox->setGeometry(x, y, width, height);
checkBox->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) checkBox->setFont(*parent.window->defaultFont);
void CheckBox::setParent(Layout &parent) {
checkBox->setParent(parent.widget->widget);
checkBox->show();
checkBox->connect(checkBox, SIGNAL(stateChanged(int)), SLOT(onTick()));
}
void CheckBox::setText(const string &text) {
checkBox->setText(QString::fromUtf8(text));
}
bool CheckBox::checked() {
@ -18,4 +18,5 @@ void CheckBox::setChecked(bool checked) {
CheckBox::CheckBox() {
checkBox = new CheckBox::Data(*this);
widget->widget = checkBox;
checkBox->connect(checkBox, SIGNAL(stateChanged(int)), SLOT(onTick()));
}

View File

@ -1,15 +1,5 @@
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
comboBox->setParent(parent.window->container);
comboBox->setGeometry(x, y, width, height);
if(*text) {
lstring list;
list.split("\n", text);
foreach(item, list) addItem(item);
}
comboBox->connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(onChange()));
if(parent.window->defaultFont) comboBox->setFont(*parent.window->defaultFont);
void ComboBox::setParent(Layout &parent) {
comboBox->setParent(parent.widget->widget);
comboBox->show();
}
@ -35,4 +25,5 @@ void ComboBox::setSelection(unsigned row) {
ComboBox::ComboBox() {
comboBox = new ComboBox::Data(*this);
widget->widget = comboBox;
comboBox->connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(onChange()));
}

View File

@ -1,10 +1,6 @@
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
editBox->setParent(parent.window->container);
editBox->setGeometry(x, y, width, height);
editBox->setPlainText(QString::fromUtf8(text));
if(parent.window->defaultFont) editBox->setFont(*parent.window->defaultFont);
void EditBox::setParent(Layout &parent) {
editBox->setParent(parent.widget->widget);
editBox->show();
editBox->connect(editBox, SIGNAL(textChanged()), SLOT(onChange()));
}
void EditBox::setEditable(bool editable) {
@ -33,4 +29,5 @@ void EditBox::setCursorPosition(unsigned position) {
EditBox::EditBox() {
editBox = new EditBox::Data(*this);
widget->widget = editBox;
editBox->connect(editBox, SIGNAL(textChanged()), SLOT(onChange()));
}

View File

@ -0,0 +1,22 @@
void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height) {
fixedLayout->children.append({ &widget, x, y, width, height });
}
void FixedLayout::create(Window &parentWindow) {
fixedLayout->parent = &parentWindow;
fixedLayout->setParent(parentWindow.window->container);
foreach(child, fixedLayout->children) {
child.widget->setParent(*this);
child.widget->setGeometry(child.x, child.y, child.width, child.height);
if(parentWindow.window->defaultFont) {
QWidget *control = child.widget->widget->widget;
control->setFont(*parentWindow.window->defaultFont);
}
}
}
FixedLayout::FixedLayout() {
fixedLayout = new FixedLayout::Data(*this);
widget->widget = fixedLayout;
}

View File

@ -1,24 +1,5 @@
void HexEditor::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
hexEditor->setParent(parent.window->container);
hexEditor->setGeometry(x, y, width, height);
if(parent.window->defaultFont) hexEditor->setFont(*parent.window->defaultFont);
hexEditor->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
hexEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
hexEditor->layout = new QHBoxLayout;
hexEditor->layout->setAlignment(Qt::AlignRight);
hexEditor->layout->setMargin(0);
hexEditor->layout->setSpacing(0);
hexEditor->setLayout(hexEditor->layout);
hexEditor->scrollBar = new QScrollBar(Qt::Vertical);
hexEditor->scrollBar->setSingleStep(1);
hexEditor->layout->addWidget(hexEditor->scrollBar);
hexEditor->scrollBar->connect(
hexEditor->scrollBar, SIGNAL(actionTriggered(int)), hexEditor, SLOT(scrollEvent())
);
void HexEditor::setParent(Layout &parent) {
hexEditor->setParent(parent.widget->widget);
hexEditor->show();
}
@ -172,4 +153,21 @@ HexEditor::HexEditor() {
hexEditor->offset = 0;
hexEditor->columns = 16;
hexEditor->rows = 16;
hexEditor->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
hexEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
hexEditor->layout = new QHBoxLayout;
hexEditor->layout->setAlignment(Qt::AlignRight);
hexEditor->layout->setMargin(0);
hexEditor->layout->setSpacing(0);
hexEditor->setLayout(hexEditor->layout);
hexEditor->scrollBar = new QScrollBar(Qt::Vertical);
hexEditor->scrollBar->setSingleStep(1);
hexEditor->layout->addWidget(hexEditor->scrollBar);
hexEditor->scrollBar->connect(
hexEditor->scrollBar, SIGNAL(actionTriggered(int)), hexEditor, SLOT(scrollEvent())
);
}

View File

@ -1,11 +1,12 @@
void HorizontalSlider::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, unsigned length) {
length += (length == 0);
horizontalSlider->setParent(parent.window->container);
horizontalSlider->setGeometry(x, y, width, height);
void HorizontalSlider::setParent(Layout &parent) {
horizontalSlider->setParent(parent.widget->widget);
horizontalSlider->show();
}
void HorizontalSlider::setLength(unsigned length) {
length = length + (length == 0);
horizontalSlider->setRange(0, length - 1);
horizontalSlider->setPageStep(length >> 3);
horizontalSlider->connect(horizontalSlider, SIGNAL(valueChanged(int)), SLOT(onChange()));
horizontalSlider->show();
}
unsigned HorizontalSlider::position() {
@ -19,4 +20,5 @@ void HorizontalSlider::setPosition(unsigned position) {
HorizontalSlider::HorizontalSlider() {
horizontalSlider = new HorizontalSlider::Data(*this);
widget->widget = horizontalSlider;
horizontalSlider->connect(horizontalSlider, SIGNAL(valueChanged(int)), SLOT(onChange()));
}

View File

@ -1,8 +1,5 @@
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
label->setParent(parent.window->container);
label->setGeometry(x, y, width, height);
label->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) label->setFont(*parent.window->defaultFont);
void Label::setParent(Layout &parent) {
label->setParent(parent.widget->widget);
label->show();
}

3
bsnes/phoenix/qt/layout.cpp Executable file
View File

@ -0,0 +1,3 @@
Layout::Layout() {
layout = new Layout::Data(*this);
}

View File

@ -1,9 +1,9 @@
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
listBox->setParent(parent.window->container);
listBox->setGeometry(x, y, width, height);
listBox->setAllColumnsShowFocus(true);
listBox->setRootIsDecorated(false);
void ListBox::setParent(Layout &parent) {
listBox->setParent(parent.widget->widget);
listBox->show();
}
void ListBox::setHeaderText(const string &text) {
lstring list;
list.split("\t", text);
QStringList labels;
@ -11,14 +11,7 @@ void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, uns
listBox->setColumnCount(list.size());
listBox->setHeaderLabels(labels);
for(unsigned i = 0; i < list.size(); i++) listBox->resizeColumnToContents(i);
listBox->setHeaderHidden(true);
listBox->setAlternatingRowColors(list.size() >= 2);
listBox->connect(listBox, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
listBox->connect(listBox, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
listBox->connect(listBox, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onTick(QTreeWidgetItem*)));
if(parent.window->defaultFont) listBox->setFont(*parent.window->defaultFont);
listBox->show();
}
void ListBox::setHeaderVisible(bool headerVisible) {
@ -99,4 +92,11 @@ void ListBox::setSelection(unsigned row) {
ListBox::ListBox() {
listBox = new ListBox::Data(*this);
widget->widget = listBox;
listBox->setAllColumnsShowFocus(true);
listBox->setRootIsDecorated(false);
listBox->setHeaderHidden(true);
listBox->connect(listBox, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
listBox->connect(listBox, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
listBox->connect(listBox, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onTick(QTreeWidgetItem*)));
}

View File

@ -1,8 +1,5 @@
void ProgressBar::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
progressBar->setParent(parent.window->container);
progressBar->setGeometry(x, y, width, height);
progressBar->setRange(0, 100);
progressBar->setTextVisible(false);
void ProgressBar::setParent(Layout &parent) {
progressBar->setParent(parent.widget->widget);
progressBar->show();
}
@ -13,4 +10,6 @@ void ProgressBar::setPosition(unsigned position) {
ProgressBar::ProgressBar() {
progressBar = new ProgressBar::Data(*this);
widget->widget = progressBar;
progressBar->setRange(0, 100);
progressBar->setTextVisible(false);
}

View File

@ -10,8 +10,10 @@ namespace phoenix {
#include "object.cpp"
#include "font.cpp"
#include "menu.cpp"
#include "widget.cpp"
#include "window.cpp"
#include "widget.cpp"
#include "layout.cpp"
#include "fixed-layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"

View File

@ -112,7 +112,12 @@ struct MenuRadioItem : Action {
Data *menuRadioItem;
};
struct Window;
struct Layout;
struct Widget : Object {
virtual void setParent(Layout &parent) {}
virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
virtual void setFont(Font &font);
bool visible();
@ -130,6 +135,7 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setLayout(Layout &layout);
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
void setDefaultFont(Font &font);
@ -149,9 +155,28 @@ struct Window : Widget {
static Window None;
};
struct Layout : Widget {
virtual void create(Window &parent) = 0;
Layout();
//private:
struct Data;
Data *layout;
};
struct FixedLayout : Layout {
void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height);
void create(Window &parent);
FixedLayout();
//private:
struct Data;
Data *fixedLayout;
};
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
Button();
//private:
struct Data;
@ -159,7 +184,7 @@ struct Button : Widget {
};
struct Canvas : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height);
void setParent(Layout &parent);
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
uint32_t* buffer();
void redraw();
@ -172,7 +197,8 @@ struct Canvas : Widget {
struct CheckBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
bool checked();
void setChecked(bool checked = true);
CheckBox();
@ -183,7 +209,7 @@ struct CheckBox : Widget {
struct ComboBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void reset();
void addItem(const nall::string &text);
unsigned selection();
@ -196,7 +222,7 @@ struct ComboBox : Widget {
struct EditBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setEditable(bool editable = true);
void setWordWrap(bool wordWrap = true);
nall::string text();
@ -211,7 +237,7 @@ struct EditBox : Widget {
struct HexEditor : Widget {
nall::function<uint8_t (unsigned)> onRead;
nall::function<void (unsigned, uint8_t)> onWrite;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height);
void setParent(Layout &parent);
void setSize(unsigned size);
void setOffset(unsigned offset);
void setColumns(unsigned columns);
@ -225,7 +251,8 @@ struct HexEditor : Widget {
struct HorizontalSlider : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, unsigned length);
void setParent(Layout &parent);
void setLength(unsigned length);
unsigned position();
void setPosition(unsigned position);
HorizontalSlider();
@ -235,7 +262,7 @@ struct HorizontalSlider : Widget {
};
struct Label : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &layout);
void setText(const nall::string &text);
Label();
//private:
@ -247,7 +274,8 @@ struct ListBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
nall::function<void (unsigned)> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setHeaderText(const nall::string &text);
void setHeaderVisible(bool headerVisible = true);
void setCheckable(bool checkable = true);
void reset();
@ -265,7 +293,7 @@ struct ListBox : Widget {
};
struct ProgressBar : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height);
void setParent(Layout &parent);
void setPosition(unsigned position);
ProgressBar();
//private:
@ -275,8 +303,9 @@ struct ProgressBar : Widget {
struct RadioBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setParent(RadioBox &parent);
void setText(const nall::string &text);
bool checked();
void setChecked();
RadioBox();
@ -288,7 +317,7 @@ struct RadioBox : Widget {
struct TextBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setEditable(bool editable = true);
nall::string text();
void setText(const nall::string &text);
@ -300,7 +329,8 @@ struct TextBox : Widget {
struct VerticalSlider : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, unsigned length);
void setParent(Layout &parent);
void setLength(unsigned length);
unsigned position();
void setPosition(unsigned position);
VerticalSlider();
@ -310,7 +340,7 @@ struct VerticalSlider : Widget {
};
struct Viewport : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height);
void setParent(Layout &parent);
uintptr_t handle();
Viewport();
//private:

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'qt.moc.hpp'
**
** Created: Mon Jan 31 08:47:12 2011
** Created: Thu Feb 3 18:21:19 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
@ -193,6 +193,104 @@ int MenuRadioItem::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
}
return _id;
}
static const uint qt_meta_data_Layout__Data[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_Layout__Data[] = {
"Layout::Data\0"
};
const QMetaObject Layout::Data::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_Layout__Data,
qt_meta_data_Layout__Data, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &Layout::Data::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *Layout::Data::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *Layout::Data::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Layout__Data))
return static_cast<void*>(const_cast< Data*>(this));
return QWidget::qt_metacast(_clname);
}
int Layout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
static const uint qt_meta_data_FixedLayout__Data[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_FixedLayout__Data[] = {
"FixedLayout::Data\0"
};
const QMetaObject FixedLayout::Data::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_FixedLayout__Data,
qt_meta_data_FixedLayout__Data, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &FixedLayout::Data::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *FixedLayout::Data::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *FixedLayout::Data::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_FixedLayout__Data))
return static_cast<void*>(const_cast< Data*>(this));
return QWidget::qt_metacast(_clname);
}
int FixedLayout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
static const uint qt_meta_data_Window__Data[] = {
// content:

View File

@ -90,13 +90,41 @@ public:
}
};
struct Layout::Data : public QWidget {
Q_OBJECT
public:
Layout &self;
Data(Layout &self) : self(self) {
}
};
struct FixedLayout::Data : public QWidget {
Q_OBJECT
public:
FixedLayout &self;
Window *parent;
struct Children {
Widget *widget;
unsigned x, y;
unsigned width, height;
};
linear_vector<Children> children;
Data(FixedLayout &self) : self(self) {
}
};
struct Window::Data : public QWidget {
Q_OBJECT
public:
Window &self;
Layout *layout;
QFont *defaultFont;
QVBoxLayout *layout;
QVBoxLayout *vlayout;
QMenuBar *menuBar;
QWidget *container;
QStatusBar *statusBar;

View File

@ -1,26 +1,15 @@
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parent = &parent;
radioBox->buttonGroup = new QButtonGroup;
radioBox->buttonGroup->addButton(radioBox);
radioBox->setParent(radioBox->parent->window->container);
radioBox->setGeometry(x, y, width, height);
radioBox->setText(QString::fromUtf8(text));
radioBox->setChecked(true);
if(parent.window->defaultFont) radioBox->setFont(*parent.window->defaultFont);
void RadioBox::setParent(Layout &parent) {
radioBox->setParent(parent.widget->widget);
radioBox->show();
radioBox->connect(radioBox, SIGNAL(toggled(bool)), SLOT(onTick()));
}
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parent = parent.radioBox->parent;
radioBox->buttonGroup = parent.radioBox->buttonGroup;
radioBox->buttonGroup->addButton(radioBox);
radioBox->setParent(radioBox->parent->window->container);
radioBox->setGeometry(x, y, width, height);
void RadioBox::setParent(RadioBox &parent) {
parent.radioBox->buttonGroup->addButton(radioBox);
parent.radioBox->setChecked(true);
}
void RadioBox::setText(const string &text) {
radioBox->setText(QString::fromUtf8(text));
if(radioBox->parent->window->defaultFont) radioBox->setFont(*radioBox->parent->window->defaultFont);
radioBox->show();
radioBox->connect(radioBox, SIGNAL(toggled(bool)), SLOT(onTick()));
}
bool RadioBox::checked() {
@ -34,4 +23,8 @@ void RadioBox::setChecked() {
RadioBox::RadioBox() {
radioBox = new RadioBox::Data(*this);
widget->widget = radioBox;
radioBox->buttonGroup = new QButtonGroup;
radioBox->buttonGroup->addButton(radioBox);
radioBox->setChecked(true);
radioBox->connect(radioBox, SIGNAL(toggled(bool)), SLOT(onTick()));
}

View File

@ -1,11 +1,6 @@
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
textBox->setParent(parent.window->container);
textBox->setGeometry(x, y, width, height);
textBox->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) textBox->setFont(*parent.window->defaultFont);
void TextBox::setParent(Layout &parent) {
textBox->setParent(parent.widget->widget);
textBox->show();
textBox->connect(textBox, SIGNAL(returnPressed()), SLOT(onActivate()));
textBox->connect(textBox, SIGNAL(textEdited(const QString&)), SLOT(onChange()));
}
void TextBox::setEditable(bool editable) {
@ -23,4 +18,6 @@ void TextBox::setText(const string &text) {
TextBox::TextBox() {
textBox = new TextBox::Data(*this);
widget->widget = textBox;
textBox->connect(textBox, SIGNAL(returnPressed()), SLOT(onActivate()));
textBox->connect(textBox, SIGNAL(textEdited(const QString&)), SLOT(onChange()));
}

View File

@ -1,13 +1,12 @@
void VerticalSlider::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, unsigned length) {
length += (length == 0);
verticalSlider->setParent(parent.window->container);
verticalSlider->setGeometry(x, y, width, height);
verticalSlider->setInvertedAppearance(true);
verticalSlider->setInvertedControls(true);
void VerticalSlider::setParent(Layout &parent) {
verticalSlider->setParent(parent.widget->widget);
verticalSlider->show();
}
void VerticalSlider::setLength(unsigned length) {
length = length + (length == 0);
verticalSlider->setRange(0, length - 1);
verticalSlider->setPageStep(length >> 3);
verticalSlider->connect(verticalSlider, SIGNAL(valueChanged(int)), SLOT(onChange()));
verticalSlider->show();
}
unsigned VerticalSlider::position() {
@ -21,4 +20,7 @@ void VerticalSlider::setPosition(unsigned position) {
VerticalSlider::VerticalSlider() {
verticalSlider = new VerticalSlider::Data(*this);
widget->widget = verticalSlider;
verticalSlider->setInvertedAppearance(true);
verticalSlider->setInvertedControls(true);
verticalSlider->connect(verticalSlider, SIGNAL(valueChanged(int)), SLOT(onChange()));
}

View File

@ -1,8 +1,5 @@
void Viewport::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
viewport->setParent(parent.window->container);
viewport->setGeometry(x, y, width, height);
viewport->setAttribute(Qt::WA_PaintOnScreen, true);
viewport->setStyleSheet("background: #000000");
void Viewport::setParent(Layout &parent) {
viewport->setParent(parent.widget->widget);
viewport->show();
}
@ -13,4 +10,6 @@ uintptr_t Viewport::handle() {
Viewport::Viewport() {
viewport = new Viewport::Data(*this);
widget->widget = viewport;
viewport->setAttribute(Qt::WA_PaintOnScreen, true);
viewport->setStyleSheet("background: #000000");
}

View File

@ -2,26 +2,31 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con
window->setWindowTitle(QString::fromUtf8(text));
window->move(x, y);
window->layout = new QVBoxLayout(window);
window->layout->setAlignment(Qt::AlignTop);
window->layout->setMargin(0);
window->layout->setSpacing(0);
window->layout->setSizeConstraint(QLayout::SetFixedSize);
window->setLayout(window->layout);
window->vlayout = new QVBoxLayout(window);
window->vlayout->setAlignment(Qt::AlignTop);
window->vlayout->setMargin(0);
window->vlayout->setSpacing(0);
window->vlayout->setSizeConstraint(QLayout::SetFixedSize);
window->setLayout(window->vlayout);
window->menuBar = new QMenuBar(window);
window->menuBar->setVisible(false);
window->layout->addWidget(window->menuBar);
window->vlayout->addWidget(window->menuBar);
window->container = new QWidget(window);
window->container->setFixedSize(width, height);
window->container->setVisible(true);
window->layout->addWidget(window->container);
window->vlayout->addWidget(window->container);
window->statusBar = new QStatusBar(window);
window->statusBar->setSizeGripEnabled(false);
window->statusBar->setVisible(false);
window->layout->addWidget(window->statusBar);
window->vlayout->addWidget(window->statusBar);
}
void Window::setLayout(Layout &layout) {
window->layout = &layout;
layout.create(*this);
}
Geometry Window::geometry() {
@ -77,10 +82,10 @@ bool Window::fullscreen() {
void Window::setFullscreen(bool fullscreen) {
if(fullscreen == false) {
window->layout->setSizeConstraint(QLayout::SetFixedSize);
window->vlayout->setSizeConstraint(QLayout::SetFixedSize);
window->showNormal();
} else {
window->layout->setSizeConstraint(QLayout::SetNoConstraint);
window->vlayout->setSizeConstraint(QLayout::SetNoConstraint);
window->container->setFixedSize(OS::desktopWidth(), OS::desktopHeight());
window->showFullScreen();
}
@ -94,6 +99,12 @@ void Window::setFullscreen(bool fullscreen) {
geom = geometry();
if(startTime - time(0) > 3) break;
} while((signed)geom.x < 0 || (signed)geom.y < 0);
if(fullscreen == false) {
window->layout->setGeometry(0, 0, geometry().width, geometry().height);
} else {
window->layout->setGeometry(0, 0, OS::desktopWidth(), OS::desktopHeight());
}
}
Window::Window() {

View File

@ -1,3 +1,21 @@
void Button::setParent(Layout &layout) {
SetParent(widget->window, layout.widget->window);
}
void Button::setText(const string &text) {
SetWindowText(widget->window, utf16_t(text));
}
Button::Button() {
widget->window = CreateWindow(
L"BUTTON", L"",
WS_CHILD | WS_TABSTOP | WS_VISIBLE,
0, 0, 64, 64,
OS::os->nullWindow, (HMENU)object->id, GetModuleHandle(0), 0
);
}
#if 0
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindow(
L"BUTTON", utf16_t(text),
@ -8,3 +26,4 @@ void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsi
SetWindowLongPtr(widget->window, GWLP_USERDATA, (LONG_PTR)this);
SendMessage(widget->window, WM_SETFONT, (WPARAM)(parent.window->defaultFont ? parent.window->defaultFont : OS::os->proportionalFont), 0);
}
#endif

View File

@ -0,0 +1,23 @@
void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height) {
fixedLayout->widgets.append({ &widget, x, y, width, height });
}
void FixedLayout::create(Window &parent_) {
SetParent(widget->window, parent_.widget->window);
setGeometry(0, 0, 640, 480);
foreach(control, fixedLayout->widgets) {
SetParent(control.widget->widget->window, widget->window);
control.widget->setGeometry(control.x, control.y, control.width, control.height);
}
}
FixedLayout::FixedLayout() {
fixedLayout = new FixedLayout::Data;
widget->window = CreateWindow(
L"phoenix_window", L"",
WS_CHILD | WS_TABSTOP | WS_VISIBLE,
0, 0, 64, 64,
OS::os->nullWindow, 0, GetModuleHandle(0), 0
);
}

View File

@ -0,0 +1,3 @@
Layout::Layout() {
layout = new Layout::Data;
}

View File

@ -15,11 +15,6 @@ struct Action::Data {
array<MenuRadioItem*> items;
};
struct Widget::Data {
HWND window;
HFONT font;
};
struct Window::Data {
HFONT defaultFont;
HBRUSH brush;
@ -33,6 +28,25 @@ struct Window::Data {
unsigned height;
};
struct Widget::Data {
HWND window;
HFONT font;
};
struct Layout::Data {
};
struct FixedLayout::Data {
Window *parent;
struct Widgets {
Widget *widget;
unsigned x, y;
unsigned width, height;
};
linear_vector<Widgets> widgets;
};
struct Canvas::Data {
uint32_t *buffer;
BITMAPINFO bmi;
@ -82,6 +96,7 @@ struct VerticalSlider::Data {
struct OS::Data {
nall::array<Object*> objects;
HWND nullWindow;
HFONT proportionalFont;
HFONT monospaceFont;
};

View File

@ -18,6 +18,10 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con
SetWindowLongPtr(widget->window, GWLP_USERDATA, (LONG_PTR)this);
}
void Window::setLayout(Layout &layout) {
layout.create(*this);
}
void Window::setDefaultFont(Font &font) {
window->defaultFont = font.font->font;
}

View File

@ -15,6 +15,8 @@ namespace phoenix {
#include "menu.cpp"
#include "widget.cpp"
#include "window.cpp"
#include "layout.cpp"
#include "fixed-layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"
@ -97,6 +99,9 @@ void OS::initialize() {
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
//default window to attach all controls to during construction (prior to attaching to layout)
os->nullWindow = CreateWindow(L"phoenix_window", L"", WS_POPUP, 0, 0, 640, 480, 0, 0, GetModuleHandle(0), 0);
}
bool OS::pending() {

View File

@ -85,15 +85,20 @@ struct MenuRadioItem : Action {
void setChecked();
};
struct Window;
struct Layout;
struct Widget : Object {
virtual void setParent(Layout &parent) {}
virtual void setFont(Font &font);
virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
bool focused();
void setFocused();
virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
Widget();
//private:
struct Data;
@ -103,6 +108,7 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setLayout(Layout &layout);
void setDefaultFont(Font &font);
void setFont(Font &font);
Geometry geometry();
@ -122,9 +128,28 @@ struct Window : Widget {
void resize(unsigned width, unsigned height);
};
struct Layout : Widget {
virtual void create(Window &parent) = 0;
Layout();
//private:
struct Data;
Data *layout;
};
struct FixedLayout : Layout {
void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height);
void create(Window &parent);
FixedLayout();
//private:
struct Data;
Data *fixedLayout;
};
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setParent(Layout &parent);
void setText(const nall::string &text);
Button();
};
struct Canvas : Widget {

View File

@ -1,12 +1,12 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "075.06";
static const char Version[] = "075.07";
static const unsigned SerializerVersion = 18;
}
}
//#define DEBUGGER
#define DEBUGGER
#include <libco/libco.h>

View File

@ -35,7 +35,8 @@ void MainWindow::create() {
help.create(*this, "Help");
helpAbout.create(help, "About ...");
viewport.create(*this, 0, 0, 160 * 2, 144 * 2);
layout.append(viewport, 0, 0, 160 * 2, 144 * 2);
setLayout(layout);
setMenuVisible(true);
setStatusVisible(true);

View File

@ -27,6 +27,7 @@ struct MainWindow : Window {
Menu help;
MenuItem helpAbout;
FixedLayout layout;
Viewport viewport;
void create();

View File

@ -4,21 +4,25 @@ void Console::create() {
Window::create(0, 0, 256, 256, "Console");
application.addWindow(this, "Debugger.Console", "192,192");
unsigned x = 5, y = 5;
output.create(*this, x, y, 580, 338); x += 580 + 5;
output.setFont(application.monospaceFont);
output.setEditable(false);
traceToConsole.create(*this, x, y, 120, Style::CheckBoxHeight, "Trace to console"); y += Style::CheckBoxHeight;
traceToConsole.setText("Trace to console");
traceToFile.setText("Trace to file");
traceCPU.setText("Trace CPU");
traceSMP.setText("Trace SMP");
traceToConsole.setChecked(true);
traceToFile.create(*this, x, y, 120, Style::CheckBoxHeight, "Trace to file"); y += Style::CheckBoxHeight;
traceCPU.create(*this, x, y, 120, Style::CheckBoxHeight, "Trace S-CPU"); y += Style::CheckBoxHeight;
traceCPU.setChecked(true);
traceSMP.create(*this, x, y, 120, Style::CheckBoxHeight, "Trace S-SMP"); y += Style::CheckBoxHeight;
clearConsole.create(*this, x, 348 - Style::ButtonHeight - 5, 120, Style::ButtonHeight, "Clear console");
clearConsole.setText("Clear console");
unsigned x = 5, y = 5;
layout.append(output, x, y, 580, 338); x += 580 + 5;
layout.append(traceToConsole, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(traceToFile, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(traceCPU, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(traceSMP, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(clearConsole, x, 348 - Style::ButtonHeight - 5, 120, Style::ButtonHeight);
setGeometry(0, 0, 715, 348);
setLayout(layout);
onClose = []() {
debugger.showConsole.setChecked(false);

View File

@ -1,4 +1,5 @@
struct Console : TopLevelWindow {
FixedLayout layout;
EditBox output;
CheckBox traceToConsole;
CheckBox traceToFile;

View File

@ -4,17 +4,20 @@ void CPUDebugger::create() {
Window::create(0, 0, 256, 256, "CPU Debugger");
application.addWindow(this, "Debugger.CPUdebugger", "192,192");
unsigned x = 5, y = 5;
output.create(*this, x, y, 400, 210); x += 400 + 5;
output.setFont(application.monospaceFont);
output.setEditable(false);
stepInto.create(*this, x, y, 80, Style::ButtonHeight, "Step Into"); y += Style::ButtonHeight;
stepOver.create(*this, x, y, 80, Style::ButtonHeight, "Step Over"); y += Style::ButtonHeight;
proceed.create(*this, x, y, 80, Style::ButtonHeight, "Proceed"); y += Style::ButtonHeight;
stepInto.setText("Step Into");
stepOver.setText("Step Over");
proceed.setText("Proceed");
proceed.setEnabled(false);
unsigned x = 5, y = 5;
layout.append(output, x, y, 400, 210); x += 400 + 5;
layout.append(stepInto, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
layout.append(stepOver, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
layout.append(proceed, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
setGeometry(0, 0, 495, 220);
setLayout(layout);
onClose = []() {
debugger.showCPUDebugger.setChecked(false);

View File

@ -1,4 +1,5 @@
struct CPUDebugger : TopLevelWindow {
FixedLayout layout;
EditBox output;
Button stepInto;
Button stepOver;

View File

@ -21,13 +21,22 @@ void Debugger::create() {
Window::create(0, 0, 256, 256, "Debugger");
application.addWindow(this, "Debugger", "160,160");
enableDebugger.setText("Enable debugger");
showConsole.setText("Console");
showCPUDebugger.setText("CPU debugger");
showSMPDebugger.setText("SMP debugger");
showBreakpointEditor.setText("Breakpoint editor");
showMemoryEditor.setText("Memory editor");
unsigned x = 5, y = 5;
enableDebugger.create(*this, x, y, 240, Style::CheckBoxHeight, "Enable debugger"); y += Style::CheckBoxHeight;
showConsole.create(*this, x, y, 240, Style::CheckBoxHeight, "Console"); y += Style::CheckBoxHeight;
showCPUDebugger.create(*this, x, y, 240, Style::CheckBoxHeight, "CPU debugger"); y += Style::CheckBoxHeight;
showSMPDebugger.create(*this, x, y, 240, Style::CheckBoxHeight, "SMP debugger"); y += Style::CheckBoxHeight;
showBreakpointEditor.create(*this, x, y, 240, Style::CheckBoxHeight, "Breakpoint editor"); y += Style::CheckBoxHeight;
showMemoryEditor.create(*this, x, y, 240, Style::CheckBoxHeight, "Memory editor"); y += Style::CheckBoxHeight;
layout.append(enableDebugger, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(showConsole, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(showCPUDebugger, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(showSMPDebugger, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(showBreakpointEditor, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(showMemoryEditor, x, y, 240, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
setGeometry(0, 0, 250, y);
setLayout(layout);
//windows shown by default
showConsole.setChecked();
@ -35,8 +44,6 @@ void Debugger::create() {
showSMPDebugger.setChecked();
showBreakpointEditor.setChecked();
setGeometry(0, 0, 250, y);
enableDebugger.onTick = []() {
debugger.enable(debugger.enableDebugger.checked());
};

View File

@ -12,6 +12,7 @@ struct Debugger : TopLevelWindow {
StepIntoSMP,
} debugMode;
FixedLayout layout;
CheckBox enableDebugger;
CheckBox showConsole;
CheckBox showCPUDebugger;

View File

@ -4,17 +4,20 @@ void SMPDebugger::create() {
Window::create(0, 0, 256, 256, "SMP Debugger");
application.addWindow(this, "Debugger.SMPDebugger", "192,192");
unsigned x = 5, y = 5;
output.create(*this, x, y, 400, 210); x += 400 + 5;
output.setFont(application.monospaceFont);
output.setEditable(false);
stepInto.create(*this, x, y, 80, Style::ButtonHeight, "Step Into"); y += Style::ButtonHeight;
stepOver.create(*this, x, y, 80, Style::ButtonHeight, "Step Over"); y += Style::ButtonHeight;
proceed.create(*this, x, y, 80, Style::ButtonHeight, "Proceed"); y += Style::ButtonHeight;
stepInto.setText("Step Into");
stepOver.setText("Step Over");
proceed.setText("Proceed");
proceed.setEnabled(false);
unsigned x = 5, y = 5;
layout.append(output, x, y, 400, 210); x += 400 + 5;
layout.append(stepInto, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
layout.append(stepOver, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
layout.append(proceed, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
setGeometry(0, 0, 495, 220);
setLayout(layout);
onClose = []() {
debugger.showSMPDebugger.setChecked(false);

View File

@ -1,4 +1,5 @@
struct SMPDebugger : TopLevelWindow {
FixedLayout layout;
EditBox output;
Button stepInto;
Button stepOver;

View File

@ -4,23 +4,31 @@ void BreakpointEditor::create() {
Window::create(0, 0, 256, 256, "Breakpoint Editor");
application.addWindow(this, "Debugger.BreakpointEditor", "192,192");
unsigned x = 5, y = 5;
runToBreakpoint.create(*this, x, y, 295, Style::CheckBoxHeight, "Run to breakpoint");
y += Style::CheckBoxHeight + 5;
runToBreakpoint.setText("Run to breakpoint");
for(unsigned n = 0; n < Breakpoints; n++) {
enableBox[n].create(*this, x, y, 35, Style::EditBoxHeight, { n + 1 });
addressBox[n].create(*this, x + 35, y, 60, Style::EditBoxHeight);
valueBox[n].create(*this, x + 100, y, 30, Style::EditBoxHeight);
typeBox[n].create(*this, x + 135, y, 80, Style::EditBoxHeight, "Exec\nRead\nWrite");
sourceBox[n].create(*this, x + 220, y, 80, Style::EditBoxHeight, "CPU\nAPU\nVRAM\nOAM\nCGRAM");
y += Style::EditBoxHeight + 5;
enableBox[n].setText({ n + 1 });
typeBox[n].addItem("Exec");
typeBox[n].addItem("Read");
typeBox[n].addItem("Write");
sourceBox[n].addItem("CPU");
sourceBox[n].addItem("APU");
sourceBox[n].addItem("VRAM");
sourceBox[n].addItem("OAM");
sourceBox[n].addItem("CGRAM");
enableBox[n].onTick = [n]() { breakpointEditor.toggleBreakpoint(n); };
}
unsigned x = 5, y = 5;
layout.append(runToBreakpoint, x, y, 295, Style::CheckBoxHeight); y += Style::CheckBoxHeight + 5;
for(unsigned n = 0; n < Breakpoints; n++) {
layout.append(enableBox[n], x, y, 35, Style::EditBoxHeight);
layout.append(addressBox[n], x + 35, y, 60, Style::EditBoxHeight);
layout.append(valueBox[n], x + 100, y, 30, Style::EditBoxHeight);
layout.append(typeBox[n], x + 135, y, 80, Style::EditBoxHeight);
layout.append(sourceBox[n], x + 220, y, 80, Style::EditBoxHeight); y += Style::EditBoxHeight + 5;
}
setGeometry(0, 0, 310, y);
setLayout(layout);
runToBreakpoint.onTick = []() {
if(breakpointEditor.runToBreakpoint.checked()) {

View File

@ -1,5 +1,6 @@
struct BreakpointEditor : TopLevelWindow {
enum : unsigned { Breakpoints = SNES::Debugger::Breakpoints };
FixedLayout layout;
CheckBox runToBreakpoint;
CheckBox enableBox[Breakpoints];
TextBox addressBox[Breakpoints];

View File

@ -4,24 +4,24 @@ void MemoryEditor::create() {
Window::create(0, 0, 256, 256, "Memory Editor");
application.addWindow(this, "Debugger.MemoryEditor", "192,192");
unsigned x = 5, y = 5;
editor.create(*this, x, y, 475, 220); x += 475 + 5;
editor.setFont(application.monospaceFont);
editor.setColumns(16);
editor.setRows(16);
sourceBox.create(*this, x, y, 80, Style::ComboBoxHeight); y += Style::ComboBoxHeight;
sourceBox.addItem("CPU");
sourceBox.addItem("APU");
sourceBox.addItem("VRAM");
sourceBox.addItem("OAM");
sourceBox.addItem("CGRAM");
refreshButton.setText("Refresh");
gotoBox.create(*this, x, y, 80, Style::TextBoxHeight); y += Style::TextBoxHeight;
refreshButton.create(*this, x, y, 80, Style::ButtonHeight, "Refresh"); y += Style::ButtonHeight;
unsigned x = 5, y = 5;
layout.append(editor, x, y, 475, 220); x += 475 + 5;
layout.append(sourceBox, x, y, 80, Style::ComboBoxHeight); y += Style::ComboBoxHeight;
layout.append(gotoBox, x, y, 80, Style::TextBoxHeight); y += Style::TextBoxHeight;
layout.append(refreshButton, x, y, 80, Style::ButtonHeight); y += Style::ButtonHeight;
setGeometry(0, 0, 570, 230);
setLayout(layout);
editor.setFont(application.monospaceFont);
onClose = []() {
debugger.showMemoryEditor.setChecked(false);

View File

@ -1,4 +1,5 @@
struct MemoryEditor : TopLevelWindow {
FixedLayout layout;
HexEditor editor;
ComboBox sourceBox;
TextBox gotoBox;

View File

@ -6,13 +6,15 @@ void FileBrowser::create() {
unsigned x = 5, y = 5, height = Style::TextBoxHeight;
pathBox.create(*this, x, y, 630 - height - height - 10, height);
browseButton.create(*this, x + 630 - height - height - 5, y, height, height, "...");
upButton.create(*this, x + 630 - height, y, height, height, ".."); y += height + 5;
contentsBox.create(*this, x, y, 630, 350); y += 350 + 5;
browseButton.setText("...");
upButton.setText("..");
layout.append(pathBox, x, y, 630 - height - height - 10, height);
layout.append(browseButton, x + 630 - height - height - 5, y, height, height);
layout.append(upButton, x + 630 - height, y, height, height); y += height + 5;
layout.append(contentsBox, x, y, 630, 350); y += 350 + 5;
setGeometry(0, 0, 640, y);
setLayout(layout);
pathBox.onActivate = []() {
string path = fileBrowser.pathBox.text();

View File

@ -1,4 +1,5 @@
struct FileBrowser : TopLevelWindow {
FixedLayout layout;
TextBox pathBox;
Button browseButton;
Button upButton;

View File

@ -101,7 +101,9 @@ void MainWindow::create() {
help.create(*this, "Help");
helpAbout.create(help, "About ...");
viewport.create(*this, 0, 0, 595, 448);
layout.append(viewport, 0, 0, 595, 448);
setLayout(layout);
utility.setStatus("");
setMenuVisible(true);
setStatusVisible(true);

View File

@ -71,6 +71,7 @@ struct MainWindow : TopLevelWindow {
Menu help;
MenuItem helpAbout;
FixedLayout layout;
Viewport viewport;
void create();

View File

@ -7,17 +7,21 @@ void SingleSlotLoader::create() {
unsigned x = 5, y = 5, height = Style::TextBoxHeight, width = 365 + height;
baseLabel.create(*this, x, y, 50, height, "Base:");
basePath.create(*this, x + 50, y, 300, height);
baseBrowse.create(*this, x + 355, y, height, height, "..."); y += height + 5;
slotLabel.create(*this, x, y, 50, height, "Slot:");
slotPath.create(*this, x + 50, y, 300, height);
slotBrowse.create(*this, x + 355, y, height, height, "..."); y += height + 5;
okButton.create(*this, x + width - 90, y, 80, Style::ButtonHeight, "Ok"); y += Style::ButtonHeight + 5;
baseLabel.setText("Base:");
baseBrowse.setText("...");
slotLabel.setText("Slot:");
slotBrowse.setText("...");
okButton.setText("Ok");
layout.append(baseLabel, x, y, 50, height);
layout.append(basePath, x + 50, y, 300, height);
layout.append(baseBrowse, x + 355, y, height, height); y += height + 5;
layout.append(slotLabel, x, y, 50, height);
layout.append(slotPath, x + 50, y, 300, height);
layout.append(slotBrowse, x + 355, y, height, height); y += height + 5;
layout.append(okButton, x + width - 90, y, 80, Style::ButtonHeight); y += Style::ButtonHeight + 5;
setGeometry(0, 0, width, y);
setLayout(layout);
baseBrowse.onTick = []() {
fileBrowser.fileOpen(FileBrowser::Mode::Cartridge, [](string filename) {
@ -92,21 +96,26 @@ void DoubleSlotLoader::create() {
unsigned x = 5, y = 5, height = Style::TextBoxHeight, width = 365 + height;
baseLabel.create(*this, x, y, 50, height, "Base:");
basePath.create(*this, x + 50, y, 300, height);
baseBrowse.create(*this, x + 355, y, height, height, "..."); y += height + 5;
slotALabel.create(*this, x, y, 50, height, "Slot A:");
slotAPath.create(*this, x + 50, y, 300, height);
slotABrowse.create(*this, x + 355, y, height, height, "..."); y += height + 5;
slotBLabel.create(*this, x, y, 50, height, "Slot B:");
slotBPath.create(*this, x + 50, y, 300, height);
slotBBrowse.create(*this, x + 355, y, height, height, "..."); y += height + 5;
okButton.create(*this, x + width - 90, y, 80, Style::ButtonHeight, "Ok"); y += Style::ButtonHeight + 5;
baseLabel.setText("Base:");
baseBrowse.setText("...");
slotALabel.setText("Slot A:");
slotABrowse.setText("...");
slotBLabel.setText("Slot B:");
slotBBrowse.setText("...");
okButton.setText("Ok");
layout.append(baseLabel, x, y, 50, height);
layout.append(basePath, x + 50, y, 300, height);
layout.append(baseBrowse, x + 355, y, height, height); y += height + 5;
layout.append(slotALabel, x, y, 50, height);
layout.append(slotAPath, x + 50, y, 300, height);
layout.append(slotABrowse, x + 355, y, height, height); y += height + 5;
layout.append(slotBLabel, x, y, 50, height);
layout.append(slotBPath, x + 50, y, 300, height);
layout.append(slotBBrowse, x + 355, y, height, height); y += height + 5;
layout.append(okButton, x + width - 90, y, 80, Style::ButtonHeight); y += Style::ButtonHeight + 5;
setGeometry(0, 0, width, y);
setLayout(layout);
baseBrowse.onTick = []() {
fileBrowser.fileOpen(FileBrowser::Mode::Cartridge, [](string filename) {

View File

@ -1,4 +1,5 @@
struct SingleSlotLoader : TopLevelWindow {
FixedLayout layout;
Label baseLabel;
TextBox basePath;
Button baseBrowse;
@ -17,6 +18,7 @@ struct SingleSlotLoader : TopLevelWindow {
};
struct DoubleSlotLoader : TopLevelWindow {
FixedLayout layout;
Label baseLabel;
TextBox basePath;
Button baseBrowse;

View File

@ -6,27 +6,35 @@ void AdvancedSettings::create() {
unsigned x = 5, y = 5;
driverSelectionLabel.create(*this, x, y, 595, Style::LabelHeight, "Driver Selection :."); y += Style::LabelHeight + 5;
driverSelectionLabel.setText("Driver Selection :.");
driverSelectionLabel.setFont(application.proportionalFontBold);
videoDriverLabel.create(*this, x, y, 45, Style::ComboBoxHeight, "Video:");
videoDriverBox.create (*this, x + 45, y, 150, Style::ComboBoxHeight);
audioDriverLabel.create(*this, x + 200, y, 45, Style::ComboBoxHeight, "Audio:");
audioDriverBox.create (*this, x + 245, y, 150, Style::ComboBoxHeight);
inputDriverLabel.create(*this, x + 400, y, 45, Style::ComboBoxHeight, "Input:");
inputDriverBox.create (*this, x + 445, y, 150, Style::ComboBoxHeight); y += Style::ComboBoxHeight + 5;
focusPolicyLabel.create(*this, x, y, 595, Style::LabelHeight, "Focus Policy :."); y += Style::LabelHeight + 5;
videoDriverLabel.setText("Video:");
audioDriverLabel.setText("Audio:");
inputDriverLabel.setText("Input:");
focusPolicyLabel.setText("Focus Policy :.");
focusPolicyLabel.setFont(application.proportionalFontBold);
focusPolicyPause.create(*this, x, y, 195, Style::CheckBoxHeight, "Pause emulator when inactive");
focusPolicyIgnore.create(focusPolicyPause, x + 200, y, 195, Style::CheckBoxHeight, "Ignore input when inactive");
focusPolicyAllow.create(focusPolicyPause, x + 400, y, 195, Style::CheckBoxHeight, "Always allow input"); y += Style::CheckBoxHeight + 5;
focusPolicyPause.setText("Pause emulator when inactive");
focusPolicyIgnore.setText("Ignore input when inactive");
focusPolicyAllow.setText("Always allow input");
focusPolicyIgnore.setParent(focusPolicyPause);
focusPolicyAllow.setParent(focusPolicyPause);
if(config.settings.focusPolicy == 0) focusPolicyPause.setChecked();
if(config.settings.focusPolicy == 1) focusPolicyIgnore.setChecked();
if(config.settings.focusPolicy == 2) focusPolicyAllow.setChecked();
layout.append(driverSelectionLabel, x, y, 595, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(videoDriverLabel, x, y, 45, Style::ComboBoxHeight);
layout.append(videoDriverBox, x + 45, y, 150, Style::ComboBoxHeight);
layout.append(audioDriverLabel, x + 200, y, 45, Style::ComboBoxHeight);
layout.append(audioDriverBox, x + 245, y, 150, Style::ComboBoxHeight);
layout.append(inputDriverLabel, x + 400, y, 45, Style::ComboBoxHeight);
layout.append(inputDriverBox, x + 445, y, 150, Style::ComboBoxHeight); y += Style::ComboBoxHeight + 5;
layout.append(focusPolicyLabel, x, y, 595, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(focusPolicyPause, x, y, 195, Style::CheckBoxHeight);
layout.append(focusPolicyIgnore, x + 200, y, 195, Style::CheckBoxHeight);
layout.append(focusPolicyAllow, x + 400, y, 195, Style::CheckBoxHeight); y += Style::CheckBoxHeight + 5;
setGeometry(0, 0, 605, y);
setLayout(layout);
lstring list;

View File

@ -1,4 +1,5 @@
struct AdvancedSettings : TopLevelWindow {
FixedLayout layout;
Label driverSelectionLabel;
Label videoDriverLabel;
ComboBox videoDriverBox;

View File

@ -4,15 +4,20 @@ void AudioSettings::create() {
Window::create(0, 0, 256, 256, "Audio Settings");
application.addWindow(this, "AudioSettings", "160,160");
volumeLabel.setText("Volume:");
volumeSlider.setLength(201);
frequencyLabel.setText("Frequency:");
frequencySlider.setLength(2001);
unsigned x = 5, y = 5;
volumeLabel.create(*this, x, y, 70, Style::SliderHeight, "Volume:");
volumeValue.create(*this, x + 70, y, 60, Style::SliderHeight);
volumeSlider.create(*this, x + 130, y, 300, Style::SliderHeight, 201); y += Style::SliderHeight + 5;
frequencyLabel.create(*this, x, y, 70, Style::SliderHeight, "Frequency:");
frequencyValue.create(*this, x + 70, y, 60, Style::SliderHeight);
frequencySlider.create(*this, x + 130, y, 300, Style::SliderHeight, 2001); y += Style::SliderHeight + 5;
layout.append(volumeLabel, x, y, 70, Style::SliderHeight);
layout.append(volumeValue, x + 70, y, 60, Style::SliderHeight);
layout.append(volumeSlider, x + 130, y, 300, Style::SliderHeight); y += Style::SliderHeight + 5;
layout.append(frequencyLabel, x, y, 70, Style::SliderHeight);
layout.append(frequencyValue, x + 70, y, 60, Style::SliderHeight);
layout.append(frequencySlider, x + 130, y, 300, Style::SliderHeight); y += Style::SliderHeight + 5;
setGeometry(0, 0, 440, y);
setLayout(layout);
volumeSlider.onChange = []() {
config.audio.volume = audioSettings.volumeSlider.position();
@ -26,8 +31,6 @@ void AudioSettings::create() {
audioSettings.frequencyValue.setText({ config.audio.inputFrequency, "hz" });
};
setGeometry(0, 0, 440, y);
volumeSlider.setPosition(config.audio.volume);
volumeValue.setText({ config.audio.volume, "%" });

View File

@ -1,4 +1,5 @@
struct AudioSettings : TopLevelWindow {
FixedLayout layout;
Label volumeLabel;
Label volumeValue;
HorizontalSlider volumeSlider;

View File

@ -10,33 +10,39 @@ void InputSettings::create() {
activeInput = 0;
activeMouse = 0;
unsigned x = 5, y = 5, height = Style::ButtonHeight;
portLabel.create(*this, x, y, 50, Style::ComboBoxHeight, "Port:");
portBox.create(*this, x + 50, y, 200, Style::ComboBoxHeight);
portLabel.setText("Port:");
portBox.addItem(inputMapper.port1.name);
portBox.addItem(inputMapper.port2.name);
deviceLabel.create(*this, x + 255, y, 50, Style::ComboBoxHeight, "Device:");
deviceBox.create(*this, x + 305, y, 200, Style::ComboBoxHeight); y += Style::ComboBoxHeight + 5;
mappingList.create(*this, x, y, 505, 265, "Name\tMapping"); y += 265 + 5;
mappingList.setHeaderVisible();
mappingList.setFocused();
mouseXaxis.create(*this, x, y, 100, height, "Mouse X-axis");
mouseXaxis.setVisible(false);
mouseYaxis.create(*this, x + 105, y, 100, height, "Mouse Y-axis");
mouseYaxis.setVisible(false);
mouseLeft.create(*this, x, y, 100, height, "Mouse Left");
mouseLeft.setVisible(false);
mouseMiddle.create(*this, x + 105, y, 100, height, "Mouse Middle");
mouseMiddle.setVisible(false);
mouseRight.create(*this, x + 105 + 105, y, 100, height, "Mouse Right");
mouseRight.setVisible(false);
clearButton.create(*this, 515 - 85, y, 80, height, "Clear");
y += height + 5;
deviceLabel.setText("Device:");
mappingList.setHeaderText("Name\tMapping");
mappingList.setHeaderVisible(true);
mouseXaxis.setText("Mouse X-axis");
mouseYaxis.setText("Mouse Y-axis");
mouseLeft.setText("Mouse Left");
mouseMiddle.setText("Mouse Middle");
mouseRight.setText("Mouse Right");
clearButton.setText("Clear");
unsigned x = 5, y = 5, height = Style::ButtonHeight;
layout.append(portLabel, x, y, 50, Style::ComboBoxHeight);
layout.append(portBox, x + 50, y, 200, Style::ComboBoxHeight);
layout.append(deviceLabel, x + 255, y, 50, Style::ComboBoxHeight);
layout.append(deviceBox, x + 305, y, 200, Style::ComboBoxHeight); y += Style::ComboBoxHeight + 5;
layout.append(mappingList, x, y, 505, 265); y += 265 + 5;
layout.append(mouseXaxis, x, y, 100, height);
layout.append(mouseYaxis, x + 105, y, 100, height);
layout.append(mouseLeft, x, y, 100, height);
layout.append(mouseMiddle, x + 105, y, 100, height);
layout.append(mouseRight, x + 105 + 105, y, 100, height);
layout.append(clearButton, 515 - 85, y, 80, height); y += height + 5;
setGeometry(0, 0, 515, y);
setLayout(layout);
mouseXaxis.setVisible(false);
mouseYaxis.setVisible(false);
mouseLeft.setVisible(false);
mouseMiddle.setVisible(false);
mouseRight.setVisible(false);
portChanged();
portBox.onChange = { &InputSettings::portChanged, this };

View File

@ -1,4 +1,5 @@
struct InputSettings : TopLevelWindow {
FixedLayout layout;
Label portLabel;
ComboBox portBox;
Label deviceLabel;

View File

@ -6,49 +6,58 @@ void VideoSettings::create() {
unsigned x = 5, y = 5, height = Style::TextBoxHeight;
colorAdjustmentLabel.create(*this, x, y, 430, Style::LabelHeight, "Color Adjustment :."); y += Style::LabelHeight + 5;
colorAdjustmentLabel.setText("Color Adjustment :.");
colorAdjustmentLabel.setFont(application.proportionalFontBold);
brightnessLabel.create (*this, x, y, 80, Style::SliderHeight, "Brightness:");
brightnessValue.create (*this, x + 80, y, 40, Style::SliderHeight);
brightnessSlider.create(*this, x + 130, y, 300, Style::SliderHeight, 201); y += Style::SliderHeight;
contrastLabel.create (*this, x, y, 80, Style::SliderHeight, "Contrast:");
contrastValue.create (*this, x + 80, y, 50, Style::SliderHeight);
contrastSlider.create (*this, x + 130, y, 300, Style::SliderHeight, 201); y += Style::SliderHeight;
gammaLabel.create (*this, x, y, 80, Style::SliderHeight, "Gamma:");
gammaValue.create (*this, x + 80, y, 50, Style::SliderHeight);
gammaSlider.create (*this, x + 130, y, 300, Style::SliderHeight, 201); y += Style::SliderHeight + 5;
gammaRampCheck.create (*this, x, y, 430, Style::CheckBoxHeight, "Enable NTSC gamma ramp simulation"); y += Style::CheckBoxHeight + 5;
fullscreenLabel.create(*this, x, y, 340, Style::LabelHeight, "Fullscreen :."); y += Style::LabelHeight + 5;
brightnessLabel.setText("Brightness:");
brightnessSlider.setLength(201);
contrastLabel.setText("Contrast:");
contrastSlider.setLength(201);
gammaLabel.setText("Gamma:");
gammaSlider.setLength(201);
gammaRampCheck.setText("Enable NTSC gamma ramp simulation");
fullscreenLabel.setText("Fullscreen :.");
fullscreenLabel.setFont(application.proportionalFontBold);
fullscreenCenter.create (*this, x, y, 135, Style::CheckBoxHeight, "Center");
fullscreenScale.create (fullscreenCenter, x + 140, y, 135, Style::CheckBoxHeight, "Scale");
fullscreenStretch.create(fullscreenCenter, x + 280, y, 135, Style::CheckBoxHeight, "Stretch"); y += Style::CheckBoxHeight + 5;
filterLabel.create(*this, x, y, 340, Style::LabelHeight, "Video Filter :."); y += Style::LabelHeight + 5;
fullscreenCenter.setText("Center");
fullscreenScale.setText("Scale");
fullscreenStretch.setText("Stretch");
fullscreenScale.setParent(fullscreenCenter);
fullscreenStretch.setParent(fullscreenCenter);
filterLabel.setText("Video Filter :.");
filterLabel.setFont(application.proportionalFontBold);
filterPath.create(*this, x, y, 430 - height - height - 10, height);
filterPath.setEditable(false);
filterPath.setText(config.video.filter);
filterClear.create(*this, x + 430 - height - height - 5, y, height, height, "");
filterSelect.create(*this, x + 430 - height, y, height, height, "..."); y += height + 5;
shaderLabel.create(*this, x, y, 340, Style::LabelHeight, "Pixel Shader :."); y += Style::LabelHeight + 5;
filterSelect.setText("...");
shaderLabel.setText("Pixel Shader :.");
shaderLabel.setFont(application.proportionalFontBold);
shaderPath.create(*this, x, y, 430 - height - height - 10, height);
shaderPath.setEditable(false);
shaderPath.setText(config.video.shader);
shaderClear.create(*this, x + 430 - height - height - 5, y, height, height, "");
shaderSelect.create(*this, x + 430 - height, y, height, height, "..."); y += height + 5;
shaderSelect.setText("...");
layout.append(colorAdjustmentLabel, x, y, 430, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(brightnessLabel, x, y, 80, Style::SliderHeight);
layout.append(brightnessValue, x + 80, y, 40, Style::SliderHeight);
layout.append(brightnessSlider, x + 130, y, 300, Style::SliderHeight); y += Style::SliderHeight;
layout.append(contrastLabel, x, y, 80, Style::SliderHeight);
layout.append(contrastValue, x + 80, y, 50, Style::SliderHeight);
layout.append(contrastSlider, x + 130, y, 300, Style::SliderHeight); y += Style::SliderHeight;
layout.append(gammaLabel, x, y, 80, Style::SliderHeight);
layout.append(gammaValue, x + 80, y, 50, Style::SliderHeight);
layout.append(gammaSlider, x + 130, y, 300, Style::SliderHeight); y += Style::SliderHeight + 5;
layout.append(gammaRampCheck, x, y, 430, Style::CheckBoxHeight); y += Style::CheckBoxHeight + 5;
layout.append(fullscreenLabel, x, y, 340, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(fullscreenCenter, x, y, 135, Style::CheckBoxHeight);
layout.append(fullscreenScale, x + 140, y, 135, Style::CheckBoxHeight);
layout.append(fullscreenStretch, x + 280, y, 135, Style::CheckBoxHeight); y += Style::CheckBoxHeight + 5;
layout.append(filterLabel, x, y, 340, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(filterPath, x, y, 430 - height - height - 10, height);
layout.append(filterClear, x + 430 - height - height - 5, y, height, height);
layout.append(filterSelect, x + 430 - height, y, height, height); y += height + 5;
layout.append(shaderLabel, x, y, 340, Style::LabelHeight); y += Style::LabelHeight + 5;
layout.append(shaderPath, x, y, 430 - height - height - 10, height);
layout.append(shaderClear, x + 430 - height - height - 5, y, height, height);
layout.append(shaderSelect, x + 430 - height, y, height, height); y += height + 5;
setGeometry(0, 0, 440, y);
setLayout(layout);
brightnessSlider.setPosition(config.video.brightness);
brightnessValue.setText({ config.video.brightness, "%" });

View File

@ -1,4 +1,5 @@
struct VideoSettings : TopLevelWindow {
FixedLayout layout;
Label colorAdjustmentLabel;
Label brightnessLabel;
Label brightnessValue;

View File

@ -82,23 +82,27 @@ void CheatEditor::create() {
Window::create(0, 0, 256, 256, "Cheat Editor");
application.addWindow(this, "CheatEditor", "160,160");
unsigned x = 5, y = 5, height = Style::ButtonHeight;
cheatList.create(*this, x, y, 500, 250, "Slot\tCode\tDescription"); y += 255;
cheatList.setHeaderText("Slot\tCode\tDescription");
cheatList.setHeaderVisible();
cheatList.setCheckable();
codeLabel.setText("Code(s):");
descLabel.setText("Description:");
findButton.setText("Find Codes ...");
clearAllButton.setText("Clear All");
clearButton.setText("Clear");
codeLabel.create(*this, x, y, 80, Style::TextBoxHeight, "Code(s):");
codeEdit.create (*this, x + 80, y, 420, Style::TextBoxHeight); y += Style::TextBoxHeight + 5;
descLabel.create(*this, x, y, 80, Style::TextBoxHeight, "Description:");
descEdit.create (*this, x + 80, y, 420, Style::TextBoxHeight); y+= Style::TextBoxHeight + 5;
findButton.create(*this, x, y, 100, height, "Find Codes ...");
clearAllButton.create(*this, x + 505 - 85 - 85, y, 80, height, "Clear All");
clearButton.create(*this, x + 505 - 85, y, 80, height, "Clear"); y += height + 5;
unsigned x = 5, y = 5, height = Style::ButtonHeight;
layout.append(cheatList, x, y, 500, 250); y += 255;
layout.append(codeLabel, x, y, 80, Style::TextBoxHeight);
layout.append(codeEdit, x + 80, y, 420, Style::TextBoxHeight); y += Style::TextBoxHeight + 5;
layout.append(descLabel, x, y, 80, Style::TextBoxHeight);
layout.append(descEdit, x + 80, y, 420, Style::TextBoxHeight); y+= Style::TextBoxHeight + 5;
layout.append(findButton, x, y, 100, height);
layout.append(clearAllButton, x + 505 - 85 - 85, y, 80, height);
layout.append(clearButton, x + 505 - 85, y, 80, height); y += height + 5;
setGeometry(0, 0, 510, y);
setLayout(layout);
synchronize();
cheatList.onChange = { &CheatEditor::synchronize, this };
@ -117,16 +121,18 @@ void CheatEditor::create() {
databaseWindow.create(0, 0, 256, 256);
application.addWindow(&databaseWindow, "CheatDatabase", "192,192");
x = 5, y = 5;
databaseList.create(databaseWindow, x, y, 600, 360); y += 365;
databaseList.setCheckable(true);
databaseSelectAll.setText("Select All");
databaseUnselectAll.setText("Unselect All");
databaseOk.setText("Ok");
databaseSelectAll.create(databaseWindow, x, y, 100, height, "Select All");
databaseUnselectAll.create(databaseWindow, x + 105, y, 100, height, "Unselect All");
databaseOk.create(databaseWindow, 605 - 80, y, 80, height, "Ok"); y += height + 5;
x = 5, y = 5;
databaseLayout.append(databaseList, x, y, 600, 360); y += 365;
databaseLayout.append(databaseSelectAll, x, y, 100, height);
databaseLayout.append(databaseUnselectAll, x + 105, y, 100, height);
databaseLayout.append(databaseOk, 605 - 80, y, 80, height); y += height + 5;
databaseWindow.setGeometry(0, 0, 610, y);
databaseWindow.setLayout(databaseLayout);
databaseSelectAll.onTick = []() {
for(unsigned i = 0; i < cheatEditor.databaseCode.size(); i++) {

View File

@ -1,4 +1,5 @@
struct CheatEditor : TopLevelWindow {
FixedLayout layout;
ListBox cheatList;
Label codeLabel;
TextBox codeEdit;
@ -9,6 +10,7 @@ struct CheatEditor : TopLevelWindow {
Button clearButton;
TopLevelWindow databaseWindow;
FixedLayout databaseLayout;
ListBox databaseList;
lstring databaseCode;
Button databaseSelectAll;

View File

@ -4,19 +4,23 @@ void StateManager::create() {
Window::create(0, 0, 256, 256, "State Manager");
application.addWindow(this, "StateManager", "160,160");
unsigned x = 5, y = 5;
stateList.create(*this, x, y, 500, 250, "Slot\tDescription"); y += 255;
stateList.setHeaderText("Slot\tDescription");
stateList.setHeaderVisible();
descLabel.setText("Description:");
loadButton.setText("Load");
saveButton.setText("Save");
eraseButton.setText("Erase");
descLabel.create(*this, x, y, 80, Style::TextBoxHeight, "Description:");
descEdit.create(*this, x + 80, y, 420, Style::TextBoxHeight); y += Style::TextBoxHeight + 5;
loadButton.create(*this, x + 505 - 85 - 85 - 85, y, 80, Style::ButtonHeight, "Load");
saveButton.create(*this, x + 505 - 85 - 85, y, 80, Style::ButtonHeight, "Save");
eraseButton.create(*this, x + 505 - 85, y, 80, Style::ButtonHeight, "Erase"); y += Style::ButtonHeight + 5;
unsigned x = 5, y = 5;
layout.append(stateList, x, y, 500, 250); y += 255;
layout.append(descLabel, x, y, 80, Style::TextBoxHeight);
layout.append(descEdit, x + 80, y, 420, Style::TextBoxHeight); y += Style::TextBoxHeight + 5;
layout.append(loadButton, x + 505 - 85 - 85 - 85, y, 80, Style::ButtonHeight);
layout.append(saveButton, x + 505 - 85 - 85, y, 80, Style::ButtonHeight);
layout.append(eraseButton, x + 505 - 85, y, 80, Style::ButtonHeight); y += Style::ButtonHeight + 5;
setGeometry(0, 0, 510, y);
setLayout(layout);
synchronize();
stateList.onActivate = { &StateManager::slotLoad, this };

View File

@ -1,4 +1,5 @@
struct StateManager : TopLevelWindow {
FixedLayout layout;
ListBox stateList;
Label descLabel;
TextBox descEdit;