int AssetVIcon::get_vy()
{
BC_ListBox *lbox = picon->gui->asset_list;
- return lbox->get_item_y(picon) + lbox->get_title_h();
+ return lbox->get_item_y(picon);
}
void AssetVIcon::load_audio()
add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
vicon_thread = new VIconThread(asset_list);
+ int x0 = 0, y0 = asset_list->get_title_h();
+ vicon_thread->set_drawing_area(x0,y0, get_w(),get_h());
vicon_thread->start();
vicon_audio = new AssetVIconAudio(this);
{
if( !vicon_drawing ) return;
if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
- if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
- vicon_thread->start_drawing();
+ switch( mwindow->edl->session->assetlist_format ) {
+ case ASSETS_ICONS:
+ case ASSETS_ICONS_PACKED:
+ case ASSETS_ICON_LIST:
+ vicon_thread->start_drawing();
+ break;
+ default:
+ break;
+ }
}
void AWindowGUI::stop_vicon_drawing()
if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
+ int x0 = 0;
+ int x1 = asset_list->get_w();
+ int y0 = asset_list->get_title_h();
+ int y1 = asset_list->get_h();
+ vicon_thread->set_drawing_area(x0,y0, x1,y1);
}
int asset_xposition = asset_list->get_xposition();
int asset_yposition = asset_list->get_yposition();
AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
: BC_ListBox(x, y, w, h,
- mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
+ mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
LISTBOX_ICONS : LISTBOX_TEXT,
&gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
0, // Titles for columns. Set to 0 for no titles
AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
- : BC_ListBox(x, y, w, h,
- (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
- LISTBOX_ICONS : LISTBOX_TEXT,
+ : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
+ mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
+ mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
+ mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
+ LISTBOX_TEXT,
&gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
gui->asset_titles,// Titles for columns. Set to 0 for no titles
mwindow->edl->session->asset_columns, // width of each column
gui->stop_vicon_drawing();
EDLSession *session = mwindow->edl->session;
- switch( session->assetlist_format ) {
- case ASSETS_TEXT:
- session->assetlist_format = ASSETS_ICONS;
- break;
- case ASSETS_ICONS:
- session->assetlist_format = ASSETS_TEXT;
- break;
+ if( mwindow->awindow->gui->allow_iconlisting ) {
+ switch( session->assetlist_format ) {
+ case ASSETS_TEXT:
+ session->assetlist_format = ASSETS_ICONS;
+ break;
+ case ASSETS_ICONS:
+ session->assetlist_format = ASSETS_ICONS_PACKED;
+ break;
+ case ASSETS_ICONS_PACKED:
+ session->assetlist_format = ASSETS_ICON_LIST;
+ break;
+ case ASSETS_ICON_LIST:
+ session->assetlist_format = ASSETS_TEXT;
+ break;
+ }
}
-
- gui->asset_list->update_format(session->assetlist_format, 1);
- if( !mwindow->awindow->gui->allow_iconlisting ) {
+ else
mwindow->edl->session->assetlist_format = ASSETS_TEXT;
- }
+ gui->asset_list->update_format(session->assetlist_format, 0);
+ int x0 = 0;
+ int x1 = gui->asset_list->get_w();
+ int y0 = gui->asset_list->get_title_h();
+ int y1 = gui->asset_list->get_h();
+ gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
+ gui->async_update_assets();
gui->start_vicon_drawing();
return 1;
}
void AWindowListFormat::update()
{
- set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
- (char*)_("Display icons") : (char*)_("Display text"));
+ EDLSession *session = mwindow->edl->session;
+ const char *text = 0;
+ switch( session->assetlist_format ) {
+ case ASSETS_TEXT:
+ text = _("Display icons");
+ break;
+ case ASSETS_ICONS:
+ text = _("Display icons packed");
+ break;
+ case ASSETS_ICONS_PACKED:
+ text = _("Display icon list");
+ break;
+ case ASSETS_ICON_LIST:
+ text = _("Display text");
+ break;
+ }
+ set_text(text);
}
AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
add_item(new EditPopupAddTrack(mwindow, this));
add_item(new EditPopupFindAsset(mwindow, this));
add_item(new EditPopupTitle(mwindow, this));
+ add_item(new EditPopupShow(mwindow, this));
resize_option = 0;
matchsize_option = 0;
}
{
this->mwindow = mwindow;
this->popup = popup;
- window = 0;
+ dialog_thread = new EditTitleDialogThread(this);
}
EditPopupTitle::~EditPopupTitle()
{
+ delete dialog_thread;
}
int EditPopupTitle::handle_event()
{
- int result;
if( popup->edit ) {
- window = new EditPopupTitleWindow (mwindow, popup);
- window->create_objects();
- result = window->run_window();
- if( !result && popup->edit ) {
- strcpy(popup->edit->user_title, window->title_text->get_text());
- mwindow->gui->draw_canvas(1, 0);
- mwindow->gui->flash_canvas(1);
- }
- delete window; window = 0;
+ dialog_thread->close_window();
+ int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2;
+ int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2;
+ dialog_thread->start(wx, wy);
}
-
return 1;
}
+void EditTitleDialogThread::start(int wx, int wy)
+{
+ this->wx = wx; this->wy = wy;
+ BC_DialogThread::start();
+}
+
+EditTitleDialogThread::EditTitleDialogThread(EditPopupTitle *edit_title)
+{
+ this->edit_title = edit_title;
+ window = 0;
+}
+EditTitleDialogThread::~EditTitleDialogThread()
+{
+ close_window();
+}
-EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup)
- : BC_Window (_(PROGRAM_NAME ": Set edit title"),
- mwindow->gui->get_abs_cursor_x(0) - 400 / 2,
- mwindow->gui->get_abs_cursor_y(0) - 500 / 2,
+BC_Window* EditTitleDialogThread::new_gui()
+{
+ MWindow *mwindow = edit_title->mwindow;
+ EditPopup *popup = edit_title->popup;
+ window = new EditPopupTitleWindow(mwindow, popup, wx, wy);
+ window->create_objects();
+ return window;
+}
+
+void EditTitleDialogThread::handle_close_event(int result)
+{
+ window = 0;
+}
+
+void EditTitleDialogThread::handle_done_event(int result)
+{
+ if( result ) return;
+ MWindow *mwindow = edit_title->mwindow;
+ EditPopup *popup = edit_title->popup;
+ strcpy(popup->edit->user_title, window->title_text->get_text());
+ mwindow->gui->lock_window("EditTitleDialogThread::handle_done_event");
+ mwindow->gui->draw_canvas(1, 0);
+ mwindow->gui->flash_canvas(1);
+ mwindow->gui->unlock_window();
+}
+
+EditPopupTitleWindow::EditPopupTitleWindow(MWindow *mwindow,
+ EditPopup *popup, int wx, int wy)
+ : BC_Window(_(PROGRAM_NAME ": Set edit title"), wx, wy,
300, 130, 300, 130, 0, 0, 1)
{
this->mwindow = mwindow;
this->popup = popup;
- if( popup->edit ) {
- strcpy(new_text, popup->edit->user_title);
- }
+ strcpy(new_text, !popup->edit ? "" : popup->edit->user_title);
}
EditPopupTitleWindow::~EditPopupTitleWindow()
{
}
-int EditPopupTitleWindow::close_event()
-{
- set_done(1);
- return 1;
-}
-
void EditPopupTitleWindow::create_objects()
{
lock_window("EditPopupTitleWindow::create_objects");
- int x = 10;
- int y = 10;
- add_subwindow (new BC_Title (x, y, _("User title:")));
- title_text = new EditPopupTitleText (this, mwindow, x+15, y+20,
- popup->edit ? popup->edit->user_title : "");
+ int x = 10, y = 10;
+ add_subwindow(new BC_Title(x, y, _("User title:")));
+ title_text = new EditPopupTitleText(this, mwindow, x+15, y+20, new_text);
add_subwindow(title_text);
add_tool(new BC_OKButton(this));
add_tool(new BC_CancelButton(this));
}
-EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window,
+EditPopupTitleText::EditPopupTitleText(EditPopupTitleWindow *window,
MWindow *mwindow, int x, int y, const char *text)
: BC_TextBox(x, y, 250, 1, text)
{
return 1;
}
+
+EditPopupShow::EditPopupShow(MWindow *mwindow, EditPopup *popup)
+ : BC_MenuItem(_("Show edit"))
+{
+ this->mwindow = mwindow;
+ this->popup = popup;
+ dialog_thread = new EditShowDialogThread(this);
+}
+
+EditPopupShow::~EditPopupShow()
+{
+ delete dialog_thread;
+}
+
+int EditPopupShow::handle_event()
+{
+ if( popup->edit ) {
+ dialog_thread->close_window();
+ int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2;
+ int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2;
+ dialog_thread->start(wx, wy);
+ }
+ return 1;
+}
+
+void EditShowDialogThread::start(int wx, int wy)
+{
+ this->wx = wx; this->wy = wy;
+ BC_DialogThread::start();
+}
+
+EditShowDialogThread::EditShowDialogThread(EditPopupShow *edit_show)
+{
+ this->edit_show = edit_show;
+ window = 0;
+}
+EditShowDialogThread::~EditShowDialogThread()
+{
+ close_window();
+}
+
+BC_Window* EditShowDialogThread::new_gui()
+{
+ MWindow *mwindow = edit_show->mwindow;
+ EditPopup *popup = edit_show->popup;
+ window = new EditPopupShowWindow(mwindow, popup, wx, wy);
+ window->create_objects();
+ return window;
+}
+
+void EditShowDialogThread::handle_close_event(int result)
+{
+ window = 0;
+}
+
+EditPopupShowWindow::EditPopupShowWindow(MWindow *mwindow,
+ EditPopup *popup, int wx, int wy)
+ : BC_Window(_(PROGRAM_NAME ": Show edit"), wx, wy,
+ 300, 200, 300, 200, 0, 0, 1)
+{
+ this->mwindow = mwindow;
+ this->popup = popup;
+}
+
+EditPopupShowWindow::~EditPopupShowWindow()
+{
+}
+
+void EditPopupShowWindow::create_objects()
+{
+ lock_window("EditPopupShowWindow::create_objects");
+ int x = 10, y = 10;
+ add_subwindow(new BC_Title(x, y, _("Show edit:")));
+
+ EDLSession *session = mwindow->edl->session;
+ int time_format = session->time_format;
+ int sample_rate = session->sample_rate;
+ double frame_rate = session->frame_rate;
+ double frames_per_foot = session->frames_per_foot;
+
+ Track *track = popup->track;
+ Edit *edit = popup->edit;
+ double startsource = track->from_units(edit->startsource);
+ double startproject = track->from_units(edit->startproject);
+ double length = track->from_units(edit->length);
+
+ char text[BCTEXTLEN], text_length[BCSTRLEN];
+ char text_startsource[BCSTRLEN], text_startproject[BCSTRLEN];
+ sprintf(text, _("StartSource: %s\nStartProject: %s\nLength: %s\n"),
+ Units::totext(text_startsource, startsource,
+ time_format, sample_rate, frame_rate, frames_per_foot),
+ Units::totext(text_startproject, startproject,
+ time_format, sample_rate, frame_rate, frames_per_foot),
+ Units::totext(text_length, length,
+ time_format, sample_rate, frame_rate, frames_per_foot));
+ show_text = new EditPopupShowText(this, mwindow, x+15, y+20, text);
+ add_subwindow(show_text);
+ add_tool(new BC_OKButton(this));
+
+ show_window();
+ flush();
+ unlock_window();
+}
+
+
+EditPopupShowText::EditPopupShowText(EditPopupShowWindow *window,
+ MWindow *mwindow, int x, int y, const char *text)
+ : BC_TextBox(x, y, 250, 4, text)
+{
+ this->window = window;
+ this->mwindow = mwindow;
+}
+
+EditPopupShowText::~EditPopupShowText()
+{
+}
+
#include "plugindialog.inc"
#include "resizetrackthread.inc"
-class EditPopupResize;
+class EditPopup;
class EditPopupMatchSize;
+class EditPopupResize;
+class EditPopupDeleteTrack;
+class EditPopupAddTrack;
+class EditPopupFindAsset;
+class EditAttachEffect;
+class EditMoveTrackUp;
+class EditMoveTrackDown;
+class EditPopupTitle;
+class EditTitleDialogThread;
class EditPopupTitleText;
class EditPopupTitleWindow;
-class EditPopupTitleButton;
-class EditPopupTitleButtonRes;
+class EditPopupShow;
+class EditShowDialogThread;
+class EditPopupShowText;
+class EditPopupShowWindow;
class EditPopup : public BC_PopupMenu
{
class EditPopupTitle : public BC_MenuItem
{
public:
- EditPopupTitle (MWindow *mwindow, EditPopup *popup);
+ EditPopupTitle(MWindow *mwindow, EditPopup *popup);
~EditPopupTitle();
int handle_event();
MWindow *mwindow;
EditPopup *popup;
+ EditTitleDialogThread *dialog_thread;
+};
+
+class EditTitleDialogThread : public BC_DialogThread
+{
+public:
+ EditTitleDialogThread(EditPopupTitle *edit_title);
+ ~EditTitleDialogThread();
+ BC_Window* new_gui();
+ void start(int wx, int wy);
+ void handle_close_event(int result);
+ void handle_done_event(int result);
+
+ int wx, wy;
+ EditPopupTitle *edit_title;
EditPopupTitleWindow *window;
};
class EditPopupTitleText : public BC_TextBox
{
public:
- EditPopupTitleText (EditPopupTitleWindow *window,
+ EditPopupTitleText(EditPopupTitleWindow *window,
MWindow *mwindow, int x, int y, const char *text);
~EditPopupTitleText();
-
int handle_event();
- EditPopupTitleWindow *window;
MWindow *mwindow;
+ EditPopupTitleWindow *window;
};
-
class EditPopupTitleWindow : public BC_Window
{
public:
- EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup);
- ~EditPopupTitleWindow ();
+ EditPopupTitleWindow(MWindow *mwindow, EditPopup *popup, int wx, int wy);
+ ~EditPopupTitleWindow();
void create_objects();
- int close_event();
+ void handle_close_event(int result);
EditPopupTitleText *title_text;
MWindow *mwindow;
char new_text[BCTEXTLEN];
};
+
+class EditPopupShow : public BC_MenuItem
+{
+public:
+ EditPopupShow(MWindow *mwindow, EditPopup *popup);
+ ~EditPopupShow();
+
+ int handle_event();
+
+ MWindow *mwindow;
+ EditPopup *popup;
+ EditShowDialogThread *dialog_thread;
+};
+
+class EditShowDialogThread : public BC_DialogThread
+{
+public:
+ EditShowDialogThread(EditPopupShow *edit_show);
+ ~EditShowDialogThread();
+ BC_Window* new_gui();
+ void start(int wx, int wy);
+ void handle_close_event(int result);
+
+ int wx, wy;
+ EditPopupShow *edit_show;
+ EditPopupShowWindow *window;
+};
+
+class EditPopupShowText : public BC_TextBox
+{
+public:
+ EditPopupShowText(EditPopupShowWindow *window,
+ MWindow *mwindow, int x, int y, const char *text);
+ ~EditPopupShowText();
+
+ EditPopupShowWindow *window;
+ MWindow *mwindow;
+};
+
+class EditPopupShowWindow : public BC_Window
+{
+public:
+ EditPopupShowWindow(MWindow *mwindow, EditPopup *popup, int wx, int wy);
+ ~EditPopupShowWindow();
+
+ void create_objects();
+
+ EditPopupShowText *show_text;
+ MWindow *mwindow;
+ EditPopup *popup;
+};
+
#endif
// Modes for AWindow views
#define ASSETS_TEXT 0
#define ASSETS_ICONS 1
+#define ASSETS_ICONS_PACKED 2
+#define ASSETS_ICON_LIST 3
#define FOLDERS_TEXT 0
#define FOLDERS_ICONS 1
if( button_press && get_buttonpress() == RIGHT_BUTTON &&
cursor_y >= track_y && cursor_y < track_y + track_h) {
- double pos = (double)cursor_x * mwindow->edl->local_session->zoom_sample /
- mwindow->edl->session->sample_rate +
- (double)mwindow->edl->local_session->view_start[pane->number] *
- mwindow->edl->local_session->zoom_sample /
- mwindow->edl->session->sample_rate;
+ double pos = mwindow->edl->get_cursor_position(cursor_x, pane->number);
int64_t position = track->to_units(pos, 0);
gui->edit_menu->update(track, track->edits->editof(position, PLAY_FORWARD, 0));
gui->edit_menu->activate_menu();
drag_cursor_x = 0;
drag_column_w = 0;
temp_display_format = display_format;
+ packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
rect_x1 = rect_x2 = 0;
rect_y1 = rect_y2 = 0;
int bl = get_baseline(item);
if( bl > row_ascent ) row_ascent = bl;
int dt = ht - bl;
- if( dt > row_descent ) row_ascent = bl;
+ if( dt > row_descent ) row_descent = dt;
// printf("BC_ListBox::calculate_item_coords_recursive %p %d %d %d %d %s \n",
// item->get_sublist(), item->get_columns(), item->get_expand(),
int BC_ListBox::get_item_x(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_TEXT )
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
return item->text_x - xposition + 2;
- if( display_format == LISTBOX_ICON_LIST )
- return item->text_x - xposition + 2;
- return item->icon_x - xposition + 2;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ return item->icon_x - xposition + 2;
+ }
+ return 0;
}
int BC_ListBox::get_item_y(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_TEXT )
- return item->text_y - yposition + title_h + 2;
- if( display_format == LISTBOX_ICON_LIST )
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
return item->text_y - yposition + title_h + 2;
- return item->icon_y - yposition + title_h + 2;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ return item->icon_y - yposition + 2;
+ }
+ return 0;
}
int BC_ListBox::get_item_w(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST: {
+ return get_text_w(item) + 2 * LISTBOX_MARGIN; }
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
int x, y, w, h;
get_icon_mask(item, x, y, w, h);
int icon_w = w;
return icon_position == ICON_LEFT ? icon_w + text_w :
icon_w > text_w ? icon_w : text_w;
+ }
}
- return get_text_w(item) + 2 * LISTBOX_MARGIN;
+ return 0;
}
int BC_ListBox::get_item_h(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
+ return get_text_h(item);
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
int x, y, w, h;
get_icon_mask(item, x, y, w, h);
int icon_h = h;
int text_h = h;
return icon_position != ICON_LEFT ? icon_h + text_h :
- icon_h > text_h ? icon_h : text_h;
+ icon_h > text_h ? icon_h : text_h; }
}
- return get_text_h(item);
+ return 0;
}
int BC_ListBox::get_items_width()
{
- int widest = 0;
-
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ return get_column_offset(columns);
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
+ int widest = 0;
for( int i=0; i<columns; ++i ) {
for( int j=0; j<data[i].total; ++j ) {
int x1, x, y, w, h;
get_icon_mask(item, x, y, w, h);
if( x1 + w > widest ) widest = x1 + w;
- if( display_format == LISTBOX_ICONS && icon_position == ICON_LEFT )
+ if( icon_position == ICON_LEFT )
x1 += w;
get_text_mask(item, x, y, w, h);
if( x1 + w > widest ) widest = x1 + w;
}
}
- }
- else
- if( display_format == LISTBOX_TEXT ) {
- return get_column_offset(columns);
- }
- else {
+ return widest; }
+ case LISTBOX_ICON_LIST:
return get_column_offset(columns);
}
- return widest;
+ return 0;
}
int BC_ListBox::get_items_height(ArrayList<BC_ListBoxItem*> *data, int columns,
int x, y, w, h;
BC_ListBoxItem *item = data[master_column].values[j];
- if( display_format == LISTBOX_ICONS ||
- display_format == LISTBOX_ICON_LIST ) {
- get_icon_mask(item, x, y, w, h);
- if( y + h + yposition > highest ) highest = y + h + yposition;
-
- get_text_mask(item, x, y, w, h);
- if( y + h + yposition > highest ) highest = y + h + yposition;
- }
- else {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
get_text_mask(item, x, y, w, h);
*result += h;
// Descend into sublist
item->get_columns(),
result);
}
+ break;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ case LISTBOX_ICON_LIST:
+ get_icon_mask(item, x, y, w, h);
+ if( y + h + yposition > highest ) highest = y + h + yposition;
+
+ get_text_mask(item, x, y, w, h);
+ if( y + h + yposition > highest ) highest = y + h + yposition;
+ break;
}
}
int BC_ListBox::get_icon_mask(BC_ListBoxItem *item,
int &x, int &y, int &w, int &h)
{
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ case LISTBOX_ICON_LIST: {
x = get_item_x(item);
y = get_item_y(item);
w = get_icon_w(item) + ICON_MARGIN * 2;
h = get_icon_h(item) + ICON_MARGIN * 2;
- }
- else
+ break; }
+ case LISTBOX_TEXT:
+ default: {
x = y = w = h = 0;
+ break; }
+ }
return 0;
}
x = get_item_x(item);
y = get_item_y(item);
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT: {
+ w = get_text_w(item) + LISTBOX_MARGIN * 2;
+ h = get_text_h(item);
+ break; }
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
if( icon_position == ICON_LEFT ) {
x += get_icon_w(item) + ICON_MARGIN * 2;
y += get_icon_h(item) - get_text_h(item);
y += get_icon_h(item) + ICON_MARGIN;
}
- w = get_text_w(item) + ICON_MARGIN * 2;
+ w = packed_icons ?
+ get_icon_w(item) + ICON_MARGIN * 4 :
+ get_text_w(item) + ICON_MARGIN * 2 ;
h = get_text_h(item) + ICON_MARGIN * 2;
- }
- else
- if( display_format == LISTBOX_TEXT ) {
- w = get_text_w(item) + LISTBOX_MARGIN * 2;
- h = get_text_h(item);
- }
- else {
+ break; }
+ case LISTBOX_ICON_LIST: {
w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2;
h = row_height;
- int ih = get_icon_h(item);
- if( h < ih ) h = ih;
+ break; }
+ default:
+ w = h = 0;
}
return 0;
}
BC_ListBoxItem *item = data[master_column].values[i];
if( (*counter) == selection ) {
BC_ListBoxItem *top_item = this->data[master_column].values[0];
-
-
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
// Icon is out of window
if( item->icon_y-yposition > view_h-get_text_h(item) ||
item->icon_y-yposition < 0 ) {
data[master_column].values[selection]->icon_x - xposition < 0 ) {
xposition = item->icon_x - view_w / 2;
}
- }
- else {
+ break; }
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
// Text coordinate is out of window
if( item->text_y-yposition > view_h-get_text_h(item) ||
item->text_y-yposition < 0 ) {
- yposition = item->text_y -
- top_item->text_y -
- view_h / 2;
+ yposition = item->text_y - top_item->text_y - view_h / 2;
}
}
return 1;
for( int i=0; i<data[master_column].total; ++i ) {
for( int j=0; j<columns; ++j ) {
BC_ListBoxItem *item = data[j].values[i];
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
int icon_x, icon_y, icon_w, icon_h;
int text_x, text_y, text_w, text_h;
get_icon_mask(item, icon_x, icon_y, icon_w, icon_h);
result = 1;
}
}
- }
- else {
+ break; }
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST: {
if( x2 >= 0 &&
x1 < (yscrollbar ?
gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() :
result = 1;
}
}
+ break; }
}
}
if( !counter ) counter = &temp;
// Icons are not treed
- if( display_format == LISTBOX_ICONS ) {
- for( int j=data[master_column].total-1; j>=0; --j ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICON_LIST: {
+ for( int j=data[master_column].total; --j>=0; ) {
int icon_x, icon_y, icon_w, icon_h;
int text_x, text_y, text_w, text_h;
BC_ListBoxItem *item = data[master_column].values[j];
return j;
}
}
- }
- else if( gui ) {
+ if( display_format == LISTBOX_ICONS ) return -1;
+ } // fall through
+ case LISTBOX_TEXT:
+ if( !gui ) break;
// Text is treed
// Cursor is inside items rectangle
if( cursor_x >= 0 &&
}
}
}
+ break;
}
return -1;
// Move icon
- if( display_format == LISTBOX_ICONS ) {
+ if( display_format == LISTBOX_ICONS ||
+ display_format == LISTBOX_ICONS_PACKED ) {
reposition_item(data,
selection_number,
top_level->cursor_x - drag_popup->get_w() / 2 -
void BC_ListBox::update_format(int display_format, int redraw)
{
this->display_format = display_format;
+ packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
xposition = 0; yposition = 0;
if( redraw && gui ) draw_items(1, 1);
}
first_in_view = -1;
last_in_view = 0;
// Icon display
- if( display_format == LISTBOX_ICONS ) {
+ if( display_format == LISTBOX_ICONS ||
+ display_format == LISTBOX_ICONS_PACKED ) {
clear_listbox(2, 2 + title_h, view_w, view_h);
set_font(MEDIUMFONT);
if( item->icon )
gui->pixmap->draw_pixmap(item->icon,
icon_x + ICON_MARGIN, icon_y + ICON_MARGIN);
-
+ char item_text[BCTEXTLEN];
+ if( display_format == LISTBOX_ICONS_PACKED )
+ gui->truncate_text(item_text, item->text, text_w);
+ else
+ strcpy(item_text, item->text);
gui->draw_text(text_x + ICON_MARGIN,
- text_y + ICON_MARGIN + get_baseline(item), item->text);
+ text_y + ICON_MARGIN + get_baseline(item), item_text);
}
else
item->set_in_view(0);
int bl = get_baseline(item);
if( bl > row_ascent ) row_ascent = bl;
int dt = ht - bl;
- if( dt > row_descent ) row_ascent = bl;
+ if( dt > row_descent ) row_descent = dt;
}
for( int i=0; i<data[column].size(); ++i ) {
// More state variables
int button_highlighted;
int list_highlighted;
+ int packed_icons;
// item cursor is over. May not exist in tables.
// Must be an index since this is needed to change the database.
int highlighted_item;
// Display format
#define LISTBOX_TEXT 0
#define LISTBOX_ICONS 1
-#define LISTBOX_ICON_LIST 2
+#define LISTBOX_ICONS_PACKED 2
+#define LISTBOX_ICON_LIST 3
// Icon position
#define ICON_LEFT 0
}
void VIcon::
-draw_vframe(BC_WindowBase *wdw, int x, int y)
+draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y)
{
- wdw->draw_vframe(frame(), x,y, vw,vh);
+ int sx0 = 0, sx1 = sx0 + vt->view_w;
+ int sy0 = 0, sy1 = sy0 + vt->view_h;
+ int dx0 = x, dx1 = dx0 + vw;
+ int dy0 = y, dy1 = dy0 + vh;
+ if( (x=vt->draw_x0-dx0) > 0 ) { sx0 += (x*vt->view_w)/vw; dx0 = vt->draw_x0; }
+ if( (x=dx1-vt->draw_x1) > 0 ) { sx1 -= (x*vt->view_w)/vw; dx1 = vt->draw_x1; }
+ if( (y=vt->draw_y0-dy0) > 0 ) { sy0 += (y*vt->view_h)/vh; dy0 = vt->draw_y0; }
+ if( (y=dy1-vt->draw_y1) > 0 ) { sy1 -= (y*vt->view_h)/vh; dy1 = vt->draw_y1; }
+ int sw = sx1 - sx0, sh = sy1 - sy0;
+ int dw = dx1 - dx0, dh = dy1 - dy0;
+ if( dw > 0 && dh > 0 && sw > 0 && sh > 0 )
+ wdw->draw_vframe(frame(), dx0,dy0, dw,dh, sx0,sy0, sw,sh);
+}
+
+void VIconThread::
+set_drawing_area(int x0, int y0, int x1, int y1)
+{
+ draw_x0 = x0; draw_y0 = y0;
+ draw_x1 = x1; draw_y1 = y1;
}
VIcon *VIconThread::low_vicon()
this->view_win = 0; this->vicon = 0;
this->view_w = vw; this->view_h = vh;
this->viewing = 0;
+ this->draw_x0 = 0; this->draw_x1 = wdw->get_w();
+ this->draw_y0 = 0; this->draw_y1 = wdw->get_h();
draw_lock = new Condition(0, "VIconThread::draw_lock", 1);
timer = new Timer();
this->refresh_rate = VICON_RATE;
visible(VIcon *vicon, int x, int y)
{
if( vicon->hidden ) return false;
- int y0 = 0;
- int my = y + vicon->vh;
- if( my <= y0 ) return false;
- int y1 = y0 + wdw->get_h();
- if( y >= y1 ) return false;
- int x0 = 0;
- int mx = x + vicon->vw;
- if( mx <= x0 ) return false;
- int x1 = x0 + wdw->get_w();
- if( x >= x1 ) return false;
+ if( y+vicon->vh <= draw_y0 ) return false;
+ if( y >= draw_y1 ) return false;
+ if( x+vicon->vw <= draw_x0 ) return false;
+ if( x >= draw_x1 ) return false;
return true;
}
if( !draw_img && !draw_win ) return 0;
if( !vicon->frame() ) return 0;
if( draw_img ) {
- vicon->draw_vframe(wdw, x, y);
+ vicon->draw_vframe(this, wdw, x, y);
img_dirty = 1;
}
if( draw_win ) {
virtual void stop_audio() {}
void add_image(VFrame *frm, int ww, int hh, int vcmdl);
- void draw_vframe(BC_WindowBase *wdw, int x, int y);
+ void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
void dump(const char *dir);
VIcon(int vw=VICON_WIDTH, int vh=VICON_HEIGHT, double rate=VICON_RATE);
ViewPopup *view_win;
VIcon *viewing, *vicon;
int view_w, view_h;
+ int draw_x0, draw_y0;
+ int draw_x1, draw_y1;
int img_dirty, win_dirty;
double refresh_rate;
void reset_images();
void remove_vicon(int i);
int keypress_event(int key);
+ void set_drawing_area(int x0, int y0, int x1, int y1);
void set_view_popup(VIcon *vicon);
ViewPopup *new_view_window(VFrame *frame);