+
+/*
+ * CINELERRA
+ * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ *
+ * 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 of the License, 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "appearanceprefs.h"
+#include "deleteallindexes.h"
+#include "edl.h"
+#include "edlsession.h"
+#include "file.h"
+#include "filesystem.h"
+#include "language.h"
+#include "mwindow.h"
+#include "preferences.h"
+#include "preferencesthread.h"
+#include "shbtnprefs.h"
+#include "theme.h"
+
+
+#define MOVE_ALL_EDITS_TITLE N_("Drag all following edits")
+#define MOVE_ONE_EDIT_TITLE N_("Drag only one edit")
+#define MOVE_NO_EDITS_TITLE N_("Drag source only")
+#define MOVE_EDITS_DISABLED_TITLE N_("No effect")
+
+
+AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
+ : PreferencesDialog(mwindow, pwindow)
+{
+ hms = 0;
+ hmsf = 0;
+ samples = 0;
+ frames = 0;
+ hex = 0;
+ feet = 0;
+ thumbnails = 0;
+}
+
+AppearancePrefs::~AppearancePrefs()
+{
+ delete hms;
+ delete hmsf;
+ delete samples;
+ delete frames;
+ delete hex;
+ delete feet;
+ delete thumbnails;
+}
+
+
+void AppearancePrefs::create_objects()
+{
+ BC_Resources *resources = BC_WindowBase::get_resources();
+ int margin = mwindow->theme->widget_border;
+ char string[BCTEXTLEN];
+ int x0 = mwindow->theme->preferencesoptions_x;
+ int y0 = mwindow->theme->preferencesoptions_y;
+ int x = x0, y = y0, x1 = x + 100;
+
+ add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT,
+ resources->text_default));
+ y += 35;
+
+ ViewTheme *theme;
+ add_subwindow(new BC_Title(x, y, _("Theme:")));
+ add_subwindow(theme = new ViewTheme(x1, y, pwindow));
+ theme->create_objects();
+ y += theme->get_h() + 5;
+
+ x = x0;
+ ViewPluginIcons *plugin_icons;
+ add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
+ add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
+ plugin_icons->create_objects();
+ y += plugin_icons->get_h() + 5;
+
+ y += 10;
+ add_subwindow(new BC_Bar(5, y, get_w() - 10));
+ y += 15;
+
+ add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT,
+ resources->text_default));
+
+ x1 = get_w()/2;
+ add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT,
+ resources->text_default));
+
+ y += get_text_height(LARGEFONT) + 5;
+ y += 10;
+ int y1 = y;
+
+ add_subwindow(hms = new TimeFormatHMS(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_HMS,
+ x, y));
+ y += 20;
+ add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_HMSF,
+ x, y));
+ y += 20;
+ add_subwindow(samples = new TimeFormatSamples(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_SAMPLES,
+ x, y));
+ y += 20;
+ add_subwindow(hex = new TimeFormatHex(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
+ x, y));
+ y += 20;
+ add_subwindow(frames = new TimeFormatFrames(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_FRAMES,
+ x, y));
+ y += 20;
+ add_subwindow(feet = new TimeFormatFeet(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
+ x, y));
+ x += feet->get_w() + 15;
+ BC_Title *title;
+ add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
+ x += title->get_w() + margin;
+ sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
+ add_subwindow(new TimeFormatFeetSetting(pwindow,
+ x, y - 5, string));
+ x = x0;
+ y += 20;
+ add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
+ pwindow->thread->edl->session->time_format == TIME_SECONDS,
+ x, y));
+ y += 35;
+
+ UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
+ add_subwindow(tip_win);
+ y1 += tip_win->get_h() + 5;
+ UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
+ add_subwindow(idx_win);
+ y1 += idx_win->get_h() + 5;
+ UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
+ add_subwindow(ver_win);
+ y1 += ver_win->get_h() + 5;
+ BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
+ add_subwindow(bdwr_win);
+ y1 += bdwr_win->get_h() + 5;
+ PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
+ add_subwindow(pop_win);
+ y1 += pop_win->get_h() + 5;
+ ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
+ add_subwindow(focus_activate);
+ y1 += focus_activate->get_h() + 5;
+ DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
+ add_subwindow(focus_deactivate);
+ y1 += focus_deactivate->get_h() + 5;
+ add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
+ if( y < y1 ) y = y1;
+}
+
+int AppearancePrefs::update(int new_value)
+{
+ pwindow->thread->redraw_times = 1;
+ pwindow->thread->edl->session->time_format = new_value;
+ hms->update(new_value == TIME_HMS);
+ hmsf->update(new_value == TIME_HMSF);
+ samples->update(new_value == TIME_SAMPLES);
+ hex->update(new_value == TIME_SAMPLES_HEX);
+ frames->update(new_value == TIME_FRAMES);
+ feet->update(new_value == TIME_FEET_FRAMES);
+ seconds->update(new_value == TIME_SECONDS);
+ return 0;
+}
+
+
+TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_HMS_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatHMS::handle_event()
+{
+ tfwindow->update(TIME_HMS);
+ return 1;
+}
+
+TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_HMSF_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatHMSF::handle_event()
+{
+ tfwindow->update(TIME_HMSF);
+ return 1;
+}
+
+TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatSamples::handle_event()
+{
+ tfwindow->update(TIME_SAMPLES);
+ return 1;
+}
+
+TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatFrames::handle_event()
+{
+ tfwindow->update(TIME_FRAMES);
+ return 1;
+}
+
+TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatHex::handle_event()
+{
+ tfwindow->update(TIME_SAMPLES_HEX);
+ return 1;
+}
+
+TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
+{
+ this->pwindow = pwindow;
+ this->tfwindow = tfwindow;
+}
+
+int TimeFormatSeconds::handle_event()
+{
+ tfwindow->update(TIME_SECONDS);
+ return 1;
+}
+
+TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
+{ this->pwindow = pwindow; this->tfwindow = tfwindow; }
+
+int TimeFormatFeet::handle_event()
+{
+ tfwindow->update(TIME_FEET_FRAMES);
+ return 1;
+}
+
+TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
+ : BC_TextBox(x, y, 90, 1, string)
+{ this->pwindow = pwindow; }
+
+int TimeFormatFeetSetting::handle_event()
+{
+ pwindow->thread->edl->session->frames_per_foot = atof(get_text());
+ if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
+ return 0;
+}
+
+
+ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
+ : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
+{
+ this->pwindow = pwindow;
+}
+ViewTheme::~ViewTheme()
+{
+}
+
+void ViewTheme::create_objects()
+{
+ ArrayList<PluginServer*> themes;
+ MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
+
+ for(int i = 0; i < themes.total; i++) {
+ add_item(new ViewThemeItem(this, themes.values[i]->title));
+ }
+}
+
+int ViewTheme::handle_event()
+{
+ return 1;
+}
+
+ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
+ : BC_MenuItem(text)
+{
+ this->popup = popup;
+}
+
+int ViewThemeItem::handle_event()
+{
+ popup->set_text(get_text());
+ strcpy(popup->pwindow->thread->preferences->theme, get_text());
+ popup->handle_event();
+ return 1;
+}
+
+
+ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
+ : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
+{
+ this->pwindow = pwindow;
+}
+ViewPluginIcons::~ViewPluginIcons()
+{
+}
+
+void ViewPluginIcons::create_objects()
+{
+ add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
+ FileSystem fs;
+ const char *plugin_path = File::get_plugin_path();
+ if( fs.update(plugin_path) ) return;
+ for( int i=0; i<fs.dir_list.total; ++i ) {
+ char *fs_path = fs.dir_list[i]->path;
+ if( !fs.is_dir(fs_path) ) continue;
+ char *cp = strrchr(fs_path,'/');
+ cp = !cp ? fs_path : cp+1;
+ if( strncmp("picon_", cp, 6) ) continue;
+ if( !strcmp(cp += 6,DEFAULT_PICON) ) continue;
+ add_item(new ViewPluginIconItem(this, cp));
+ }
+}
+
+int ViewPluginIcons::handle_event()
+{
+ return 1;
+}
+
+ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
+ : BC_MenuItem(text)
+{
+ this->popup = popup;
+}
+
+int ViewPluginIconItem::handle_event()
+{
+ popup->set_text(get_text());
+ strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
+ popup->handle_event();
+ return 1;
+}
+
+
+ViewThumbnails::ViewThumbnails(int x,
+ int y,
+ PreferencesWindow *pwindow)
+ : BC_CheckBox(x,
+ y,
+ pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
+{
+ this->pwindow = pwindow;
+}
+
+int ViewThumbnails::handle_event()
+{
+ pwindow->thread->preferences->use_thumbnails = get_value();
+ return 1;
+}
+
+
+
+UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x,
+ y,
+ pwindow->thread->preferences->use_tipwindow,
+ _("Show tip of the day"))
+{
+ this->pwindow = pwindow;
+}
+int UseTipWindow::handle_event()
+{
+ pwindow->thread->preferences->use_tipwindow = get_value();
+ return 1;
+}
+
+
+UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
+ _("ffmpeg probe warns rebuild indexes"))
+{
+ this->pwindow = pwindow;
+}
+
+int UseWarnIndecies::handle_event()
+{
+ pwindow->thread->preferences->warn_indexes = get_value();
+ return 1;
+}
+
+UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
+ _("EDL version warns if mismatched"))
+{
+ this->pwindow = pwindow;
+}
+
+int UseWarnVersion::handle_event()
+{
+ pwindow->thread->preferences->warn_version = get_value();
+ return 1;
+}
+
+BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
+ _("Create Bluray warns if not root"))
+{
+ this->pwindow = pwindow;
+}
+
+int BD_WarnRoot::handle_event()
+{
+ pwindow->thread->preferences->bd_warn_root = get_value();
+ return 1;
+}
+
+PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
+ _("Popups activate on button up"))
+{
+ this->pwindow = pwindow;
+}
+
+int PopupMenuBtnup::handle_event()
+{
+ pwindow->thread->preferences->popupmenu_btnup = get_value();
+ return 1;
+}
+
+ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
+ _("Click to activate text focus"))
+{
+ this->pwindow = pwindow;
+}
+
+int ActivateFocusPolicy::handle_event()
+{
+ if( get_value() )
+ pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
+ else
+ pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
+ return 1;
+}
+
+DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
+ : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
+ _("Click to deactivate text focus"))
+{
+ this->pwindow = pwindow;
+}
+
+int DeactivateFocusPolicy::handle_event()
+{
+ if( get_value() )
+ pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
+ else
+ pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
+ return 1;
+}
+