Update to v075r11 release.

byuu says:

Rewrote the way menus are attached, they act like layouts/widgets now.

All three phoenix targets once again work with both radio menu items and
radio widgets. Both GTK+ and Qt have built-in group controls right
inside the widgets, so I don't have to keep my own groups around
anymore. They do act screwy at widget creation though, have to jump
through some hoops to get it to work right. All I can say is, definitely
set all child widgets to the parent before trying to check any of them.

My long-term goal for the main window is to honor the fullscreen video
setting as a generic setting, and let the window scale auto-fit the best
possible size that matches your scale preference into the output window,
centered just like fullscreen. For now, I've just set it to a fixed
window size until I finish working on phoenix. The scale X settings will
just be to snap the window to an exact size in case you don't want any
black borders, they won't be radio items and the bsnes-geometry.cfg file
will save width/height information as well.

Simplified the sizing requirements for creating layouts and updated all
bsnes windows to support the new system. Layouts also expose their
minimum width/height values, which I use to create perfectly sized
windows on all three platforms. This will fix cut-off heights on the
last Windows WIP. Qt is being annoying though and forcing a minimum
window size of 300,100 despite me telling it to use a smaller window
size. Always have to fight with Qt, I swear to god.
This commit is contained in:
Tim Allen 2011-02-10 21:08:12 +11:00
parent 7dda70baa4
commit a8ee35633c
111 changed files with 1429 additions and 1104 deletions

View File

@ -65,8 +65,11 @@ intmax_t integer(const char *str) {
intmax_t result = 0;
bool negate = false;
//check for negation
if(*str == '-') {
//check for sign
if(*str == '+') {
negate = false;
str++;
} else if(*str == '-') {
negate = true;
str++;
}

View File

@ -50,7 +50,7 @@ string integer(intmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string linteger(intmax_t value) {
@ -77,7 +77,7 @@ template<unsigned length_> string linteger(intmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string rinteger(intmax_t value) {
@ -104,7 +104,7 @@ template<unsigned length_> string rinteger(intmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
string decimal(uintmax_t value) {
@ -126,7 +126,7 @@ string decimal(uintmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string ldecimal(uintmax_t value) {
@ -149,7 +149,7 @@ template<unsigned length_> string ldecimal(uintmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string rdecimal(uintmax_t value) {
@ -172,7 +172,7 @@ template<unsigned length_> string rdecimal(uintmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string hex(uintmax_t value) {
@ -194,7 +194,7 @@ template<unsigned length_> string hex(uintmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
template<unsigned length_> string binary(uintmax_t value) {
@ -216,7 +216,7 @@ template<unsigned length_> string binary(uintmax_t value) {
result[x] = buffer[y];
}
return result;
return (const char*)result;
}
//using sprintf is certainly not the most ideal method to convert

View File

@ -0,0 +1,29 @@
static void Action_setFont(GtkWidget *widget, gpointer font) {
if(font) {
gtk_widget_modify_font(widget, (PangoFontDescription*)font);
if(GTK_IS_CONTAINER(widget)) {
gtk_container_foreach(GTK_CONTAINER(widget), (GtkCallback)Action_setFont, (PangoFontDescription*)font);
}
}
}
bool Action::visible() {
return gtk_widget_get_visible(object->widget);
}
void Action::setVisible(bool visible) {
gtk_widget_set_visible(object->widget, visible);
}
bool Action::enabled() {
return gtk_widget_get_sensitive(object->widget);
}
void Action::setEnabled(bool enabled) {
gtk_widget_set_sensitive(object->widget, enabled);
}
Action::Action() {
action = new Action::Data;
action->font = 0;
}

View File

@ -0,0 +1,22 @@
static void MenuCheckItem_tick(MenuCheckItem *self) {
if(self->onTick && self->object->locked == false) self->onTick();
}
void MenuCheckItem::setText(const string &text) {
gtk_menu_item_set_label(GTK_MENU_ITEM(object->widget), text);
}
bool MenuCheckItem::checked() {
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(object->widget));
}
void MenuCheckItem::setChecked(bool state) {
object->locked = true;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(object->widget), state);
object->locked = false;
}
MenuCheckItem::MenuCheckItem() {
object->widget = gtk_check_menu_item_new_with_label("");
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuCheckItem_tick), (gpointer)this);
}

View File

@ -0,0 +1,12 @@
static void MenuItem_tick(MenuItem *self) {
if(self->onTick) self->onTick();
}
void MenuItem::setText(const string &text) {
gtk_menu_item_set_label(GTK_MENU_ITEM(object->widget), text);
}
MenuItem::MenuItem() {
object->widget = gtk_menu_item_new_with_label("");
g_signal_connect_swapped(G_OBJECT(object->widget), "activate", G_CALLBACK(MenuItem_tick), (gpointer)this);
}

View File

@ -0,0 +1,31 @@
static void MenuRadioItem_tick(MenuRadioItem *self) {
if(self->onTick && self->checked() && self->object->locked == false) self->onTick();
}
void MenuRadioItem::setParent(MenuRadioItem &parent) {
gtk_radio_menu_item_set_group(
GTK_RADIO_MENU_ITEM(object->widget),
gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(parent.object->widget))
);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(object->widget), false);
}
void MenuRadioItem::setText(const string &text) {
gtk_menu_item_set_label(GTK_MENU_ITEM(object->widget), text);
}
bool MenuRadioItem::checked() {
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(object->widget));
}
void MenuRadioItem::setChecked() {
object->locked = true;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(object->widget), true);
object->locked = false;
}
MenuRadioItem::MenuRadioItem() {
object->widget = gtk_radio_menu_item_new_with_label(0, "");
setChecked();
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuRadioItem_tick), (gpointer)this);
}

View File

@ -0,0 +1,3 @@
MenuSeparator::MenuSeparator() {
object->widget = gtk_separator_menu_item_new();
}

View File

@ -0,0 +1,14 @@
void Menu::append(Action &action) {
gtk_menu_shell_append(GTK_MENU_SHELL(object->menu), action.object->widget);
gtk_widget_show(action.object->widget);
}
void Menu::setText(const string &text) {
gtk_menu_item_set_label(GTK_MENU_ITEM(object->widget), text);
}
Menu::Menu() {
object->menu = gtk_menu_new();
object->widget = gtk_menu_item_new_with_label("");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(object->widget), object->menu);
}

View File

@ -1,3 +1,7 @@
#include <nall/config.hpp>
#include <nall/platform.hpp>
using namespace nall;
#include <unistd.h>
#include <pwd.h>
#include <sys/stat.h>
@ -17,27 +21,35 @@ using namespace nall;
namespace phoenix {
#include "settings.cpp"
#include "object.cpp"
#include "font.cpp"
#include "menu.cpp"
#include "widget.cpp"
#include "window.cpp"
#include "layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"
#include "combobox.cpp"
#include "editbox.cpp"
#include "hexeditor.cpp"
#include "horizontalslider.cpp"
#include "label.cpp"
#include "listbox.cpp"
#include "progressbar.cpp"
#include "radiobox.cpp"
#include "textbox.cpp"
#include "verticalslider.cpp"
#include "viewport.cpp"
#include "messagewindow.cpp"
#include "message-window.cpp"
#include "action/action.cpp"
#include "action/menu.cpp"
#include "action/menu-separator.cpp"
#include "action/menu-item.cpp"
#include "action/menu-check-item.cpp"
#include "action/menu-radio-item.cpp"
#include "widget/widget.cpp"
#include "widget/button.cpp"
#include "widget/canvas.cpp"
#include "widget/check-box.cpp"
#include "widget/combo-box.cpp"
#include "widget/edit-box.cpp"
#include "widget/hex-editor.cpp"
#include "widget/horizontal-slider.cpp"
#include "widget/label.cpp"
#include "widget/list-box.cpp"
#include "widget/progress-bar.cpp"
#include "widget/radio-box.cpp"
#include "widget/text-box.cpp"
#include "widget/vertical-slider.cpp"
#include "widget/viewport.cpp"
Window Window::None;
@ -46,6 +58,8 @@ void OS::initialize() {
if(initialized == true) return;
initialized = true;
settings.load();
int argc = 1;
char *argv[2];
argv[0] = new char[8];
@ -78,6 +92,7 @@ void OS::main() {
}
void OS::quit() {
settings.save();
gtk_main_quit();
}

View File

@ -13,10 +13,10 @@ struct Object {
};
struct Geometry {
unsigned x, y;
signed x, y;
unsigned width, height;
inline Geometry() : x(0), y(0), width(0), height(0) {}
inline Geometry(unsigned x, unsigned y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
inline Geometry(signed x, signed y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
};
struct Font : Object {
@ -36,63 +36,24 @@ struct Font : Object {
inline Font::Style operator|(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a | (unsigned)b); }
inline Font::Style operator&(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a & (unsigned)b); }
struct Action : Object {
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
Action();
//private:
struct Data;
Data *action;
};
struct Menu : Action {
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
};
struct MenuSeparator : Action {
void create(Menu &parent);
};
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
bool checked();
void setChecked(bool checked = true);
};
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
bool checked();
void setChecked();
private:
MenuRadioItem *first;
};
struct Menu;
struct Layout;
struct Widget;
struct Window : Object {
static Window None;
nall::function<bool ()> onClose;
nall::function<void ()> onMove;
nall::function<void ()> onResize;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
nall::function<void ()> onSize;
void append(Menu &menu);
void setLayout(Layout &layout);
void setResizable(bool resizable = true);
bool focused();
void setFocused();
Geometry frameGeometry();
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
void setFrameGeometry(signed x, signed y, unsigned width, unsigned height);
void setGeometry(signed x, signed y, unsigned width, unsigned height);
void setDefaultFont(Font &font);
void setFont(Font &font);
void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
@ -107,13 +68,57 @@ struct Window : Object {
//private:
struct Data;
Data *window;
static Window None;
void updateFrameGeometry();
};
struct Action : Object {
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
Action();
//private:
struct Data;
Data *action;
};
struct Menu : Action {
void append(Action &action);
void setText(const nall::string &text);
Menu();
};
struct MenuSeparator : Action {
MenuSeparator();
};
struct MenuItem : Action {
nall::function<void ()> onTick;
void setText(const nall::string &text);
MenuItem();
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void setText(const nall::string &text);
bool checked();
void setChecked(bool checked = true);
MenuCheckItem();
};
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void setParent(MenuRadioItem &parent);
void setText(const nall::string &text);
bool checked();
void setChecked();
MenuRadioItem();
};
struct Layout : Object {
virtual void setParent(Window &parent);
virtual void setGeometry(Geometry &geometry) = 0;
virtual void append(Widget &widget);
virtual void update(Geometry &geometry) = 0;
Layout();
//private:
struct Data;
@ -255,8 +260,6 @@ struct RadioBox : Widget {
bool checked();
void setChecked();
RadioBox();
private:
RadioBox *first;
};
struct TextBox : Widget {

View File

@ -1,129 +0,0 @@
static void Action_setFont(GtkWidget *widget, gpointer font) {
if(font) {
gtk_widget_modify_font(widget, (PangoFontDescription*)font);
if(GTK_IS_CONTAINER(widget)) {
gtk_container_foreach(GTK_CONTAINER(widget), (GtkCallback)Action_setFont, (PangoFontDescription*)font);
}
}
}
bool Action::visible() {
return gtk_widget_get_visible(object->widget);
}
void Action::setVisible(bool visible) {
gtk_widget_set_visible(object->widget, visible);
}
bool Action::enabled() {
return gtk_widget_get_sensitive(object->widget);
}
void Action::setEnabled(bool enabled) {
gtk_widget_set_sensitive(object->widget, enabled);
}
Action::Action() {
action = new Action::Data;
action->font = 0;
}
void Menu::create(Window &parent, const string &text) {
action->font = parent.window->defaultFont;
object->menu = gtk_menu_new();
object->widget = gtk_menu_item_new_with_label(text);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(object->widget), object->menu);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_bar_append(parent.object->menu, object->widget);
gtk_widget_show(object->widget);
}
void Menu::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->menu = gtk_menu_new();
object->widget = gtk_menu_item_new_with_label(text);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(object->widget), object->menu);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(parent.object->menu), object->widget);
gtk_widget_show(object->widget);
}
void MenuSeparator::create(Menu &parent) {
action->font = parent.action->font;
object->widget = gtk_separator_menu_item_new();
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(parent.object->menu), object->widget);
gtk_widget_show(object->widget);
}
static void MenuItem_tick(MenuItem *self) {
if(self->onTick) self->onTick();
}
void MenuItem::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->widget = gtk_menu_item_new_with_label(text);
g_signal_connect_swapped(G_OBJECT(object->widget), "activate", G_CALLBACK(MenuItem_tick), (gpointer)this);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(parent.object->menu), object->widget);
gtk_widget_show(object->widget);
}
static void MenuCheckItem_tick(MenuCheckItem *self) {
if(self->onTick && self->object->locked == false) self->onTick();
}
void MenuCheckItem::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->widget = gtk_check_menu_item_new_with_label(text);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuCheckItem_tick), (gpointer)this);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(parent.object->menu), object->widget);
gtk_widget_show(object->widget);
}
bool MenuCheckItem::checked() {
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(object->widget));
}
void MenuCheckItem::setChecked(bool state) {
object->locked = true;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(object->widget), state);
object->locked = false;
}
static void MenuRadioItem_tick(MenuRadioItem *self) {
if(self->onTick && self->checked() && self->object->locked == false) self->onTick();
}
void MenuRadioItem::create(Menu &parent, const string &text) {
first = this;
action->font = parent.action->font;
object->parentMenu = &parent;
object->widget = gtk_radio_menu_item_new_with_label(0, text);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuRadioItem_tick), (gpointer)this);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(parent.object->menu), object->widget);
gtk_widget_show(object->widget);
}
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
first = parent.first;
action->font = parent.action->font;
object->parentMenu = parent.object->parentMenu;
object->widget = gtk_radio_menu_item_new_with_label_from_widget(GTK_RADIO_MENU_ITEM(first->object->widget), text);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuRadioItem_tick), (gpointer)this);
if(action->font) Action_setFont(object->widget, action->font->font->font);
gtk_menu_shell_append(GTK_MENU_SHELL(object->parentMenu->object->menu), object->widget);
gtk_widget_show(object->widget);
}
bool MenuRadioItem::checked() {
return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(object->widget));
}
void MenuRadioItem::setChecked() {
object->locked = true;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(object->widget), true);
object->locked = false;
}

