menus...
	* Shortcuts item moved from Help to Edit
misc...
	* fix: q1 mdl reader out of bounds reading crash
	* fix: q1 mdl loading of MDL_FRAME_GROUP case
	* fix: rightclick main wnd border, release in texbro glwidget == crash (unfreezepointer)
	* texbro: search in currently shown textures
	* ask for saving nonsaved map on project settings change
	* func_detail to nongame group ents counter
	* deiconify main wnd, unmaximize maximized view on app closing to save correct layout data
	* close preferences dialog on ESC
	* Enter = Ok in global and path settings dialogs
	* print renderer stats in XY views too
	* global 'show renderer stats' option, def = off
	* ~10x faster opengl text rendering
This commit is contained in:
Garux
2017-08-02 09:25:04 +03:00
parent cba5583d23
commit 65ca31fd44
12 changed files with 286 additions and 119 deletions

View File

@@ -166,9 +166,14 @@ gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDia
return TRUE;
}
#include <gdk/gdkkeysyms.h>
GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){
GtkWindow* window = create_fixedsize_modal_dialog_window( 0, title, dialog );
GtkAccelGroup* accel = gtk_accel_group_new();
gtk_window_add_accel_group( window, accel );
GtkVBox* vbox1 = create_dialog_vbox( 8, 4 );
gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) );
@@ -180,6 +185,8 @@ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& di
GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) );
gtk_widget_grab_default( GTK_WIDGET( button ) );
gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
return window;
}

View File

@@ -169,7 +169,7 @@ GLFont *glfont_create( const char* font_string ){
return new GLFontCallList( font_list_base, font_ascent, font_descent, font_height );
}
#else
#elif 0
// new font code ripped from ZeroRadiant
@@ -336,4 +336,68 @@ GLFont *glfont_create( const char* font_string ){
return new GLFontInternal( font_string );
}
#elif 1
#include <pango/pangoft2.h>
#include <pango/pango-utils.h>
#include <gtk/gtkglwidget.h>
GLFont *glfont_create( const char* font_string ){
GLuint font_list_base = glGenLists( 256 );
int font_height = 0, font_ascent = 0, font_descent = 0;
PangoFontDescription* font_desc = pango_font_description_from_string( font_string );
//PangoFontDescription* font_desc = pango_font_description_from_string( "arial 7" );
PangoFont* font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "arial 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "fixed 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "courier new 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font != 0 ) {
PangoFontMap *fontmap = pango_ft2_font_map_new();
pango_ft2_font_map_set_resolution( PANGO_FT2_FONT_MAP( fontmap ), 72, 72 );
PangoContext *ft2_context = pango_font_map_create_context( fontmap );
pango_context_set_font_description( ft2_context, font_desc );
PangoLayout *layout = pango_layout_new( ft2_context );
#if 1 //FONT_SIZE_WORKAROUND
pango_layout_set_width( layout, -1 ); // -1 no wrapping. All text on one line.
pango_layout_set_text( layout, "_|The quick brown fox jumped over the lazy sleeping dog's back then sat on a tack.", -1 ); // -1 null-terminated string.
#endif
int font_ascent_pango_units = pango_layout_get_baseline( layout );
PangoRectangle log_rect;
pango_layout_get_extents( layout, NULL, &log_rect );
g_object_unref( G_OBJECT( layout ) );
int font_descent_pango_units = log_rect.height - font_ascent_pango_units;
pango_font_description_free( font_desc );
g_object_unref( G_OBJECT( ft2_context ) );
g_object_unref( G_OBJECT( fontmap ) );
font_ascent = PANGO_PIXELS_CEIL( font_ascent_pango_units );
font_descent = PANGO_PIXELS_CEIL( font_descent_pango_units );
font_height = font_ascent + font_descent;
}
return new GLFontCallList( font_list_base, font_ascent, font_descent, font_height );
}
#endif

View File

@@ -251,6 +251,23 @@ inline char* string_to_uppercase( char* string ){
return string;
}
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
inline const char* string_in_string_nocase( const char* haystack, const char* needle ) {
do {
const char* h = haystack;
const char* n = needle;
while ( std::tolower( ( unsigned char ) *h ) == std::tolower( ( unsigned char ) *n ) && *n ) {
h++;
n++;
}
if ( *n == 0 ) {
return haystack;
}
} while ( *haystack++ );
return 0;
}
/// \brief A re-entrant string tokeniser similar to strchr.
class StringTokeniser
{