Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert to legacy color chooser for pixel/beam #161

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions src/src/ui_gtk3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ GtkWindow *quickadd_window;
GtkEntry *quickadd_entry;

/** --Color Chooser (for Plastic beam & Pixel) **/
GtkColorChooserDialog *beam_color_dialog;
GtkColorSelectionDialog *beam_color_dialog;

/** --Info Dialog **/
GtkWindow *info_dialog;
Expand Down Expand Up @@ -8350,13 +8350,15 @@ int _gtk_loop(void *p)

/** --Color Chooser (for Plastic beam & Pixel) **/
{
beam_color_dialog = GTK_COLOR_CHOOSER_DIALOG(gtk_color_chooser_dialog_new("Color", NULL));
GtkColorChooser *sel = GTK_COLOR_CHOOSER(beam_color_dialog);
beam_color_dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new("Color"));
GtkColorSelectionDialog *sel = GTK_COLOR_SELECTION_DIALOG(beam_color_dialog);

gtk_window_set_position(GTK_WINDOW(beam_color_dialog), GTK_WIN_POS_CENTER);
//gtk_window_set_keep_above(GTK_WINDOW(beam_color_dialog), TRUE);

gtk_color_chooser_set_use_alpha(sel, false);
gtk_color_selection_set_has_opacity_control(
GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(
GTK_COLOR_SELECTION_DIALOG(sel))), false);

g_signal_connect(beam_color_dialog, "delete-event", G_CALLBACK(on_window_close), 0);

Expand Down Expand Up @@ -10198,28 +10200,24 @@ _open_quickadd(gpointer unused)
static gboolean
_open_beam_color(gpointer unused)
{
GtkColorChooser *sel = 0;

/* set current chooser to beam/pixel current color */
sel = GTK_COLOR_CHOOSER(beam_color_dialog);
GtkColorSelection *sel = GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(beam_color_dialog));

entity *e = G->selection.e;
if (e) {
GdkRGBA color;
tvec4 c = e->get_color();
color.red = c.r;
color.green = c.g;
color.blue = c.b;
color.alpha = (double)(e->properties[4].v.i8) / 255.0;
//color.alpha = (double)((guint16) e->properties[4].v.i8 * 257) / 65535.;

gtk_color_chooser_set_rgba(sel, &color);

if (e->g_id == O_PIXEL) {
gtk_color_chooser_set_rgba(sel, &color);
gtk_color_chooser_set_use_alpha(sel, true);
color.alpha = (double)(e->properties[4].v.i8) / 255.0;
gtk_color_selection_set_has_opacity_control(sel, true);
} else {
gtk_color_chooser_set_use_alpha(sel, false);
color.alpha = 1.;
gtk_color_selection_set_has_opacity_control(sel, false);
}
gtk_color_selection_set_current_rgba(sel, &color);
} else if (W->is_adventure() && adventure::player && adventure::is_player_alive()) {
robot_parts::tool *t = adventure::player->get_tool();
if (t && t->get_arm_type() == TOOL_PAINTER) {
Expand All @@ -10237,11 +10235,12 @@ _open_beam_color(gpointer unused)
}

if (gtk_dialog_run(GTK_DIALOG(beam_color_dialog)) == GTK_RESPONSE_OK) {
sel = GTK_COLOR_CHOOSER(beam_color_dialog);
entity *e = G->selection.e;
//GtkColorSelection *sel = GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(beam_color_dialog)));

GdkRGBA color;
gtk_color_chooser_get_rgba(sel, &color);
gtk_color_selection_get_current_rgba(sel, &color);

entity *e = G->selection.e;

if (e) {
e->set_color4(color.red, color.green, color.blue);
Expand Down