From 266495b475b3273ebe670ed7dbf4e253d47c2eaf Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Mon, 7 Feb 2011 20:15:43 +1100 Subject: [PATCH] Update to v075r08 release. byuu says: Eleven hours of work. Window is now a base type (inherits from Object, not Widget), same for Layout. FixedLayout still inherits from Layout. Added HorizontalLayout and VerticalLayout types, that can append each other to themselves to create box layouts. Layout margins are supported, spacing is specified inline (I find this a much better way to fine-grain spacing than Qt's single setSpacing function), and alignment is handled strictly via padding widgets (insert a zero-sized label and it will automatically grow to consume all extra space.) Overall, my box packing model is slightly less powerful than Qt's, but it is a good deal simpler and and easier to use in 90% of cases. The one limitation I hit was with my input settings window, I'm not currently able to embed two different layouts and toggle one on and the other off to show only either { mouse x-axis, y-axis } or { mouse left, middle, right }, so they instead just space out differently and I had to grow the input window width a bit to compensate. Resizing works great, pretty cool seeing that this is the first time I've ever written my own resizer. I had to fight with Qt for several hours to the point of potentially developing an aneurysm, but I finally got it to properly handle geometry and sizing stuff. Some weird issue with the bsnes viewport widget, I tell it to resize and for some reason it doesn't. Cheap hack, I just make it constantly resize every video refresh and it eventually takes. Wish I knew what was up with that. All of bsnes now uses dynamic layouts sans the main window, so you can resize them however you like. This is still all Qt-only, I'm afraid. The other two ports are in-progress. --- bsnes/Makefile | 2 +- bsnes/phoenix/gtk/button.cpp | 3 - bsnes/phoenix/gtk/checkbox.cpp | 3 - bsnes/phoenix/gtk/fixed-layout.cpp | 27 +- bsnes/phoenix/gtk/gtk.hpp | 94 +++--- bsnes/phoenix/gtk/label.cpp | 3 - bsnes/phoenix/gtk/layout.cpp | 17 + bsnes/phoenix/gtk/object.cpp | 8 +- bsnes/phoenix/gtk/radiobox.cpp | 5 +- bsnes/phoenix/gtk/window.cpp | 8 +- bsnes/phoenix/qt/button.cpp | 5 - bsnes/phoenix/qt/canvas.cpp | 5 - bsnes/phoenix/qt/checkbox.cpp | 5 - bsnes/phoenix/qt/combobox.cpp | 5 - bsnes/phoenix/qt/editbox.cpp | 5 - bsnes/phoenix/qt/fixed-layout.cpp | 23 +- bsnes/phoenix/qt/hexeditor.cpp | 5 - bsnes/phoenix/qt/horizontal-layout.cpp | 70 +++++ bsnes/phoenix/qt/horizontalslider.cpp | 5 - bsnes/phoenix/qt/label.cpp | 5 - bsnes/phoenix/qt/layout.cpp | 15 + bsnes/phoenix/qt/listbox.cpp | 5 - bsnes/phoenix/qt/progressbar.cpp | 5 - bsnes/phoenix/qt/qt.cpp | 2 + bsnes/phoenix/qt/qt.hpp | 89 +++--- bsnes/phoenix/qt/qt.moc | 296 ++++++++++++------ bsnes/phoenix/qt/qt.moc.hpp | 121 +++++-- bsnes/phoenix/qt/radiobox.cpp | 5 - bsnes/phoenix/qt/textbox.cpp | 5 - bsnes/phoenix/qt/vertical-layout.cpp | 70 +++++ bsnes/phoenix/qt/verticalslider.cpp | 5 - bsnes/phoenix/qt/viewport.cpp | 5 - bsnes/phoenix/qt/widget.cpp | 8 + bsnes/phoenix/qt/window.cpp | 58 ++-- bsnes/snes/cheat/cheat.cpp | 1 - bsnes/snes/snes.hpp | 4 +- bsnes/ui/debugger/console.cpp | 17 +- bsnes/ui/debugger/console.hpp | 4 +- bsnes/ui/debugger/cpu/debugger.cpp | 14 +- bsnes/ui/debugger/cpu/debugger.hpp | 3 +- bsnes/ui/debugger/debugger.cpp | 15 +- bsnes/ui/debugger/debugger.hpp | 2 +- bsnes/ui/debugger/smp/debugger.cpp | 14 +- bsnes/ui/debugger/smp/debugger.hpp | 3 +- bsnes/ui/debugger/tools/breakpoint-editor.cpp | 18 +- bsnes/ui/debugger/tools/breakpoint-editor.hpp | 3 +- bsnes/ui/debugger/tools/memory-editor.cpp | 17 +- bsnes/ui/debugger/tools/memory-editor.hpp | 3 +- bsnes/ui/general/file-browser.cpp | 15 +- bsnes/ui/general/file-browser.hpp | 3 +- bsnes/ui/general/slot-loader.cpp | 55 ++-- bsnes/ui/general/slot-loader.hpp | 13 +- bsnes/ui/interface.cpp | 5 + bsnes/ui/settings/advanced.cpp | 23 +- bsnes/ui/settings/advanced.hpp | 4 +- bsnes/ui/settings/audio.cpp | 17 +- bsnes/ui/settings/audio.hpp | 4 +- bsnes/ui/settings/input.cpp | 30 +- bsnes/ui/settings/input.hpp | 5 +- bsnes/ui/settings/video.cpp | 58 ++-- bsnes/ui/settings/video.hpp | 12 +- bsnes/ui/tools/cheat-editor.cpp | 40 +-- bsnes/ui/tools/cheat-editor.hpp | 12 +- bsnes/ui/tools/state-manager.cpp | 18 +- bsnes/ui/tools/state-manager.hpp | 5 +- bsnes/ui/utility/utility.cpp | 17 +- bsnes/ui/utility/utility.hpp | 3 + 67 files changed, 950 insertions(+), 499 deletions(-) create mode 100755 bsnes/phoenix/qt/horizontal-layout.cpp create mode 100755 bsnes/phoenix/qt/vertical-layout.cpp diff --git a/bsnes/Makefile b/bsnes/Makefile index 88a4caaf..3b20cc03 100755 --- a/bsnes/Makefile +++ b/bsnes/Makefile @@ -2,7 +2,7 @@ include nall/Makefile snes := snes gameboy := gameboy profile := compatibility -ui := ui-gameboy +ui := ui # compiler c := $(compiler) -std=gnu99 diff --git a/bsnes/phoenix/gtk/button.cpp b/bsnes/phoenix/gtk/button.cpp index e244c25d..b1f92199 100755 --- a/bsnes/phoenix/gtk/button.cpp +++ b/bsnes/phoenix/gtk/button.cpp @@ -2,9 +2,6 @@ static void Button_tick(Button *self) { if(self->onTick) self->onTick(); } -void Button::setParent(Layout &parent) { -} - void Button::setText(const string &text) { gtk_button_set_label(GTK_BUTTON(object->widget), text); } diff --git a/bsnes/phoenix/gtk/checkbox.cpp b/bsnes/phoenix/gtk/checkbox.cpp index 934f2d06..74edfabe 100755 --- a/bsnes/phoenix/gtk/checkbox.cpp +++ b/bsnes/phoenix/gtk/checkbox.cpp @@ -2,9 +2,6 @@ static void CheckBox_tick(CheckBox *self) { if(self->onTick && self->object->locked == false) self->onTick(); } -void CheckBox::setParent(Layout &parent) { -} - void CheckBox::setText(const string &text) { gtk_button_set_label(GTK_BUTTON(object->widget), text); } diff --git a/bsnes/phoenix/gtk/fixed-layout.cpp b/bsnes/phoenix/gtk/fixed-layout.cpp index 651e9bc6..bb6c7357 100755 --- a/bsnes/phoenix/gtk/fixed-layout.cpp +++ b/bsnes/phoenix/gtk/fixed-layout.cpp @@ -1,21 +1,24 @@ -void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height) { - fixedLayout->widgets.append({ &widget, x, y, width, height }); +void FixedLayout::setParent(Window &parent) { + Layout::setParent(parent); + foreach(child, fixedLayout->children) { + gtk_fixed_put(GTK_FIXED(layout->parent->object->formContainer), child.widget->object->widget, 0, 0); + } } -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); +void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height) { + fixedLayout->children.append({ &widget, x, y, width, height }); +} - 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); +void FixedLayout::update(Geometry &geometry) { + Layout::update(geometry); + + foreach(child, fixedLayout->children) { + gtk_fixed_move(GTK_FIXED(layout->parent->object->formContainer), child.widget->object->widget, child.x, child.y); + gtk_widget_set_size_request(child.widget->object->widget, child.width, child.height); + gtk_widget_show(child.widget->object->widget); } - - gtk_widget_show(fixedLayout->container); } FixedLayout::FixedLayout() { fixedLayout = new FixedLayout::Data; - fixedLayout->container = gtk_fixed_new(); } diff --git a/bsnes/phoenix/gtk/gtk.hpp b/bsnes/phoenix/gtk/gtk.hpp index 8a294ad9..1575a0aa 100755 --- a/bsnes/phoenix/gtk/gtk.hpp +++ b/bsnes/phoenix/gtk/gtk.hpp @@ -78,12 +78,55 @@ private: MenuRadioItem *first; }; -struct Window; struct Layout; +struct Widget; + +struct Window : Object { + nall::function 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(); + void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height); + void setDefaultFont(Font &font); + void setFont(Font &font); + void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue); + void setTitle(const nall::string &text); + void setStatusText(const nall::string &text); + void setVisible(bool visible = true); + void setMenuVisible(bool visible = true); + void setStatusVisible(bool visible = true); + bool fullscreen(); + void setFullscreen(bool fullscreen = true); + Window(); +//private: + struct Data; + Data *window; + static Window None; +}; + +struct Layout : Object { + virtual void setParent(Window &parent); + virtual void update(Geometry &geometry); + void setMargin(unsigned margin); + Layout(); +//private: + struct Data; + Data *layout; +}; + +struct FixedLayout : Layout { + void setParent(Window &parent); + void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height); + void update(Geometry &geometry); + FixedLayout(); +//private: + struct Data; + Data *fixedLayout; +}; 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(); @@ -98,50 +141,8 @@ struct Widget : Object { Data *widget; }; -struct Window : Widget { - nall::function 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(); - void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height); - void setDefaultFont(Font &font); - void setFont(Font &font); - void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue); - void setTitle(const nall::string &text); - void setStatusText(const nall::string &text); - void setMenuVisible(bool visible = true); - void setStatusVisible(bool visible = true); - bool fullscreen(); - void setFullscreen(bool fullscreen = true); - Window(); -//private: - struct Data; - Data *window; - 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 onTick; - void setParent(Layout &parent); void setText(const nall::string &text); Button(); }; @@ -159,7 +160,6 @@ struct Canvas : Widget { struct CheckBox : Widget { nall::function onTick; - void setParent(Layout &parent); void setText(const nall::string &text); bool checked(); void setChecked(bool checked = true); @@ -218,7 +218,6 @@ struct HorizontalSlider : Widget { }; struct Label : Widget { - void setParent(Layout &parent); void setText(const nall::string &text); Label(); }; @@ -253,7 +252,6 @@ struct ProgressBar : Widget { struct RadioBox : Widget { nall::function onTick; - void setParent(Layout &parent); void setParent(RadioBox &parent); void setText(const nall::string &text); bool checked(); diff --git a/bsnes/phoenix/gtk/label.cpp b/bsnes/phoenix/gtk/label.cpp index 60940761..3f91075a 100755 --- a/bsnes/phoenix/gtk/label.cpp +++ b/bsnes/phoenix/gtk/label.cpp @@ -1,6 +1,3 @@ -void Label::setParent(Layout &parent) { -} - void Label::setText(const string &text) { gtk_label_set_text(GTK_LABEL(object->widget), text); } diff --git a/bsnes/phoenix/gtk/layout.cpp b/bsnes/phoenix/gtk/layout.cpp index e257ad42..e862a3c7 100755 --- a/bsnes/phoenix/gtk/layout.cpp +++ b/bsnes/phoenix/gtk/layout.cpp @@ -1,3 +1,20 @@ +void Layout::setParent(Window &parent) { + layout->parent = &parent; +} + +void Layout::update(Geometry &geometry) { + geometry.x += layout->margin; + geometry.y += layout->margin; + geometry.width -= layout->margin * 2; + geometry.height -= layout->margin * 2; +} + +void Layout::setMargin(unsigned margin) { + layout->margin = margin; +} + Layout::Layout() { layout = new Layout::Data; + layout->parent = 0; + layout->margin = 0; } diff --git a/bsnes/phoenix/gtk/object.cpp b/bsnes/phoenix/gtk/object.cpp index 710aee29..e812ad58 100755 --- a/bsnes/phoenix/gtk/object.cpp +++ b/bsnes/phoenix/gtk/object.cpp @@ -35,18 +35,18 @@ struct Widget::Data { }; struct Layout::Data { + Window *parent; + unsigned margin; }; struct FixedLayout::Data { Window *parent; - GtkWidget *container; - - struct Widgets { + struct Children { Widget *widget; unsigned x, y; unsigned width, height; }; - linear_vector widgets; + linear_vector children; }; struct Canvas::Data { diff --git a/bsnes/phoenix/gtk/radiobox.cpp b/bsnes/phoenix/gtk/radiobox.cpp index 831a6266..2b13101a 100755 --- a/bsnes/phoenix/gtk/radiobox.cpp +++ b/bsnes/phoenix/gtk/radiobox.cpp @@ -2,10 +2,6 @@ static void RadioBox_tick(RadioBox *self) { if(self->onTick && self->checked() && self->object->locked == false) self->onTick(); } -void RadioBox::setParent(Layout &parent) { - first = this; -} - void RadioBox::setParent(RadioBox &parent) { first = parent.first; } @@ -25,6 +21,7 @@ void RadioBox::setChecked() { } RadioBox::RadioBox() { + first = this; object->widget = gtk_radio_button_new_with_label(0, ""); g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(RadioBox_tick), (gpointer)this); } diff --git a/bsnes/phoenix/gtk/window.cpp b/bsnes/phoenix/gtk/window.cpp index 6dd51bb7..4a1cd069 100755 --- a/bsnes/phoenix/gtk/window.cpp +++ b/bsnes/phoenix/gtk/window.cpp @@ -45,7 +45,9 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con } void Window::setLayout(Layout &layout) { - layout.create(*this); + layout.setParent(*this); + Geometry geom = geometry(); + layout.update(geom); } bool Window::focused() { @@ -94,6 +96,10 @@ void Window::setStatusText(const string &text) { gtk_statusbar_push(GTK_STATUSBAR(object->status), 1, text); } +void Window::setVisible(bool visible) { + gtk_widget_set_visible(object->widget, visible); +} + void Window::setMenuVisible(bool visible) { gtk_widget_set_visible(object->menu, visible); } diff --git a/bsnes/phoenix/qt/button.cpp b/bsnes/phoenix/qt/button.cpp index 8d9b1044..7ae0d524 100755 --- a/bsnes/phoenix/qt/button.cpp +++ b/bsnes/phoenix/qt/button.cpp @@ -1,8 +1,3 @@ -void Button::setParent(Layout &parent) { - button->setParent(parent.widget->widget); - button->show(); -} - void Button::setText(const string &text) { button->setText(QString::fromUtf8(text)); } diff --git a/bsnes/phoenix/qt/canvas.cpp b/bsnes/phoenix/qt/canvas.cpp index 114c5042..9d528f49 100755 --- a/bsnes/phoenix/qt/canvas.cpp +++ b/bsnes/phoenix/qt/canvas.cpp @@ -1,8 +1,3 @@ -void Canvas::setParent(Layout &parent) { - canvas->setParent(parent.widget->widget); - canvas->show(); -} - void Canvas::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) { delete canvas->image; canvas->image = new QImage(width, height, QImage::Format_RGB32); diff --git a/bsnes/phoenix/qt/checkbox.cpp b/bsnes/phoenix/qt/checkbox.cpp index 9cccd61c..d0125f3c 100755 --- a/bsnes/phoenix/qt/checkbox.cpp +++ b/bsnes/phoenix/qt/checkbox.cpp @@ -1,8 +1,3 @@ -void CheckBox::setParent(Layout &parent) { - checkBox->setParent(parent.widget->widget); - checkBox->show(); -} - void CheckBox::setText(const string &text) { checkBox->setText(QString::fromUtf8(text)); } diff --git a/bsnes/phoenix/qt/combobox.cpp b/bsnes/phoenix/qt/combobox.cpp index 534face5..6b28e84b 100755 --- a/bsnes/phoenix/qt/combobox.cpp +++ b/bsnes/phoenix/qt/combobox.cpp @@ -1,8 +1,3 @@ -void ComboBox::setParent(Layout &parent) { - comboBox->setParent(parent.widget->widget); - comboBox->show(); -} - void ComboBox::reset() { while(comboBox->count()) comboBox->removeItem(0); } diff --git a/bsnes/phoenix/qt/editbox.cpp b/bsnes/phoenix/qt/editbox.cpp index 2be25690..9b1c943f 100755 --- a/bsnes/phoenix/qt/editbox.cpp +++ b/bsnes/phoenix/qt/editbox.cpp @@ -1,8 +1,3 @@ -void EditBox::setParent(Layout &parent) { - editBox->setParent(parent.widget->widget); - editBox->show(); -} - void EditBox::setEditable(bool editable) { editBox->setReadOnly(editable == false); } diff --git a/bsnes/phoenix/qt/fixed-layout.cpp b/bsnes/phoenix/qt/fixed-layout.cpp index a45a1deb..4a7f08d2 100755 --- a/bsnes/phoenix/qt/fixed-layout.cpp +++ b/bsnes/phoenix/qt/fixed-layout.cpp @@ -1,22 +1,31 @@ +void FixedLayout::setParent(Window &parent) { + Layout::setParent(parent); + foreach(child, fixedLayout->children) { + child.widget->widget->widget->setParent(layout->parent->window->container); + if(!child.widget->widget->font && layout->parent->window->defaultFont) { + QWidget *control = child.widget->widget->widget; + control->setFont(*layout->parent->window->defaultFont); + } + } +} + 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); +void FixedLayout::update(Geometry &geometry) { + Layout::update(geometry); foreach(child, fixedLayout->children) { - child.widget->setParent(*this); + child.widget->widget->widget->setParent(layout->parent->window->container); child.widget->setGeometry(child.x, child.y, child.width, child.height); - if(parentWindow.window->defaultFont) { + if(layout->parent->window->defaultFont) { QWidget *control = child.widget->widget->widget; - control->setFont(*parentWindow.window->defaultFont); + control->setFont(*layout->parent->window->defaultFont); } } } FixedLayout::FixedLayout() { fixedLayout = new FixedLayout::Data(*this); - widget->widget = fixedLayout; } diff --git a/bsnes/phoenix/qt/hexeditor.cpp b/bsnes/phoenix/qt/hexeditor.cpp index d76b3795..8716d3b9 100755 --- a/bsnes/phoenix/qt/hexeditor.cpp +++ b/bsnes/phoenix/qt/hexeditor.cpp @@ -1,8 +1,3 @@ -void HexEditor::setParent(Layout &parent) { - hexEditor->setParent(parent.widget->widget); - hexEditor->show(); -} - void HexEditor::setSize(unsigned size) { hexEditor->size = size; bool indivisible = (hexEditor->size % hexEditor->columns) != 0; //add one for incomplete row diff --git a/bsnes/phoenix/qt/horizontal-layout.cpp b/bsnes/phoenix/qt/horizontal-layout.cpp new file mode 100755 index 00000000..b2b0e076 --- /dev/null +++ b/bsnes/phoenix/qt/horizontal-layout.cpp @@ -0,0 +1,70 @@ +void HorizontalLayout::setParent(Window &parent) { + Layout::setParent(parent); + foreach(child, horizontalLayout->children) { + if(child.layout) { + child.layout->setParent(parent); + } + + if(child.widget) { + child.widget->widget->widget->setParent(layout->parent->window->container); + if(!child.widget->widget->font && layout->parent->window->defaultFont) { + QWidget *control = child.widget->widget->widget; + control->setFont(*layout->parent->window->defaultFont); + } + } + } +} + +void HorizontalLayout::append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing) { + horizontalLayout->children.append({ &layout, 0, width, height, spacing }); +} + +void HorizontalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) { + horizontalLayout->children.append({ 0, &widget, width, height, spacing }); +} + +void HorizontalLayout::update(Geometry &geometry) { + Layout::update(geometry); + Geometry baseGeometry = geometry; + linear_vector children = horizontalLayout->children; + + unsigned minimumWidth = 0; + foreach(child, children) minimumWidth += child.width + child.spacing; + + unsigned autosizeWidgets = 0; + foreach(child, children) { + if(child.width == 0) autosizeWidgets++; + } + foreach(child, children) { + if(child.width == 0) child.width = (geometry.width - minimumWidth) / autosizeWidgets; + if(child.height == 0) child.height = geometry.height; + } + + unsigned maxHeight = 0; + foreach(child, children) { + maxHeight = max(maxHeight, child.height); + } + + foreach(child, children) { + if(child.layout) { + child.layout->update(geometry); + geometry.x += child.spacing; + geometry.width -= child.spacing; + geometry.y = baseGeometry.y; + geometry.height = baseGeometry.height; + } + + if(child.widget) { + child.widget->setGeometry(geometry.x, geometry.y, child.width, child.height); + geometry.x += child.width + child.spacing; + geometry.width -= child.width + child.spacing; + } + } + + geometry.y += maxHeight; + geometry.height -= maxHeight; +} + +HorizontalLayout::HorizontalLayout() { + horizontalLayout = new HorizontalLayout::Data(*this); +} diff --git a/bsnes/phoenix/qt/horizontalslider.cpp b/bsnes/phoenix/qt/horizontalslider.cpp index 0529b711..60ed5692 100755 --- a/bsnes/phoenix/qt/horizontalslider.cpp +++ b/bsnes/phoenix/qt/horizontalslider.cpp @@ -1,8 +1,3 @@ -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); diff --git a/bsnes/phoenix/qt/label.cpp b/bsnes/phoenix/qt/label.cpp index bd9b58e5..b5d20f49 100755 --- a/bsnes/phoenix/qt/label.cpp +++ b/bsnes/phoenix/qt/label.cpp @@ -1,8 +1,3 @@ -void Label::setParent(Layout &parent) { - label->setParent(parent.widget->widget); - label->show(); -} - void Label::setText(const string &text) { label->setText(QString::fromUtf8(text)); } diff --git a/bsnes/phoenix/qt/layout.cpp b/bsnes/phoenix/qt/layout.cpp index 783c8726..82456905 100755 --- a/bsnes/phoenix/qt/layout.cpp +++ b/bsnes/phoenix/qt/layout.cpp @@ -1,3 +1,18 @@ +void Layout::setParent(Window &parent) { + layout->parent = &parent; +} + +void Layout::update(Geometry &geometry) { + geometry.x += layout->margin; + geometry.y += layout->margin; + geometry.width -= layout->margin * 2; + geometry.height -= layout->margin * 2; +} + +void Layout::setMargin(unsigned margin) { + layout->margin = margin; +} + Layout::Layout() { layout = new Layout::Data(*this); } diff --git a/bsnes/phoenix/qt/listbox.cpp b/bsnes/phoenix/qt/listbox.cpp index 2500baa4..210117ff 100755 --- a/bsnes/phoenix/qt/listbox.cpp +++ b/bsnes/phoenix/qt/listbox.cpp @@ -1,8 +1,3 @@ -void ListBox::setParent(Layout &parent) { - listBox->setParent(parent.widget->widget); - listBox->show(); -} - void ListBox::setHeaderText(const string &text) { lstring list; list.split("\t", text); diff --git a/bsnes/phoenix/qt/progressbar.cpp b/bsnes/phoenix/qt/progressbar.cpp index 6f4b31db..2ae7cb1f 100755 --- a/bsnes/phoenix/qt/progressbar.cpp +++ b/bsnes/phoenix/qt/progressbar.cpp @@ -1,8 +1,3 @@ -void ProgressBar::setParent(Layout &parent) { - progressBar->setParent(parent.widget->widget); - progressBar->show(); -} - void ProgressBar::setPosition(unsigned position) { progressBar->setValue(position); } diff --git a/bsnes/phoenix/qt/qt.cpp b/bsnes/phoenix/qt/qt.cpp index a81fed0d..e5421472 100755 --- a/bsnes/phoenix/qt/qt.cpp +++ b/bsnes/phoenix/qt/qt.cpp @@ -14,6 +14,8 @@ namespace phoenix { #include "widget.cpp" #include "layout.cpp" #include "fixed-layout.cpp" +#include "horizontal-layout.cpp" +#include "vertical-layout.cpp" #include "button.cpp" #include "canvas.cpp" #include "checkbox.cpp" diff --git a/bsnes/phoenix/qt/qt.hpp b/bsnes/phoenix/qt/qt.hpp index 64277a77..d7f697cc 100755 --- a/bsnes/phoenix/qt/qt.hpp +++ b/bsnes/phoenix/qt/qt.hpp @@ -112,28 +112,13 @@ struct MenuRadioItem : Action { Data *menuRadioItem; }; -struct Window; struct Layout; +struct Widget; -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); - bool enabled(); - void setEnabled(bool enabled = true); - virtual bool focused(); - virtual void setFocused(); - Widget(); -//private: - struct Data; - Data *widget; -}; - -struct Window : Widget { +struct Window : Object { nall::function onClose; + nall::function onMove; + nall::function onResize; void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = ""); void setLayout(Layout &layout); Geometry geometry(); @@ -143,6 +128,7 @@ struct Window : Widget { void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue); void setTitle(const nall::string &text); void setStatusText(const nall::string &text); + void setVisible(bool visible = true); void setMenuVisible(bool visible = true); void setStatusVisible(bool visible = true); bool focused(); @@ -155,8 +141,10 @@ struct Window : Widget { static Window None; }; -struct Layout : Widget { - virtual void create(Window &parent) = 0; +struct Layout : Object { + virtual void setParent(Window &parent); + virtual void update(Geometry &geometry); + void setMargin(unsigned margin); Layout(); //private: struct Data; @@ -164,18 +152,58 @@ struct Layout : Widget { }; struct FixedLayout : Layout { + void setParent(Window &parent); void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height); - void create(Window &parent); + void update(Geometry &geometry); FixedLayout(); - //private: struct Data; Data *fixedLayout; }; +struct HorizontalLayout; +struct VerticalLayout; + +struct HorizontalLayout : Layout { + void setParent(Window &parent); + void append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0); + void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0); + void update(Geometry &geometry); + HorizontalLayout(); +//private: + struct Data; + Data *horizontalLayout; +}; + +struct VerticalLayout : Layout { + void setParent(Window &parent); + void append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0); + void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0); + void update(Geometry &geometry); + VerticalLayout(); +//private: + struct Data; + Data *verticalLayout; +}; + +struct Widget : Object { + virtual Geometry geometry(); + virtual void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height); + void setFont(Font &font); + bool visible(); + void setVisible(bool visible = true); + bool enabled(); + void setEnabled(bool enabled = true); + bool focused(); + void setFocused(); + Widget(); +//private: + struct Data; + Data *widget; +}; + struct Button : Widget { nall::function onTick; - void setParent(Layout &parent); void setText(const nall::string &text); Button(); //private: @@ -184,7 +212,6 @@ struct Button : Widget { }; struct Canvas : Widget { - void setParent(Layout &parent); void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height); uint32_t* buffer(); void redraw(); @@ -197,7 +224,6 @@ struct Canvas : Widget { struct CheckBox : Widget { nall::function onTick; - void setParent(Layout &parent); void setText(const nall::string &text); bool checked(); void setChecked(bool checked = true); @@ -209,7 +235,6 @@ struct CheckBox : Widget { struct ComboBox : Widget { nall::function onChange; - void setParent(Layout &parent); void reset(); void addItem(const nall::string &text); unsigned selection(); @@ -222,7 +247,6 @@ struct ComboBox : Widget { struct EditBox : Widget { nall::function onChange; - void setParent(Layout &parent); void setEditable(bool editable = true); void setWordWrap(bool wordWrap = true); nall::string text(); @@ -237,7 +261,6 @@ struct EditBox : Widget { struct HexEditor : Widget { nall::function onRead; nall::function onWrite; - void setParent(Layout &parent); void setSize(unsigned size); void setOffset(unsigned offset); void setColumns(unsigned columns); @@ -251,7 +274,6 @@ struct HexEditor : Widget { struct HorizontalSlider : Widget { nall::function onChange; - void setParent(Layout &parent); void setLength(unsigned length); unsigned position(); void setPosition(unsigned position); @@ -262,7 +284,6 @@ struct HorizontalSlider : Widget { }; struct Label : Widget { - void setParent(Layout &layout); void setText(const nall::string &text); Label(); //private: @@ -274,7 +295,6 @@ struct ListBox : Widget { nall::function onActivate; nall::function onChange; nall::function onTick; - void setParent(Layout &parent); void setHeaderText(const nall::string &text); void setHeaderVisible(bool headerVisible = true); void setCheckable(bool checkable = true); @@ -293,7 +313,6 @@ struct ListBox : Widget { }; struct ProgressBar : Widget { - void setParent(Layout &parent); void setPosition(unsigned position); ProgressBar(); //private: @@ -303,7 +322,6 @@ struct ProgressBar : Widget { struct RadioBox : Widget { nall::function onTick; - void setParent(Layout &parent); void setParent(RadioBox &parent); void setText(const nall::string &text); bool checked(); @@ -317,7 +335,6 @@ struct RadioBox : Widget { struct TextBox : Widget { nall::function onActivate; nall::function onChange; - void setParent(Layout &parent); void setEditable(bool editable = true); nall::string text(); void setText(const nall::string &text); @@ -329,7 +346,6 @@ struct TextBox : Widget { struct VerticalSlider : Widget { nall::function onChange; - void setParent(Layout &parent); void setLength(unsigned length); unsigned position(); void setPosition(unsigned position); @@ -340,7 +356,6 @@ struct VerticalSlider : Widget { }; struct Viewport : Widget { - void setParent(Layout &parent); uintptr_t handle(); Viewport(); //private: diff --git a/bsnes/phoenix/qt/qt.moc b/bsnes/phoenix/qt/qt.moc index 9bebe987..4039970e 100755 --- a/bsnes/phoenix/qt/qt.moc +++ b/bsnes/phoenix/qt/qt.moc @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'qt.moc.hpp' ** -** Created: Thu Feb 3 18:21:19 2011 +** Created: Fri Feb 4 22:10:00 2011 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2) ** ** WARNING! All changes made in this file will be lost! @@ -193,104 +193,6 @@ 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(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(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: @@ -340,6 +242,202 @@ int Window::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a) return _id; 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 = { + { &QObject::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(const_cast< Data*>(this)); + return QObject::qt_metacast(_clname); +} + +int Layout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::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 = { + { &QObject::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(const_cast< Data*>(this)); + return QObject::qt_metacast(_clname); +} + +int FixedLayout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} +static const uint qt_meta_data_HorizontalLayout__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_HorizontalLayout__Data[] = { + "HorizontalLayout::Data\0" +}; + +const QMetaObject HorizontalLayout::Data::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_HorizontalLayout__Data, + qt_meta_data_HorizontalLayout__Data, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &HorizontalLayout::Data::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *HorizontalLayout::Data::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *HorizontalLayout::Data::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_HorizontalLayout__Data)) + return static_cast(const_cast< Data*>(this)); + return QObject::qt_metacast(_clname); +} + +int HorizontalLayout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} +static const uint qt_meta_data_VerticalLayout__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_VerticalLayout__Data[] = { + "VerticalLayout::Data\0" +}; + +const QMetaObject VerticalLayout::Data::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_VerticalLayout__Data, + qt_meta_data_VerticalLayout__Data, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &VerticalLayout::Data::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *VerticalLayout::Data::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *VerticalLayout::Data::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_VerticalLayout__Data)) + return static_cast(const_cast< Data*>(this)); + return QObject::qt_metacast(_clname); +} + +int VerticalLayout::Data::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} static const uint qt_meta_data_Button__Data[] = { // content: diff --git a/bsnes/phoenix/qt/qt.moc.hpp b/bsnes/phoenix/qt/qt.moc.hpp index f45108d1..3b60a37c 100755 --- a/bsnes/phoenix/qt/qt.moc.hpp +++ b/bsnes/phoenix/qt/qt.moc.hpp @@ -81,26 +81,84 @@ public slots: } }; -struct Widget::Data { -public: - Widget &self; - QWidget *widget; +struct Window::Data : public QWidget { + Q_OBJECT - Data(Widget &self) : self(self) { +public: + Window &self; + unsigned x, y, width, height; + bool fullscreen, menuVisible, statusVisible; + Layout *layout; + QFont *defaultFont; + QVBoxLayout *vlayout; + QMenuBar *menuBar; + QStatusBar *statusBar; + QWidget *container; + + QSize sizeHint() const { + unsigned actualHeight = height; + if(menuVisible) actualHeight += menuBar->height(); + if(statusVisible) actualHeight += statusBar->height(); + return QSize(width, actualHeight); + } + + void closeEvent(QCloseEvent *event) { + if(self.onClose) { + bool result = self.onClose(); + if(result == false) event->ignore(); + } + } + + void moveEvent(QMoveEvent *event) { + if(fullscreen == false && isVisible() == true) { + x = frameGeometry().x(); + y = frameGeometry().y(); + } + + if(self.onMove) { + self.onMove(); + } + } + + void resizeEvent(QResizeEvent *event) { + if(fullscreen == false && isVisible() == true) { + width = container->geometry().width(); + height = container->geometry().height(); + } + + if(layout) { + Geometry geom = self.geometry(); + geom.x = geom.y = 0; + layout->update(geom); + } + + if(self.onResize) { + self.onResize(); + } + } + + Data(Window &self) : self(self) { + fullscreen = false; + menuVisible = false; + statusVisible = false; } }; -struct Layout::Data : public QWidget { +struct Layout::Data : public QObject { Q_OBJECT public: Layout &self; + Window *parent; + unsigned margin; Data(Layout &self) : self(self) { + parent = 0; + margin = 0; } }; -struct FixedLayout::Data : public QWidget { +struct FixedLayout::Data : public QObject { Q_OBJECT public: @@ -117,26 +175,47 @@ public: } }; -struct Window::Data : public QWidget { +struct HorizontalLayout::Data : public QObject { Q_OBJECT public: - Window &self; - Layout *layout; - QFont *defaultFont; - QVBoxLayout *vlayout; - QMenuBar *menuBar; - QWidget *container; - QStatusBar *statusBar; + HorizontalLayout &self; + struct Children { + VerticalLayout *layout; + Widget *widget; + unsigned width, height, spacing; + }; + linear_vector children; - void closeEvent(QCloseEvent *event) { - if(self.onClose) { - bool result = self.onClose(); - if(result == false) event->ignore(); - } + Data(HorizontalLayout &self) : self(self) { } +}; - Data(Window &self) : self(self) { +struct VerticalLayout::Data : public QObject { + Q_OBJECT + +public: + VerticalLayout &self; + struct Children { + HorizontalLayout *layout; + Widget *widget; + unsigned width, height, spacing; + }; + linear_vector children; + + Data(VerticalLayout &self) : self(self) { + } +}; + +struct Widget::Data { +public: + Widget &self; + QWidget *widget; + Font *font; + + Data(Widget &self) : self(self) { + widget = 0; + font = 0; } }; diff --git a/bsnes/phoenix/qt/radiobox.cpp b/bsnes/phoenix/qt/radiobox.cpp index a95f2d3e..c2642b4b 100755 --- a/bsnes/phoenix/qt/radiobox.cpp +++ b/bsnes/phoenix/qt/radiobox.cpp @@ -1,8 +1,3 @@ -void RadioBox::setParent(Layout &parent) { - radioBox->setParent(parent.widget->widget); - radioBox->show(); -} - void RadioBox::setParent(RadioBox &parent) { parent.radioBox->buttonGroup->addButton(radioBox); parent.radioBox->setChecked(true); diff --git a/bsnes/phoenix/qt/textbox.cpp b/bsnes/phoenix/qt/textbox.cpp index ea2a7854..1e0e9d59 100755 --- a/bsnes/phoenix/qt/textbox.cpp +++ b/bsnes/phoenix/qt/textbox.cpp @@ -1,8 +1,3 @@ -void TextBox::setParent(Layout &parent) { - textBox->setParent(parent.widget->widget); - textBox->show(); -} - void TextBox::setEditable(bool editable) { textBox->setReadOnly(editable == false); } diff --git a/bsnes/phoenix/qt/vertical-layout.cpp b/bsnes/phoenix/qt/vertical-layout.cpp new file mode 100755 index 00000000..e3085d21 --- /dev/null +++ b/bsnes/phoenix/qt/vertical-layout.cpp @@ -0,0 +1,70 @@ +void VerticalLayout::setParent(Window &parent) { + Layout::setParent(parent); + foreach(child, verticalLayout->children) { + if(child.layout) { + child.layout->setParent(parent); + } + + if(child.widget) { + child.widget->widget->widget->setParent(layout->parent->window->container); + if(!child.widget->widget->font && layout->parent->window->defaultFont) { + QWidget *control = child.widget->widget->widget; + control->setFont(*layout->parent->window->defaultFont); + } + } + } +} + +void VerticalLayout::append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing) { + verticalLayout->children.append({ &layout, 0, width, height, spacing }); +} + +void VerticalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) { + verticalLayout->children.append({ 0, &widget, width, height, spacing }); +} + +void VerticalLayout::update(Geometry &geometry) { + Layout::update(geometry); + Geometry baseGeometry = geometry; + linear_vector children = verticalLayout->children; + + unsigned minimumHeight = 0; + foreach(child, children) minimumHeight += child.height + child.spacing; + + unsigned autosizeWidgets = 0; + foreach(child, children) { + if(child.height == 0) autosizeWidgets++; + } + foreach(child, children) { + if(child.width == 0) child.width = geometry.width; + if(child.height == 0) child.height = (geometry.height - minimumHeight) / autosizeWidgets; + } + + unsigned maxWidth = 0; + foreach(child, children) { + maxWidth = max(maxWidth, child.width); + } + + foreach(child, children) { + if(child.layout) { + child.layout->update(geometry); + geometry.x = baseGeometry.x; + geometry.width = baseGeometry.width; + geometry.y += child.spacing; + geometry.height -= child.spacing; + } + + if(child.widget) { + child.widget->setGeometry(geometry.x, geometry.y, child.width, child.height); + geometry.y += child.height + child.spacing; + geometry.height -= child.height + child.spacing; + } + } + + geometry.x += maxWidth; + geometry.width -= maxWidth; +} + +VerticalLayout::VerticalLayout() { + verticalLayout = new VerticalLayout::Data(*this); +} diff --git a/bsnes/phoenix/qt/verticalslider.cpp b/bsnes/phoenix/qt/verticalslider.cpp index f0d6d226..0cfaab7a 100755 --- a/bsnes/phoenix/qt/verticalslider.cpp +++ b/bsnes/phoenix/qt/verticalslider.cpp @@ -1,8 +1,3 @@ -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); diff --git a/bsnes/phoenix/qt/viewport.cpp b/bsnes/phoenix/qt/viewport.cpp index 311cf5af..707d6e69 100755 --- a/bsnes/phoenix/qt/viewport.cpp +++ b/bsnes/phoenix/qt/viewport.cpp @@ -1,8 +1,3 @@ -void Viewport::setParent(Layout &parent) { - viewport->setParent(parent.widget->widget); - viewport->show(); -} - uintptr_t Viewport::handle() { return (uintptr_t)viewport->winId(); } diff --git a/bsnes/phoenix/qt/widget.cpp b/bsnes/phoenix/qt/widget.cpp index 9510607a..03668fdf 100755 --- a/bsnes/phoenix/qt/widget.cpp +++ b/bsnes/phoenix/qt/widget.cpp @@ -1,8 +1,16 @@ +Geometry Widget::geometry() { + return { + widget->widget->x(), widget->widget->y(), + widget->widget->width(), widget->widget->height() + }; +} + void Widget::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) { widget->widget->setGeometry(x, y, width, height); } void Widget::setFont(Font &font) { + widget->font = &font; widget->widget->setFont(*font.font); } diff --git a/bsnes/phoenix/qt/window.cpp b/bsnes/phoenix/qt/window.cpp index c5261c63..b395201b 100755 --- a/bsnes/phoenix/qt/window.cpp +++ b/bsnes/phoenix/qt/window.cpp @@ -1,12 +1,9 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) { window->setWindowTitle(QString::fromUtf8(text)); - window->move(x, y); 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); @@ -14,7 +11,7 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con window->vlayout->addWidget(window->menuBar); window->container = new QWidget(window); - window->container->setFixedSize(width, height); + window->container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); window->container->setVisible(true); window->vlayout->addWidget(window->container); @@ -22,20 +19,33 @@ void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, con window->statusBar->setSizeGripEnabled(false); window->statusBar->setVisible(false); window->vlayout->addWidget(window->statusBar); + + setGeometry(x, y, width, height); } void Window::setLayout(Layout &layout) { window->layout = &layout; - layout.create(*this); + + Geometry geom = geometry(); + geom.x = geom.y = 0; + layout.setParent(*this); + layout.update(geom); } Geometry Window::geometry() { - return Geometry(window->x(), window->y(), window->container->width(), window->container->height()); + //QWidget::geometry() is not at all reliable + if(window->fullscreen == false) return { window->x, window->y, window->width, window->height }; + return { 0, 0, OS::desktopWidth(), OS::desktopHeight() }; } void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) { - window->container->setFixedSize(width, height); + window->x = x; + window->y = y; + window->width = width; + window->height = height; + window->move(x, y); + window->adjustSize(); } void Window::setDefaultFont(Font &font) { @@ -62,12 +72,23 @@ void Window::setStatusText(const string &text) { window->statusBar->showMessage(QString::fromUtf8(text), 0); } +void Window::setVisible(bool visible) { + if(visible) { + window->show(); + window->adjustSize(); + } else { + window->hide(); + } +} + void Window::setMenuVisible(bool visible) { + window->menuVisible = visible; if(visible) window->menuBar->show(); else window->menuBar->hide(); } void Window::setStatusVisible(bool visible) { + window->statusVisible = visible; if(visible) window->statusBar->show(); else window->statusBar->hide(); } @@ -81,34 +102,17 @@ bool Window::fullscreen() { } void Window::setFullscreen(bool fullscreen) { + window->fullscreen = fullscreen; + if(fullscreen == false) { - window->vlayout->setSizeConstraint(QLayout::SetFixedSize); window->showNormal(); + window->adjustSize(); } else { - window->vlayout->setSizeConstraint(QLayout::SetNoConstraint); - window->container->setFixedSize(OS::desktopWidth(), OS::desktopHeight()); window->showFullScreen(); } - - //Qt returns negative coordinates for x,y immediately after setFullscreen(false) - //wait for Qt to return sane values, or until timeout occurs - Geometry geom; - time_t startTime = time(0); - do { - OS::run(); - 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() { window = new Window::Data(*this); window->defaultFont = 0; - widget->widget = window; } diff --git a/bsnes/snes/cheat/cheat.cpp b/bsnes/snes/cheat/cheat.cpp index 5528a93d..4a51c4a8 100755 --- a/bsnes/snes/cheat/cheat.cpp +++ b/bsnes/snes/cheat/cheat.cpp @@ -77,7 +77,6 @@ void Cheat::init() { Cheat::Cheat() { lookup = new uint8[16 * 1024 * 1024]; system_enabled = true; - synchronize(); } Cheat::~Cheat() { diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index bc753ebd..7501b7c9 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,12 +1,12 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "075.07"; + static const char Version[] = "075.08"; static const unsigned SerializerVersion = 18; } } -#define DEBUGGER +//#define DEBUGGER #include diff --git a/bsnes/ui/debugger/console.cpp b/bsnes/ui/debugger/console.cpp index b233c57f..1df20688 100755 --- a/bsnes/ui/debugger/console.cpp +++ b/bsnes/ui/debugger/console.cpp @@ -1,7 +1,7 @@ Console console; void Console::create() { - Window::create(0, 0, 256, 256, "Console"); + Window::create(0, 0, 715, 350, "Console"); application.addWindow(this, "Debugger.Console", "192,192"); output.setFont(application.monospaceFont); @@ -14,7 +14,18 @@ void Console::create() { traceCPU.setChecked(true); clearConsole.setText("Clear console"); - unsigned x = 5, y = 5; + layout.setMargin(5); + layout.append(output, 0, 0, 5); + controlLayout.append(traceToConsole, 120, Style::CheckBoxHeight); + controlLayout.append(traceToFile, 120, Style::CheckBoxHeight); + controlLayout.append(traceCPU, 120, Style::CheckBoxHeight); + controlLayout.append(traceSMP, 120, Style::CheckBoxHeight); + controlLayout.append(spacer, 120, 0, Style::CheckBoxHeight); + controlLayout.append(clearConsole, 120, Style::ButtonHeight); + layout.append(controlLayout, 120, 0); + setLayout(layout); + +/*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; @@ -22,7 +33,7 @@ void Console::create() { 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); + setLayout(layout);*/ onClose = []() { debugger.showConsole.setChecked(false); diff --git a/bsnes/ui/debugger/console.hpp b/bsnes/ui/debugger/console.hpp index 05497025..088436e4 100755 --- a/bsnes/ui/debugger/console.hpp +++ b/bsnes/ui/debugger/console.hpp @@ -1,10 +1,12 @@ struct Console : TopLevelWindow { - FixedLayout layout; + HorizontalLayout layout; EditBox output; + VerticalLayout controlLayout; CheckBox traceToConsole; CheckBox traceToFile; CheckBox traceCPU; CheckBox traceSMP; + Label spacer; Button clearConsole; string buffer; diff --git a/bsnes/ui/debugger/cpu/debugger.cpp b/bsnes/ui/debugger/cpu/debugger.cpp index 3f125aef..100c910d 100755 --- a/bsnes/ui/debugger/cpu/debugger.cpp +++ b/bsnes/ui/debugger/cpu/debugger.cpp @@ -1,7 +1,7 @@ CPUDebugger cpuDebugger; void CPUDebugger::create() { - Window::create(0, 0, 256, 256, "CPU Debugger"); + Window::create(0, 0, 495, 220, "CPU Debugger"); application.addWindow(this, "Debugger.CPUdebugger", "192,192"); output.setFont(application.monospaceFont); @@ -11,12 +11,12 @@ void CPUDebugger::create() { 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); + layout.setMargin(5); + layout.append(output, 0, 0, 5); + controlLayout.append(stepInto, 80, Style::ButtonHeight); + controlLayout.append(stepOver, 80, Style::ButtonHeight); + controlLayout.append(proceed, 80, Style::ButtonHeight); + layout.append(controlLayout, 80, 0); setLayout(layout); onClose = []() { diff --git a/bsnes/ui/debugger/cpu/debugger.hpp b/bsnes/ui/debugger/cpu/debugger.hpp index 1f83bf79..6d21c01a 100755 --- a/bsnes/ui/debugger/cpu/debugger.hpp +++ b/bsnes/ui/debugger/cpu/debugger.hpp @@ -1,6 +1,7 @@ struct CPUDebugger : TopLevelWindow { - FixedLayout layout; + HorizontalLayout layout; EditBox output; + VerticalLayout controlLayout; Button stepInto; Button stepOver; Button proceed; diff --git a/bsnes/ui/debugger/debugger.cpp b/bsnes/ui/debugger/debugger.cpp index 8520b6d7..769e6261 100755 --- a/bsnes/ui/debugger/debugger.cpp +++ b/bsnes/ui/debugger/debugger.cpp @@ -18,7 +18,7 @@ void Debugger::create() { breakpointEditor.create(); memoryEditor.create(); - Window::create(0, 0, 256, 256, "Debugger"); + Window::create(0, 0, 256, 80, "Debugger"); application.addWindow(this, "Debugger", "160,160"); enableDebugger.setText("Enable debugger"); @@ -28,7 +28,16 @@ void Debugger::create() { showBreakpointEditor.setText("Breakpoint editor"); showMemoryEditor.setText("Memory editor"); - unsigned x = 5, y = 5; + layout.setMargin(5); + layout.append(enableDebugger, 0, Style::CheckBoxHeight); + layout.append(showConsole, 0, Style::CheckBoxHeight); + layout.append(showCPUDebugger, 0, Style::CheckBoxHeight); + layout.append(showSMPDebugger, 0, Style::CheckBoxHeight); + layout.append(showBreakpointEditor, 0, Style::CheckBoxHeight); + layout.append(showMemoryEditor, 0, Style::CheckBoxHeight); + setLayout(layout); + +/*unsigned x = 5, y = 5; 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; @@ -36,7 +45,7 @@ void Debugger::create() { 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); + setLayout(layout);*/ //windows shown by default showConsole.setChecked(); diff --git a/bsnes/ui/debugger/debugger.hpp b/bsnes/ui/debugger/debugger.hpp index 8048039b..0e25a96f 100755 --- a/bsnes/ui/debugger/debugger.hpp +++ b/bsnes/ui/debugger/debugger.hpp @@ -12,7 +12,7 @@ struct Debugger : TopLevelWindow { StepIntoSMP, } debugMode; - FixedLayout layout; + VerticalLayout layout; CheckBox enableDebugger; CheckBox showConsole; CheckBox showCPUDebugger; diff --git a/bsnes/ui/debugger/smp/debugger.cpp b/bsnes/ui/debugger/smp/debugger.cpp index e162da7b..0b4444f1 100755 --- a/bsnes/ui/debugger/smp/debugger.cpp +++ b/bsnes/ui/debugger/smp/debugger.cpp @@ -1,7 +1,7 @@ SMPDebugger smpDebugger; void SMPDebugger::create() { - Window::create(0, 0, 256, 256, "SMP Debugger"); + Window::create(0, 0, 495, 220, "SMP Debugger"); application.addWindow(this, "Debugger.SMPDebugger", "192,192"); output.setFont(application.monospaceFont); @@ -11,12 +11,12 @@ void SMPDebugger::create() { 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); + layout.setMargin(5); + layout.append(output, 0, 0, 5); + controlLayout.append(stepInto, 80, Style::ButtonHeight); + controlLayout.append(stepOver, 80, Style::ButtonHeight); + controlLayout.append(proceed, 80, Style::ButtonHeight); + layout.append(controlLayout, 80, 0); setLayout(layout); onClose = []() { diff --git a/bsnes/ui/debugger/smp/debugger.hpp b/bsnes/ui/debugger/smp/debugger.hpp index ebb408fc..c3837bb9 100755 --- a/bsnes/ui/debugger/smp/debugger.hpp +++ b/bsnes/ui/debugger/smp/debugger.hpp @@ -1,6 +1,7 @@ struct SMPDebugger : TopLevelWindow { - FixedLayout layout; + HorizontalLayout layout; EditBox output; + VerticalLayout controlLayout; Button stepInto; Button stepOver; Button proceed; diff --git a/bsnes/ui/debugger/tools/breakpoint-editor.cpp b/bsnes/ui/debugger/tools/breakpoint-editor.cpp index e449a3d2..e09548bc 100755 --- a/bsnes/ui/debugger/tools/breakpoint-editor.cpp +++ b/bsnes/ui/debugger/tools/breakpoint-editor.cpp @@ -1,7 +1,7 @@ BreakpointEditor breakpointEditor; void BreakpointEditor::create() { - Window::create(0, 0, 256, 256, "Breakpoint Editor"); + Window::create(0, 0, 310, 240, "Breakpoint Editor"); application.addWindow(this, "Debugger.BreakpointEditor", "192,192"); runToBreakpoint.setText("Run to breakpoint"); @@ -18,7 +18,19 @@ void BreakpointEditor::create() { enableBox[n].onTick = [n]() { breakpointEditor.toggleBreakpoint(n); }; } - unsigned x = 5, y = 5; + layout.setMargin(5); + layout.append(runToBreakpoint, 0, Style::CheckBoxHeight, 5); + for(unsigned n = 0; n < Breakpoints; n++) { + breakpointLayout[n].append(enableBox[n], 35, Style::EditBoxHeight); + breakpointLayout[n].append(addressBox[n], 60, Style::EditBoxHeight, 5); + breakpointLayout[n].append(valueBox[n], 30, Style::EditBoxHeight, 5); + breakpointLayout[n].append(typeBox[n], 80, Style::EditBoxHeight, 5); + breakpointLayout[n].append(sourceBox[n], 80, Style::EditBoxHeight); + layout.append(breakpointLayout[n], 0, Style::EditBoxHeight, 5); + } + setLayout(layout); + +/*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); @@ -28,7 +40,7 @@ void BreakpointEditor::create() { layout.append(sourceBox[n], x + 220, y, 80, Style::EditBoxHeight); y += Style::EditBoxHeight + 5; } setGeometry(0, 0, 310, y); - setLayout(layout); + setLayout(layout);*/ runToBreakpoint.onTick = []() { if(breakpointEditor.runToBreakpoint.checked()) { diff --git a/bsnes/ui/debugger/tools/breakpoint-editor.hpp b/bsnes/ui/debugger/tools/breakpoint-editor.hpp index 0a70911c..0248ca5e 100755 --- a/bsnes/ui/debugger/tools/breakpoint-editor.hpp +++ b/bsnes/ui/debugger/tools/breakpoint-editor.hpp @@ -1,7 +1,8 @@ struct BreakpointEditor : TopLevelWindow { enum : unsigned { Breakpoints = SNES::Debugger::Breakpoints }; - FixedLayout layout; + VerticalLayout layout; CheckBox runToBreakpoint; + HorizontalLayout breakpointLayout[Breakpoints]; CheckBox enableBox[Breakpoints]; TextBox addressBox[Breakpoints]; TextBox valueBox[Breakpoints]; diff --git a/bsnes/ui/debugger/tools/memory-editor.cpp b/bsnes/ui/debugger/tools/memory-editor.cpp index 408ab600..76b06f48 100755 --- a/bsnes/ui/debugger/tools/memory-editor.cpp +++ b/bsnes/ui/debugger/tools/memory-editor.cpp @@ -1,9 +1,10 @@ MemoryEditor memoryEditor; void MemoryEditor::create() { - Window::create(0, 0, 256, 256, "Memory Editor"); + Window::create(0, 0, 570, 230, "Memory Editor"); application.addWindow(this, "Debugger.MemoryEditor", "192,192"); + editor.setFont(application.monospaceFont); editor.setColumns(16); editor.setRows(16); sourceBox.addItem("CPU"); @@ -13,16 +14,14 @@ void MemoryEditor::create() { sourceBox.addItem("CGRAM"); refreshButton.setText("Refresh"); - 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); + layout.setMargin(5); + layout.append(editor, 0, 0, 5); + controlLayout.append(sourceBox, 80, Style::ComboBoxHeight); + controlLayout.append(gotoBox, 80, Style::ComboBoxHeight); + controlLayout.append(refreshButton, 80, Style::ComboBoxHeight); + layout.append(controlLayout, 80, 0); setLayout(layout); - editor.setFont(application.monospaceFont); - onClose = []() { debugger.showMemoryEditor.setChecked(false); return true; diff --git a/bsnes/ui/debugger/tools/memory-editor.hpp b/bsnes/ui/debugger/tools/memory-editor.hpp index 799a4305..4f6d9944 100755 --- a/bsnes/ui/debugger/tools/memory-editor.hpp +++ b/bsnes/ui/debugger/tools/memory-editor.hpp @@ -1,6 +1,7 @@ struct MemoryEditor : TopLevelWindow { - FixedLayout layout; + HorizontalLayout layout; HexEditor editor; + VerticalLayout controlLayout; ComboBox sourceBox; TextBox gotoBox; Button refreshButton; diff --git a/bsnes/ui/general/file-browser.cpp b/bsnes/ui/general/file-browser.cpp index d7a364b4..9c5a82f1 100755 --- a/bsnes/ui/general/file-browser.cpp +++ b/bsnes/ui/general/file-browser.cpp @@ -1,19 +1,18 @@ FileBrowser fileBrowser; void FileBrowser::create() { - Window::create(0, 0, 256, 256); + Window::create(0, 0, 640, 400); application.addWindow(this, "FileBrowser", "160,160"); - unsigned x = 5, y = 5, height = Style::TextBoxHeight; - 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); + layout.setMargin(5); + pathLayout.append(pathBox, 0, Style::TextBoxHeight, 5); + pathLayout.append(browseButton, Style::TextBoxHeight, Style::TextBoxHeight, 5); + pathLayout.append(upButton, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(pathLayout, 0, Style::TextBoxHeight, 5); + layout.append(contentsBox, 0, 0); setLayout(layout); pathBox.onActivate = []() { diff --git a/bsnes/ui/general/file-browser.hpp b/bsnes/ui/general/file-browser.hpp index 5bbbf9f1..4efa8a16 100755 --- a/bsnes/ui/general/file-browser.hpp +++ b/bsnes/ui/general/file-browser.hpp @@ -1,5 +1,6 @@ struct FileBrowser : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; + HorizontalLayout pathLayout; TextBox pathBox; Button browseButton; Button upButton; diff --git a/bsnes/ui/general/slot-loader.cpp b/bsnes/ui/general/slot-loader.cpp index e99c8e0d..fd7a4e4f 100755 --- a/bsnes/ui/general/slot-loader.cpp +++ b/bsnes/ui/general/slot-loader.cpp @@ -2,25 +2,27 @@ SingleSlotLoader singleSlotLoader; DoubleSlotLoader doubleSlotLoader; void SingleSlotLoader::create() { - Window::create(0, 0, 256, 256); + Window::create(0, 0, 480, 80); application.addWindow(this, "SingleSlotLoader", "160,160"); - unsigned x = 5, y = 5, height = Style::TextBoxHeight, width = 365 + height; - 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); + layout.setMargin(5); + baseLayout.append(baseLabel, 40, Style::TextBoxHeight, 5); + baseLayout.append(basePath, 0, Style::TextBoxHeight, 5); + baseLayout.append(baseBrowse, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(baseLayout, 0, Style::TextBoxHeight, 5); + slotLayout.append(slotLabel, 40, Style::TextBoxHeight, 5); + slotLayout.append(slotPath, 0, Style::TextBoxHeight, 5); + slotLayout.append(slotBrowse, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(slotLayout, 0, Style::TextBoxHeight, 5); + controlLayout.append(spacer, 0, Style::ButtonHeight); + controlLayout.append(okButton, 80, Style::ButtonHeight); + layout.append(controlLayout, 0, Style::ButtonHeight); setLayout(layout); baseBrowse.onTick = []() { @@ -91,11 +93,9 @@ void SingleSlotLoader::load() { // void DoubleSlotLoader::create() { - Window::create(0, 0, 256, 256); + Window::create(0, 0, 480, 115); application.addWindow(this, "DoubleSlotLoader", "160,160"); - unsigned x = 5, y = 5, height = Style::TextBoxHeight, width = 365 + height; - baseLabel.setText("Base:"); baseBrowse.setText("..."); slotALabel.setText("Slot A:"); @@ -104,17 +104,22 @@ void DoubleSlotLoader::create() { 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); + layout.setMargin(5); + baseLayout.append(baseLabel, 40, Style::TextBoxHeight, 5); + baseLayout.append(basePath, 0, Style::TextBoxHeight, 5); + baseLayout.append(baseBrowse, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(baseLayout, 0, Style::TextBoxHeight, 5); + slotALayout.append(slotALabel, 40, Style::TextBoxHeight, 5); + slotALayout.append(slotAPath, 0, Style::TextBoxHeight, 5); + slotALayout.append(slotABrowse, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(slotALayout, 0, Style::TextBoxHeight, 5); + slotBLayout.append(slotBLabel, 40, Style::TextBoxHeight, 5); + slotBLayout.append(slotBPath, 0, Style::TextBoxHeight, 5); + slotBLayout.append(slotBBrowse, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(slotBLayout, 0, Style::TextBoxHeight, 5); + controlLayout.append(spacer, 0, Style::ButtonHeight); + controlLayout.append(okButton, 80, Style::ButtonHeight); + layout.append(controlLayout, 0, Style::ButtonHeight); setLayout(layout); baseBrowse.onTick = []() { diff --git a/bsnes/ui/general/slot-loader.hpp b/bsnes/ui/general/slot-loader.hpp index 905aad21..3a56f462 100755 --- a/bsnes/ui/general/slot-loader.hpp +++ b/bsnes/ui/general/slot-loader.hpp @@ -1,11 +1,15 @@ struct SingleSlotLoader : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; + HorizontalLayout baseLayout; Label baseLabel; TextBox basePath; Button baseBrowse; + HorizontalLayout slotLayout; Label slotLabel; TextBox slotPath; Button slotBrowse; + HorizontalLayout controlLayout; + Label spacer; Button okButton; void create(); @@ -18,16 +22,21 @@ struct SingleSlotLoader : TopLevelWindow { }; struct DoubleSlotLoader : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; + HorizontalLayout baseLayout; Label baseLabel; TextBox basePath; Button baseBrowse; + HorizontalLayout slotALayout; Label slotALabel; TextBox slotAPath; Button slotABrowse; + HorizontalLayout slotBLayout; Label slotBLabel; TextBox slotBPath; Button slotBBrowse; + HorizontalLayout controlLayout; + Label spacer; Button okButton; void create(); diff --git a/bsnes/ui/interface.cpp b/bsnes/ui/interface.cpp index 5ee935cf..07c6ba2d 100755 --- a/bsnes/ui/interface.cpp +++ b/bsnes/ui/interface.cpp @@ -79,6 +79,11 @@ void Filter::render(uint32_t *output, unsigned outpitch, const uint16_t *input, } void Interface::video_refresh(const uint16_t *data, unsigned width, unsigned height) { + //TODO: this should not be necessary ... somehow window is not updated otherwise + mainWindow.viewport.setGeometry( + utility.viewportX, utility.viewportY, utility.viewportWidth, utility.viewportHeight + ); + bool interlace = (height >= 240); bool overscan = (height == 239 || height == 478); unsigned inpitch = interlace ? 1024 : 2048; diff --git a/bsnes/ui/settings/advanced.cpp b/bsnes/ui/settings/advanced.cpp index 6ce1f533..1a37fb2d 100755 --- a/bsnes/ui/settings/advanced.cpp +++ b/bsnes/ui/settings/advanced.cpp @@ -1,11 +1,9 @@ AdvancedSettings advancedSettings; void AdvancedSettings::create() { - Window::create(0, 0, 256, 256, "Advanced Settings"); + Window::create(0, 0, 640, 80, "Advanced Settings"); application.addWindow(this, "AdvancedSettings", "160,160"); - unsigned x = 5, y = 5; - driverSelectionLabel.setText("Driver Selection :."); driverSelectionLabel.setFont(application.proportionalFontBold); videoDriverLabel.setText("Video:"); @@ -22,6 +20,23 @@ void AdvancedSettings::create() { if(config.settings.focusPolicy == 1) focusPolicyIgnore.setChecked(); if(config.settings.focusPolicy == 2) focusPolicyAllow.setChecked(); + layout.setMargin(5); + layout.append(driverSelectionLabel, 0, Style::LabelHeight); + driverLayout.append(videoDriverLabel, 40, Style::ComboBoxHeight, 5); + driverLayout.append(videoDriverBox, 0, Style::ComboBoxHeight, 5); + driverLayout.append(audioDriverLabel, 40, Style::ComboBoxHeight, 5); + driverLayout.append(audioDriverBox, 0, Style::ComboBoxHeight, 5); + driverLayout.append(inputDriverLabel, 40, Style::ComboBoxHeight, 5); + driverLayout.append(inputDriverBox, 0, Style::ComboBoxHeight); + layout.append(driverLayout, 0, Style::ComboBoxHeight, 5); + layout.append(focusPolicyLabel, 0, Style::LabelHeight); + focusPolicyLayout.append(focusPolicyPause, 0, Style::CheckBoxHeight, 5); + focusPolicyLayout.append(focusPolicyIgnore, 0, Style::CheckBoxHeight, 5); + focusPolicyLayout.append(focusPolicyAllow, 0, Style::CheckBoxHeight); + layout.append(focusPolicyLayout, 0, Style::CheckBoxHeight); + setLayout(layout); + +/*unsigned x = 5, y = 5; 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); @@ -34,7 +49,7 @@ void AdvancedSettings::create() { 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); + setLayout(layout);*/ lstring list; diff --git a/bsnes/ui/settings/advanced.hpp b/bsnes/ui/settings/advanced.hpp index 57db6ce5..6676636a 100755 --- a/bsnes/ui/settings/advanced.hpp +++ b/bsnes/ui/settings/advanced.hpp @@ -1,6 +1,7 @@ struct AdvancedSettings : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; Label driverSelectionLabel; + HorizontalLayout driverLayout; Label videoDriverLabel; ComboBox videoDriverBox; Label audioDriverLabel; @@ -8,6 +9,7 @@ struct AdvancedSettings : TopLevelWindow { Label inputDriverLabel; ComboBox inputDriverBox; Label focusPolicyLabel; + HorizontalLayout focusPolicyLayout; RadioBox focusPolicyPause; RadioBox focusPolicyIgnore; RadioBox focusPolicyAllow; diff --git a/bsnes/ui/settings/audio.cpp b/bsnes/ui/settings/audio.cpp index 387ba4e2..d97d7873 100755 --- a/bsnes/ui/settings/audio.cpp +++ b/bsnes/ui/settings/audio.cpp @@ -1,7 +1,7 @@ AudioSettings audioSettings; void AudioSettings::create() { - Window::create(0, 0, 256, 256, "Audio Settings"); + Window::create(0, 0, 480, 50, "Audio Settings"); application.addWindow(this, "AudioSettings", "160,160"); volumeLabel.setText("Volume:"); @@ -9,7 +9,18 @@ void AudioSettings::create() { frequencyLabel.setText("Frequency:"); frequencySlider.setLength(2001); - unsigned x = 5, y = 5; + layout.setMargin(5); + volumeLayout.append(volumeLabel, 70, Style::SliderHeight); + volumeLayout.append(volumeValue, 60, Style::SliderHeight); + volumeLayout.append(volumeSlider, 0, Style::SliderHeight); + layout.append(volumeLayout, 0, Style::SliderHeight); + frequencyLayout.append(frequencyLabel, 70, Style::SliderHeight); + frequencyLayout.append(frequencyValue, 60, Style::SliderHeight); + frequencyLayout.append(frequencySlider, 0, Style::SliderHeight); + layout.append(frequencyLayout, 0, Style::SliderHeight); + setLayout(layout); + +/*unsigned x = 5, y = 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; @@ -17,7 +28,7 @@ void AudioSettings::create() { 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); + setLayout(layout);*/ volumeSlider.onChange = []() { config.audio.volume = audioSettings.volumeSlider.position(); diff --git a/bsnes/ui/settings/audio.hpp b/bsnes/ui/settings/audio.hpp index 35944d0c..e67d52ed 100755 --- a/bsnes/ui/settings/audio.hpp +++ b/bsnes/ui/settings/audio.hpp @@ -1,8 +1,10 @@ struct AudioSettings : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; + HorizontalLayout volumeLayout; Label volumeLabel; Label volumeValue; HorizontalSlider volumeSlider; + HorizontalLayout frequencyLayout; Label frequencyLabel; Label frequencyValue; HorizontalSlider frequencySlider; diff --git a/bsnes/ui/settings/input.cpp b/bsnes/ui/settings/input.cpp index 4c706292..3bbb8565 100755 --- a/bsnes/ui/settings/input.cpp +++ b/bsnes/ui/settings/input.cpp @@ -2,7 +2,7 @@ InputSettings inputSettings; static InputMapper::AbstractInput *activeInput = 0; void InputSettings::create() { - Window::create(0, 0, 256, 256, "Input Settings"); + Window::create(0, 0, 640, 300, "Input Settings"); application.addWindow(this, "InputSettings", "160,160"); setFont(application.proportionalFontBold); setStatusVisible(); @@ -23,19 +23,21 @@ void InputSettings::create() { 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); + layout.setMargin(5); + selectionLayout.append(portLabel, 50, Style::ComboBoxHeight, 5); + selectionLayout.append(portBox, 0, Style::ComboBoxHeight, 5); + selectionLayout.append(deviceLabel, 50, Style::ComboBoxHeight, 5); + selectionLayout.append(deviceBox, 0, Style::ComboBoxHeight); + layout.append(selectionLayout, 0, Style::ComboBoxHeight, 5); + layout.append(mappingList, 0, 0, 5); + mapLayout.append(mouseXaxis, 100, Style::ButtonHeight, 5); + mapLayout.append(mouseYaxis, 100, Style::ButtonHeight, 5); + mapLayout.append(mouseLeft, 100, Style::ButtonHeight, 5); + mapLayout.append(mouseMiddle, 100, Style::ButtonHeight, 5); + mapLayout.append(mouseRight, 100, Style::ButtonHeight, 5); + mapLayout.append(spacer, 0, Style::ButtonHeight); + mapLayout.append(clearButton, 80, Style::ButtonHeight); + layout.append(mapLayout, 0, Style::ButtonHeight); setLayout(layout); mouseXaxis.setVisible(false); diff --git a/bsnes/ui/settings/input.hpp b/bsnes/ui/settings/input.hpp index 2d4743ca..e2967065 100755 --- a/bsnes/ui/settings/input.hpp +++ b/bsnes/ui/settings/input.hpp @@ -1,15 +1,18 @@ struct InputSettings : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; + HorizontalLayout selectionLayout; Label portLabel; ComboBox portBox; Label deviceLabel; ComboBox deviceBox; ListBox mappingList; + HorizontalLayout mapLayout; Button mouseXaxis; Button mouseYaxis; Button mouseLeft; Button mouseMiddle; Button mouseRight; + Label spacer; Button clearButton; void inputEvent(uint16_t scancode, int16_t value); diff --git a/bsnes/ui/settings/video.cpp b/bsnes/ui/settings/video.cpp index be609e47..913fb5f3 100755 --- a/bsnes/ui/settings/video.cpp +++ b/bsnes/ui/settings/video.cpp @@ -1,11 +1,9 @@ VideoSettings videoSettings; void VideoSettings::create() { - Window::create(0, 0, 256, 256, "Video Settings"); + Window::create(0, 0, 480, 225, "Video Settings"); application.addWindow(this, "VideoSettings", "160,160"); - unsigned x = 5, y = 5, height = Style::TextBoxHeight; - colorAdjustmentLabel.setText("Color Adjustment :."); colorAdjustmentLabel.setFont(application.proportionalFontBold); brightnessLabel.setText("Brightness:"); @@ -33,30 +31,36 @@ void VideoSettings::create() { shaderPath.setText(config.video.shader); 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); + layout.setMargin(5); + layout.append(colorAdjustmentLabel, 0, Style::LabelHeight); + brightnessLayout.append(brightnessLabel, 80, Style::SliderHeight); + brightnessLayout.append(brightnessValue, 50, Style::SliderHeight); + brightnessLayout.append(brightnessSlider, 0, Style::SliderHeight); + layout.append(brightnessLayout, 0, Style::SliderHeight); + contrastLayout.append(contrastLabel, 80, Style::SliderHeight); + contrastLayout.append(contrastValue, 50, Style::SliderHeight); + contrastLayout.append(contrastSlider, 0, Style::SliderHeight); + layout.append(contrastLayout, 0, Style::SliderHeight); + gammaLayout.append(gammaLabel, 80, Style::SliderHeight); + gammaLayout.append(gammaValue, 50, Style::SliderHeight); + gammaLayout.append(gammaSlider, 0, Style::SliderHeight); + layout.append(gammaLayout, 0, Style::SliderHeight); + layout.append(gammaRampCheck, 0, Style::CheckBoxHeight, 5); + layout.append(fullscreenLabel, 0, Style::LabelHeight); + fullscreenLayout.append(fullscreenCenter, 0, Style::CheckBoxHeight); + fullscreenLayout.append(fullscreenScale, 0, Style::CheckBoxHeight); + fullscreenLayout.append(fullscreenStretch, 0, Style::CheckBoxHeight); + layout.append(fullscreenLayout, 0, Style::CheckBoxHeight, 5); + layout.append(filterLabel, 0, Style::LabelHeight); + filterLayout.append(filterPath, 0, Style::TextBoxHeight, 5); + filterLayout.append(filterClear, Style::TextBoxHeight, Style::TextBoxHeight, 5); + filterLayout.append(filterSelect, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(filterLayout, 0, Style::TextBoxHeight, 5); + layout.append(shaderLabel, 0, Style::LabelHeight); + shaderLayout.append(shaderPath, 0, Style::TextBoxHeight, 5); + shaderLayout.append(shaderClear, Style::TextBoxHeight, Style::TextBoxHeight, 5); + shaderLayout.append(shaderSelect, Style::TextBoxHeight, Style::TextBoxHeight); + layout.append(shaderLayout, 0, Style::TextBoxHeight); setLayout(layout); brightnessSlider.setPosition(config.video.brightness); diff --git a/bsnes/ui/settings/video.hpp b/bsnes/ui/settings/video.hpp index fc16949a..6321a5ba 100755 --- a/bsnes/ui/settings/video.hpp +++ b/bsnes/ui/settings/video.hpp @@ -1,28 +1,38 @@ struct VideoSettings : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; Label colorAdjustmentLabel; + Label brightnessLabel; + HorizontalLayout brightnessLayout; Label brightnessValue; HorizontalSlider brightnessSlider; + Label contrastLabel; + HorizontalLayout contrastLayout; Label contrastValue; HorizontalSlider contrastSlider; + Label gammaLabel; + HorizontalLayout gammaLayout; Label gammaValue; HorizontalSlider gammaSlider; + CheckBox gammaRampCheck; Label fullscreenLabel; + HorizontalLayout fullscreenLayout; RadioBox fullscreenCenter; RadioBox fullscreenScale; RadioBox fullscreenStretch; Label filterLabel; + HorizontalLayout filterLayout; TextBox filterPath; Button filterClear; Button filterSelect; Label shaderLabel; + HorizontalLayout shaderLayout; TextBox shaderPath; Button shaderClear; Button shaderSelect; diff --git a/bsnes/ui/tools/cheat-editor.cpp b/bsnes/ui/tools/cheat-editor.cpp index a27dcdc1..869beac0 100755 --- a/bsnes/ui/tools/cheat-editor.cpp +++ b/bsnes/ui/tools/cheat-editor.cpp @@ -79,7 +79,7 @@ void CheatEditor::save(string filename) { } void CheatEditor::create() { - Window::create(0, 0, 256, 256, "Cheat Editor"); + Window::create(0, 0, 480, 325, "Cheat Editor"); application.addWindow(this, "CheatEditor", "160,160"); cheatList.setHeaderText("Slot\tCode\tDescription"); @@ -91,16 +91,19 @@ void CheatEditor::create() { clearAllButton.setText("Clear All"); clearButton.setText("Clear"); - 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); + layout.setMargin(5); + layout.append(cheatList, 0, 0, 5); + codeLayout.append(codeLabel, 80, Style::TextBoxHeight, 5); + codeLayout.append(codeEdit, 0, Style::TextBoxHeight); + layout.append(codeLayout, 0, Style::TextBoxHeight, 5); + descLayout.append(descLabel, 80, Style::TextBoxHeight, 5); + descLayout.append(descEdit, 0, Style::TextBoxHeight); + layout.append(descLayout, 0, Style::TextBoxHeight, 5); + controlLayout.append(findButton, 100, Style::ButtonHeight); + controlLayout.append(spacer, 0, Style::ButtonHeight); + controlLayout.append(clearAllButton, 80, Style::ButtonHeight, 5); + controlLayout.append(clearButton, 80, Style::ButtonHeight); + layout.append(controlLayout, 0, Style::ButtonHeight); setLayout(layout); synchronize(); @@ -118,7 +121,7 @@ void CheatEditor::create() { }; //databaseWindow - databaseWindow.create(0, 0, 256, 256); + databaseWindow.create(0, 0, 600, 360); application.addWindow(&databaseWindow, "CheatDatabase", "192,192"); databaseList.setCheckable(true); @@ -126,12 +129,13 @@ void CheatEditor::create() { databaseUnselectAll.setText("Unselect All"); databaseOk.setText("Ok"); - 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); + databaseLayout.setMargin(5); + databaseLayout.append(databaseList, 0, 0, 5); + databaseControlLayout.append(databaseSelectAll, 100, Style::ButtonHeight, 5); + databaseControlLayout.append(databaseUnselectAll, 100, Style::ButtonHeight); + databaseControlLayout.append(databaseSpacer, 0, Style::ButtonHeight); + databaseControlLayout.append(databaseOk, 80, Style::ButtonHeight); + databaseLayout.append(databaseControlLayout, 0, Style::ButtonHeight); databaseWindow.setLayout(databaseLayout); databaseSelectAll.onTick = []() { diff --git a/bsnes/ui/tools/cheat-editor.hpp b/bsnes/ui/tools/cheat-editor.hpp index 790a1815..29e00d5a 100755 --- a/bsnes/ui/tools/cheat-editor.hpp +++ b/bsnes/ui/tools/cheat-editor.hpp @@ -1,21 +1,27 @@ struct CheatEditor : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; ListBox cheatList; + HorizontalLayout codeLayout; Label codeLabel; TextBox codeEdit; + HorizontalLayout descLayout; Label descLabel; TextBox descEdit; + HorizontalLayout controlLayout; + Label spacer; Button findButton; Button clearAllButton; Button clearButton; TopLevelWindow databaseWindow; - FixedLayout databaseLayout; + VerticalLayout databaseLayout; ListBox databaseList; - lstring databaseCode; + HorizontalLayout databaseControlLayout; Button databaseSelectAll; Button databaseUnselectAll; + Label databaseSpacer; Button databaseOk; + lstring databaseCode; void load(string filename); void save(string filename); diff --git a/bsnes/ui/tools/state-manager.cpp b/bsnes/ui/tools/state-manager.cpp index eaef9946..b00d9658 100755 --- a/bsnes/ui/tools/state-manager.cpp +++ b/bsnes/ui/tools/state-manager.cpp @@ -1,7 +1,7 @@ StateManager stateManager; void StateManager::create() { - Window::create(0, 0, 256, 256, "State Manager"); + Window::create(0, 0, 480, 300, "State Manager"); application.addWindow(this, "StateManager", "160,160"); stateList.setHeaderText("Slot\tDescription"); @@ -11,7 +11,19 @@ void StateManager::create() { saveButton.setText("Save"); eraseButton.setText("Erase"); - unsigned x = 5, y = 5; + layout.setMargin(5); + layout.append(stateList, 0, 0, 5); + descLayout.append(descLabel, 80, Style::TextBoxHeight, 5); + descLayout.append(descEdit, 0, Style::TextBoxHeight); + layout.append(descLayout, 0, Style::TextBoxHeight, 5); + controlLayout.append(spacer, 0, Style::ButtonHeight); + controlLayout.append(loadButton, 80, Style::ButtonHeight, 5); + controlLayout.append(saveButton, 80, Style::ButtonHeight, 5); + controlLayout.append(eraseButton, 80, Style::ButtonHeight); + layout.append(controlLayout, 0, Style::ButtonHeight); + setLayout(layout); + +/*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; @@ -19,7 +31,7 @@ void StateManager::create() { 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); + setLayout(layout);*/ synchronize(); diff --git a/bsnes/ui/tools/state-manager.hpp b/bsnes/ui/tools/state-manager.hpp index 4dd104fa..dc3f5003 100755 --- a/bsnes/ui/tools/state-manager.hpp +++ b/bsnes/ui/tools/state-manager.hpp @@ -1,8 +1,11 @@ struct StateManager : TopLevelWindow { - FixedLayout layout; + VerticalLayout layout; ListBox stateList; + HorizontalLayout descLayout; Label descLabel; TextBox descEdit; + HorizontalLayout controlLayout; + Label spacer; Button loadButton; Button saveButton; Button eraseButton; diff --git a/bsnes/ui/utility/utility.cpp b/bsnes/ui/utility/utility.cpp index 12a31e41..f48b9c60 100755 --- a/bsnes/ui/utility/utility.cpp +++ b/bsnes/ui/utility/utility.cpp @@ -70,6 +70,12 @@ void Utility::setScale(unsigned scale) { height = 239 * scale; if(config.video.aspectRatioCorrection) width *= 32.0 / 23.0; } + + viewportX = 0; + viewportY = 0; + viewportWidth = width; + viewportHeight = height; + mainWindow.viewport.setGeometry(0, 0, width, height); Geometry geom = mainWindow.geometry(); mainWindow.setGeometry(geom.x, geom.y, width, height); @@ -114,11 +120,12 @@ void Utility::setFullscreen(bool fullscreen) { } } - mainWindow.viewport.setGeometry( - (OS::desktopWidth() - width) / 2, - (OS::desktopHeight() - height) / 2, - width, height - ); + viewportX = (OS::desktopWidth() - width) / 2; + viewportY = (OS::desktopHeight() - height) / 2; + viewportWidth = width; + viewportHeight = height; + + mainWindow.viewport.setGeometry(viewportX, viewportY, viewportWidth, viewportHeight); } } diff --git a/bsnes/ui/utility/utility.hpp b/bsnes/ui/utility/utility.hpp index 99dd9bf4..b04fa7e6 100755 --- a/bsnes/ui/utility/utility.hpp +++ b/bsnes/ui/utility/utility.hpp @@ -18,6 +18,9 @@ struct Utility : property { Utility(); + unsigned viewportX, viewportY; + unsigned viewportWidth, viewportHeight; + private: string statusCurrentText; string statusText;