rework keyframe hide popup, keyframe auto render, textbox set_selection wide text
[goodguy/history.git] / cinelerra-5.1 / cinelerra / labeledit.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2006 Pierre Dumuid
5  * 
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.
10  * 
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.
15  * 
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
19  * 
20  */
21
22 #include "awindow.h"
23 #include "awindowgui.h"
24 #include "labeledit.h"
25 #include "edl.h"
26 #include "fonts.h"
27 #include "language.h"
28 #include "localsession.h"
29 #include "mainsession.h"
30 #include "mwindow.h"
31 #include "mwindowgui.h"
32 #include "vwindow.h"
33 #include "vwindowgui.h"
34
35
36
37 LabelEdit::LabelEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
38  : Thread()
39 {
40         this->mwindow = mwindow;
41         this->awindow = awindow;
42         this->vwindow = vwindow;
43         this->label = 0;
44 }
45
46 LabelEdit::~LabelEdit()
47 {
48 }
49
50 void LabelEdit::edit_label(Label *label)
51 {
52 // Allow more than one window so we don't have to delete the clip in handle_event
53         if(label)
54         {
55                 this->label = label;
56                 Thread::start();
57         }
58 }
59
60 void LabelEdit::run()
61 {
62         if(label)
63         {
64                 LabelEditWindow *window = new LabelEditWindow(mwindow, this);
65                 window->create_objects();
66                 /*int result = */ window->run_window();
67                 delete window;
68                 if (awindow) awindow->gui->async_update_assets();
69         }
70 }
71
72
73
74
75
76
77
78 LabelEditWindow::LabelEditWindow(MWindow *mwindow, LabelEdit *thread)
79  : BC_Window(PROGRAM_NAME ": Label Info", 
80         mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
81         mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
82         400, 
83         350,
84         400,
85         430,
86         0,
87         0,
88         1)
89 {
90         this->mwindow = mwindow;
91         this->thread = thread;
92 }
93
94 LabelEditWindow::~LabelEditWindow()
95 {
96 }
97
98         
99 void LabelEditWindow::create_objects()
100 {
101         this->label = thread->label;
102
103         int x = 10, y = 10;
104         int x1 = x;
105         BC_TextBox *textbox;
106         BC_Title *title;
107
108         add_subwindow(title = new BC_Title(x1, y, _("Label Text:")));
109         y += title->get_h() + 5;
110         add_subwindow(textbox = new LabelEditComments(this, 
111                 x1, 
112                 y, 
113                 get_w() - x1 * 2, 
114                 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - 40 - y)));
115
116
117         add_subwindow(new BC_OKButton(this));
118         add_subwindow(new BC_CancelButton(this));
119         show_window();
120         textbox->activate();
121 }
122
123
124
125
126
127
128 LabelEditComments::LabelEditComments(LabelEditWindow *window, int x, int y, int w, int rows)
129  : BC_TextBox(x, y, w, rows, window->label->textstr,  1, MEDIUMFONT, 1)
130 {
131         this->window = window;
132 }
133
134 int LabelEditComments::handle_event()
135 {
136         strcpy(window->label->textstr, get_text());
137         return 1;
138 }