diff --git a/bsnes/Makefile b/bsnes/Makefile index d415b9d8..0ae818e5 100755 --- a/bsnes/Makefile +++ b/bsnes/Makefile @@ -1,11 +1,11 @@ include nall/Makefile snes := snes gameboy := gameboy -profile := accuracy +profile := compatibility ui := ui # debugger -options := debugger +options := # compiler c := $(compiler) -std=gnu99 diff --git a/bsnes/phoenix/core/core.cpp b/bsnes/phoenix/core/core.cpp index ee586f67..2ae68c1d 100755 --- a/bsnes/phoenix/core/core.cpp +++ b/bsnes/phoenix/core/core.cpp @@ -26,6 +26,7 @@ void OS::processEvents() { return pOS::processEvents(); } void OS::quit() { return pOS::quit(); } void OS::initialize() { static bool initialized = false; if(initialized == false) { initialized = true; return pOS::initialize(); } } +Geometry Font::geometry(const string &text) { return p.geometry(text); } void Font::setBold(bool bold) { state.bold = bold; return p.setBold(bold); } void Font::setFamily(const string &family) { state.family = family; return p.setFamily(family); } void Font::setItalic(bool italic) { state.italic = italic; return p.setItalic(italic); } @@ -87,6 +88,8 @@ void RadioItem::setText(const string &text) { state.text = text; return p.setTex RadioItem::RadioItem() : state(*new State), base_from_member(*new pRadioItem(*this)), Action(base_from_member::value), p(base_from_member::value) { p.constructor(); } bool Widget::enabled() { return state.enabled; } +Font& Widget::font() { return p.font(); } +Geometry Widget::minimumGeometry() { return p.minimumGeometry(); } void Widget::setEnabled(bool enabled) { state.enabled = enabled; return p.setEnabled(enabled); } void Widget::setFocused() { return p.setFocused(); } void Widget::setFont(Font &font) { state.font = &font; return p.setFont(font); } diff --git a/bsnes/phoenix/core/core.hpp b/bsnes/phoenix/core/core.hpp index 75c82012..d763e8ad 100755 --- a/bsnes/phoenix/core/core.hpp +++ b/bsnes/phoenix/core/core.hpp @@ -29,6 +29,11 @@ struct pTextEdit; struct pVerticalSlider; struct pViewport; +enum : unsigned { + MaximumSize = ~0u, + MinimumSize = 0u, +}; + struct Geometry { signed x, y; unsigned width, height; @@ -63,6 +68,7 @@ private: }; struct Font : Object { + Geometry geometry(const nall::string &text); void setBold(bool bold = true); void setFamily(const nall::string &family); void setItalic(bool italic = true); @@ -195,13 +201,15 @@ struct RadioItem : private nall::base_from_member, Action { }; struct Layout : Object { - virtual void setGeometry(Geometry &geometry) = 0; + virtual void setGeometry(const Geometry &geometry) = 0; virtual void setParent(Window &parent) = 0; virtual void setVisible(bool visible = true) = 0; }; struct Widget : Object { bool enabled(); + Font& font(); + Geometry minimumGeometry(); void setEnabled(bool enabled = true); void setFocused(); void setFont(Font &font); diff --git a/bsnes/phoenix/core/layout/fixed-layout.cpp b/bsnes/phoenix/core/layout/fixed-layout.cpp index a1c0c093..a9b9628e 100755 --- a/bsnes/phoenix/core/layout/fixed-layout.cpp +++ b/bsnes/phoenix/core/layout/fixed-layout.cpp @@ -9,7 +9,7 @@ void FixedLayout::append(Widget &widget, const Geometry &geometry) { children.append({ &widget, geometry }); } -void FixedLayout::setGeometry(Geometry &geometry) { +void FixedLayout::setGeometry(const Geometry &geometry) { } void FixedLayout::setVisible(bool visible) { diff --git a/bsnes/phoenix/core/layout/fixed-layout.hpp b/bsnes/phoenix/core/layout/fixed-layout.hpp index 14f90f76..9b4be043 100755 --- a/bsnes/phoenix/core/layout/fixed-layout.hpp +++ b/bsnes/phoenix/core/layout/fixed-layout.hpp @@ -1,6 +1,6 @@ struct FixedLayout : Layout { void append(Widget &widget, const Geometry &geometry); - void setGeometry(Geometry &geometry); + void setGeometry(const Geometry &geometry); void setParent(Window &parent); void setVisible(bool visible); FixedLayout(); diff --git a/bsnes/phoenix/core/layout/horizontal-layout.cpp b/bsnes/phoenix/core/layout/horizontal-layout.cpp index 9fa43139..14cd0ea1 100755 --- a/bsnes/phoenix/core/layout/horizontal-layout.cpp +++ b/bsnes/phoenix/core/layout/horizontal-layout.cpp @@ -1,77 +1,98 @@ -void HorizontalLayout::setParent(Window &parent) { - foreach(child, children) { - if(child.layout) child.layout->setParent(parent); - if(child.widget) parent.append(*child.widget); - } -} - -void HorizontalLayout::append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing) { - layout.width = width; - layout.height = height; - children.append({ &layout, 0, width, height, spacing }); +void HorizontalLayout::append(VerticalLayout &layout, unsigned spacing) { + children.append({ &layout, 0, 0, 0, spacing }); } void HorizontalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) { children.append({ 0, &widget, width, height, spacing }); } -void HorizontalLayout::setGeometry(Geometry &geometry) { - geometry.x += margin; - geometry.y += margin; - geometry.width -= margin * 2; +Geometry HorizontalLayout::minimumGeometry() { + bool maximumWidth = false; + bool maximumHeight = false; + + unsigned width = margin * 2; + unsigned height = margin * 2; + + foreach(child, children) { + if(child.width == MaximumSize) maximumWidth = true; + if(child.height == MaximumSize) maximumHeight = true; + + if(child.width != MaximumSize) width += child.width; + if(child.height != MaximumSize) height = max(height, child.height); + } + + return { 0, 0, maximumWidth ? MaximumSize : width, maximumHeight ? MaximumSize : height }; +} + +void HorizontalLayout::setGeometry(const Geometry &containerGeometry) { + setMinimumGeometry(); + setLayoutGeometry(); + + Geometry geometry = containerGeometry; + geometry.x += margin; + geometry.y += margin; + geometry.width -= margin * 2; geometry.height -= margin * 2; - unsigned geometryWidth = width ? width : geometry.width; - unsigned geometryHeight = height ? height : geometry.height; + Geometry layoutGeometry = geometry; + auto children = this->children; - Geometry baseGeometry = geometry; - linear_vector children = this->children; - - unsigned minimumWidth = 0; - foreach(child, children) minimumWidth += child.width + child.spacing; - - unsigned autosizeWidgets = 0; + unsigned minimumWidth = 0, maximumWidthCounter = 0; foreach(child, children) { - if(child.width == 0) autosizeWidgets++; - } - foreach(child, children) { - if(child.width == 0) child.width = (geometryWidth - minimumWidth) / autosizeWidgets; - if(child.height == 0) child.height = geometryHeight; + if(child.width == MaximumSize) maximumWidthCounter++; + if(child.width != MaximumSize) minimumWidth += child.width; + minimumWidth += child.spacing; } - unsigned maxHeight = 0; foreach(child, children) { - maxHeight = max(maxHeight, child.height); + if(child.width == MaximumSize) child.width = (geometry.width - minimumWidth) / maximumWidthCounter; + if(child.height == MaximumSize) child.height = geometry.height; } + unsigned maximumHeight = 0; + foreach(child, children) maximumHeight = max(maximumHeight, child.height); + + foreach(child, children) { + unsigned pivot = (maximumHeight - child.height) / 2; + Geometry childGeometry = { geometry.x, geometry.y + pivot, child.width, child.height }; + + if(child.layout) child.layout->setGeometry(childGeometry); + if(child.widget) child.widget->setGeometry(childGeometry); + + geometry.x += child.width + child.spacing; + geometry.width -= child.width + child.spacing; + } +} + +void HorizontalLayout::setLayoutGeometry() { foreach(child, children) { if(child.layout) { - child.layout->setGeometry(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; + child.width = child.layout->minimumGeometry().width; + child.height = child.layout->minimumGeometry().height; } } - - geometry.y += maxHeight; - geometry.height -= maxHeight; } -void HorizontalLayout::setMargin(unsigned margin_) { - margin = margin_; +void HorizontalLayout::setMargin(unsigned margin) { + this->margin = margin; } -unsigned HorizontalLayout::minimumWidth() { - unsigned width = margin * 2; - foreach(child, children) width += child.width + child.spacing; - return width; +void HorizontalLayout::setMinimumGeometry() { + foreach(child, children) { + if(child.layout) child.layout->setMinimumGeometry(); + if(child.widget) { + Geometry minimumGeometry = child.widget->minimumGeometry(); + if(child.width == MinimumSize) child.width = minimumGeometry.width; + if(child.height == MinimumSize) child.height = minimumGeometry.height; + } + } +} + +void HorizontalLayout::setParent(Window &parent) { + foreach(child, children) { + if(child.layout) child.layout->setParent(parent); + if(child.widget) parent.append(*child.widget); + } } void HorizontalLayout::setVisible(bool visible) { @@ -83,6 +104,4 @@ void HorizontalLayout::setVisible(bool visible) { HorizontalLayout::HorizontalLayout() { margin = 0; - width = 0; - height = 0; } diff --git a/bsnes/phoenix/core/layout/horizontal-layout.hpp b/bsnes/phoenix/core/layout/horizontal-layout.hpp index 2fd3c45a..3eb14d93 100755 --- a/bsnes/phoenix/core/layout/horizontal-layout.hpp +++ b/bsnes/phoenix/core/layout/horizontal-layout.hpp @@ -1,19 +1,19 @@ struct VerticalLayout; struct HorizontalLayout : public Layout { - void append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0); + void append(VerticalLayout &layout, unsigned spacing = 0); void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0); - unsigned minimumWidth(); - void setGeometry(Geometry &geometry); + Geometry minimumGeometry(); + void setGeometry(const Geometry &geometry); + void setLayoutGeometry(); void setMargin(unsigned margin); + void setMinimumGeometry(); void setParent(Window &parent); void setVisible(bool visible); HorizontalLayout(); //private: unsigned margin; - unsigned width; - unsigned height; struct Children { VerticalLayout *layout; Widget *widget; diff --git a/bsnes/phoenix/core/layout/vertical-layout.cpp b/bsnes/phoenix/core/layout/vertical-layout.cpp index 0bebb14b..3a6f54e9 100755 --- a/bsnes/phoenix/core/layout/vertical-layout.cpp +++ b/bsnes/phoenix/core/layout/vertical-layout.cpp @@ -1,77 +1,98 @@ -void VerticalLayout::setParent(Window &parent) { - foreach(child, children) { - if(child.layout) child.layout->setParent(parent); - if(child.widget) parent.append(*child.widget); - } -} - -void VerticalLayout::append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing) { - layout.width = width; - layout.height = height; - children.append({ &layout, 0, width, height, spacing }); +void VerticalLayout::append(HorizontalLayout &layout, unsigned spacing) { + children.append({ &layout, 0, 0, 0, spacing }); } void VerticalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) { children.append({ 0, &widget, width, height, spacing }); } -void VerticalLayout::setGeometry(Geometry &geometry) { - geometry.x += margin; - geometry.y += margin; - geometry.width -= margin * 2; +Geometry VerticalLayout::minimumGeometry() { + bool maximumWidth = false; + bool maximumHeight = false; + + unsigned width = margin * 2; + unsigned height = margin * 2; + + foreach(child, children) { + if(child.width == MaximumSize) maximumWidth = true; + if(child.height == MaximumSize) maximumHeight = true; + + if(child.width != MaximumSize) width = max(width, child.width); + if(child.height != MaximumSize) height += child.height; + } + + return { 0, 0, maximumWidth ? MaximumSize : width, maximumHeight ? MaximumSize : height }; +} + +void VerticalLayout::setGeometry(const Geometry &containerGeometry) { + setMinimumGeometry(); + setLayoutGeometry(); + + Geometry geometry = containerGeometry; + geometry.x += margin; + geometry.y += margin; + geometry.width -= margin * 2; geometry.height -= margin * 2; - unsigned geometryWidth = width ? width : geometry.width; - unsigned geometryHeight = height ? height : geometry.height; + Geometry layoutGeometry = geometry; + auto children = this->children; - Geometry baseGeometry = geometry; - linear_vector children = this->children; - - unsigned minimumHeight = 0; - foreach(child, children) minimumHeight += child.height + child.spacing; - - unsigned autosizeWidgets = 0; + unsigned minimumHeight = 0, maximumHeightCounter = 0; foreach(child, children) { - if(child.height == 0) autosizeWidgets++; - } - foreach(child, children) { - if(child.width == 0) child.width = geometryWidth; - if(child.height == 0) child.height = (geometryHeight - minimumHeight) / autosizeWidgets; + if(child.height == MaximumSize) maximumHeightCounter++; + if(child.height != MaximumSize) minimumHeight += child.height; + minimumHeight += child.spacing; } - unsigned maxWidth = 0; foreach(child, children) { - maxWidth = max(maxWidth, child.width); + if(child.width == MaximumSize) child.width = geometry.width; + if(child.height == MaximumSize) child.height = (geometry.height - minimumHeight) / maximumHeightCounter; } + unsigned maximumWidth = 0; + foreach(child, children) maximumWidth = max(maximumWidth, child.width); + + foreach(child, children) { + unsigned pivot = 0; //(maximumWidth - child.width) / 2; + Geometry childGeometry = { geometry.x + pivot, geometry.y, child.width, child.height }; + + if(child.layout) child.layout->setGeometry(childGeometry); + if(child.widget) child.widget->setGeometry(childGeometry); + + geometry.y += child.height + child.spacing; + geometry.height -= child.height + child.spacing; + } +} + +void VerticalLayout::setLayoutGeometry() { foreach(child, children) { if(child.layout) { - child.layout->setGeometry(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; + child.width = child.layout->minimumGeometry().width; + child.height = child.layout->minimumGeometry().height; } } - - geometry.x += maxWidth; - geometry.width -= maxWidth; } -void VerticalLayout::setMargin(unsigned margin_) { - margin = margin_; +void VerticalLayout::setMargin(unsigned margin) { + this->margin = margin; } -unsigned VerticalLayout::minimumHeight() { - unsigned height = margin * 2; - foreach(child, children) height += child.height + child.spacing; - return height; +void VerticalLayout::setMinimumGeometry() { + foreach(child, children) { + if(child.layout) child.layout->setMinimumGeometry(); + if(child.widget) { + Geometry minimumGeometry = child.widget->minimumGeometry(); + if(child.width == MinimumSize) child.width = minimumGeometry.width; + if(child.height == MinimumSize) child.height = minimumGeometry.height; + } + } +} + +void VerticalLayout::setParent(Window &parent) { + foreach(child, children) { + if(child.layout) child.layout->setParent(parent); + if(child.widget) parent.append(*child.widget); + } } void VerticalLayout::setVisible(bool visible) { @@ -83,6 +104,4 @@ void VerticalLayout::setVisible(bool visible) { VerticalLayout::VerticalLayout() { margin = 0; - width = 0; - height = 0; } diff --git a/bsnes/phoenix/core/layout/vertical-layout.hpp b/bsnes/phoenix/core/layout/vertical-layout.hpp index 28ec0f4d..13b2bedb 100755 --- a/bsnes/phoenix/core/layout/vertical-layout.hpp +++ b/bsnes/phoenix/core/layout/vertical-layout.hpp @@ -1,19 +1,19 @@ struct HorizontalLayout; struct VerticalLayout : public Layout { - void append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0); + void append(HorizontalLayout &layout, unsigned spacing = 0); void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0); - unsigned minimumHeight(); - void setGeometry(Geometry &geometry); + Geometry minimumGeometry(); + void setGeometry(const Geometry &geometry); + void setLayoutGeometry(); void setMargin(unsigned margin); + void setMinimumGeometry(); void setParent(Window &parent); void setVisible(bool visible); VerticalLayout(); //private: unsigned margin; - unsigned width; - unsigned height; struct Children { HorizontalLayout *layout; Widget *widget; diff --git a/bsnes/phoenix/gtk/font.cpp b/bsnes/phoenix/gtk/font.cpp index 7ece6ad8..93bc0303 100755 --- a/bsnes/phoenix/gtk/font.cpp +++ b/bsnes/phoenix/gtk/font.cpp @@ -1,3 +1,11 @@ +Geometry pFont::geometry(const string &text) { + pango_layout_set_font_description(gtkLayout, gtkFont); + pango_layout_set_text(gtkLayout, text, -1); + int width = 0, height = 0; + pango_layout_get_pixel_size(gtkLayout, &width, &height); + return { 0, 0, width, height }; +} + void pFont::setBold(bool bold) { pango_font_description_set_weight(gtkFont, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); } @@ -19,4 +27,6 @@ void pFont::setUnderline(bool underline) { void pFont::constructor() { gtkFont = pango_font_description_new(); + PangoContext *context = gdk_pango_context_get_for_screen(gdk_screen_get_default()); + gtkLayout = pango_layout_new(context); } diff --git a/bsnes/phoenix/gtk/gtk.cpp b/bsnes/phoenix/gtk/gtk.cpp index bf83c963..5974fd6e 100755 --- a/bsnes/phoenix/gtk/gtk.cpp +++ b/bsnes/phoenix/gtk/gtk.cpp @@ -27,6 +27,8 @@ #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" +Font pOS::defaultFont; + Geometry pOS::availableGeometry() { //TODO: is there a GTK+ function for this? //should return desktopGeometry() sans panels, toolbars, docks, etc. diff --git a/bsnes/phoenix/gtk/gtk.hpp b/bsnes/phoenix/gtk/gtk.hpp index 1e5a60d4..c2df6619 100755 --- a/bsnes/phoenix/gtk/gtk.hpp +++ b/bsnes/phoenix/gtk/gtk.hpp @@ -26,6 +26,8 @@ struct pObject { }; struct pOS : public pObject { + static Font defaultFont; + static Geometry availableGeometry(); static Geometry desktopGeometry(); static string fileLoad(Window &parent, const string &path, const lstring &filter); @@ -42,7 +44,9 @@ struct pOS : public pObject { struct pFont : public pObject { Font &font; PangoFontDescription *gtkFont; + PangoLayout *gtkLayout; + Geometry geometry(const string &text); void setBold(bool bold); void setFamily(const string &family); void setItalic(bool italic); @@ -164,6 +168,8 @@ struct pWidget : public pObject { pWindow *parentWindow; bool enabled(); + Font& font(); + virtual Geometry minimumGeometry(); void setEnabled(bool enabled); virtual void setFocused(); virtual void setFont(Font &font); @@ -177,6 +183,7 @@ struct pWidget : public pObject { struct pButton : public pWidget { Button &button; + Geometry minimumGeometry(); void setText(const string &text); pButton(Button &button) : pWidget(button), button(button) {} @@ -187,6 +194,7 @@ struct pCheckBox : public pWidget { CheckBox &checkBox; bool checked(); + Geometry minimumGeometry(); void setChecked(bool checked); void setText(const string &text); @@ -199,6 +207,7 @@ struct pComboBox : public pWidget { unsigned itemCounter; void append(const string &text); + Geometry minimumGeometry(); void reset(); unsigned selection(); void setSelection(unsigned row); @@ -234,6 +243,7 @@ struct pHexEdit : public pWidget { struct pHorizontalSlider : public pWidget { HorizontalSlider &horizontalSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -245,6 +255,7 @@ struct pHorizontalSlider : public pWidget { struct pLabel : public pWidget { Label &label; + Geometry minimumGeometry(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -254,6 +265,7 @@ struct pLabel : public pWidget { struct pLineEdit : public pWidget { LineEdit &lineEdit; + Geometry minimumGeometry(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -297,6 +309,7 @@ struct pListView : public pWidget { struct pProgressBar : public pWidget { ProgressBar &progressBar; + Geometry minimumGeometry(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -307,6 +320,7 @@ struct pRadioBox : public pWidget { RadioBox &radioBox; bool checked(); + Geometry minimumGeometry(); void setChecked(); void setGroup(const reference_array &group); void setText(const string &text); @@ -333,6 +347,7 @@ struct pTextEdit : public pWidget { struct pVerticalSlider : public pWidget { VerticalSlider &verticalSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); diff --git a/bsnes/phoenix/gtk/widget/button.cpp b/bsnes/phoenix/gtk/widget/button.cpp index 75774ddd..360ccedf 100755 --- a/bsnes/phoenix/gtk/widget/button.cpp +++ b/bsnes/phoenix/gtk/widget/button.cpp @@ -2,6 +2,12 @@ static void Button_tick(Button *self) { if(self->onTick) self->onTick(); } +Geometry pButton::minimumGeometry() { + Font &font = pWidget::font(); + Geometry geometry = font.geometry(button.state.text); + return { 0, 0, geometry.width + 24, geometry.height + 14 }; +} + void pButton::setText(const string &text) { gtk_button_set_label(GTK_BUTTON(gtkWidget), text); } diff --git a/bsnes/phoenix/gtk/widget/check-box.cpp b/bsnes/phoenix/gtk/widget/check-box.cpp index bcacb7f3..4169c68b 100755 --- a/bsnes/phoenix/gtk/widget/check-box.cpp +++ b/bsnes/phoenix/gtk/widget/check-box.cpp @@ -6,6 +6,12 @@ bool pCheckBox::checked() { return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); } +Geometry pCheckBox::minimumGeometry() { + Font &font = pWidget::font(); + Geometry geometry = font.geometry(checkBox.state.text); + return { 0, 0, geometry.width + 28, geometry.height + 4 }; +} + void pCheckBox::setChecked(bool checked) { locked = true; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), checked); diff --git a/bsnes/phoenix/gtk/widget/combo-box.cpp b/bsnes/phoenix/gtk/widget/combo-box.cpp index 72338cca..0ea1e200 100755 --- a/bsnes/phoenix/gtk/widget/combo-box.cpp +++ b/bsnes/phoenix/gtk/widget/combo-box.cpp @@ -7,6 +7,15 @@ void pComboBox::append(const string &text) { if(itemCounter++ == 0) setSelection(0); } +Geometry pComboBox::minimumGeometry() { + Font &font = pWidget::font(); + unsigned maximumWidth = 0; + foreach(item, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(item).width); + + Geometry geometry = font.geometry(" "); + return { 0, 0, maximumWidth + 44, geometry.height + 10 }; +} + void pComboBox::reset() { locked = true; for(signed n = itemCounter - 1; n >= 0; n--) { diff --git a/bsnes/phoenix/gtk/widget/horizontal-slider.cpp b/bsnes/phoenix/gtk/widget/horizontal-slider.cpp index 44f6614d..07771f36 100755 --- a/bsnes/phoenix/gtk/widget/horizontal-slider.cpp +++ b/bsnes/phoenix/gtk/widget/horizontal-slider.cpp @@ -4,6 +4,10 @@ static void HorizontalSlider_change(HorizontalSlider *self) { if(self->onChange) self->onChange(); } +Geometry pHorizontalSlider::minimumGeometry() { + return { 0, 0, 100, 20 }; +} + unsigned pHorizontalSlider::position() { return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget)); } diff --git a/bsnes/phoenix/gtk/widget/label.cpp b/bsnes/phoenix/gtk/widget/label.cpp index bcf38121..645abdbf 100755 --- a/bsnes/phoenix/gtk/widget/label.cpp +++ b/bsnes/phoenix/gtk/widget/label.cpp @@ -1,3 +1,9 @@ +Geometry pLabel::minimumGeometry() { + Font &font = pWidget::font(); + Geometry geometry = font.geometry(label.state.text); + return { 0, 0, geometry.width, geometry.height }; +} + void pLabel::setText(const string &text) { gtk_label_set_text(GTK_LABEL(gtkWidget), text); } diff --git a/bsnes/phoenix/gtk/widget/line-edit.cpp b/bsnes/phoenix/gtk/widget/line-edit.cpp index 65359fbd..e783b3e2 100755 --- a/bsnes/phoenix/gtk/widget/line-edit.cpp +++ b/bsnes/phoenix/gtk/widget/line-edit.cpp @@ -6,6 +6,12 @@ static void LineEdit_change(LineEdit *self) { if(self->p.locked == false && self->onChange) self->onChange(); } +Geometry pLineEdit::minimumGeometry() { + Font &font = pWidget::font(); + Geometry geometry = font.geometry(lineEdit.state.text); + return { 0, 0, geometry.width + 10, geometry.height + 10 }; +} + void pLineEdit::setEditable(bool editable) { gtk_entry_set_editable(GTK_ENTRY(gtkWidget), editable); } diff --git a/bsnes/phoenix/gtk/widget/progress-bar.cpp b/bsnes/phoenix/gtk/widget/progress-bar.cpp index 96959b62..721587a4 100755 --- a/bsnes/phoenix/gtk/widget/progress-bar.cpp +++ b/bsnes/phoenix/gtk/widget/progress-bar.cpp @@ -1,3 +1,7 @@ +Geometry pProgressBar::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + void pProgressBar::setPosition(unsigned position) { position = position <= 100 ? position : 0; gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkWidget), (double)position / 100.0); diff --git a/bsnes/phoenix/gtk/widget/radio-box.cpp b/bsnes/phoenix/gtk/widget/radio-box.cpp index 2fb7d38f..67e709ae 100755 --- a/bsnes/phoenix/gtk/widget/radio-box.cpp +++ b/bsnes/phoenix/gtk/widget/radio-box.cpp @@ -6,6 +6,12 @@ bool pRadioBox::checked() { return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); } +Geometry pRadioBox::minimumGeometry() { + Font &font = pWidget::font(); + Geometry geometry = font.geometry(radioBox.state.text); + return { 0, 0, geometry.width + 28, geometry.height + 4 }; +} + void pRadioBox::setChecked() { locked = true; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), true); diff --git a/bsnes/phoenix/gtk/widget/vertical-slider.cpp b/bsnes/phoenix/gtk/widget/vertical-slider.cpp index dbd4347c..028abcea 100755 --- a/bsnes/phoenix/gtk/widget/vertical-slider.cpp +++ b/bsnes/phoenix/gtk/widget/vertical-slider.cpp @@ -4,6 +4,10 @@ static void VerticalSlider_change(VerticalSlider *self) { if(self->onChange) self->onChange(); } +Geometry pVerticalSlider::minimumGeometry() { + return { 0, 0, 20, 100 }; +} + unsigned pVerticalSlider::position() { return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget)); } diff --git a/bsnes/phoenix/gtk/widget/widget.cpp b/bsnes/phoenix/gtk/widget/widget.cpp index d26d0c6c..9a21a02c 100755 --- a/bsnes/phoenix/gtk/widget/widget.cpp +++ b/bsnes/phoenix/gtk/widget/widget.cpp @@ -6,6 +6,15 @@ static void Widget_setFont(GtkWidget *widget, gpointer font) { } } +Font& pWidget::font() { + if(widget.state.font) return *widget.state.font; + return pOS::defaultFont; +} + +Geometry pWidget::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + bool pWidget::enabled() { return gtk_widget_get_sensitive(gtkWidget); } diff --git a/bsnes/phoenix/qt/font.cpp b/bsnes/phoenix/qt/font.cpp index c492fca1..f9c7acb7 100755 --- a/bsnes/phoenix/qt/font.cpp +++ b/bsnes/phoenix/qt/font.cpp @@ -1,3 +1,17 @@ +Geometry pFont::geometry(const string &text) { + QFontMetrics metrics(*qtFont); + + lstring lines; + lines.split("\n", text); + + unsigned maxWidth = 0; + foreach(line, lines) { + maxWidth = max(maxWidth, metrics.width(line)); + } + + return { 0, 0, maxWidth, metrics.height() * lines.size() }; +} + void pFont::setBold(bool bold) { update(); } void pFont::setFamily(const string &family) { update(); } void pFont::setItalic(bool italic) { update(); } diff --git a/bsnes/phoenix/qt/qt.cpp b/bsnes/phoenix/qt/qt.cpp index b10df857..9f5f4e7a 100755 --- a/bsnes/phoenix/qt/qt.cpp +++ b/bsnes/phoenix/qt/qt.cpp @@ -29,6 +29,7 @@ #include "widget/viewport.cpp" QApplication *pOS::application = 0; +Font pOS::defaultFont; Geometry pOS::availableGeometry() { QRect rect = QApplication::desktop()->availableGeometry(); diff --git a/bsnes/phoenix/qt/qt.moc b/bsnes/phoenix/qt/qt.moc index 6370cfc9..f1b11619 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: Tue Mar 15 13:54:13 2011 +** Created: Mon Mar 21 22:59:16 2011 ** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) ** ** WARNING! All changes made in this file will be lost! diff --git a/bsnes/phoenix/qt/qt.moc.hpp b/bsnes/phoenix/qt/qt.moc.hpp index 10f170cc..8b1e71a7 100755 --- a/bsnes/phoenix/qt/qt.moc.hpp +++ b/bsnes/phoenix/qt/qt.moc.hpp @@ -25,6 +25,7 @@ struct pObject { struct pOS : public pObject { static QApplication *application; + static Font defaultFont; static Geometry availableGeometry(); static Geometry desktopGeometry(); @@ -43,6 +44,7 @@ struct pFont : public pObject { Font &font; QFont *qtFont; + Geometry geometry(const string &text); void setBold(bool bold); void setFamily(const string &family); void setItalic(bool italic); @@ -193,6 +195,8 @@ struct pWidget : public pObject { Widget &widget; QWidget *qtWidget; + Font& font(); + virtual Geometry minimumGeometry(); void setEnabled(bool enabled); void setFocused(); void setFont(Font &font); @@ -210,6 +214,7 @@ public: Button &button; QPushButton *qtButton; + Geometry minimumGeometry(); void setText(const string &text); pButton(Button &button) : pWidget(button), button(button) {} @@ -227,6 +232,7 @@ public: QCheckBox *qtCheckBox; bool checked(); + Geometry minimumGeometry(); void setChecked(bool checked); void setText(const string &text); @@ -245,6 +251,7 @@ public: QComboBox *qtComboBox; void append(const string &text); + Geometry minimumGeometry(); void reset(); unsigned selection(); void setSelection(unsigned row); @@ -291,6 +298,7 @@ public: HorizontalSlider &horizontalSlider; QSlider *qtSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -306,6 +314,7 @@ struct pLabel : public pWidget { Label &label; QLabel *qtLabel; + Geometry minimumGeometry(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -319,6 +328,7 @@ public: LineEdit &lineEdit; QLineEdit *qtLineEdit; + Geometry minimumGeometry(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -365,6 +375,7 @@ struct pProgressBar : public pWidget { ProgressBar &progressBar; QProgressBar *qtProgressBar; + Geometry minimumGeometry(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -380,6 +391,7 @@ public: QButtonGroup *qtGroup; bool checked(); + Geometry minimumGeometry(); void setChecked(); void setGroup(const reference_array &group); void setText(const string &text); @@ -418,6 +430,7 @@ public: VerticalSlider &verticalSlider; QSlider *qtSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); diff --git a/bsnes/phoenix/qt/widget/button.cpp b/bsnes/phoenix/qt/widget/button.cpp index 0fdcd04b..e6645dce 100755 --- a/bsnes/phoenix/qt/widget/button.cpp +++ b/bsnes/phoenix/qt/widget/button.cpp @@ -1,3 +1,9 @@ +Geometry pButton::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(button.state.text); + return { 0, 0, geometry.width + 20, geometry.height + 12 }; +} + void pButton::setText(const string &text) { qtButton->setText(QString::fromUtf8(text)); } diff --git a/bsnes/phoenix/qt/widget/check-box.cpp b/bsnes/phoenix/qt/widget/check-box.cpp index ef0484b9..1cd89157 100755 --- a/bsnes/phoenix/qt/widget/check-box.cpp +++ b/bsnes/phoenix/qt/widget/check-box.cpp @@ -2,6 +2,12 @@ bool pCheckBox::checked() { return qtCheckBox->isChecked(); } +Geometry pCheckBox::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(checkBox.state.text); + return { 0, 0, geometry.width + 26, geometry.height + 6 }; +} + void pCheckBox::setChecked(bool checked) { locked = true; qtCheckBox->setChecked(checked); diff --git a/bsnes/phoenix/qt/widget/combo-box.cpp b/bsnes/phoenix/qt/widget/combo-box.cpp index a51cd7fd..83090415 100755 --- a/bsnes/phoenix/qt/widget/combo-box.cpp +++ b/bsnes/phoenix/qt/widget/combo-box.cpp @@ -2,6 +2,14 @@ void pComboBox::append(const string &text) { qtComboBox->addItem(QString::fromUtf8(text)); } +Geometry pComboBox::minimumGeometry() { + Font &font = this->font(); + unsigned maximumWidth = 0; + foreach(text, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(text).width); + Geometry geometry = font.geometry(" "); + return { 0, 0, maximumWidth + 32, geometry.height + 12 }; +} + void pComboBox::reset() { while(qtComboBox->count()) qtComboBox->removeItem(0); } diff --git a/bsnes/phoenix/qt/widget/horizontal-slider.cpp b/bsnes/phoenix/qt/widget/horizontal-slider.cpp index af875776..05b13578 100755 --- a/bsnes/phoenix/qt/widget/horizontal-slider.cpp +++ b/bsnes/phoenix/qt/widget/horizontal-slider.cpp @@ -1,3 +1,7 @@ +Geometry pHorizontalSlider::minimumGeometry() { + return { 0, 0, 100, 20 }; +} + unsigned pHorizontalSlider::position() { return qtSlider->value(); } diff --git a/bsnes/phoenix/qt/widget/label.cpp b/bsnes/phoenix/qt/widget/label.cpp index 2dc5c013..fb233fa0 100755 --- a/bsnes/phoenix/qt/widget/label.cpp +++ b/bsnes/phoenix/qt/widget/label.cpp @@ -1,3 +1,9 @@ +Geometry pLabel::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(label.state.text); + return { 0, 0, geometry.width, geometry.height }; +} + void pLabel::setText(const string &text) { qtLabel->setText(QString::fromUtf8(text)); } diff --git a/bsnes/phoenix/qt/widget/line-edit.cpp b/bsnes/phoenix/qt/widget/line-edit.cpp index ac647251..237e658c 100755 --- a/bsnes/phoenix/qt/widget/line-edit.cpp +++ b/bsnes/phoenix/qt/widget/line-edit.cpp @@ -1,3 +1,9 @@ +Geometry pLineEdit::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(lineEdit.state.text); + return { 0, 0, geometry.width + 12, geometry.height + 12 }; +} + void pLineEdit::setEditable(bool editable) { qtLineEdit->setReadOnly(!editable); } diff --git a/bsnes/phoenix/qt/widget/progress-bar.cpp b/bsnes/phoenix/qt/widget/progress-bar.cpp index d7c66b8f..c8051e5a 100755 --- a/bsnes/phoenix/qt/widget/progress-bar.cpp +++ b/bsnes/phoenix/qt/widget/progress-bar.cpp @@ -1,3 +1,7 @@ +Geometry pProgressBar::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + void pProgressBar::setPosition(unsigned position) { qtProgressBar->setValue(position); } diff --git a/bsnes/phoenix/qt/widget/radio-box.cpp b/bsnes/phoenix/qt/widget/radio-box.cpp index 62a9abbc..22f0e911 100755 --- a/bsnes/phoenix/qt/widget/radio-box.cpp +++ b/bsnes/phoenix/qt/widget/radio-box.cpp @@ -2,6 +2,12 @@ bool pRadioBox::checked() { return qtRadioBox->isChecked(); } +Geometry pRadioBox::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(radioBox.state.text); + return { 0, 0, geometry.width + 26, geometry.height + 6 }; +} + void pRadioBox::setChecked() { locked = true; foreach(item, radioBox.state.group) { diff --git a/bsnes/phoenix/qt/widget/vertical-slider.cpp b/bsnes/phoenix/qt/widget/vertical-slider.cpp index 684da804..a9f6e8e5 100755 --- a/bsnes/phoenix/qt/widget/vertical-slider.cpp +++ b/bsnes/phoenix/qt/widget/vertical-slider.cpp @@ -1,3 +1,7 @@ +Geometry pVerticalSlider::minimumGeometry() { + return { 0, 0, 20, 100 }; +} + unsigned pVerticalSlider::position() { return qtSlider->value(); } diff --git a/bsnes/phoenix/qt/widget/widget.cpp b/bsnes/phoenix/qt/widget/widget.cpp index 99f21526..875b4fab 100755 --- a/bsnes/phoenix/qt/widget/widget.cpp +++ b/bsnes/phoenix/qt/widget/widget.cpp @@ -1,3 +1,12 @@ +Font& pWidget::font() { + if(widget.state.font) return *widget.state.font; + return pOS::defaultFont; +} + +Geometry pWidget::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + void pWidget::setEnabled(bool enabled) { qtWidget->setEnabled(enabled); } diff --git a/bsnes/phoenix/windows/font.cpp b/bsnes/phoenix/windows/font.cpp index 20612be7..10d36580 100755 --- a/bsnes/phoenix/windows/font.cpp +++ b/bsnes/phoenix/windows/font.cpp @@ -6,6 +6,15 @@ static HFONT Font_createFont(const string &family, unsigned size, bool bold, boo ); } +Geometry pFont::geometry(const string &text) { + HDC hdc = GetDC(0); + SelectObject(hdc, hfont); + RECT rc = { 0, 0, 0, 0 }; + DrawText(hdc, utf16_t(text), -1, &rc, DT_CALCRECT); + ReleaseDC(0, hdc); + return { 0, 0, rc.right, rc.bottom }; +} + void pFont::setBold(bool bold) { if(hfont) { DeleteObject(hfont); hfont = 0; } hfont = Font_createFont(font.state.family, font.state.size, font.state.bold, font.state.italic, font.state.underline); @@ -32,5 +41,5 @@ void pFont::setUnderline(bool underline) { } void pFont::constructor() { - hfont = 0; + hfont = Font_createFont("Tahoma", 8, false, false, false); } diff --git a/bsnes/phoenix/windows/widget/button.cpp b/bsnes/phoenix/windows/widget/button.cpp index 936877b2..2c0a5d36 100755 --- a/bsnes/phoenix/windows/widget/button.cpp +++ b/bsnes/phoenix/windows/widget/button.cpp @@ -1,3 +1,9 @@ +Geometry pButton::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(button.state.text); + return { 0, 0, geometry.width + 20, geometry.height + 12 }; +} + void pButton::setText(const string &text) { SetWindowText(hwnd, utf16_t(text)); } diff --git a/bsnes/phoenix/windows/widget/check-box.cpp b/bsnes/phoenix/windows/widget/check-box.cpp index a20bd7be..886d78ca 100755 --- a/bsnes/phoenix/windows/widget/check-box.cpp +++ b/bsnes/phoenix/windows/widget/check-box.cpp @@ -2,6 +2,12 @@ bool pCheckBox::checked() { return SendMessage(hwnd, BM_GETCHECK, 0, 0); } +Geometry pCheckBox::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(checkBox.state.text); + return { 0, 0, geometry.width + 20, geometry.height + 4 }; +} + void pCheckBox::setChecked(bool checked) { SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0); } diff --git a/bsnes/phoenix/windows/widget/combo-box.cpp b/bsnes/phoenix/windows/widget/combo-box.cpp index ecc6e6a3..db823947 100755 --- a/bsnes/phoenix/windows/widget/combo-box.cpp +++ b/bsnes/phoenix/windows/widget/combo-box.cpp @@ -3,6 +3,14 @@ void pComboBox::append(const string &text) { if(SendMessage(hwnd, CB_GETCOUNT, 0, 0) == 1) setSelection(0); } +Geometry pComboBox::minimumGeometry() { + Font &font = this->font(); + unsigned maximumWidth = 0; + foreach(text, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(text).width); + Geometry geometry = font.geometry(" "); + return { 0, 0, maximumWidth + 24, geometry.height + 10 }; +} + void pComboBox::reset() { SendMessage(hwnd, CB_RESETCONTENT, 0, 0); } diff --git a/bsnes/phoenix/windows/widget/horizontal-slider.cpp b/bsnes/phoenix/windows/widget/horizontal-slider.cpp index b0758a59..f1f3f956 100755 --- a/bsnes/phoenix/windows/widget/horizontal-slider.cpp +++ b/bsnes/phoenix/windows/widget/horizontal-slider.cpp @@ -1,3 +1,7 @@ +Geometry pHorizontalSlider::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + unsigned pHorizontalSlider::position() { return SendMessage(hwnd, TBM_GETPOS, 0, 0); } diff --git a/bsnes/phoenix/windows/widget/label.cpp b/bsnes/phoenix/windows/widget/label.cpp index 0c827952..dc40ed61 100755 --- a/bsnes/phoenix/windows/widget/label.cpp +++ b/bsnes/phoenix/windows/widget/label.cpp @@ -1,3 +1,9 @@ +Geometry pLabel::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(label.state.text); + return { 0, 0, geometry.width, geometry.height }; +} + void pLabel::setText(const string &text) { SetWindowText(hwnd, utf16_t(text)); InvalidateRect(hwnd, 0, false); diff --git a/bsnes/phoenix/windows/widget/line-edit.cpp b/bsnes/phoenix/windows/widget/line-edit.cpp index d701ffe1..d94ffd99 100755 --- a/bsnes/phoenix/windows/widget/line-edit.cpp +++ b/bsnes/phoenix/windows/widget/line-edit.cpp @@ -1,3 +1,9 @@ +Geometry pLineEdit::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(lineEdit.state.text); + return { 0, 0, geometry.width + 12, geometry.height + 8 }; +} + void pLineEdit::setEditable(bool editable) { SendMessage(hwnd, EM_SETREADONLY, editable == false, 0); } diff --git a/bsnes/phoenix/windows/widget/progress-bar.cpp b/bsnes/phoenix/windows/widget/progress-bar.cpp index e3b7b9d7..530dfbb2 100755 --- a/bsnes/phoenix/windows/widget/progress-bar.cpp +++ b/bsnes/phoenix/windows/widget/progress-bar.cpp @@ -1,3 +1,7 @@ +Geometry pProgressBar::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + void pProgressBar::setPosition(unsigned position) { SendMessage(hwnd, PBM_SETPOS, (WPARAM)position, 0); } diff --git a/bsnes/phoenix/windows/widget/radio-box.cpp b/bsnes/phoenix/windows/widget/radio-box.cpp index 8f48e4d9..0efbce1a 100755 --- a/bsnes/phoenix/windows/widget/radio-box.cpp +++ b/bsnes/phoenix/windows/widget/radio-box.cpp @@ -2,6 +2,12 @@ bool pRadioBox::checked() { return SendMessage(hwnd, BM_GETCHECK, 0, 0); } +Geometry pRadioBox::minimumGeometry() { + Font &font = this->font(); + Geometry geometry = font.geometry(radioBox.state.text); + return { 0, 0, geometry.width + 20, geometry.height + 4 }; +} + void pRadioBox::setChecked() { foreach(item, radioBox.state.group) { SendMessage(item.p.hwnd, BM_SETCHECK, (WPARAM)(&item == &radioBox), 0); diff --git a/bsnes/phoenix/windows/widget/vertical-slider.cpp b/bsnes/phoenix/windows/widget/vertical-slider.cpp index 5db91514..f8da0ec9 100755 --- a/bsnes/phoenix/windows/widget/vertical-slider.cpp +++ b/bsnes/phoenix/windows/widget/vertical-slider.cpp @@ -1,3 +1,7 @@ +Geometry pVerticalSlider::minimumGeometry() { + return { 0, 0, 25, 100 }; +} + unsigned pVerticalSlider::position() { return SendMessage(hwnd, TBM_GETPOS, 0, 0); } diff --git a/bsnes/phoenix/windows/widget/widget.cpp b/bsnes/phoenix/windows/widget/widget.cpp index 062da650..a6af16ad 100755 --- a/bsnes/phoenix/windows/widget/widget.cpp +++ b/bsnes/phoenix/windows/widget/widget.cpp @@ -2,6 +2,15 @@ bool pWidget::enabled() { return IsWindowEnabled(hwnd); } +Font& pWidget::font() { + if(widget.state.font) return *widget.state.font; + return pOS::state->defaultFont; +} + +Geometry pWidget::minimumGeometry() { + return { 0, 0, 100, 25 }; +} + void pWidget::setEnabled(bool enabled) { EnableWindow(hwnd, enabled); } diff --git a/bsnes/phoenix/windows/windows.hpp b/bsnes/phoenix/windows/windows.hpp index 2e641308..3e14d9ff 100755 --- a/bsnes/phoenix/windows/windows.hpp +++ b/bsnes/phoenix/windows/windows.hpp @@ -37,6 +37,7 @@ struct pFont : public pObject { Font &font; HFONT hfont; + Geometry geometry(const string &text); void setBold(bool bold); void setFamily(const string &family); void setItalic(bool italic); @@ -155,6 +156,8 @@ struct pWidget : public pObject { HWND hwnd; bool enabled(); + Font& font(); + virtual Geometry minimumGeometry(); void setEnabled(bool enabled); void setFocused(); void setFont(Font &font); @@ -170,6 +173,7 @@ struct pWidget : public pObject { struct pButton : public pWidget { Button &button; + Geometry minimumGeometry(); void setText(const string &text); pButton(Button &button) : pWidget(button), button(button) {} @@ -181,6 +185,7 @@ struct pCheckBox : public pWidget { CheckBox &checkBox; bool checked(); + Geometry minimumGeometry(); void setChecked(bool checked); void setText(const string &text); @@ -193,6 +198,7 @@ struct pComboBox : public pWidget { ComboBox &comboBox; void append(const string &text); + Geometry minimumGeometry(); void reset(); unsigned selection(); void setSelection(unsigned row); @@ -222,6 +228,7 @@ struct pHexEdit : public pWidget { struct pHorizontalSlider : public pWidget { HorizontalSlider &horizontalSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -234,6 +241,7 @@ struct pHorizontalSlider : public pWidget { struct pLabel : public pWidget { Label &label; + Geometry minimumGeometry(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -244,6 +252,7 @@ struct pLabel : public pWidget { struct pLineEdit : public pWidget { LineEdit &lineEdit; + Geometry minimumGeometry(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -280,6 +289,7 @@ struct pListView : public pWidget { struct pProgressBar : public pWidget { ProgressBar &progressBar; + Geometry minimumGeometry(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -291,6 +301,7 @@ struct pRadioBox : public pWidget { RadioBox &radioBox; bool checked(); + Geometry minimumGeometry(); void setChecked(); void setGroup(const reference_array &group); void setText(const string &text); @@ -317,6 +328,7 @@ struct pTextEdit : public pWidget { struct pVerticalSlider : public pWidget { VerticalSlider &verticalSlider; + Geometry minimumGeometry(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index 6375e249..602b2f0a 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,7 +1,7 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "077.01"; + static const char Version[] = "077.02"; static const unsigned SerializerVersion = 19; } } diff --git a/bsnes/ui/debugger/console.cpp b/bsnes/ui/debugger/console.cpp index fcbe6518..03a31cc4 100755 --- a/bsnes/ui/debugger/console.cpp +++ b/bsnes/ui/debugger/console.cpp @@ -15,16 +15,16 @@ void Console::create() { clearConsole.setText("Clear console"); 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); + layout.append(output, ~0, ~0, 5); + controlLayout.append(traceToConsole, 120, 0 ); + controlLayout.append(traceToFile, 120, 0 ); + controlLayout.append(traceCPU, 120, 0 ); + controlLayout.append(traceSMP, 120, 0 ); + controlLayout.append(spacer, 120, ~0 ); + controlLayout.append(clearConsole, 120, 0 ); + layout.append(controlLayout ); - setGeometry({ 0, 0, layout.minimumWidth() + 580, 350 }); + setGeometry({ 0, 0, layout.minimumGeometry().width + 580, 350 }); append(layout); onClose = []() { diff --git a/bsnes/ui/debugger/cpu/debugger.cpp b/bsnes/ui/debugger/cpu/debugger.cpp index 845fd659..84a67fd0 100755 --- a/bsnes/ui/debugger/cpu/debugger.cpp +++ b/bsnes/ui/debugger/cpu/debugger.cpp @@ -12,13 +12,14 @@ void CPUDebugger::create() { proceed.setEnabled(false); 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); + layout.append(output, ~0, ~0, 5); + controlLayout.append(stepInto, 80, 0 ); + controlLayout.append(stepOver, 80, 0 ); + controlLayout.append(proceed, 80, 0 ); + controlLayout.append(spacer, 80, ~0 ); + layout.append(controlLayout ); - setGeometry({ 0, 0, layout.minimumWidth() + 300, 220 }); + setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); append(layout); onClose = []() { diff --git a/bsnes/ui/debugger/cpu/debugger.hpp b/bsnes/ui/debugger/cpu/debugger.hpp index 402692c2..5d3d8f36 100755 --- a/bsnes/ui/debugger/cpu/debugger.hpp +++ b/bsnes/ui/debugger/cpu/debugger.hpp @@ -5,6 +5,7 @@ struct CPUDebugger : TopLevelWindow { Button stepInto; Button stepOver; Button proceed; + Widget spacer; void create(); void synchronize(); diff --git a/bsnes/ui/debugger/debugger.cpp b/bsnes/ui/debugger/debugger.cpp index 43862bea..95c811d3 100755 --- a/bsnes/ui/debugger/debugger.cpp +++ b/bsnes/ui/debugger/debugger.cpp @@ -29,14 +29,14 @@ void Debugger::create() { showMemoryEditor.setText("Memory editor"); 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); + layout.append(enableDebugger, ~0, 0); + layout.append(showConsole, ~0, 0); + layout.append(showCPUDebugger, ~0, 0); + layout.append(showSMPDebugger, ~0, 0); + layout.append(showBreakpointEditor, ~0, 0); + layout.append(showMemoryEditor, ~0, 0); - setGeometry({ 0, 0, 256, layout.minimumHeight() }); + setGeometry({ 0, 0, 256, layout.minimumGeometry().height }); append(layout); //windows shown by default diff --git a/bsnes/ui/debugger/smp/debugger.cpp b/bsnes/ui/debugger/smp/debugger.cpp index 7dd1a44b..baa63c6c 100755 --- a/bsnes/ui/debugger/smp/debugger.cpp +++ b/bsnes/ui/debugger/smp/debugger.cpp @@ -12,13 +12,14 @@ void SMPDebugger::create() { proceed.setEnabled(false); 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); + layout.append(output, ~0, ~0, 5); + controlLayout.append(stepInto, 80, 0 ); + controlLayout.append(stepOver, 80, 0 ); + controlLayout.append(proceed, 80, 0 ); + controlLayout.append(spacer, 80, ~0 ); + layout.append(controlLayout ); - setGeometry({ 0, 0, layout.minimumWidth() + 300, 220 }); + setGeometry({ 0, 0, layout.minimumGeometry().width + 300, 220 }); append(layout); onClose = []() { diff --git a/bsnes/ui/debugger/smp/debugger.hpp b/bsnes/ui/debugger/smp/debugger.hpp index a2c134ce..9d5220c2 100755 --- a/bsnes/ui/debugger/smp/debugger.hpp +++ b/bsnes/ui/debugger/smp/debugger.hpp @@ -5,6 +5,7 @@ struct SMPDebugger : TopLevelWindow { Button stepInto; Button stepOver; Button proceed; + Widget spacer; void create(); void synchronize(); diff --git a/bsnes/ui/debugger/tools/breakpoint-editor.cpp b/bsnes/ui/debugger/tools/breakpoint-editor.cpp index de8dd5d1..cec01123 100755 --- a/bsnes/ui/debugger/tools/breakpoint-editor.cpp +++ b/bsnes/ui/debugger/tools/breakpoint-editor.cpp @@ -19,17 +19,17 @@ void BreakpointEditor::create() { } layout.setMargin(5); - layout.append(runToBreakpoint, 0, Style::CheckBoxHeight, 5); + layout.append(runToBreakpoint, ~0, 0, 5); for(unsigned n = 0; n < Breakpoints; n++) { - breakpointLayout[n].append(enableBox[n], 35, Style::LineEditHeight); - breakpointLayout[n].append(addressBox[n], 60, Style::LineEditHeight, 5); - breakpointLayout[n].append(valueBox[n], 30, Style::LineEditHeight, 5); - breakpointLayout[n].append(typeBox[n], 80, Style::LineEditHeight, 5); - breakpointLayout[n].append(sourceBox[n], 80, Style::LineEditHeight); - layout.append(breakpointLayout[n], 0, Style::LineEditHeight, 5); + breakpointLayout[n].append(enableBox[n], 35, 0 ); + breakpointLayout[n].append(addressBox[n], 60, 0, 5); + breakpointLayout[n].append(valueBox[n], 30, 0, 5); + breakpointLayout[n].append(typeBox[n], 0, 0, 5); + breakpointLayout[n].append(sourceBox[n], 0, 0 ); + layout.append(breakpointLayout[n], 5); } - setGeometry({ 0, 0, 310, layout.minimumHeight() }); + setGeometry({ 0, 0, 310, layout.minimumGeometry().height }); append(layout); onClose = []() { diff --git a/bsnes/ui/debugger/tools/memory-editor.cpp b/bsnes/ui/debugger/tools/memory-editor.cpp index cd119bd9..ce580196 100755 --- a/bsnes/ui/debugger/tools/memory-editor.cpp +++ b/bsnes/ui/debugger/tools/memory-editor.cpp @@ -15,13 +15,14 @@ void MemoryEditor::create() { refreshButton.setText("Refresh"); 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); + layout.append(editor, ~0, ~0, 5); + controlLayout.append(sourceBox, 80, 0 ); + controlLayout.append(gotoBox, 80, 0 ); + controlLayout.append(refreshButton, 80, 0 ); + controlLayout.append(spacer, 80, ~0 ); + layout.append(controlLayout ); - setGeometry({ 0, 0, layout.minimumWidth() + 475, 230 }); + setGeometry({ 0, 0, layout.minimumGeometry().width + 475, 230 }); append(layout); onClose = []() { diff --git a/bsnes/ui/debugger/tools/memory-editor.hpp b/bsnes/ui/debugger/tools/memory-editor.hpp index 8a2a9dae..8d32be3d 100755 --- a/bsnes/ui/debugger/tools/memory-editor.hpp +++ b/bsnes/ui/debugger/tools/memory-editor.hpp @@ -5,6 +5,7 @@ struct MemoryEditor : TopLevelWindow { ComboBox sourceBox; LineEdit gotoBox; Button refreshButton; + Widget spacer; SNES::Debugger::MemorySource source; unsigned size; diff --git a/bsnes/ui/general/file-browser.cpp b/bsnes/ui/general/file-browser.cpp index 9bd26e59..79fbad34 100755 --- a/bsnes/ui/general/file-browser.cpp +++ b/bsnes/ui/general/file-browser.cpp @@ -7,13 +7,13 @@ void FileBrowser::create() { upButton.setText(".."); layout.setMargin(5); - pathLayout.append(pathBox, 0, 0, 5); - pathLayout.append(browseButton, Style::LineEditHeight, 0, 5); - pathLayout.append(upButton, Style::LineEditHeight, 0); - layout.append(pathLayout, 0, Style::LineEditHeight, 5); - layout.append(contentsBox, 0, 0); + pathLayout.append(pathBox, ~0, 0, 5); + pathLayout.append(browseButton, 25, 25, 5); + pathLayout.append(upButton, 25, 25 ); + layout.append(pathLayout, 5); + layout.append(contentsBox, ~0, ~0 ); - setGeometry({ 0, 0, 640, layout.minimumHeight() + 400 }); + setGeometry({ 0, 0, 640, layout.minimumGeometry().height + 400 }); append(layout); pathBox.onActivate = []() { diff --git a/bsnes/ui/general/slot-loader.cpp b/bsnes/ui/general/slot-loader.cpp index 55bf5280..6230a18f 100755 --- a/bsnes/ui/general/slot-loader.cpp +++ b/bsnes/ui/general/slot-loader.cpp @@ -11,19 +11,19 @@ void SingleSlotLoader::create() { okButton.setText("Ok"); layout.setMargin(5); - baseLayout.append(baseLabel, 40, 0, 5); - baseLayout.append(basePath, 0, 0, 5); - baseLayout.append(baseBrowse, Style::LineEditHeight, 0); - layout.append(baseLayout, 0, Style::LineEditHeight, 5); - slotLayout.append(slotLabel, 40, 0, 5); - slotLayout.append(slotPath, 0, 0, 5); - slotLayout.append(slotBrowse, Style::LineEditHeight, 0); - layout.append(slotLayout, 0, Style::LineEditHeight, 5); - controlLayout.append(spacer, 0, 0); - controlLayout.append(okButton, 80, 0); - layout.append(controlLayout, 0, Style::ButtonHeight); + baseLayout.append(baseLabel, 40, 0, 5); + baseLayout.append(basePath, ~0, 0, 5); + baseLayout.append(baseBrowse, 25, 25 ); + layout.append(baseLayout, 5); + slotLayout.append(slotLabel, 40, 0, 5); + slotLayout.append(slotPath, ~0, 0, 5); + slotLayout.append(slotBrowse, 25, 25 ); + layout.append(slotLayout, 5); + controlLayout.append(spacer, ~0, 0 ); + controlLayout.append(okButton, 80, 0 ); + layout.append(controlLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); baseBrowse.onTick = []() { @@ -105,23 +105,23 @@ void DoubleSlotLoader::create() { okButton.setText("Ok"); layout.setMargin(5); - baseLayout.append(baseLabel, 40, 0, 5); - baseLayout.append(basePath, 0, 0, 5); - baseLayout.append(baseBrowse, Style::LineEditHeight, 0); - layout.append(baseLayout, 0, Style::LineEditHeight, 5); - slotALayout.append(slotALabel, 40, 0, 5); - slotALayout.append(slotAPath, 0, 0, 5); - slotALayout.append(slotABrowse, Style::LineEditHeight, 0); - layout.append(slotALayout, 0, Style::LineEditHeight, 5); - slotBLayout.append(slotBLabel, 40, 0, 5); - slotBLayout.append(slotBPath, 0, 0, 5); - slotBLayout.append(slotBBrowse, Style::LineEditHeight, 0); - layout.append(slotBLayout, 0, Style::LineEditHeight, 5); - controlLayout.append(spacer, 0, 0); - controlLayout.append(okButton, 80, 0); - layout.append(controlLayout, 0, Style::ButtonHeight); + baseLayout.append(baseLabel, 40, 0, 5); + baseLayout.append(basePath, ~0, 0, 5); + baseLayout.append(baseBrowse, 25, 25 ); + layout.append(baseLayout, 5); + slotALayout.append(slotALabel, 40, 0, 5); + slotALayout.append(slotAPath, ~0, 0, 5); + slotALayout.append(slotABrowse, 25, 25 ); + layout.append(slotALayout, 5); + slotBLayout.append(slotBLabel, 40, 0, 5); + slotBLayout.append(slotBPath, ~0, 0, 5); + slotBLayout.append(slotBBrowse, 25, 25 ); + layout.append(slotBLayout, 5); + controlLayout.append(spacer, ~0, 0 ); + controlLayout.append(okButton, 80, 0 ); + layout.append(controlLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); baseBrowse.onTick = []() { diff --git a/bsnes/ui/settings/advanced.cpp b/bsnes/ui/settings/advanced.cpp index 73b6470c..f6c61b29 100755 --- a/bsnes/ui/settings/advanced.cpp +++ b/bsnes/ui/settings/advanced.cpp @@ -20,21 +20,21 @@ void AdvancedSettings::create() { if(config.settings.focusPolicy == 2) focusPolicyAllow.setChecked(); layout.setMargin(5); - layout.append(driverSelectionLabel, 0, Style::LabelHeight); - driverLayout.append(videoDriverLabel, 40, 0, 5); - driverLayout.append(videoDriverBox, 0, 0, 5); - driverLayout.append(audioDriverLabel, 40, 0, 5); - driverLayout.append(audioDriverBox, 0, 0, 5); - driverLayout.append(inputDriverLabel, 40, 0, 5); - driverLayout.append(inputDriverBox, 0, 0); - layout.append(driverLayout, 0, Style::ComboBoxHeight, 5); - layout.append(focusPolicyLabel, 0, Style::LabelHeight); - focusPolicyLayout.append(focusPolicyPause, 0, 0, 5); - focusPolicyLayout.append(focusPolicyIgnore, 0, 0, 5); - focusPolicyLayout.append(focusPolicyAllow, 0, 0); - layout.append(focusPolicyLayout, 0, Style::CheckBoxHeight); + layout.append(driverSelectionLabel, ~0, 0 ); + driverLayout.append(videoDriverLabel, 0, 0, 5); + driverLayout.append(videoDriverBox, ~0, 0, 5); + driverLayout.append(audioDriverLabel, 0, 0, 5); + driverLayout.append(audioDriverBox, ~0, 0, 5); + driverLayout.append(inputDriverLabel, 0, 0, 5); + driverLayout.append(inputDriverBox, ~0, 0 ); + layout.append(driverLayout, 5); + layout.append(focusPolicyLabel, ~0, 0 ); + focusPolicyLayout.append(focusPolicyPause, ~0, 0, 5); + focusPolicyLayout.append(focusPolicyIgnore, ~0, 0, 5); + focusPolicyLayout.append(focusPolicyAllow, ~0, 0); + layout.append(focusPolicyLayout); - setGeometry({ 0, 0, 640, layout.minimumHeight() }); + setGeometry({ 0, 0, 640, layout.minimumGeometry().height }); append(layout); lstring list; diff --git a/bsnes/ui/settings/audio.cpp b/bsnes/ui/settings/audio.cpp index 77c3e7b5..679e77a6 100755 --- a/bsnes/ui/settings/audio.cpp +++ b/bsnes/ui/settings/audio.cpp @@ -10,16 +10,16 @@ void AudioSettings::create() { frequencySlider.setLength(2001); layout.setMargin(5); - volumeLayout.append(volumeLabel, 70, 0); - volumeLayout.append(volumeValue, 60, 0); - volumeLayout.append(volumeSlider, 0, 0); - layout.append(volumeLayout, 0, Style::SliderHeight); - frequencyLayout.append(frequencyLabel, 70, 0); - frequencyLayout.append(frequencyValue, 60, 0); - frequencyLayout.append(frequencySlider, 0, 0); - layout.append(frequencyLayout, 0, Style::SliderHeight); + volumeLayout.append(volumeLabel, 70, 0); + volumeLayout.append(volumeValue, 60, 0); + volumeLayout.append(volumeSlider, ~0, 0); + layout.append(volumeLayout ); + frequencyLayout.append(frequencyLabel, 70, 0); + frequencyLayout.append(frequencyValue, 60, 0); + frequencyLayout.append(frequencySlider, ~0, 0); + layout.append(frequencyLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); volumeSlider.onChange = []() { diff --git a/bsnes/ui/settings/input.cpp b/bsnes/ui/settings/input.cpp index 1dd10288..077ee6f7 100755 --- a/bsnes/ui/settings/input.cpp +++ b/bsnes/ui/settings/input.cpp @@ -24,30 +24,30 @@ void InputSettings::create() { mouseRight.setText("Mouse Right"); layout.setMargin(5); - selectionLayout.append(portLabel, 50, 0, 5); - selectionLayout.append(portBox, 0, 0, 5); - selectionLayout.append(deviceLabel, 50, 0, 5); - selectionLayout.append(deviceBox, 0, 0); - layout.append(selectionLayout, 0, Style::ComboBoxHeight, 5); - layout.append(mappingList, 0, 0, 5); - mapLayout.append(spacer, 0, 0); - mapLayout.append(clearButton, 80, 0); - layout.append(mapLayout, 0, Style::ButtonHeight); + selectionLayout.append(portLabel, 0, 0, 5); + selectionLayout.append(portBox, ~0, 0, 5); + selectionLayout.append(deviceLabel, 0, 0, 5); + selectionLayout.append(deviceBox, ~0, 0 ); + layout.append(selectionLayout, 5); + layout.append(mappingList, ~0, ~0, 5); + mapLayout.append(spacer, ~0, 0 ); + mapLayout.append(clearButton, 80, 0 ); + layout.append(mapLayout); axisLayout.setMargin(5); - axisLayout.append(axisSpacer, 0, 0); - axisControlLayout.append(mouseXaxis, 100, 0, 5); - axisControlLayout.append(mouseYaxis, 100, 0, 5); - axisLayout.append(axisControlLayout, 0, Style::ButtonHeight); + axisLayout.append(axisSpacer, ~0, ~0 ); + axisControlLayout.append(mouseXaxis, 100, 0, 5); + axisControlLayout.append(mouseYaxis, 100, 0, 5); + axisLayout.append(axisControlLayout); buttonLayout.setMargin(5); - buttonLayout.append(buttonSpacer, 0, 0); - buttonControlLayout.append(mouseLeft, 100, 0, 5); - buttonControlLayout.append(mouseMiddle, 100, 0, 5); - buttonControlLayout.append(mouseRight, 100, 0, 5); - buttonLayout.append(buttonControlLayout, 0, Style::ButtonHeight); + buttonLayout.append(buttonSpacer, ~0, ~0 ); + buttonControlLayout.append(mouseLeft, 100, 0, 5); + buttonControlLayout.append(mouseMiddle, 100, 0, 5); + buttonControlLayout.append(mouseRight, 100, 0, 5); + buttonLayout.append(buttonControlLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() + 250 }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); append(axisLayout); append(buttonLayout); diff --git a/bsnes/ui/settings/video.cpp b/bsnes/ui/settings/video.cpp index f7de6f2a..605223e4 100755 --- a/bsnes/ui/settings/video.cpp +++ b/bsnes/ui/settings/video.cpp @@ -21,27 +21,27 @@ void VideoSettings::create() { RadioBox::group(fullscreenCenter, fullscreenScale, fullscreenStretch); layout.setMargin(5); - layout.append(colorAdjustmentLabel, 0, Style::LabelHeight); - brightnessLayout.append(brightnessLabel, 80, 0); - brightnessLayout.append(brightnessValue, 50, 0); - brightnessLayout.append(brightnessSlider, 0, 0); - layout.append(brightnessLayout, 0, Style::SliderHeight); - contrastLayout.append(contrastLabel, 80, 0); - contrastLayout.append(contrastValue, 50, 0); - contrastLayout.append(contrastSlider, 0, 0); - layout.append(contrastLayout, 0, Style::SliderHeight); - gammaLayout.append(gammaLabel, 80, 0); - gammaLayout.append(gammaValue, 50, 0); - gammaLayout.append(gammaSlider, 0, 0); - layout.append(gammaLayout, 0, Style::SliderHeight); - layout.append(gammaRampCheck, 0, Style::CheckBoxHeight, 5); - layout.append(fullscreenLabel, 0, Style::LabelHeight); - fullscreenLayout.append(fullscreenCenter, 0, 0); - fullscreenLayout.append(fullscreenScale, 0, 0); - fullscreenLayout.append(fullscreenStretch, 0, 0); - layout.append(fullscreenLayout, 0, Style::CheckBoxHeight); + layout.append(colorAdjustmentLabel, ~0, 0 ); + brightnessLayout.append(brightnessLabel, 80, 0 ); + brightnessLayout.append(brightnessValue, 50, 0 ); + brightnessLayout.append(brightnessSlider, ~0, 0 ); + layout.append(brightnessLayout ); + contrastLayout.append(contrastLabel, 80, 0 ); + contrastLayout.append(contrastValue, 50, 0 ); + contrastLayout.append(contrastSlider, ~0, 0 ); + layout.append(contrastLayout ); + gammaLayout.append(gammaLabel, 80, 0 ); + gammaLayout.append(gammaValue, 50, 0 ); + gammaLayout.append(gammaSlider, ~0, 0 ); + layout.append(gammaLayout ); + layout.append(gammaRampCheck, ~0, 0, 5); + layout.append(fullscreenLabel, ~0, 0 ); + fullscreenLayout.append(fullscreenCenter, ~0, 0, 5); + fullscreenLayout.append(fullscreenScale, ~0, 0, 5); + fullscreenLayout.append(fullscreenStretch, ~0, 0 ); + layout.append(fullscreenLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height }); append(layout); brightnessSlider.setPosition(config.video.brightness); diff --git a/bsnes/ui/tools/cheat-database.cpp b/bsnes/ui/tools/cheat-database.cpp index fc5d8b5d..0ab13654 100755 --- a/bsnes/ui/tools/cheat-database.cpp +++ b/bsnes/ui/tools/cheat-database.cpp @@ -9,13 +9,13 @@ void CheatDatabase::create() { okButton.setText("Ok"); layout.setMargin(5); - layout.append(listView, 0, 0, 5); - controlLayout.append(selectAllButton, 100, 0, 5); - controlLayout.append(unselectAllButton, 100, 0); - controlLayout.append(spacerWidget, 0, 0); - controlLayout.append(okButton, 80, 0); - layout.append(controlLayout, 0, Style::ButtonHeight); - setGeometry({ 0, 0, 600, layout.minimumHeight() + 350 }); + layout.append(listView, ~0, ~0, 5); + controlLayout.append(selectAllButton, 100, 0, 5); + controlLayout.append(unselectAllButton, 100, 0 ); + controlLayout.append(spacerWidget, ~0, 0 ); + controlLayout.append(okButton, 80, 0 ); + layout.append(controlLayout ); + setGeometry({ 0, 0, 600, layout.minimumGeometry().height + 350 }); append(layout); selectAllButton.onTick = [this]() { diff --git a/bsnes/ui/tools/cheat-editor.cpp b/bsnes/ui/tools/cheat-editor.cpp index 7cb5798b..5e580728 100755 --- a/bsnes/ui/tools/cheat-editor.cpp +++ b/bsnes/ui/tools/cheat-editor.cpp @@ -92,20 +92,20 @@ void CheatEditor::create() { clearButton.setText("Clear"); layout.setMargin(5); - layout.append(cheatList, 0, 0, 5); - codeLayout.append(codeLabel, 80, 0, 5); - codeLayout.append(codeEdit, 0, 0); - layout.append(codeLayout, 0, Style::LineEditHeight, 5); - descLayout.append(descLabel, 80, 0, 5); - descLayout.append(descEdit, 0, 0); - layout.append(descLayout, 0, Style::LineEditHeight, 5); - controlLayout.append(findButton, 100, 0); - controlLayout.append(spacerWidget, 0, 0); + layout.append(cheatList, ~0, ~0, 5); + codeLayout.append(codeLabel, 80, 0, 5); + codeLayout.append(codeEdit, ~0, 0 ); + layout.append(codeLayout, 5); + descLayout.append(descLabel, 80, 0, 5); + descLayout.append(descEdit, ~0, 0 ); + layout.append(descLayout, 5); + controlLayout.append(findButton, 100, 0 ); + controlLayout.append(spacerWidget, ~0, 0 ); controlLayout.append(clearAllButton, 80, 0, 5); - controlLayout.append(clearButton, 80, 0); - layout.append(controlLayout, 0, Style::ButtonHeight); + controlLayout.append(clearButton, 80, 0 ); + layout.append(controlLayout); - setGeometry({ 0, 0, 480, layout.minimumHeight() + 250 }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); synchronize(); diff --git a/bsnes/ui/tools/state-manager.cpp b/bsnes/ui/tools/state-manager.cpp index 3ebbf2cb..e8578e10 100755 --- a/bsnes/ui/tools/state-manager.cpp +++ b/bsnes/ui/tools/state-manager.cpp @@ -12,17 +12,17 @@ void StateManager::create() { eraseButton.setText("Erase"); layout.setMargin(5); - layout.append(stateList, 0, 0, 5); - descLayout.append(descLabel, 80, 0, 5); - descLayout.append(descEdit, 0, 0); - layout.append(descLayout, 0, Style::LineEditHeight, 5); - controlLayout.append(spacer, 0, 0); - controlLayout.append(loadButton, 80, 0, 5); - controlLayout.append(saveButton, 80, 0, 5); - controlLayout.append(eraseButton, 80, 0); - layout.append(controlLayout, 0, Style::ButtonHeight); + layout.append(stateList, ~0, ~0, 5); + descLayout.append(descLabel, 80, 0, 5); + descLayout.append(descEdit, ~0, 0 ); + layout.append(descLayout, 5); + controlLayout.append(spacer, 0, 0 ); + controlLayout.append(loadButton, 80, 0, 5); + controlLayout.append(saveButton, 80, 0, 5); + controlLayout.append(eraseButton, 80, 0 ); + layout.append(controlLayout ); - setGeometry({ 0, 0, 480, layout.minimumHeight() + 250 }); + setGeometry({ 0, 0, 480, layout.minimumGeometry().height + 250 }); append(layout); synchronize();