3 * Copyright (C) 2006 Pierre Dumuid
4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "awindowgui.h"
26 #include "effectlist.h"
30 #include "pluginserver.h"
32 EffectTipDialog::EffectTipDialog(MWindow *mwindow, AWindow *awindow)
35 this->mwindow = mwindow;
36 this->awindow = awindow;
41 EffectTipDialog::~EffectTipDialog()
48 void EffectTipDialog::start(int x, int y, const char *effect, const char *text)
51 AWindowGUI *gui = awindow->gui;
52 char string[BCTEXTLEN];
53 sprintf(string, _("Effect info: %s"), _(effect));
54 int effect_w = BC_Title::calculate_w(gui, string);
55 int text_w = BC_Title::calculate_w(gui, text);
56 int text_h = BC_Title::calculate_h(gui, text);
57 this->w = bmax(text_w + 30, bmax(effect_w + 30, 120));
58 this->h = bmax(text_h + 100, 120);
59 this->x = x - this->w / 2;
60 this->y = y - this->h / 2;
61 delete [] this->effect; this->effect = cstrdup(string);
62 delete [] this->text; this->text = cstrdup(text);
63 BC_DialogThread::start();
66 BC_Window* EffectTipDialog::new_gui()
68 AWindowGUI *gui = awindow->gui;
69 effect_gui = new EffectTipWindow(gui, this);
70 effect_gui->create_objects();
75 EffectTipWindow::EffectTipWindow(AWindowGUI *gui, EffectTipDialog *thread)
76 : BC_Window(_(PROGRAM_NAME ": Effect Info"),
77 thread->x + thread->w/2, thread->y + thread->h/2,
78 thread->w, thread->h, thread->w, thread->h, 0, 0, 1)
81 this->thread = thread;
83 EffectTipWindow::~EffectTipWindow()
87 void EffectTipWindow::create_objects()
91 add_subwindow(title = new BC_Title(x, y, thread->effect));
92 y += title->get_h() + 10;
93 add_subwindow(tip_text = new BC_Title(x+5, y, thread->text));
94 add_subwindow(new BC_OKButton(this));
98 EffectTipItem::EffectTipItem(AWindowGUI *gui)
99 : BC_MenuItem(_("Info"))
103 EffectTipItem::~EffectTipItem()
107 int EffectTipItem::handle_event()
109 AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
110 if( result && result->plugin ) {
111 const char *info = result->plugin->tip;
112 if( !info ) info = _("No info available");
114 gui->get_abs_cursor(cur_x, cur_y, 0);
115 gui->awindow->effect_tip->start(cur_x, cur_y,
116 result->plugin->title, info);
122 EffectListMenu::EffectListMenu(MWindow *mwindow, AWindowGUI *gui)
123 : BC_PopupMenu(0, 0, 0, "", 0)
125 this->mwindow = mwindow;
129 EffectListMenu:: ~EffectListMenu()
133 void EffectListMenu::create_objects()
135 add_item(new EffectTipItem(gui));
136 add_item(format = new AWindowListFormat(mwindow, gui));
137 add_item(new AWindowListSort(mwindow, gui));
140 void EffectListMenu::update()