29
bsnes/phoenix/gtk/settings.cpp Executable file
View File

@ -0,0 +1,29 @@
struct Settings : public configuration {
unsigned frameGeometryX;
unsigned frameGeometryY;
unsigned frameGeometryWidth;
unsigned frameGeometryHeight;
void load() {
string path = { userpath(), ".config/phoenix/gtk.cfg" };
configuration::load(path);
}
void save() {
string path = { userpath(), ".config/" };
mkdir(path, 0755);
path.append("phoenix/");
mkdir(path, 0755);
path.append("gtk.cfg");
configuration::save(path);
}
Settings() {
attach(frameGeometryX = 0, "frameGeometryX");
attach(frameGeometryY = 0, "frameGeometryY");
attach(frameGeometryWidth = 0, "frameGeometryWidth");
attach(frameGeometryHeight = 0, "frameGeometryHeight");
}
};
static Settings settings;

View File

@ -3,7 +3,11 @@ static void RadioBox_tick(RadioBox *self) {
}
void RadioBox::setParent(RadioBox &parent) {
first = parent.first;
gtk_radio_button_set_group(
GTK_RADIO_BUTTON(object->widget),
gtk_radio_button_get_group(GTK_RADIO_BUTTON(parent.object->widget))
);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object->widget), false);
}
void RadioBox::setText(const string &text) {
@ -21,7 +25,7 @@ void RadioBox::setChecked() {
}
RadioBox::RadioBox() {
first = this;
object->widget = gtk_radio_button_new_with_label(0, "");
// setChecked();
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(RadioBox_tick), (gpointer)this);
}

View File

@ -1,3 +1,6 @@
static void Action_setFont(GtkWidget *widget, gpointer font);
static void Widget_setFont(GtkWidget *widget, gpointer font);
static gint Window_close(Window *window) {
if(window->onClose) {
if(window->onClose()) window->setVisible(false);
@ -8,58 +11,33 @@ static gint Window_close(Window *window) {
}
static void Window_configure(GtkWindow *widget, GdkEvent *event, Window *window) {
if(gtk_widget_get_realized(window->object->widget) == false) return;
window->updateFrameGeometry();
if(window->window->x != event->configure.x || window->window->y != event->configure.y) {
window->window->x = event->configure.x;
window->window->y = event->configure.y;
if(window->onMove) window->onMove();
}
if(window->window->width != event->configure.width || window->window->height != event->configure.height) {
window->window->width = event->configure.width;
window->window->height = event->configure.height;
Geometry geom = window->geometry();
geom.x = geom.y = 0;
if(window->window->layout) window->window->layout->update(geom);
if(window->onResize) window->onResize();
if(window->window->layout) window->window->layout->setGeometry(geom);
if(window->onSize) window->onSize();
}
}
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
window->x = x;
window->y = y;
window->width = width;
window->height = height;
object->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_move(GTK_WINDOW(object->widget), x, y);
gtk_window_set_title(GTK_WINDOW(object->widget), text);
gtk_window_set_resizable(GTK_WINDOW(object->widget), true);
gtk_widget_set_app_paintable(object->widget, true);
g_signal_connect_swapped(G_OBJECT(object->widget), "delete_event", G_CALLBACK(Window_close), (gpointer)this);
g_signal_connect(G_OBJECT(object->widget), "configure_event", G_CALLBACK(Window_configure), (gpointer)this);
object->menuContainer = gtk_vbox_new(false, 0);
gtk_container_add(GTK_CONTAINER(object->widget), object->menuContainer);
gtk_widget_show(object->menuContainer);
object->menu = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->menu, false, false, 0);
object->formContainer = gtk_fixed_new();
gtk_widget_set_size_request(object->formContainer, width, height);
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->formContainer, true, true, 0);
gtk_widget_show(object->formContainer);
object->statusContainer = gtk_event_box_new();
object->status = gtk_statusbar_new();
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(object->status), false);
gtk_container_add(GTK_CONTAINER(object->statusContainer), object->status);
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->statusContainer, false, false, 0);
gtk_widget_show(object->statusContainer);
gtk_widget_realize(object->widget);
void Window::append(Menu &menu) {
menu.action->font = window->defaultFont;
if(window->defaultFont) Action_setFont(menu.object->widget, window->defaultFont->font->font);
gtk_menu_bar_append(object->menu, menu.object->widget);
gtk_widget_show(menu.object->widget);
}
void Window::setLayout(Layout &layout) {
@ -67,7 +45,7 @@ void Window::setLayout(Layout &layout) {
layout.setParent(*this);
Geometry geom = geometry();
geom.x = geom.y = 0;
layout.update(geom);
layout.setGeometry(geom);
}
void Window::setResizable(bool resizable) {
@ -84,15 +62,31 @@ void Window::setFocused() {
}
Geometry Window::frameGeometry() {
return {
window->x - settings.frameGeometryX, window->y - settings.frameGeometryY,
window->width + settings.frameGeometryWidth, window->height + settings.frameGeometryHeight
};
}
Geometry Window::geometry() {
return { window->x, window->y, window->width, window->height };
}
void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) {
gtk_window_move(GTK_WINDOW(object->widget), window->x = x, window->y = y);
gtk_widget_set_size_request(object->formContainer, window->width = width, window->height = height);
void Window::setFrameGeometry(signed x, signed y, unsigned width, unsigned height) {
setGeometry(
x + settings.frameGeometryX, y + settings.frameGeometryY,
width - settings.frameGeometryWidth, height - settings.frameGeometryHeight
);
}
void Window::setGeometry(signed x, signed y, unsigned width, unsigned height) {
window->x = x;
window->y = y;
window->width = width;
window->height = height;
gtk_window_move(GTK_WINDOW(object->widget), x - settings.frameGeometryX, y - settings.frameGeometryY);
gtk_widget_set_size_request(object->formContainer, width, height);
}
void Window::setDefaultFont(Font &font) {
@ -156,10 +150,57 @@ Window::Window() {
window = new Window::Data;
window->layout = 0;
window->defaultFont = 0;
window->resizable = false;
window->resizable = true;
window->fullscreen = false;
window->x = 0;
window->y = 0;
window->width = 0;
window->height = 0;
window->x = 128;
window->y = 128;
window->width = 256;
window->height = 256;
object->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_move(GTK_WINDOW(object->widget), window->x, window->y);
gtk_window_set_resizable(GTK_WINDOW(object->widget), window->resizable);
gtk_widget_set_app_paintable(object->widget, true);
object->menuContainer = gtk_vbox_new(false, 0);
gtk_container_add(GTK_CONTAINER(object->widget), object->menuContainer);
gtk_widget_show(object->menuContainer);
object->menu = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->menu, false, false, 0);
object->formContainer = gtk_fixed_new();
gtk_widget_set_size_request(object->formContainer, window->width, window->height);
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->formContainer, true, true, 0);
gtk_widget_show(object->formContainer);
object->statusContainer = gtk_event_box_new();
object->status = gtk_statusbar_new();
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(object->status), false);
gtk_container_add(GTK_CONTAINER(object->statusContainer), object->status);
gtk_box_pack_start(GTK_BOX(object->menuContainer), object->statusContainer, false, false, 0);
gtk_widget_show(object->statusContainer);
g_signal_connect_swapped(G_OBJECT(object->widget), "delete_event", G_CALLBACK(Window_close), (gpointer)this);
g_signal_connect(G_OBJECT(object->widget), "configure_event", G_CALLBACK(Window_configure), (gpointer)this);
}
//internal
void Window::updateFrameGeometry() {
Display *display = XOpenDisplay(0);
XWindowAttributes attributes, parentAttributes;
XGetWindowAttributes(display, GDK_WINDOW_XID(object->widget->window), &attributes);
X11Window rootWindow, parentWindow, *childWindow = 0;
unsigned int childCount;
XQueryTree(display, GDK_WINDOW_XID(object->widget->window), &rootWindow, &parentWindow, &childWindow, &childCount);
XGetWindowAttributes(display, parentWindow, &parentAttributes);
if(childWindow) XFree(childWindow);
XCloseDisplay(display);
settings.frameGeometryX = attributes.x;
settings.frameGeometryY = attributes.y;
settings.frameGeometryWidth = parentAttributes.width - attributes.width;
settings.frameGeometryHeight = parentAttributes.height - attributes.height;
}

