mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-25 06:31:04 +02:00
Update to v106r48 release.
byuu says: The problems with the Windows and Qt4 ports have all been resolved, although there's a fairly gross hack on a few Qt widgets to not destruct once Application::quit() is called to avoid a double free crash (I'm unsure where Qt is destructing the widgets internally.) The Cocoa port compiles again at least, though it's bound to have endless problems. I improved the Label painting in the GTK ports, which fixes the background color on labels inside TabFrame widgets. I've optimized the Makefile system even further. I added a "redo state" command to bsnes, which is created whenever you load the undo state. There are also hotkeys for both now, although I don't think they're really something you want to map hotkeys to. I moved the nall::Locale object inside hiro::Application, so that it can be used to translate the BrowserDialog and MessageDialog window strings. I improved the Super Game Boy emulation of `MLT_REQ`, fixing Pokemon Yellow's custom border and probably more stuff. Lots of other small fixes and improvements. Things are finally stable once again after the harrowing layout redesign catastrophe. Errata: - ICD::joypID should be set to 3 on reset(). joypWrite() may as well take uint1 instead of bool. - hiro/Qt: remove pWindow::setMaximumSize() comment; found a workaround for it - nall/GNUmakefile: don't set object.path if it's already set (allow overrides before including the file)
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
namespace hiro {
|
||||
struct pWindow;
|
||||
struct pMenu;
|
||||
struct pLayout;
|
||||
struct pWidget;
|
||||
}
|
||||
|
||||
#define Declare(Name, Base) \
|
||||
p##Name(m##Name& reference) : p##Base(reference) {} \
|
||||
auto self() const -> m##Name& { return (m##Name&)reference; } \
|
||||
|
@@ -39,6 +39,7 @@ auto pFrame::setFont(const Font& font) -> void {
|
||||
}
|
||||
|
||||
auto pFrame::setGeometry(Geometry geometry) -> void {
|
||||
pWidget::setGeometry(geometry);
|
||||
if(auto& sizable = state().sizable) {
|
||||
Size size = pFont::size(self().font(true), state().text);
|
||||
if(!state().text) size.setHeight(10);
|
||||
|
@@ -2,6 +2,50 @@
|
||||
|
||||
namespace hiro {
|
||||
|
||||
static auto Label_draw(GtkWidget* widget, cairo_t* context, pLabel* p) -> int {
|
||||
auto color = p->state().backgroundColor;
|
||||
if(auto window = p->self().parentWindow(true)) {
|
||||
if(!color) color = window->backgroundColor();
|
||||
}
|
||||
|
||||
if(color) {
|
||||
double red = (double)color.red() / 255.0;
|
||||
double green = (double)color.green() / 255.0;
|
||||
double blue = (double)color.blue() / 255.0;
|
||||
double alpha = (double)color.alpha() / 255.0;
|
||||
|
||||
if(gdk_screen_is_composited(gdk_screen_get_default())
|
||||
&& gdk_screen_get_rgba_visual(gdk_screen_get_default())
|
||||
) {
|
||||
cairo_set_source_rgba(context, red, green, blue, alpha);
|
||||
} else {
|
||||
cairo_set_source_rgb(context, red, green, blue);
|
||||
}
|
||||
|
||||
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_paint(context);
|
||||
} else {
|
||||
#if HIRO_GTK==3
|
||||
auto style = gtk_widget_get_style_context(widget);
|
||||
if(auto tabFrame = p->self().parentTabFrame(true)) {
|
||||
if(auto self = tabFrame->self()) style = gtk_widget_get_style_context(self->gtkWidget);
|
||||
}
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation(widget, &allocation);
|
||||
gtk_render_background(style, context, 0, 0, allocation.width, allocation.height);
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto Label_expose(GtkWidget* widget, GdkEvent* event, pLabel* p) -> int {
|
||||
cairo_t* context = gdk_cairo_create(gtk_widget_get_window(widget));
|
||||
Label_draw(widget, context, p);
|
||||
cairo_destroy(context);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto pLabel::construct() -> void {
|
||||
gtkWidget = gtk_event_box_new();
|
||||
subWidget = gtk_label_new("");
|
||||
@@ -13,6 +57,12 @@ auto pLabel::construct() -> void {
|
||||
setForegroundColor(state().foregroundColor);
|
||||
setText(state().text);
|
||||
|
||||
#if HIRO_GTK==2
|
||||
g_signal_connect(G_OBJECT(subWidget), "expose-event", G_CALLBACK(Label_expose), (gpointer)this);
|
||||
#elif HIRO_GTK==3
|
||||
g_signal_connect(G_OBJECT(subWidget), "draw", G_CALLBACK(Label_draw), (gpointer)this);
|
||||
#endif
|
||||
|
||||
pWidget::construct();
|
||||
}
|
||||
|
||||
@@ -36,9 +86,9 @@ auto pLabel::setAlignment(Alignment alignment) -> void {
|
||||
}
|
||||
|
||||
auto pLabel::setBackgroundColor(Color color) -> void {
|
||||
if(!color) color = self().parentWindow(true)->backgroundColor();
|
||||
auto gdkColor = CreateColor(color);
|
||||
gtk_widget_modify_bg(gtkWidget, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||
//GTK3 will paint the wrong background color when a label is inside of a TabFrame
|
||||
//this is caused by the GtkEventBox wrapper that is required to paint custom backgrounds
|
||||
//handle background painting via "draw" or "expose-event" signals instead
|
||||
}
|
||||
|
||||
auto pLabel::setForegroundColor(Color color) -> void {
|
||||
|
@@ -157,8 +157,7 @@ auto pTabFrame::setFont(const Font& font) -> void {
|
||||
|
||||
auto pTabFrame::setGeometry(Geometry geometry) -> void {
|
||||
pWidget::setGeometry(geometry);
|
||||
|
||||
geometry.setPosition(0, 0);
|
||||
geometry.setPosition();
|
||||
if(state().navigation == Navigation::Top || state().navigation == Navigation::Bottom) {
|
||||
geometry.setWidth(geometry.width() - 6);
|
||||
geometry.setHeight(geometry.height() - (15 + _tabHeight()));
|
||||
|
@@ -66,7 +66,7 @@ GtkSelectionData* data, unsigned type, unsigned timestamp, pWindow* p) -> void {
|
||||
static auto Window_getPreferredWidth(GtkWidget* widget, int* minimalWidth, int* naturalWidth) -> void {
|
||||
if(auto p = (pWindow*)g_object_get_data(G_OBJECT(widget), "hiro::window")) {
|
||||
*minimalWidth = 1;
|
||||
*naturalWidth = 1; //p->state().geometry.width();
|
||||
*naturalWidth = p->state().geometry.width();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ static auto Window_sizeRequest(GtkWidget* widget, GtkRequisition* requisition, p
|
||||
static auto Window_stateEvent(GtkWidget* widget, GdkEvent* event, pWindow* p) -> void {
|
||||
p->_synchronizeState();
|
||||
|
||||
/*if(event->type == GDK_WINDOW_STATE) {
|
||||
if(event->type == GDK_WINDOW_STATE) {
|
||||
auto windowStateEvent = (GdkEventWindowState*)event;
|
||||
if(windowStateEvent->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
|
||||
p->state().maximized = windowStateEvent->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
|
||||
@@ -122,7 +122,7 @@ static auto Window_stateEvent(GtkWidget* widget, GdkEvent* event, pWindow* p) ->
|
||||
if(windowStateEvent->changed_mask & GDK_WINDOW_STATE_ICONIFIED) {
|
||||
p->state().minimized = windowStateEvent->new_window_state & GDK_WINDOW_STATE_ICONIFIED;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
auto pWindow::construct() -> void {
|
||||
@@ -191,7 +191,7 @@ auto pWindow::construct() -> void {
|
||||
g_signal_connect(G_OBJECT(formContainer), "size-request", G_CALLBACK(Window_sizeRequest), (gpointer)this);
|
||||
#elif HIRO_GTK==3
|
||||
auto widgetClass = GTK_WIDGET_GET_CLASS(formContainer);
|
||||
widgetClass->get_preferred_width = Window_getPreferredWidth;
|
||||
widgetClass->get_preferred_width = Window_getPreferredWidth;
|
||||
widgetClass->get_preferred_height = Window_getPreferredHeight;
|
||||
#endif
|
||||
g_signal_connect(G_OBJECT(widget), "window-state-event", G_CALLBACK(Window_stateEvent), (gpointer)this);
|
||||
|
Reference in New Issue
Block a user