/* * Copyright (C) 2004-2005 Vadim Berezniker * http://www.kryptolus.com * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "common.h" #include "sabbu.h" #include "gui_main_style.h" #include "gui_main_fontsel.h" #include "gui_main_tab_video.h" #include "gui_main_style_manager.h" #include "sub_preview.h" #include "kryString.h" extern struct sabbu app; struct gui_main_style_editor *ui_style = &app.ui.style_editor; /** MODIFY STYLE CALLBACKS START */ void gui_main_style_underline_cb(GtkWidget *widget, gpointer data) { gboolean old_val = ui_style->current->GetUnderline() ? 1 : 0; gboolean new_val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(old_val == new_val) return; ui_style->current->SetUnderline(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_style_strikethrough_cb(GtkWidget *widget, gpointer data) { gboolean old_val = ui_style->current->GetStrikethrough() ? 1 : 0; gboolean new_val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(old_val == new_val) return; ui_style->current->SetStrikethrough(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_style_bold_cb(GtkWidget *widget, gpointer data) { gboolean old_val = ui_style->current->GetBold() ? 1 : 0; gboolean new_val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(old_val == new_val) return; ui_style->current->SetBold(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_style_italic_cb(GtkWidget *widget, gpointer data) { gboolean old_val = ui_style->current->GetItalic() ? 1 : 0; gboolean new_val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(old_val == new_val) return; ui_style->current->SetItalic(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_style_font_size_cb(GtkWidget *widget, gpointer data) { double old_size = ui_style->current->GetFontSize(); double new_size = gui_spin_button_get_value(ui_style->spin_font_size); if(fabs(new_size - old_size) < 0.000001) return; ui_style->current->SetFontSize(new_size); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_scalex_changed_cb(GtkWidget *widget, gpointer data) { double old_val = ui_style->current->GetFontScaleX(); double new_val = gui_spin_button_get_value(GTK_SPIN_BUTTON(ui_style->spin_scalex)); if(fabs(new_val - old_val) < 0.000001) return; ui_style->current->SetFontScaleX(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_scaley_changed_cb(GtkWidget *widget, gpointer data) { double old_val = ui_style->current->GetFontScaleY(); double new_val = gui_spin_button_get_value(GTK_SPIN_BUTTON(ui_style->spin_scaley)); if(fabs(new_val - old_val) < 0.000001) return; ui_style->current->SetFontScaleY(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_spacing_changed_cb(GtkWidget *widget, gpointer data) { double old_val = ui_style->current->GetFontSpacing(); double new_val = gui_spin_button_get_value(GTK_SPIN_BUTTON(ui_style->spin_spacing)); if(fabs(new_val - old_val) < 0.000001) return; ui_style->current->SetFontSpacing(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_angle_changed_cb(GtkWidget *widget, gpointer data) { double old_val = ui_style->current->GetFontAngleZ(); double new_val = gui_spin_button_get_value(GTK_SPIN_BUTTON(ui_style->spin_angle)); if(fabs(new_val - old_val) < 0.000001) return; ui_style->current->SetFontAngleZ(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_margin_changed_cb(GtkWidget *widget, gpointer data) { int new_val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); double new_val_dbl = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); if(widget == GTK_WIDGET(ui_style->spin_margin_left)) { int old_val = ui_style->current->GetMarginLeft(); if(old_val == new_val) return; ui_style->current->SetMarginLeft(new_val); } if(widget == GTK_WIDGET(ui_style->spin_margin_right)) { int old_val = ui_style->current->GetMarginRight(); if(old_val == new_val) return; ui_style->current->SetMarginRight(new_val); } if(widget == GTK_WIDGET(ui_style->spin_margin_vertical)) { int old_val = ui_style->current->GetMarginTop(); if(old_val == new_val) return; ui_style->current->SetMarginVertical(new_val); } if(widget == GTK_WIDGET(ui_style->spin_border_size)) { double old_val = ui_style->current->GetBorderSize(); if(fabs(new_val_dbl - old_val) < 0.000001) return; ui_style->current->SetBorderSize(new_val_dbl); } if(widget == GTK_WIDGET(ui_style->spin_shadow_size)) { double old_val = ui_style->current->GetShadowSize(); if(fabs(new_val_dbl - old_val) < 0.000001) return; ui_style->current->SetShadowSize(new_val_dbl); } gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); gtk_widget_queue_draw(GTK_WIDGET(app.ui.style_editor.draw_primary)); gtk_widget_queue_draw(GTK_WIDGET(app.ui.style_editor.draw_secondary)); gtk_widget_queue_draw(GTK_WIDGET(app.ui.style_editor.draw_outline)); gtk_widget_queue_draw(GTK_WIDGET(app.ui.style_editor.draw_shadow)); app.script->SetModifiedFlag(TRUE); } void gui_main_align_changed_cb(GtkWidget *widget, int pos) { if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) == FALSE) return; int old_val = ui_style->current->GetAlignment(); int new_val = pos; if(old_val == new_val) return; ui_style->current->SetAlignment(new_val); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_border_style_changed_cb(GtkWidget *widget, gpointer data) { char *str = KRY_TS(gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget))); if(!strcmp(str, __("StyleBorder|Outline"))) { kry_free(str); if(ui_style->current->GetBorderStyle() == BORDER_OUTLINE) return; ui_style->current->SetBorderStyle(BORDER_OUTLINE); } else if(!strcmp(str, __("StyleBorder|Opaque Box"))) { kry_free(str); if(ui_style->current->GetBorderStyle() == BORDER_OPAQUE) return; ui_style->current->SetBorderStyle(BORDER_OPAQUE); } else { kry_free(str); } gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); app.script->SetModifiedFlag(TRUE); } void gui_main_style_color_changed_cb(kryObject *obj, kryColor *color) { kryColorTable *table = (kryColorTable *) obj; kryStyle *style = app.ui.style_editor.current; unsigned int color_val; color_val = color->GetRed() | (color->GetGreen() << 8) | (color->GetBlue() << 16); if(color->HasOpacity()) color_val |= ((0xFF - color->GetAlpha()) << 24); if(color->GetID() == TAB_VIDEO_COLOR_PRIMARY) { style->SetColorPrimary(color_val); } else if(color->GetID() == TAB_VIDEO_COLOR_SECONDARY) { style->SetColorSecondary(color_val); } else if(color->GetID() == TAB_VIDEO_COLOR_TERTIARY) { style->SetColorTertiary(color_val); } else if(color->GetID() == TAB_VIDEO_COLOR_OUTLINE) { style->SetColorOutline(color_val); } else if(color->GetID() == TAB_VIDEO_COLOR_SHADOW) { style->SetColorShadow(color_val); } else if(color->GetID() == TAB_VIDEO_COLOR_BACK) { style->SetColorBack(color_val); table->Get(TAB_VIDEO_COLOR_OUTLINE)->SetColor(color->GetRed(), color->GetGreen(), color->GetBlue()); table->Get(TAB_VIDEO_COLOR_OUTLINE)->SetAlpha(color->GetAlpha()); table->Get(TAB_VIDEO_COLOR_SHADOW)->SetColor(color->GetRed(), color->GetGreen(), color->GetBlue()); table->Get(TAB_VIDEO_COLOR_SHADOW)->SetAlpha(color->GetAlpha()); } else if(color->GetID() == TAB_VIDEO_COLOR_BACKGROUND) { app.ui.tab_video.color_solid = color_val; } else g_warning("unknown color in callback"); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); if(color->GetID() != TAB_VIDEO_COLOR_BACKGROUND) app.script->SetModifiedFlag(TRUE); } /** MODIFY STYLE CALLBACKS END */ gboolean gui_main_style_check_name(char *name) { kryString strName(name); if(strName.Find(',') != -1) return FALSE; if(app.script->GetStyle(name)) return FALSE; return TRUE; } void gui_main_style_manager_cb(GtkWidget *widget, gpointer data) { gui_main_disable(); gui_main_style_manager_create(); } void gui_main_style_new_cb(GtkWidget *widget, gpointer data) { GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("New Style"), app.ui.window, GTK_DIALOG_MODAL, GTK_STOCK_OK, 1, GTK_STOCK_CANCEL, 2, NULL)); GtkEntry *entry = GTK_ENTRY(gtk_entry_new()); GtkCheckButton *button = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(_("Copy from selected style"))); int rv; const char *text; kryStyle *style; char *style_name = NULL; int index = 1; do { if(style_name) kry_free(style_name); style_name = kry_strdup_printf(KRY_LOC "New Style %d", index); index++; } while(app.script->GetStyle(style_name)); gtk_entry_set_text(entry, style_name); kry_free(style_name); gtk_box_pack_start(GTK_BOX(dialog->vbox), GTK_WIDGET(entry), FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(dialog->vbox), GTK_WIDGET(button), FALSE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(dialog)); gui_main_disable(); for(;;) { rv = gtk_dialog_run(dialog); if(rv != 1) { gui_main_enable(); gui_main_focus(); gtk_widget_destroy(GTK_WIDGET(dialog)); return; } text = gtk_entry_get_text(entry); if(!gui_main_style_check_name((char *) text)) { gui_error(_("Error creating style (Name must be unique and must not contain any commas)")); } else { break; } } if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) style = app.ui.style_editor.current->Copy(); else style = new kryStyle(); style->SetName((char *) text); app.script->AddStyle(style); gui_main_style_list_fill(); gui_combo_box_set_text(app.ui.style_editor.combo_style, (char *) text); gui_main_enable(); gui_main_focus(); gtk_widget_destroy(GTK_WIDGET(dialog)); } void gui_main_style_rename_cb(GtkWidget *widget, gpointer data) { GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Rename Style"), app.ui.window, GTK_DIALOG_MODAL, GTK_STOCK_OK, 1, GTK_STOCK_CANCEL, 2, NULL)); GtkEntry *entry = GTK_ENTRY(gtk_entry_new()); int rv; const char *text; kryStyle *style; gtk_entry_set_text(entry, app.ui.style_editor.current->GetName()); gtk_box_pack_start(GTK_BOX(dialog->vbox), GTK_WIDGET(entry), FALSE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(dialog)); gui_main_disable(); for(;;) { rv = gtk_dialog_run(dialog); if(rv != 1) { gui_main_enable(); gui_main_focus(); gtk_widget_destroy(GTK_WIDGET(dialog)); return; } text = gtk_entry_get_text(entry); if(strcmp((char *) text, app.ui.style_editor.current->GetName()) && !gui_main_style_check_name((char *) text)) { gui_error(_("Error creating style (Name must be unique and must not contain any commas)")); } else { break; } } if(strcmp(text, app.ui.style_editor.current->GetName())) { gboolean is_default = !strcmp(app.ui.style_editor.current->GetName(), "Default"); style = app.ui.style_editor.current->Copy(); style->SetName((char *) text); app.script->RemoveStyle((char *) app.ui.style_editor.current->GetName()); app.script->AddStyle(style); if(is_default) { app.script->AddDefaultStyle(); gui_main_style_changed_cb(GTK_WIDGET(app.ui.style_editor.combo_style), NULL); } #ifdef _WINDOWS subtest_set_modified(); #endif app.ui.style_editor.current = style; gui_main_style_list_fill(); gui_combo_box_set_text(app.ui.style_editor.combo_style, (char *) text); } gui_main_enable(); gui_main_focus(); gtk_widget_destroy(GTK_WIDGET(dialog)); } void gui_main_style_delete_cb(GtkWidget *widget, gpointer data) { int rv = gui_question_yes_no(_("Are you sure you want to delete this style?")); kryStyle *style = app.ui.style_editor.current; gboolean is_default = !strcmp(style->GetName(), "Default"); if(!rv) return; app.script->RemoveStyle(style->GetName()); if(is_default) { app.script->AddDefaultStyle(); gui_main_style_changed_cb(GTK_WIDGET(app.ui.style_editor.combo_style), NULL); } #ifdef _WINDOWS subtest_set_modified(); #endif app.ui.style_editor.current = app.script->GetStyle("Default"); gui_main_style_list_fill(); gui_combo_box_set_text(app.ui.style_editor.combo_style, "Default"); } void gui_main_style_font_cb(GtkWidget *widget, gpointer data) { struct gui_main_style_editor *ui = &app.ui.style_editor; struct fontsel_info fontsel_info; fontsel_info.font_name = kry_strdup((char *) gtk_entry_get_text(ui->entry_font_name)); fontsel_info.font_size = (int) ui->current->GetFontSize(); fontsel_info.bold = ui->current->GetBold() ? 700 : 400; fontsel_info.italic = ui->current->GetItalic(); fontsel_info.strikethough = ui->current->GetStrikethrough(); fontsel_info.underline = ui->current->GetUnderline(); if(gui_main_select_font(&fontsel_info)) { ui->current->SetFontName(fontsel_info.font_name); ui->current->SetFontSize(fontsel_info.font_size); ui->current->SetBold((fontsel_info.bold == 700 ? 1 : 0)); ui->current->SetItalic(fontsel_info.italic); ui->current->SetUnderline(fontsel_info.underline); ui->current->SetStrikethrough(fontsel_info.strikethough); } kry_free(fontsel_info.font_name); gui_main_style_update_gui(); return; } gboolean gui_main_color_release_cb(GtkWidget *widget, GdkEventButton *event, kryColor *color) { gboolean need_confirm = TRUE; if(event->button != 3) return FALSE; if(event->state & GDK_CONTROL_MASK) need_confirm = FALSE; if(need_confirm) { int rv; rv = gui_question_yes_no(_("Reset this color to the default value? \n\n(You can Ctrl+Right click the colors to supress this message)")); if(!rv) return TRUE; } color->Reset(); return TRUE; } GtkButton *gui_main_color_button_new(GtkDrawingArea **area, kryColor *color) { GtkButton *button = GTK_BUTTON(gtk_button_new()); GtkDrawingArea *draw = GTK_DRAWING_AREA(gtk_drawing_area_new()); gtk_widget_set_size_request(GTK_WIDGET(draw), 20, 20); gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(draw)); g_signal_connect(draw, "expose-event", G_CALLBACK(gui_main_color_expose_cb), color); g_signal_connect(button, "clicked", G_CALLBACK(gui_main_color_clicked_cb), color); g_signal_connect(button, "button-release-event", G_CALLBACK(gui_main_color_release_cb), color); if(area) *area = draw; gtk_widget_show(GTK_WIDGET(button)); return button; } void gui_main_draw_color(GtkWidget *widget, GdkColor color_gdk) { } void gui_main_color_fill(GtkDrawingArea *area, kryColor *color, gboolean border) { GdkColor color_gdk; int x, y; int every = 6; int width = GTK_WIDGET(area)->allocation.width; int height = GTK_WIDGET(area)->allocation.height; char *data = (char *) kry_malloc(width * height * 3); char *data_color = (char *) kry_malloc(width * height * 4); GdkPixbuf *pixbuf; GdkPixbuf *pixbuf_color; int color_int; GdkDrawable *draw = GTK_WIDGET(area)->window; GdkGC *gc; if(color) { color_gdk.red = color->GetRed() * 257; color_gdk.green = color->GetGreen() * 257; color_gdk.blue = color->GetBlue() * 257; } else { color_gdk.red = 65535; color_gdk.green = 0; color_gdk.blue = 0; } color_int = color->GetRed() | (color->GetGreen() << 8) | (color->GetBlue() << 16); if(color->HasOpacity()) color_int |= ((255 - color->GetAlpha()) << 24); for(y = 0; y < height; y++) { int start_white = (y % (every * 2)) < every; for(x = 0; x < width; x++) { int index = y * width * 3 + x * 3; int color = ((x % (every * 2)) < every) ^ start_white; if(color) color = 192; else color = 255; data[index] = color; data[index+1] = color; data[index+2] = color; } } for(y = 0; y < height; y++) { for(x = 0; x < width; x++) { int index = y * width * 4 + x * 4; data_color[index] = (color_int & 0x000000FF); data_color[index+1] = (color_int & 0x0000FF00) >> 8; data_color[index+2] = (color_int & 0x00FF0000) >> 16; data_color[index+3] = 0xFF - ((color_int & 0xFF000000) >> 24); } } pixbuf = gdk_pixbuf_new_from_data((const guchar *) data, GDK_COLORSPACE_RGB, FALSE, 8, width, height, width * 3, NULL, NULL); pixbuf_color = gdk_pixbuf_new_from_data((const guchar *) data_color, GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * 4, NULL, NULL); gc = gdk_gc_new(draw); gdk_gc_set_rgb_fg_color(gc, &color_gdk); gdk_draw_pixbuf(draw, NULL, pixbuf, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NORMAL, 0, 0); gdk_draw_pixbuf(draw, NULL, pixbuf_color, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NORMAL, 0, 0); if(border) { GdkColor black; black.blue = 0; black.green = 0; black.red = 0; gdk_gc_set_rgb_fg_color(gc, &black); gdk_draw_rectangle(draw, gc, FALSE, 0, 0, width - 1, height - 1); } g_object_unref(gc); g_object_unref(pixbuf); g_object_unref(pixbuf_color); kry_free(data); kry_free(data_color); } void gui_main_color_expose_cb(GtkWidget *widget, GdkEventExpose *event, kryColor *color) { gui_main_color_fill(GTK_DRAWING_AREA(widget), color, FALSE); } void gui_main_waveforms_set_color(enum waveform_colors id, GdkColor color) { } void gui_main_color_clicked_cb(GtkWidget *widget, kryColor *color) { int rv; GdkColor color_gdk; GtkColorSelectionDialog *dialog; int alpha; if(color) { color_gdk.red = color->GetRed() * 257; color_gdk.green = color->GetGreen() * 257; color_gdk.blue = color->GetBlue() * 257; } else { color_gdk.red = 65535; color_gdk.green = 0; color_gdk.blue = 0; } gui_main_disable(); dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new(_("Style Color"))); if(color->HasOpacity()) { gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(dialog->colorsel), TRUE); gtk_color_selection_set_current_alpha(GTK_COLOR_SELECTION(dialog->colorsel), color->GetAlpha() * 257); } gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(dialog->colorsel), &color_gdk); rv = gtk_dialog_run(GTK_DIALOG(dialog)); if(rv == GTK_RESPONSE_OK) { gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(dialog->colorsel), &color_gdk); alpha = gtk_color_selection_get_current_alpha(GTK_COLOR_SELECTION(dialog->colorsel)); if(color) { if(color->HasOpacity()) color->SetAlpha(alpha / 257); color->SetColor(color_gdk.red / 257, color_gdk.green / 257, color_gdk.blue / 257); char *val = kry_strdup_printf(KRY_LOC "%d", color->GetRed() << 16 | color->GetGreen() << 8 | color->GetBlue()); if(color->GetTextID()) app.prefs->SetString("Colors", color->GetTextID(), val); kry_free(val); } } gtk_widget_destroy(GTK_WIDGET(dialog)); gui_main_enable(); } void gui_main_style_list_fill() { GtkTreeIter tree_iter; char *sel_text1 = KRY_TS(gtk_combo_box_get_active_text(app.ui.combo_style)); char *sel_text2 = KRY_TS(gtk_combo_box_get_active_text(app.ui.style_editor.combo_style)); gtk_list_store_clear(app.ui.style_store); kryListIterator iter; app.script->GetStyleNameIterator(&iter); char *style_name; while((style_name = iter.GetNext())) { kryStyle *style = app.script->GetStyle(style_name); if(style->GetType() == KRY_STYLE_COMMENT) continue; gtk_list_store_append(app.ui.style_store, &tree_iter); gtk_list_store_set(app.ui.style_store, &tree_iter, 0, style_name, 1, 0, -1); } if(!sel_text1 || !strcmp(sel_text1, "")) sel_text1 = kry_strdup("Default"); if(!sel_text2 || !strcmp(sel_text2, "")) sel_text2 = kry_strdup("Default"); if(sel_text1) { gui_combo_box_set_text(app.ui.combo_style, sel_text1); kry_free(sel_text1); } if(sel_text2) { gui_combo_box_set_text(app.ui.style_editor.combo_style, sel_text2); kry_free(sel_text2); } gui_main_style_update_gui(); } void gui_main_style_update_gui() { kryStyle *style = app.ui.style_editor.current; struct gui_main_style_editor *ui = &app.ui.style_editor; if(!style) return; gtk_entry_set_text(ui->entry_font_name, style->GetFontName()); gtk_spin_button_set_value(ui->spin_font_size, style->GetFontSize()); gtk_toggle_button_set_active(ui->button_font_bold, style->GetBold()); gtk_toggle_button_set_active(ui->button_font_italic, style->GetItalic()); gtk_toggle_button_set_active(ui->button_font_underline, style->GetUnderline()); gtk_toggle_button_set_active(ui->button_font_strikethrough, style->GetStrikethrough()); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->button_align[style->GetAlignment() - 1]), TRUE); kryColorTable *color_table = app.ui.style_color_table; color_table->Set(TAB_VIDEO_COLOR_PRIMARY, NULL, NULL, (style->GetColorPrimary() & 0x0000FF) >> 0, (style->GetColorPrimary() & 0x00FF00) >> 8, (style->GetColorPrimary() & 0xFF0000) >> 16 ); color_table->Set(TAB_VIDEO_COLOR_SECONDARY, NULL, NULL, (style->GetColorSecondary() & 0x0000FF) >> 0, (style->GetColorSecondary() & 0x00FF00) >> 8, (style->GetColorSecondary() & 0xFF0000) >> 16 ); color_table->Set(TAB_VIDEO_COLOR_TERTIARY, NULL, NULL, (style->GetColorTertiary() & 0x0000FF) >> 0, (style->GetColorTertiary() & 0x00FF00) >> 8, (style->GetColorTertiary() & 0xFF0000) >> 16 ); color_table->Set(TAB_VIDEO_COLOR_OUTLINE, NULL, NULL, (style->GetColorOutline() & 0x0000FF) >> 0, (style->GetColorOutline() & 0x00FF00) >> 8, (style->GetColorOutline() & 0xFF0000) >> 16 ); color_table->Set(TAB_VIDEO_COLOR_SHADOW, NULL, NULL, (style->GetColorShadow() & 0x0000FF) >> 0, (style->GetColorShadow() & 0x00FF00) >> 8, (style->GetColorShadow() & 0xFF0000) >> 16 ); color_table->Set(TAB_VIDEO_COLOR_BACK, NULL, NULL, (style->GetColorBack() & 0x0000FF) >> 0, (style->GetColorBack() & 0x00FF00) >> 8, (style->GetColorBack() & 0xFF0000) >> 16 ); gtk_spin_button_set_value(ui->spin_margin_left, style->GetMarginLeft()); gtk_spin_button_set_value(ui->spin_margin_right, style->GetMarginRight()); gtk_spin_button_set_value(ui->spin_margin_vertical, style->GetMarginTop()); gtk_spin_button_set_value(ui->spin_angle, style->GetFontAngleZ()); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->spin_border_size), style->GetBorderSize()); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->spin_shadow_size), style->GetShadowSize()); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->spin_scaley), style->GetFontScaleY()); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->spin_scalex), style->GetFontScaleX()); gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->spin_spacing), style->GetFontSpacing()); if(style->GetBorderStyle() == BORDER_OUTLINE) gtk_combo_box_set_active(ui->combo_border, 0); else if(style->GetBorderStyle() == BORDER_OPAQUE) gtk_combo_box_set_active(ui->combo_border, 1); gtk_widget_queue_draw(GTK_WIDGET(app.ui.video_area)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_primary)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_secondary)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_tertiary)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_outline)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_shadow)); gtk_widget_queue_draw(GTK_WIDGET(ui->draw_back)); } void gui_main_style_changed_cb(GtkWidget *widget, gpointer data) { char *style_name = KRY_TS(gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget))); gboolean found = FALSE; kryListIterator iter; app.script->GetStyleNameIterator(&iter); char *style_name_cur; while((style_name_cur = iter.GetNext())) { kryStyle *style = app.script->GetStyle(style_name_cur); if(!strcmp(style->GetName(), style_name)) { app.ui.style_editor.current = style; found = TRUE; } } if(found) { gui_main_style_update_gui(); } kry_free(style_name); }