View File

@ -10,7 +10,7 @@ void FixedLayout::append(Widget &widget, unsigned x, unsigned y, unsigned width,
children.append({ &widget, x, y, width, height });
}
void FixedLayout::update(Geometry &geometry) {
void FixedLayout::setGeometry(Geometry &geometry) {
}
FixedLayout::FixedLayout() {

View File

@ -1,7 +1,7 @@
struct FixedLayout : public Layout {
void setParent(Window &parent);
void setGeometry(Geometry &geometry);
void append(Widget &widget, unsigned x, unsigned y, unsigned width, unsigned height);
void update(Geometry &geometry);
FixedLayout();
//private:

View File

@ -7,6 +7,8 @@ void HorizontalLayout::setParent(Window &parent) {
}
void HorizontalLayout::append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing) {
layout.width = width;
layout.height = height;
children.append({ &layout, 0, width, height, spacing });
}
@ -14,12 +16,15 @@ void HorizontalLayout::append(Widget &widget, unsigned width, unsigned height, u
children.append({ 0, &widget, width, height, spacing });
}
void HorizontalLayout::update(Geometry &geometry) {
void HorizontalLayout::setGeometry(Geometry &geometry) {
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 baseGeometry = geometry;
linear_vector<HorizontalLayout::Children> children = this->children;
@ -31,8 +36,8 @@ void HorizontalLayout::update(Geometry &geometry) {
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;
if(child.width == 0) child.width = (geometryWidth - minimumWidth) / autosizeWidgets;
if(child.height == 0) child.height = geometryHeight;
}
unsigned maxHeight = 0;
@ -42,7 +47,7 @@ void HorizontalLayout::update(Geometry &geometry) {
foreach(child, children) {
if(child.layout) {
child.layout->update(geometry);
child.layout->setGeometry(geometry);
geometry.x += child.spacing;
geometry.width -= child.spacing;
geometry.y = baseGeometry.y;
@ -64,6 +69,14 @@ void HorizontalLayout::setMargin(unsigned margin_) {
margin = margin_;
}
unsigned HorizontalLayout::minimumWidth() {
unsigned width = margin * 2;
foreach(child, children) width += child.width + child.spacing;
return width;
}
HorizontalLayout::HorizontalLayout() {
margin = 0;
width = 0;
height = 0;
}

View File

@ -2,14 +2,17 @@ struct VerticalLayout;
struct HorizontalLayout : public Layout {
void setParent(Window &parent);
void setGeometry(Geometry &geometry);
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);
void setMargin(unsigned margin);
unsigned minimumWidth();
HorizontalLayout();
//private:
unsigned margin;
unsigned width;
unsigned height;
struct Children {
VerticalLayout *layout;
Widget *widget;

View File

@ -7,6 +7,8 @@ void VerticalLayout::setParent(Window &parent) {
}
void VerticalLayout::append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing) {
layout.width = width;
layout.height = height;
children.append({ &layout, 0, width, height, spacing });
}
@ -14,12 +16,15 @@ void VerticalLayout::append(Widget &widget, unsigned width, unsigned height, uns
children.append({ 0, &widget, width, height, spacing });
}
void VerticalLayout::update(Geometry &geometry) {
void VerticalLayout::setGeometry(Geometry &geometry) {
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 baseGeometry = geometry;
linear_vector<VerticalLayout::Children> children = this->children;
@ -31,8 +36,8 @@ void VerticalLayout::update(Geometry &geometry) {
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;
if(child.width == 0) child.width = geometryWidth;
if(child.height == 0) child.height = (geometryHeight - minimumHeight) / autosizeWidgets;
}
unsigned maxWidth = 0;
@ -42,7 +47,7 @@ void VerticalLayout::update(Geometry &geometry) {
foreach(child, children) {
if(child.layout) {
child.layout->update(geometry);
child.layout->setGeometry(geometry);
geometry.x = baseGeometry.x;
geometry.width = baseGeometry.width;
geometry.y += child.spacing;
@ -64,6 +69,14 @@ void VerticalLayout::setMargin(unsigned margin_) {
margin = margin_;
}
unsigned VerticalLayout::minimumHeight() {
unsigned height = margin * 2;
foreach(child, children) height += child.height + child.spacing;
return height;
}
VerticalLayout::VerticalLayout() {
margin = 0;
width = 0;
height = 0;
}

View File

@ -2,14 +2,17 @@ struct HorizontalLayout;
struct VerticalLayout : public Layout {
void setParent(Window &parent);
void setGeometry(Geometry &geometry);
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);
void setMargin(unsigned margin);
unsigned minimumHeight();
VerticalLayout();
//private:
unsigned margin;
unsigned width;
unsigned height;
struct Children {
HorizontalLayout *layout;
Widget *widget;

View File

View File

@ -0,0 +1,33 @@
void MenuCheckItem::setText(const string &text) {
menuCheckItem->setText(QString::fromUtf8(text));
}
bool MenuCheckItem::visible() {
return menuCheckItem->isVisible();
}
void MenuCheckItem::setVisible(bool visible) {
menuCheckItem->setVisible(visible);
}
bool MenuCheckItem::enabled() {
return menuCheckItem->isEnabled();
}
void MenuCheckItem::setEnabled(bool enabled) {
menuCheckItem->setEnabled(enabled);
}
bool MenuCheckItem::checked() {
return menuCheckItem->isChecked();
}
void MenuCheckItem::setChecked(bool checked) {
menuCheckItem->setChecked(checked);
}
MenuCheckItem::MenuCheckItem() {
menuCheckItem = new MenuCheckItem::Data(*this);
menuCheckItem->setCheckable(true);
menuCheckItem->connect(menuCheckItem, SIGNAL(triggered()), SLOT(onTick()));
}

View File

@ -0,0 +1,24 @@
void MenuItem::setText(const string &text) {
menuItem->setText(QString::fromUtf8(text));
}
bool MenuItem::visible() {
return menuItem->isVisible();
}
void MenuItem::setVisible(bool visible) {
menuItem->setVisible(visible);
}
bool MenuItem::enabled() {
return menuItem->isEnabled();
}
void MenuItem::setEnabled(bool enabled) {
menuItem->setEnabled(enabled);
}
MenuItem::MenuItem() {
menuItem = new MenuItem::Data(*this);
menuItem->connect(menuItem, SIGNAL(triggered()), SLOT(onTick()));
}

View File

@ -0,0 +1,41 @@
void MenuRadioItem::setParent(MenuRadioItem &parent) {
delete menuRadioItem->actionGroup();
menuRadioItem->setActionGroup(parent.menuRadioItem->actionGroup());
}
void MenuRadioItem::setText(const string &text) {
menuRadioItem->setText(QString::fromUtf8(text));
}
bool MenuRadioItem::visible() {
return menuRadioItem->isVisible();
}
void MenuRadioItem::setVisible(bool visible) {
menuRadioItem->setVisible(visible);
}
bool MenuRadioItem::enabled() {
return menuRadioItem->isEnabled();
}
void MenuRadioItem::setEnabled(bool enabled) {
menuRadioItem->setEnabled(enabled);
}
bool MenuRadioItem::checked() {
return menuRadioItem->isChecked();
}
void MenuRadioItem::setChecked() {
object->locked = true;
menuRadioItem->setChecked(true);
object->locked = false;
}
MenuRadioItem::MenuRadioItem() {
menuRadioItem = new MenuRadioItem::Data(*this);
menuRadioItem->setCheckable(true);
menuRadioItem->setActionGroup(new QActionGroup(0));
menuRadioItem->connect(menuRadioItem, SIGNAL(changed()), SLOT(onTick()));
}

View File

@ -0,0 +1,19 @@
bool MenuSeparator::visible() {
return menuSeparator->action->isVisible();
}
void MenuSeparator::setVisible(bool visible) {
menuSeparator->action->setVisible(visible);
}
bool MenuSeparator::enabled() {
return menuSeparator->action->isEnabled();
}
void MenuSeparator::setEnabled(bool enabled) {
menuSeparator->action->setEnabled(enabled);
}
MenuSeparator::MenuSeparator() {
menuSeparator = new MenuSeparator::Data(*this);
}

View File

@ -0,0 +1,39 @@
void Menu::setText(const string &text) {
menu->setTitle(QString::fromUtf8(text));
}
void Menu::append(Action &item) {
if(dynamic_cast<Menu*>(&item)) {
menu->addMenu(((Menu*)&item)->menu);
} else if(dynamic_cast<MenuSeparator*>(&item)) {
menu->addSeparator();
} else if(dynamic_cast<MenuItem*>(&item)) {
menu->addAction(((MenuItem*)&item)->menuItem);
} else if(dynamic_cast<MenuCheckItem*>(&item)) {
menu->addAction(((MenuCheckItem*)&item)->menuCheckItem);
} else if(dynamic_cast<MenuRadioItem*>(&item)) {
MenuRadioItem &radioItem = (MenuRadioItem&)item;
menu->addAction(radioItem.menuRadioItem);
if(radioItem.menuRadioItem->actionGroup()->checkedAction() == 0) radioItem.setChecked();
}
}
bool Menu::visible() {
return menu->isVisible();
}
void Menu::setVisible(bool visible) {
menu->setVisible(visible);
}
bool Menu::enabled() {
return menu->isEnabled();
}
void Menu::setEnabled(bool enabled) {
menu->setEnabled(enabled);
}
Menu::Menu() {
menu = new Menu::Data(*this);
}

View File

@ -1,169 +0,0 @@
void Menu::create(Window &parent, const string &text) {
menu->parent = &parent;
if(menu->parent->window->defaultFont) menu->setFont(*menu->parent->window->defaultFont);
menu->setTitle(QString::fromUtf8(text));
parent.window->menuBar->addMenu(menu);
}
void Menu::create(Menu &parent, const string &text) {
menu->parent = parent.menu->parent;
if(menu->parent->window->defaultFont) menu->setFont(*menu->parent->window->defaultFont);
menu->setTitle(QString::fromUtf8(text));
parent.menu->addMenu(menu);
}
bool Menu::visible() {
return menu->isVisible();
}
void Menu::setVisible(bool visible) {
menu->setVisible(visible);
}
bool Menu::enabled() {
return menu->isEnabled();
}
void Menu::setEnabled(bool enabled) {
menu->setEnabled(enabled);
}
Menu::Menu() {
menu = new Menu::Data(*this);
}
void MenuSeparator::create(Menu &parent) {
menuSeparator->action = parent.menu->addSeparator();
}
bool MenuSeparator::visible() {
return menuSeparator->action->isVisible();
}
void MenuSeparator::setVisible(bool visible) {
menuSeparator->action->setVisible(visible);
}
bool MenuSeparator::enabled() {
return menuSeparator->action->isEnabled();
}
void MenuSeparator::setEnabled(bool enabled) {
menuSeparator->action->setEnabled(enabled);
}
MenuSeparator::MenuSeparator() {
menuSeparator = new MenuSeparator::Data(*this);
}
void MenuItem::create(Menu &parent, const string &text) {
menuItem->setText(QString::fromUtf8(text));
menuItem->connect(menuItem, SIGNAL(triggered()), SLOT(onTick()));
parent.menu->addAction(menuItem);
}
bool MenuItem::visible() {
return menuItem->isVisible();
}
void MenuItem::setVisible(bool visible) {
menuItem->setVisible(visible);
}
bool MenuItem::enabled() {
return menuItem->isEnabled();
}
void MenuItem::setEnabled(bool enabled) {
menuItem->setEnabled(enabled);
}
MenuItem::MenuItem() {
menuItem = new MenuItem::Data(*this);
}
void MenuCheckItem::create(Menu &parent, const string &text) {
menuCheckItem->setText(QString::fromUtf8(text));
menuCheckItem->setCheckable(true);
menuCheckItem->connect(menuCheckItem, SIGNAL(triggered()), SLOT(onTick()));
parent.menu->addAction(menuCheckItem);
}
bool MenuCheckItem::visible() {
return menuCheckItem->isVisible();
}
void MenuCheckItem::setVisible(bool visible) {
menuCheckItem->setVisible(visible);
}
bool MenuCheckItem::enabled() {
return menuCheckItem->isEnabled();
}
void MenuCheckItem::setEnabled(bool enabled) {
menuCheckItem->setEnabled(enabled);
}
bool MenuCheckItem::checked() {
return menuCheckItem->isChecked();
}
void MenuCheckItem::setChecked(bool checked) {
menuCheckItem->setChecked(checked);
}
MenuCheckItem::MenuCheckItem() {
menuCheckItem = new MenuCheckItem::Data(*this);
}
void MenuRadioItem::create(Menu &parent, const string &text) {
menuRadioItem->parent = &parent;
menuRadioItem->actionGroup = new QActionGroup(0);
menuRadioItem->actionGroup->addAction(menuRadioItem);
menuRadioItem->setText(QString::fromUtf8(text));
menuRadioItem->setCheckable(true);
menuRadioItem->setChecked(true);
menuRadioItem->connect(menuRadioItem, SIGNAL(changed()), SLOT(onTick()));
menuRadioItem->parent->menu->addAction(menuRadioItem);
}
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
menuRadioItem->parent = parent.menuRadioItem->parent;
menuRadioItem->actionGroup = parent.menuRadioItem->actionGroup;
menuRadioItem->actionGroup->addAction(menuRadioItem);
menuRadioItem->setText(QString::fromUtf8(text));
menuRadioItem->setCheckable(true);
menuRadioItem->connect(menuRadioItem, SIGNAL(changed()), SLOT(onTick()));
menuRadioItem->parent->menu->addAction(menuRadioItem);
}
bool MenuRadioItem::visible() {
return menuRadioItem->isVisible();
}
void MenuRadioItem::setVisible(bool visible) {
menuRadioItem->setVisible(visible);
}
bool MenuRadioItem::enabled() {
return menuRadioItem->isEnabled();
}
void MenuRadioItem::setEnabled(bool enabled) {
menuRadioItem->setEnabled(enabled);
}
bool MenuRadioItem::checked() {
return menuRadioItem->isChecked();
}
void MenuRadioItem::setChecked() {
object->locked = true;
menuRadioItem->setChecked(true);
object->locked = false;
}
MenuRadioItem::MenuRadioItem() {
menuRadioItem = new MenuRadioItem::Data(*this);
}

View File

@ -1,5 +1,8 @@
#include <QApplication>
#include <QtGui>
#include <nall/config.hpp>
#include <nall/platform.hpp>
using namespace nall;
namespace phoenix {
@ -7,27 +10,35 @@ namespace phoenix {
#include "qt.moc.hpp"
#include "qt.moc"
#include "settings.cpp"
#include "object.cpp"
#include "font.cpp"
#include "menu.cpp"
#include "window.cpp"
#include "widget.cpp"
#include "layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"
#include "combobox.cpp"
#include "editbox.cpp"
#include "hexeditor.cpp"
#include "horizontalslider.cpp"
#include "label.cpp"
#include "listbox.cpp"
#include "progressbar.cpp"
#include "radiobox.cpp"
#include "textbox.cpp"
#include "verticalslider.cpp"
#include "viewport.cpp"
#include "messagewindow.cpp"
#include "message-window.cpp"
#include "action/action.cpp"
#include "action/menu.cpp"
#include "action/menu-separator.cpp"
#include "action/menu-item.cpp"
#include "action/menu-check-item.cpp"
#include "action/menu-radio-item.cpp"
#include "widget/widget.cpp"
#include "widget/button.cpp"
#include "widget/canvas.cpp"
#include "widget/check-box.cpp"
#include "widget/combo-box.cpp"
#include "widget/edit-box.cpp"
#include "widget/hex-editor.cpp"
#include "widget/horizontal-slider.cpp"
#include "widget/label.cpp"
#include "widget/list-box.cpp"
#include "widget/progress-bar.cpp"
#include "widget/radio-box.cpp"
#include "widget/text-box.cpp"
#include "widget/vertical-slider.cpp"
#include "widget/viewport.cpp"
OS::Data *OS::os = 0;
Window Window::None;
@ -37,6 +48,8 @@ void OS::initialize() {
if(initialized == true) return;
initialized = true;
settings.load();
os = new OS::Data;
static int argc = 1;
static char *argv[2];
@ -60,6 +73,7 @@ void OS::main() {
}
void OS::quit() {
settings.save();
QApplication::quit();
}

View File

@ -13,10 +13,10 @@ struct Object {
};
struct Geometry {
unsigned x, y;
signed x, y;
unsigned width, height;
inline Geometry() : x(0), y(0), width(0), height(0) {}
inline Geometry(unsigned x, unsigned y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
inline Geometry(signed x, signed y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
};
struct Font : Object {
@ -36,95 +36,22 @@ struct Font : Object {
inline Font::Style operator|(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a | (unsigned)b); }
inline Font::Style operator&(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a & (unsigned)b); }
struct Action : Object {
virtual bool visible() = 0;
virtual void setVisible(bool visible = true) = 0;
virtual bool enabled() = 0;
virtual void setEnabled(bool enabled = true) = 0;
};
struct Menu : Action {
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
Menu();
//private:
struct Data;
Data *menu;
};
struct MenuSeparator : Action {
void create(Menu &parent);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
MenuSeparator();
//private:
struct Data;
Data *menuSeparator;
};
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
MenuItem();
//private:
struct Data;
Data *menuItem;
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
void setChecked(bool checked = true);
MenuCheckItem();
//private:
struct Data;
Data *menuCheckItem;
};
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
void setChecked();
MenuRadioItem();
//private:
struct Data;
Data *menuRadioItem;
};
struct Menu;
struct Layout;
struct Widget;
struct Window : Object {
static Window None;
nall::function<bool ()> onClose;
nall::function<void ()> onMove;
nall::function<void ()> onResize;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
nall::function<void ()> onSize;
void append(Menu &menu);
void setLayout(Layout &layout);
void setResizable(bool resizable = true);
Geometry frameGeometry();
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
void setFrameGeometry(signed x, signed y, unsigned width, unsigned height);
void setGeometry(signed x, signed y, unsigned width, unsigned height);
void setDefaultFont(Font &font);
void setFont(Font &font);
void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
@ -140,13 +67,89 @@ struct Window : Object {
//private:
struct Data;
Data *window;
static Window None;
private:
void updateFrameGeometry();
};
struct Action : Object {
virtual bool visible() = 0;
virtual void setVisible(bool visible = true) = 0;
virtual bool enabled() = 0;
virtual void setEnabled(bool enabled = true) = 0;
};
struct Menu : Action {
void append(Action &action);
void setText(const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
Menu();
//private:
struct Data;
Data *menu;
};
struct MenuSeparator : Action {
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
MenuSeparator();
//private:
struct Data;
Data *menuSeparator;
};
struct MenuItem : Action {
nall::function<void ()> onTick;
void setText(const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
MenuItem();
//private:
struct Data;
Data *menuItem;
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void setText(const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
void setChecked(bool checked = true);
MenuCheckItem();
//private:
struct Data;
Data *menuCheckItem;
};
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void setParent(MenuRadioItem &parent);
void setText(const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
void setChecked();
MenuRadioItem();
//private:
struct Data;
Data *menuRadioItem;
};
struct Layout : Object {
virtual void setParent(Window &parent);
virtual void setGeometry(Geometry &geometry) = 0;
virtual void append(Widget &widget);
virtual void update(Geometry &geometry) = 0;
Layout();
//private:
struct Data;

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'qt.moc.hpp'
**
** Created: Mon Feb 7 01:23:56 2011
** Created: Tue Feb 8 19:56:49 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!

View File

@ -1,3 +1,13 @@
struct Settings : public configuration {
unsigned frameGeometryX;
unsigned frameGeometryY;
unsigned frameGeometryWidth;
unsigned frameGeometryHeight;
void load();
void save();
};
struct Object::Data {
public:
Object &self;
@ -69,8 +79,6 @@ struct MenuRadioItem::Data : public QAction {
public:
MenuRadioItem &self;
Menu *parent;
QActionGroup *actionGroup;
Data(MenuRadioItem &self) : self(self), QAction(0) {
}
@ -129,11 +137,11 @@ public:
if(layout) {
Geometry geom = self.geometry();
geom.x = geom.y = 0;
layout->update(geom);
layout->setGeometry(geom);
}
if(self.object->locked == false && self.onResize) {
self.onResize();
if(self.object->locked == false && self.onSize) {
self.onSize();
}
}

20
bsnes/phoenix/qt/settings.cpp Executable file
View File

@ -0,0 +1,20 @@
static Settings settings;
void Settings::load() {
attach(frameGeometryX = 0, "frameGeometryX");
attach(frameGeometryY = 0, "frameGeometryY");
attach(frameGeometryWidth = 0, "frameGeometryWidth");
attach(frameGeometryHeight = 0, "frameGeometryHeight");
string path = { userpath(), ".config/phoenix/qt.cfg" };
configuration::load(path);
}
void Settings::save() {
string path = { userpath(), ".config/" };
mkdir(path, 0755);
path.append("phoenix/");
mkdir(path, 0755);
path.append("qt.cfg");
configuration::save(path);
}

View File

@ -1,26 +1,7 @@
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
window->setWindowTitle(QString::fromUtf8(text));
window->vlayout = new QVBoxLayout(window);
window->vlayout->setMargin(0);
window->vlayout->setSpacing(0);
window->setLayout(window->vlayout);
window->menuBar = new QMenuBar(window);
window->menuBar->setVisible(false);
window->vlayout->addWidget(window->menuBar);
window->container = new QWidget(window);
window->container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
window->container->setVisible(true);
window->vlayout->addWidget(window->container);
window->statusBar = new QStatusBar(window);
window->statusBar->setSizeGripEnabled(false);
window->statusBar->setVisible(false);
window->vlayout->addWidget(window->statusBar);
setGeometry(x, y, width, height);
void Window::append(Menu &menu) {
menu.menu->parent = this;
if(window->defaultFont) menu.menu->setFont(*window->defaultFont);
window->menuBar->addMenu(menu.menu);
}
void Window::setLayout(Layout &layout) {
@ -29,7 +10,7 @@ void Window::setLayout(Layout &layout) {
Geometry geom = geometry();
geom.x = geom.y = 0;
layout.setParent(*this);
layout.update(geom);
layout.setGeometry(geom);
}
void Window::setResizable(bool resizable) {
@ -45,43 +26,26 @@ void Window::setResizable(bool resizable) {
Geometry Window::frameGeometry() {
if(window->fullscreen) return { 0, 0, OS::desktopWidth(), OS::desktopHeight() };
QRect rect = window->frameGeometry();
unsigned x = rect.x();
unsigned y = rect.y();
unsigned width = rect.width();
unsigned height = rect.height();
if(x > 65535) x = 0;
if(y > 65535) y = 0;
return { x, y, width, height };
return {
window->x - settings.frameGeometryX, window->y - settings.frameGeometryY,
window->width + settings.frameGeometryWidth, window->height + settings.frameGeometryHeight
};
}
Geometry Window::geometry() {
if(window->fullscreen) return { 0, 0, OS::desktopWidth(), OS::desktopHeight() };
return { window->x, window->y, window->width, window->height };
unsigned x = window->x;
unsigned y = window->y;
if(window->fullscreen == false) {
QRect border = window->frameGeometry();
QRect client = window->geometry();
x += client.x() - border.x();
y += client.y() - border.y();
if(window->menuVisible) y += window->menuBar->height();
if(x > 65535) x = 0;
if(y > 65535) y = 0;
}
return { x, y, window->width, window->height };
}
void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) {
object->locked = true;
void Window::setFrameGeometry(signed x, signed y, unsigned width, unsigned height) {
setGeometry(
x + settings.frameGeometryX, y + settings.frameGeometryY,
width - settings.frameGeometryWidth, height - settings.frameGeometryHeight
);
}
QRect border = window->frameGeometry();
QRect client = window->geometry();
void Window::setGeometry(signed x, signed y, unsigned width, unsigned height) {
object->locked = true;
window->x = x;
window->y = y;
@ -89,7 +53,7 @@ void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height
window->height = height;
setResizable(window->resizable);
window->move(x - (client.x() - border.x()), y - (client.y() - border.y()));
window->move(x - settings.frameGeometryX, y - settings.frameGeometryY);
window->adjustSize();
object->locked = false;
@ -124,13 +88,7 @@ void Window::setVisible(bool visible) {
if(visible) {
window->show();
//an unfortunate hack: before window is visible, geometry() == frameGeometry();
//we must wait for frameGeometry() to correctly populate and then move window
if(window->fullscreen == false) for(unsigned n = 0; n < 100; n++) {
if(window->geometry().x() > window->frameGeometry().x()) break;
usleep(100);
QApplication::processEvents();
}
updateFrameGeometry();
setGeometry(window->x, window->y, window->width, window->height);
} else {
window->hide();
@ -176,4 +134,58 @@ void Window::setFullscreen(bool fullscreen) {
Window::Window() {
window = new Window::Data(*this);
window->defaultFont = 0;
window->vlayout = new QVBoxLayout(window);
window->vlayout->setMargin(0);
window->vlayout->setSpacing(0);
window->setLayout(window->vlayout);
window->menuBar = new QMenuBar(window);
window->menuBar->setVisible(false);
window->vlayout->addWidget(window->menuBar);
window->container = new QWidget(window);
window->container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
window->container->setVisible(true);
window->vlayout->addWidget(window->container);
window->statusBar = new QStatusBar(window);
window->statusBar->setSizeGripEnabled(false);
window->statusBar->setVisible(false);
window->vlayout->addWidget(window->statusBar);
setGeometry(128, 128, 256, 256);
}
//
void Window::updateFrameGeometry() {
//Qt does not even attempt to cache frameGeometry, so if this is called before
//a window is visible onscreen, it is equivalent to geometry(). Without proper
//frameGeometry, phoenix's set(Frame)Geometry functions will not work
//properly. Attempting to detect frame geometry after the window is visible
//would require moving a visible window, causing a slight jitter effect.
//This routine is called every time a new window is shown, and attempts to
//cache frame geometry for the next set(Frame)Geometry call. The information
//is stored to disk, so that hopefully a phoenix window will never jitter more
//than once.
//The information is constantly updated after each window show to detect theme
//changes that may adjust frame geometry.
if(window->fullscreen == false) {
for(unsigned n = 0; n < 100; n++) {
if(window->geometry().x() > window->frameGeometry().x()) break;
usleep(100);
QApplication::processEvents();
}
}
QRect border = window->frameGeometry();
QRect client = window->geometry();
settings.frameGeometryX = client.x() - border.x();
settings.frameGeometryY = client.y() - border.y();
settings.frameGeometryWidth = border.width() - client.width();
settings.frameGeometryHeight = border.height() - client.height();
}

View File

@ -0,0 +1,4 @@
Action::Action() {
OS::os->objects.append(this);
action = new Action::Data;
}

View File

@ -0,0 +1,30 @@
void MenuCheckItem::setText(const string &text) {
action->text = text;
}
bool MenuCheckItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuCheckItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
bool MenuCheckItem::checked() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return info.fState & MFS_CHECKED;
}
void MenuCheckItem::setChecked(bool checked) {
action->checked = checked;
if(action->parent) CheckMenuItem(action->parent->action->menu, object->id, checked ? MF_CHECKED : MF_UNCHECKED);
}

View File

@ -0,0 +1,16 @@
void MenuItem::setText(const string &text) {
action->text = text;
}
bool MenuItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}

View File

@ -0,0 +1,49 @@
void MenuRadioItem::setText(const string &text) {
action->text = text;
}
void MenuRadioItem::setParent(MenuRadioItem &parent) {
action->checked = false;
action->radioParent = parent.action->radioParent;
action->radioParent->action->items.append(this);
}
bool MenuRadioItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuRadioItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
bool MenuRadioItem::checked() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return info.fState & MFS_CHECKED;
}
void MenuRadioItem::setChecked() {
action->checked = true;
MenuRadioItem *parent = action->radioParent;
foreach(item, parent->action->items) {
if(action->parent) CheckMenuRadioItem(
action->parent->action->menu,
item->object->id, item->object->id, item->object->id + (item != this),
MF_BYCOMMAND
);
}
}
MenuRadioItem::MenuRadioItem() {
action->radioParent = this;
action->items.append(this);
action->checked = true;
}

View File

@ -0,0 +1,12 @@
bool MenuSeparator::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuSeparator::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}

View File

@ -0,0 +1,51 @@
void Menu::setText(const string &text) {
action->text = text;
}
void Menu::append(Action &item) {
menu->children.append(&item);
}
bool Menu::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parentMenu, (UINT_PTR)action->menu, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void Menu::setEnabled(bool enabled) {
EnableMenuItem(action->parentMenu, (UINT_PTR)action->menu, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
Menu::Menu() {
menu = new Menu::Data;
}
//internal
void Menu::create() {
action->menu = CreatePopupMenu();
foreach(child, menu->children) {
child->action->parent = this;
if(dynamic_cast<Menu*>(child)) {
Menu &item = *(Menu*)child;
item.action->parentMenu = action->menu;
item.create();
AppendMenu(action->menu, MF_STRING | MF_POPUP, (UINT_PTR)item.action->menu, utf16_t(item.action->text));
} else if(dynamic_cast<MenuSeparator*>(child)) {
AppendMenu(action->menu, MF_SEPARATOR, child->object->id, L"");
} else if(dynamic_cast<MenuItem*>(child)) {
AppendMenu(action->menu, MF_STRING, child->object->id, utf16_t(child->action->text));
} else if(dynamic_cast<MenuCheckItem*>(child)) {
AppendMenu(action->menu, MF_STRING, child->object->id, utf16_t(child->action->text));
MenuCheckItem &item = *(MenuCheckItem*)child;
if(item.action->checked) item.setChecked();
} else if(dynamic_cast<MenuRadioItem*>(child)) {
AppendMenu(action->menu, MF_STRING, child->object->id, utf16_t(child->action->text));
MenuRadioItem &item = *(MenuRadioItem*)child;
if(item.action->checked) item.setChecked();
}
}
}

View File

@ -3,7 +3,7 @@ void Layout::setParent(Window &parent) {
}
void Layout::append(Widget &child) {
SetParent(child.widget->window, layout->parent->widget->window);
SetParent(child.widget->window, layout->parent->window->window);
SendMessage(
child.widget->window, WM_SETFONT,
(WPARAM)(layout->parent->window->defaultFont ? layout->parent->window->defaultFont : OS::os->proportionalFont), 0

View File

@ -1,144 +0,0 @@
Action::Action() {
OS::os->objects.append(this);
action = new Action::Data;
}
void Menu::create(Window &parent, const string &text) {
action->parentMenu = parent.window->menu;
action->menu = CreatePopupMenu();
AppendMenu(parent.window->menu, MF_STRING | MF_POPUP, (UINT_PTR)action->menu, utf16_t(text));
}
void Menu::create(Menu &parent, const string &text) {
action->parentMenu = parent.action->menu;
action->menu = CreatePopupMenu();
AppendMenu(parent.action->menu, MF_STRING | MF_POPUP, (UINT_PTR)action->menu, utf16_t(text));
}
bool Menu::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parentMenu, (UINT_PTR)action->menu, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void Menu::setEnabled(bool enabled) {
EnableMenuItem(action->parentMenu, (UINT_PTR)action->menu, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void MenuSeparator::create(Menu &parent) {
action->parent = &parent;
AppendMenu(parent.action->menu, MF_SEPARATOR, object->id, L"");
}
bool MenuSeparator::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuSeparator::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void MenuItem::create(Menu &parent, const string &text) {
action->parent = &parent;
AppendMenu(parent.action->menu, MF_STRING, object->id, utf16_t(text));
}
bool MenuItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void MenuCheckItem::create(Menu &parent, const string &text) {
action->parent = &parent;
AppendMenu(parent.action->menu, MF_STRING, object->id, utf16_t(text));
}
bool MenuCheckItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuCheckItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
bool MenuCheckItem::checked() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return info.fState & MFS_CHECKED;
}
void MenuCheckItem::setChecked(bool checked) {
CheckMenuItem(action->parent->action->menu, object->id, checked ? MF_CHECKED : MF_UNCHECKED);
}
void MenuRadioItem::create(Menu &parent, const string &text) {
action->parent = &parent;
action->radioParent = this;
action->items.append(this);
AppendMenu(parent.action->menu, MF_STRING, object->id, utf16_t(text));
setChecked();
}
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
action->parent = parent.action->parent;
action->radioParent = parent.action->radioParent;
action->radioParent->action->items.append(this);
AppendMenu(action->parent->action->menu, MF_STRING, object->id, utf16_t(text));
}
bool MenuRadioItem::enabled() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return (info.fState & MFS_GRAYED) == 0;
}
void MenuRadioItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
bool MenuRadioItem::checked() {
MENUITEMINFO info;
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_STATE;
GetMenuItemInfo(action->parent->action->menu, object->id, false, &info);
return info.fState & MFS_CHECKED;
}
void MenuRadioItem::setChecked() {
MenuRadioItem *parent = action->radioParent;
foreach(item, parent->action->items) {
CheckMenuRadioItem(
action->parent->action->menu,
item->object->id, item->object->id, item->object->id + (item != this),
MF_BYCOMMAND
);
}
}

View File

@ -13,7 +13,7 @@ MessageWindow::Response MessageWindow::information(Window &parent, const string
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
if(buttons == Buttons::YesNo) flags |= MB_YESNO;
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.window->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) {
@ -21,7 +21,7 @@ MessageWindow::Response MessageWindow::question(Window &parent, const string &te
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
if(buttons == Buttons::YesNo) flags |= MB_YESNO;
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.window->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) {
@ -29,7 +29,7 @@ MessageWindow::Response MessageWindow::warning(Window &parent, const string &tex
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
if(buttons == Buttons::YesNo) flags |= MB_YESNO;
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.window->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) {
@ -37,5 +37,5 @@ MessageWindow::Response MessageWindow::critical(Window &parent, const string &te
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
if(buttons == Buttons::YesNo) flags |= MB_YESNO;
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.window->window : 0, utf16_t(text), L"", flags));
}

View File

@ -13,9 +13,24 @@ struct Action::Data {
HMENU menu;
MenuRadioItem *radioParent;
array<MenuRadioItem*> items;
string text;
bool checked;
Data() {
parent = 0;
parentMenu = 0;
menu = 0;
radioParent = 0;
checked = false;
}
};
struct Menu::Data {
array<Action*> children;
};
struct Window::Data {
HWND window;
Layout *layout;
HFONT defaultFont;
HBRUSH brush;
@ -30,6 +45,7 @@ struct Window::Data {
unsigned height;
Data() {
window = 0;
layout = 0;
defaultFont = 0;
brush = 0;

View File

@ -16,7 +16,7 @@ void Canvas::create(Window &parent, unsigned x, unsigned y, unsigned width, unsi
L"phoenix_canvas", L"",
WS_CHILD | WS_VISIBLE,
x, y, width, height,
parent.widget->window, (HMENU)object->id, GetModuleHandle(0), 0
parent.window->window, (HMENU)object->id, GetModuleHandle(0), 0
);
SetWindowLongPtr(widget->window, GWLP_USERDATA, (LONG_PTR)this);
}

View File

@ -4,7 +4,7 @@ void Widget::setFont(Font &font) {
}
bool Widget::visible() {
return GetWindowLong(widget->window, GWL_STYLE) & WS_VISIBLE;
return GetWindowLongPtr(widget->window, GWL_STYLE) & WS_VISIBLE;
}
void Widget::setVisible(bool visible) {

View File

@ -1,20 +1,10 @@
static const unsigned FixedStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_BORDER;
static const unsigned ResizableStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME;
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
0, L"phoenix_window", utf16_t(text), ResizableStyle,
0, 0, 64, 64, 0, 0, GetModuleHandle(0), 0
);
window->menu = CreateMenu();
window->status = CreateWindowEx(
0, STATUSCLASSNAME, L"", WS_CHILD,
0, 0, 0, 0, widget->window, 0, GetModuleHandle(0), 0
);
//StatusBar will be capable of receiving tab focus if it is not disabled
SetWindowLongPtr(window->status, GWL_STYLE, GetWindowLong(window->status, GWL_STYLE) | WS_DISABLED);
SetWindowLongPtr(widget->window, GWLP_USERDATA, (LONG_PTR)this);
setGeometry(x, y, width, height);
void Window::append(Menu &menu) {
menu.action->parentMenu = window->menu;
menu.create();
AppendMenu(window->menu, MF_STRING | MF_POPUP, (UINT_PTR)menu.action->menu, utf16_t(menu.action->text));
}
void Window::setLayout(Layout &layout) {
@ -22,12 +12,12 @@ void Window::setLayout(Layout &layout) {
Geometry geom = geometry();
geom.x = geom.y = 0;
layout.setParent(*this);
layout.update(geom);
layout.setGeometry(geom);
}
void Window::setResizable(bool resizable) {
window->resizable = resizable;
SetWindowLongPtr(widget->window, GWL_STYLE, window->resizable ? ResizableStyle : FixedStyle);
SetWindowLongPtr(window->window, GWL_STYLE, window->resizable ? ResizableStyle : FixedStyle);
setGeometry(window->x, window->y, window->width, window->height);
}
@ -41,14 +31,12 @@ void Window::setFont(Font &font) {
Geometry Window::frameGeometry() {
RECT rc;
GetWindowRect(widget->window, &rc);
GetWindowRect(window->window, &rc);
unsigned x = rc.left;
unsigned y = rc.top;
signed x = rc.left;
signed y = rc.top;
unsigned width = (rc.right - rc.left);
unsigned height = (rc.bottom - rc.top);
if((signed)x < 0) x = 0;
if((signed)y < 0) y = 0;
return { x, y, width, height };
}
@ -56,19 +44,22 @@ Geometry Window::frameGeometry() {
Geometry Window::geometry() {
Geometry fm = frameMargin();
RECT rc;
GetWindowRect(widget->window, &rc);
GetWindowRect(window->window, &rc);
unsigned x = rc.left + fm.x;
unsigned y = rc.top + fm.y;
signed x = rc.left + fm.x;
signed y = rc.top + fm.y;
unsigned width = (rc.right - rc.left) - fm.width;
unsigned height = (rc.bottom - rc.top) - fm.height;
if((signed)x < 0) x = 0;
if((signed)y < 0) y = 0;
return { x, y, width, height };
}
void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) {
void Window::setFrameGeometry(signed x, signed y, unsigned width, unsigned height) {
Geometry fm = frameMargin();
setGeometry(x + fm.x, y + fm.y, width - fm.width, height - fm.height);
}
void Window::setGeometry(signed x, signed y, unsigned width, unsigned height) {
object->locked = true;
if(window->fullscreen == false) {
window->x = x;
@ -77,8 +68,11 @@ void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height
window->height = height;
}
Geometry fm = frameMargin();
SetWindowPos(widget->window, NULL, x - fm.x, y - fm.y, width + fm.width, height + fm.height, SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowPos(window->window, NULL, x - fm.x, y - fm.y, width + fm.width, height + fm.height, SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowPos(window->status, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_FRAMECHANGED);
Geometry geom = geometry();
geom.x = geom.y = 0;
if(window->layout) window->layout->setGeometry(geom);
object->locked = false;
}
@ -89,7 +83,7 @@ void Window::setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) {
}
void Window::setTitle(const string &text) {
SetWindowText(widget->window, utf16_t(text));
SetWindowText(window->window, utf16_t(text));
}
void Window::setStatusText(const string &text) {
@ -98,7 +92,7 @@ void Window::setStatusText(const string &text) {
void Window::setMenuVisible(bool visible) {
object->locked = true;
SetMenu(widget->window, visible ? window->menu : 0);
SetMenu(window->window, visible ? window->menu : 0);
setGeometry(window->x, window->y, window->width, window->height);
object->locked = false;
}
@ -118,17 +112,48 @@ void Window::setFullscreen(bool fullscreen) {
object->locked = true;
window->fullscreen = fullscreen;
if(window->fullscreen == false) {
SetWindowLong(widget->window, GWL_STYLE, WS_VISIBLE | (window->resizable ? ResizableStyle : FixedStyle));
SetWindowLong(window->window, GWL_STYLE, WS_VISIBLE | (window->resizable ? ResizableStyle : FixedStyle));
setGeometry(window->x, window->y, window->width, window->height);
} else {
SetWindowLong(widget->window, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowLong(window->window, GWL_STYLE, WS_VISIBLE | WS_POPUP);
setGeometry(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
object->locked = false;
}
bool Window::visible() {
return GetWindowLongPtr(window->window, GWL_STYLE) & WS_VISIBLE;
}
void Window::setVisible(bool visible) {
ShowWindow(window->window, visible ? SW_SHOWNORMAL : SW_HIDE);
}
bool Window::focused() {
return (GetForegroundWindow() == window->window);
}
void Window::setFocused() {
if(visible() == false) setVisible(true);
SetFocus(window->window);
}
Window::Window() {
window = new Window::Data;
window->window = CreateWindowEx(
0, L"phoenix_window", L"", ResizableStyle,
0, 0, 64, 64, 0, 0, GetModuleHandle(0), 0
);
window->menu = CreateMenu();
window->status = CreateWindowEx(
0, STATUSCLASSNAME, L"", WS_CHILD,
0, 0, 0, 0, window->window, 0, GetModuleHandle(0), 0
);
//StatusBar will be capable of receiving tab focus if it is not disabled
SetWindowLongPtr(window->status, GWL_STYLE, GetWindowLong(window->status, GWL_STYLE) | WS_DISABLED);
SetWindowLongPtr(window->window, GWLP_USERDATA, (LONG_PTR)this);
setGeometry(128, 128, 256, 256);
}
//internal
@ -139,7 +164,7 @@ Geometry Window::frameMargin() {
//width,height: total pixels of window geometry that are not part of client area
//width-x,height-y: pixels from the bottom-right of window to the client area
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect(&rc, window->resizable ? ResizableStyle : FixedStyle, (bool)GetMenu(widget->window));
AdjustWindowRect(&rc, window->resizable ? ResizableStyle : FixedStyle, (bool)GetMenu(window->window));
unsigned statusHeight = 0;
if(GetWindowLongPtr(window->status, GWL_STYLE) & WS_VISIBLE) {
RECT src;

View File

@ -12,25 +12,32 @@ namespace phoenix {
#include "object.cpp"
#include "font.cpp"
#include "menu.cpp"
#include "widget.cpp"
#include "window.cpp"
#include "layout.cpp"
#include "button.cpp"
#include "canvas.cpp"
#include "checkbox.cpp"
#include "combobox.cpp"
#include "editbox.cpp"
#include "hexeditor.cpp"
#include "horizontalslider.cpp"
#include "label.cpp"
#include "listbox.cpp"
#include "progressbar.cpp"
#include "radiobox.cpp"
#include "textbox.cpp"
#include "verticalslider.cpp"
#include "viewport.cpp"
#include "messagewindow.cpp"
#include "message-window.cpp"
#include "action/action.cpp"
#include "action/menu.cpp"
#include "action/menu-separator.cpp"
#include "action/menu-item.cpp"
#include "action/menu-check-item.cpp"
#include "action/menu-radio-item.cpp"
#include "widget/widget.cpp"
#include "widget/button.cpp"
#include "widget/canvas.cpp"
#include "widget/check-box.cpp"
#include "widget/combo-box.cpp"
#include "widget/edit-box.cpp"
#include "widget/hex-editor.cpp"
#include "widget/horizontal-slider.cpp"
#include "widget/label.cpp"
#include "widget/list-box.cpp"
#include "widget/progress-bar.cpp"
#include "widget/radio-box.cpp"
#include "widget/text-box.cpp"
#include "widget/vertical-slider.cpp"
#include "widget/viewport.cpp"
OS::Data *OS::os = 0;
Window Window::None;
@ -151,7 +158,7 @@ unsigned OS::desktopHeight() {
string OS::folderSelect(Window &parent, const string &path) {
wchar_t wfilename[PATH_MAX + 1] = L"";
BROWSEINFO bi;
bi.hwndOwner = &parent != &Window::None ? parent.widget->window : 0;
bi.hwndOwner = &parent != &Window::None ? parent.window->window : 0;
bi.pidlRoot = NULL;
bi.pszDisplayName = wfilename;
bi.lpszTitle = L"";
@ -211,7 +218,7 @@ string OS::fileOpen(Window &parent, const string &filter, const string &path) {
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = &parent != &Window::None ? parent.widget->window : 0;
ofn.hwndOwner = &parent != &Window::None ? parent.window->window : 0;
ofn.lpstrFilter = wfilter;
ofn.lpstrInitialDir = wdir;
ofn.lpstrFile = wfilename;
@ -259,7 +266,7 @@ string OS::fileSave(Window &parent, const string &filter, const string &path) {
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = &parent != &Window::None ? parent.widget->window : 0;
ofn.hwndOwner = &parent != &Window::None ? parent.window->window : 0;
ofn.lpstrFilter = wfilter;
ofn.lpstrInitialDir = wdir;
ofn.lpstrFile = wfilename;
@ -335,10 +342,10 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
if(window.window->layout) {
geometry.x = geometry.y = 0;
window.window->layout->update(geometry);
window.window->layout->setGeometry(geometry);
}
if(window.onResize) window.onResize();
if(window.onSize) window.onSize();
break;
}
@ -352,11 +359,11 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case WM_ERASEBKGND: {
if(window.window->brush == 0) break;
RECT rc;
GetClientRect(window.widget->window, &rc);
GetClientRect(window.window->window, &rc);
PAINTSTRUCT ps;
BeginPaint(window.widget->window, &ps);
BeginPaint(window.window->window, &ps);
FillRect(ps.hdc, &rc, window.window->brush);
EndPaint(window.widget->window, &ps);
EndPaint(window.window->window, &ps);
return TRUE;
}
@ -372,7 +379,7 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case WM_COMMAND: {
unsigned id = LOWORD(wparam);
HWND control = GetDlgItem(window.widget->window, id);
HWND control = GetDlgItem(window.window->window, id);
if(control == 0) {
Object *object_ptr = (Object*)OS::findObject(id);
if(object_ptr) {
@ -432,7 +439,7 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case WM_NOTIFY: {
unsigned id = LOWORD(wparam);
HWND control = GetDlgItem(window.widget->window, id);
HWND control = GetDlgItem(window.window->window, id);
if(control) {
Object *object_ptr = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
if(object_ptr) {
@ -465,7 +472,7 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case WM_HSCROLL: {
unsigned id = LOWORD(wparam);
HWND control = GetDlgItem(window.widget->window, id);
HWND control = GetDlgItem(window.window->window, id);
if(control) {
Object *object_ptr = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
if(object_ptr) {
@ -482,7 +489,7 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
case WM_VSCROLL: {
unsigned id = LOWORD(wparam);
HWND control = GetDlgItem(window.widget->window, id);
HWND control = GetDlgItem(window.window->window, id);
if(control) {
Object *object_ptr = (Object*)GetWindowLongPtr(control, GWLP_USERDATA);
if(object_ptr) {

View File

@ -14,10 +14,10 @@ private:
};
struct Geometry {
unsigned x, y;
signed x, y;
unsigned width, height;
inline Geometry() : x(0), y(0), width(0), height(0) {}
inline Geometry(unsigned x, unsigned y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
inline Geometry(signed x, signed y, unsigned width, unsigned height) : x(x), y(y), width(width), height(height) {}
};
struct Font : Object {
@ -37,6 +37,42 @@ struct Font : Object {
inline Font::Style operator|(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a | (unsigned)b); }
inline Font::Style operator&(Font::Style a, Font::Style b) { return (Font::Style)((unsigned)a & (unsigned)b); }
struct Menu;
struct Layout;
struct Widget;
struct Window : Object {
nall::function<bool ()> onClose;
nall::function<void ()> onMove;
nall::function<void ()> onSize;
void append(Menu &menu);
void setLayout(Layout &layout);
void setResizable(bool resizable);
void setDefaultFont(Font &font);
void setFont(Font &font);
Geometry frameGeometry();
Geometry geometry();
void setFrameGeometry(signed x, signed y, unsigned width, unsigned height);
void setGeometry(signed x, signed y, unsigned width, unsigned height);
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);
bool visible();
void setVisible(bool visible = true);
bool focused();
void setFocused();
Window();
//private:
struct Data;
Data *window;
static Window None;
Geometry frameMargin();
};
struct Action : Object {
virtual bool enabled() = 0;
virtual void setEnabled(bool enabled = true) = 0;
@ -47,28 +83,32 @@ struct Action : Object {
};
struct Menu : Action {
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
void append(Action &action);
void setText(const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
Menu();
//private:
struct Data;
Data *menu;
void create();
};
struct MenuSeparator : Action {
void create(Menu &parent);
bool enabled();
void setEnabled(bool enabled = true);
};
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
void setText(const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
void setText(const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
@ -77,17 +117,15 @@ struct MenuCheckItem : Action {
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
void setParent(MenuRadioItem &parent);
void setText(const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
void setChecked();
MenuRadioItem();
};
struct Window;
struct Layout;
struct Widget : Object {
virtual void setParent(Layout &parent) {}
@ -105,39 +143,10 @@ struct Widget : Object {
Data *widget;
};
struct Window : Widget {
nall::function<bool ()> onClose;
nall::function<void ()> onMove;
nall::function<void ()> onResize;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setLayout(Layout &layout);
void setResizable(bool resizable);
void setDefaultFont(Font &font);
void setFont(Font &font);
Geometry frameGeometry();
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
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;
//private:
Geometry frameMargin();
void resize(unsigned width, unsigned height);
};
struct Layout : Widget {
virtual void setParent(Window &parent);
virtual void setGeometry(Geometry &geometry) = 0;
virtual void append(Widget &widget);
virtual void update(Geometry &geometry) = 0;
Layout();
//private:
struct Data;

View File

@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "075.10";
static const char Version[] = "075.11";
static const unsigned SerializerVersion = 18;
}
}

View File

@ -1,7 +1,7 @@
Console console;
void Console::create() {
Window::create(0, 0, 715, 350, "Console");
setTitle("Console");
application.addWindow(this, "Debugger.Console", "192,192");
output.setFont(application.monospaceFont);
@ -23,17 +23,9 @@ void Console::create() {
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;
layout.append(traceCPU, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(traceSMP, x, y, 120, Style::CheckBoxHeight); y += Style::CheckBoxHeight;
layout.append(clearConsole, x, 348 - Style::ButtonHeight - 5, 120, Style::ButtonHeight);
setGeometry(0, 0, 715, 348);
setLayout(layout);*/
setGeometry(0, 0, layout.minimumWidth() + 565, 350);
setLayout(layout);
onClose = []() {
debugger.showConsole.setChecked(false);

View File

@ -1,7 +1,7 @@
CPUDebugger cpuDebugger;
void CPUDebugger::create() {
Window::create(0, 0, 495, 220, "CPU Debugger");
setTitle("CPU Debugger");
application.addWindow(this, "Debugger.CPUdebugger", "192,192");
output.setFont(application.monospaceFont);
@ -17,6 +17,8 @@ void CPUDebugger::create() {
controlLayout.append(stepOver, 80, Style::ButtonHeight);
controlLayout.append(proceed, 80, Style::ButtonHeight);
layout.append(controlLayout, 80, 0);
setGeometry(0, 0, layout.minimumWidth() + 300, 220);
setLayout(layout);
onClose = []() {

View File

@ -18,7 +18,7 @@ void Debugger::create() {
breakpointEditor.create();
memoryEditor.create();
Window::create(0, 0, 256, 80, "Debugger");
setTitle("Debugger");
application.addWindow(this, "Debugger", "160,160");
enableDebugger.setText("Enable debugger");
@ -35,6 +35,8 @@ void Debugger::create() {
layout.append(showSMPDebugger, 0, Style::CheckBoxHeight);
layout.append(showBreakpointEditor, 0, Style::CheckBoxHeight);
layout.append(showMemoryEditor, 0, Style::CheckBoxHeight);
setGeometry(0, 0, 256, layout.minimumHeight());
setLayout(layout);
/*unsigned x = 5, y = 5;

View File

@ -1,7 +1,7 @@
SMPDebugger smpDebugger;
void SMPDebugger::create() {
Window::create(0, 0, 495, 220, "SMP Debugger");
setTitle("SMP Debugger");
application.addWindow(this, "Debugger.SMPDebugger", "192,192");
output.setFont(application.monospaceFont);
@ -17,6 +17,8 @@ void SMPDebugger::create() {
controlLayout.append(stepOver, 80, Style::ButtonHeight);
controlLayout.append(proceed, 80, Style::ButtonHeight);
layout.append(controlLayout, 80, 0);
setGeometry(0, 0, layout.minimumWidth() + 300, 220);
setLayout(layout);
onClose = []() {

View File

@ -1,7 +1,7 @@
BreakpointEditor breakpointEditor;
void BreakpointEditor::create() {
Window::create(0, 0, 310, 240, "Breakpoint Editor");
setTitle("Breakpoint Editor");
application.addWindow(this, "Debugger.BreakpointEditor", "192,192");
runToBreakpoint.setText("Run to breakpoint");
@ -28,19 +28,9 @@ void BreakpointEditor::create() {
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);
layout.append(addressBox[n], x + 35, y, 60, Style::EditBoxHeight);
layout.append(valueBox[n], x + 100, y, 30, Style::EditBoxHeight);
layout.append(typeBox[n], x + 135, y, 80, Style::EditBoxHeight);
layout.append(sourceBox[n], x + 220, y, 80, Style::EditBoxHeight); y += Style::EditBoxHeight + 5;
}
setGeometry(0, 0, 310, y);
setLayout(layout);*/
setGeometry(0, 0, 310, layout.minimumHeight());
setLayout(layout);
runToBreakpoint.onTick = []() {
if(breakpointEditor.runToBreakpoint.checked()) {

View File

@ -1,7 +1,7 @@
MemoryEditor memoryEditor;
void MemoryEditor::create() {
Window::create(0, 0, 570, 230, "Memory Editor");
setTitle("Memory Editor");
application.addWindow(this, "Debugger.MemoryEditor", "192,192");
editor.setFont(application.monospaceFont);
@ -20,6 +20,8 @@ void MemoryEditor::create() {
controlLayout.append(gotoBox, 80, Style::ComboBoxHeight);
controlLayout.append(refreshButton, 80, Style::ComboBoxHeight);
layout.append(controlLayout, 80, 0);
setGeometry(0, 0, layout.minimumWidth() + 475, 230);
setLayout(layout);
onClose = []() {

View File

@ -1,18 +1,19 @@
FileBrowser fileBrowser;
void FileBrowser::create() {
Window::create(0, 0, 640, 400);
application.addWindow(this, "FileBrowser", "160,160");
browseButton.setText("...");
upButton.setText("..");
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);
pathLayout.append(pathBox, 0, 0, 5);
pathLayout.append(browseButton, Style::TextBoxHeight, 0, 5);
pathLayout.append(upButton, Style::TextBoxHeight, 0);
layout.append(pathLayout, 0, Style::TextBoxHeight, 5);
layout.append(contentsBox, 0, 0);
setGeometry(0, 0, 640, layout.minimumHeight() + 400);
setLayout(layout);
pathBox.onActivate = []() {

Some files were not shown because too many files have changed in this diff Show More