fix UI bug when placing text and immediately deleting it (did not delete)

This commit is contained in:
Stefan Frederik 2021-11-04 13:30:50 +01:00
parent 966ebdc26e
commit 7490c80a9c
5 changed files with 27 additions and 18 deletions

View File

@ -2,6 +2,7 @@ GUI_CFLAGS = -DPLUGIN_GUI
GUI_OBJS = \ GUI_OBJS = \
$(BIN)/gui/find_gtk2.o \ $(BIN)/gui/find_gtk2.o \
$(BIN)/gui/find_gtk3.o \ $(BIN)/gui/find_gtk3.o \
$(BIN)/gui/find_gtk4.o \
$(BIN)/gui/find_lesstif2.o \ $(BIN)/gui/find_lesstif2.o \
$(BIN)/gui/find_x.o \ $(BIN)/gui/find_x.o \
$(BIN)/gui/find_gd.o \ $(BIN)/gui/find_gd.o \

View File

@ -32,29 +32,25 @@ int find_gtk3(const char *name, int logdepth, int fatal, const char *call, const
const char *test_c = const char *test_c =
NL "#include <gtk/gtk.h>" NL "#include <gtk/gtk.h>"
NL NL
NL "static void" NL "static void activate(GtkApplication* app, gpointer user_data)"
NL "activate (GtkApplication* app,"
NL " gpointer user_data)"
NL "{" NL "{"
NL " GtkWidget *window;" NL " GtkWidget *window;"
NL NL
NL " window = gtk_application_window_new (app);" NL " window = gtk_application_window_new(app);"
NL " gtk_window_set_title (GTK_WINDOW (window), \"Window\");" NL " gtk_window_set_title(GTK_WINDOW(window), \"Window\");"
NL " gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);" NL " gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);"
NL " gtk_widget_show_all (window);" NL " gtk_widget_show_all(window);"
NL "}" NL "}"
NL NL
NL "int" NL "int main (int argc, char **argv)"
NL "main (int argc,"
NL " char **argv)"
NL "{" NL "{"
NL " GtkApplication *app;" NL " GtkApplication *app;"
NL " int status;" NL " int status;"
NL NL
NL " app = gtk_application_new (\"org.gtk.example\", G_APPLICATION_FLAGS_NONE);" NL " app = gtk_application_new(\"org.gtk.example\", G_APPLICATION_FLAGS_NONE);"
NL " g_signal_connect (app, \"activate\", G_CALLBACK (activate), NULL);" NL " g_signal_connect(app, \"activate\", G_CALLBACK(activate), NULL);"
NL " status = g_application_run (G_APPLICATION (app), argc, argv);" NL " status = g_application_run(G_APPLICATION(app), argc, argv);"
NL " g_object_unref (app);" NL " g_object_unref(app);"
NL NL
NL " return status;" NL " return status;"
NL "}" NL "}"

View File

@ -6,6 +6,7 @@
#include "find_x.h" #include "find_x.h"
#include "find_gtk2.h" #include "find_gtk2.h"
#include "find_gtk3.h" #include "find_gtk3.h"
#include "find_gtk4.h"
#include "find_lesstif2.h" #include "find_lesstif2.h"
#include "find_gd.h" #include "find_gd.h"
#include "find_cairo.h" #include "find_cairo.h"
@ -26,6 +27,8 @@ void deps_gui_init()
dep_add("libs/gui/gtk2/key_prefix", find_gtk2_key_prefix); dep_add("libs/gui/gtk2/key_prefix", find_gtk2_key_prefix);
dep_add("libs/gui/gtk2/modversion", find_gtk2_modversion); dep_add("libs/gui/gtk2/modversion", find_gtk2_modversion);
dep_add("libs/gui/gtk3/*", find_gtk3); dep_add("libs/gui/gtk3/*", find_gtk3);
dep_add("libs/gui/gtk4/*", find_gtk4);
dep_add("libs/gui/gtk4/modversion", find_gtk4_modversion);
dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi); dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi);
dep_add("libs/gui/lesstif2/*", find_lesstif2); dep_add("libs/gui/lesstif2/*", find_lesstif2);
dep_add("libs/gui/libstroke/*", find_libstroke); dep_add("libs/gui/libstroke/*", find_libstroke);

View File

@ -2323,10 +2323,11 @@ void place_text(int draw_text, double mx, double my)
cairo_restore(xctx->cairo_save_ctx); cairo_restore(xctx->cairo_save_ctx);
} }
#endif #endif
select_text(xctx->texts, SELECTED, 0); xctx->texts++;
select_text(xctx->texts - 1, SELECTED, 0);
rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION */
drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
xctx->texts++;
set_modify(1); set_modify(1);
} }

View File

@ -725,7 +725,11 @@ int callback(int event, int mx, int my, KeySym key,
{ {
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
xctx->last_command = 0; xctx->last_command = 0;
place_text(1, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text 24122002 */ place_text(0, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text 24122002 */
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
move_objects(START,0,0,0);
break; break;
} }
if(key=='r' && !xctx->ui_state && state==0) /* start rect */ if(key=='r' && !xctx->ui_state && state==0) /* start rect */
@ -1500,7 +1504,11 @@ int callback(int event, int mx, int my, KeySym key,
break; break;
case 6: case 6:
xctx->last_command = 0; xctx->last_command = 0;
place_text(1, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text */ place_text(0, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text */
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
move_objects(START,0,0,0);
break; break;
case 7: /* cut selection into clipboard */ case 7: /* cut selection into clipboard */
rebuild_selected_array(); rebuild_selected_array();