add 2 asset list fmts, user title rework, added show edit, bt tweak
authorGood Guy <good1.2guy@gmail.com>
Sat, 28 Jul 2018 02:37:19 +0000 (20:37 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sat, 28 Jul 2018 02:37:19 +0000 (20:37 -0600)
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/editpopup.C
cinelerra-5.1/cinelerra/editpopup.h
cinelerra-5.1/cinelerra/edl.inc
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/guicast/bclistbox.C
cinelerra-5.1/guicast/bclistbox.h
cinelerra-5.1/guicast/bclistbox.inc
cinelerra-5.1/guicast/vicon.C
cinelerra-5.1/guicast/vicon.h

index 7ea4759f49fdc36d402fc243b9a5529096a12a10..e7f8e7bee9daf24980b67d1314079838394ab733 100644 (file)
@@ -171,7 +171,7 @@ int AssetVIcon::get_vx()
 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()
@@ -1026,6 +1026,8 @@ void AWindowGUI::create_objects()
        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);
 
@@ -1177,8 +1179,15 @@ void AWindowGUI::start_vicon_drawing()
 {
        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()
@@ -1783,6 +1792,11 @@ void AWindowGUI::update_assets()
 
        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();
@@ -1910,7 +1924,7 @@ int AWindowDivider::button_release_event()
 
 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
@@ -1976,9 +1990,11 @@ int AWindowFolders::button_press_event()
 
 
 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
@@ -2600,28 +2616,55 @@ int AWindowListFormat::handle_event()
        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)
index 5fcd8152485f90d156c90d0d3a25b8790055c9d4..1851e058da35b8ed1e281bd3a42ea2b93c6967ec 100644 (file)
@@ -63,6 +63,7 @@ void EditPopup::create_objects()
        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;
 }
@@ -260,63 +261,87 @@ EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
 {
        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));
@@ -328,7 +353,7 @@ void EditPopupTitleWindow::create_objects()
 }
 
 
-EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window,
+EditPopupTitleText::EditPopupTitleText(EditPopupTitleWindow *window,
        MWindow *mwindow, int x, int y, const char *text)
  : BC_TextBox(x, y, 250, 1, text)
 {
@@ -347,3 +372,120 @@ int EditPopupTitleText::handle_event()
        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()
+{
+}
+
index 50ae929382ebaeb0c723039f4324fd2871397bfc..89754a25b880ce9ebbb23f9b72723c67c49326e7 100644 (file)
 #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
 {
@@ -144,38 +155,51 @@ public:
 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;
@@ -183,4 +207,56 @@ public:
        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
index 337d4bd4c5a2c7cd95d9ce19192aca743da04f17..ee7a82481efa1db3f4e0259d2eaf3430923b8916 100644 (file)
@@ -70,6 +70,8 @@ class EDL;
 // 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
 
index f593b5803af6b586cb79e16289747889769d5112..2edb89bea19dd64f2d3f42e918e36059739b3975 100644 (file)
@@ -4572,11 +4572,7 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press)
 
                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();
index 23c4e185accd27c9477060d7581c14bfd8e7048e..a6946530ffb1638f2cfe0690589d7653dcd44462 100644 (file)
@@ -369,6 +369,7 @@ BC_ListBox::BC_ListBox(int x, int y, int w, int h,
        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;
 
@@ -708,7 +709,7 @@ void BC_ListBox::calculate_item_coords_recursive(
                                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(),
@@ -851,25 +852,38 @@ int BC_ListBox::get_highlighted_item()
 
 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;
@@ -878,13 +892,19 @@ int BC_ListBox::get_item_w(BC_ListBoxItem *item)
 
                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;
@@ -892,9 +912,9 @@ int BC_ListBox::get_item_h(BC_ListBoxItem *item)
                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;
 }
 
 
@@ -931,9 +951,12 @@ int BC_ListBox::get_baseline(BC_ListBoxItem *item)
 
 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;
@@ -943,22 +966,18 @@ int BC_ListBox::get_items_width()
                                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,
@@ -976,15 +995,8 @@ 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
@@ -993,6 +1005,16 @@ int BC_ListBox::get_items_height(ArrayList<BC_ListBoxItem*> *data, int columns,
                                        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;
                }
        }
 
@@ -1147,14 +1169,20 @@ int BC_ListBox::get_column_width(int column, int clamp_right)
 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;
 }
 
@@ -1164,7 +1192,13 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item,
        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);
@@ -1173,19 +1207,17 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *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;
 }
@@ -1581,9 +1613,9 @@ int BC_ListBox::center_selection(int selection,
                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 ) {
@@ -1594,14 +1626,13 @@ int BC_ListBox::center_selection(int selection,
                                    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;
@@ -1849,7 +1880,9 @@ int BC_ListBox::select_rectangle(ArrayList<BC_ListBoxItem*> *data,
        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);
@@ -1870,8 +1903,9 @@ int BC_ListBox::select_rectangle(ArrayList<BC_ListBoxItem*> *data,
                                                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() :
@@ -1889,6 +1923,7 @@ int BC_ListBox::select_rectangle(ArrayList<BC_ListBoxItem*> *data,
                                                result = 1;
                                        }
                                }
+                               break; }
                        }
                }
 
@@ -2039,8 +2074,10 @@ int BC_ListBox::get_cursor_item(ArrayList<BC_ListBoxItem*> *data, int cursor_x,
        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];
@@ -2055,8 +2092,10 @@ int BC_ListBox::get_cursor_item(ArrayList<BC_ListBoxItem*> *data, int cursor_x,
                                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 &&
@@ -2090,6 +2129,7 @@ int BC_ListBox::get_cursor_item(ArrayList<BC_ListBoxItem*> *data, int cursor_x,
                                }
                        }
                }
+               break;
        }
 
        return -1;
@@ -3246,7 +3286,8 @@ int BC_ListBox::drag_stop_event()
 // 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 -
@@ -3575,6 +3616,7 @@ void BC_ListBox::clear_listbox(int x, int y, int w, int h)
 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);
 }
@@ -3604,7 +3646,8 @@ int BC_ListBox::draw_items(int flush, int draw_bg)
                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);
@@ -3651,9 +3694,13 @@ int BC_ListBox::draw_items(int flush, int draw_bg)
                                        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);
@@ -3734,7 +3781,7 @@ void BC_ListBox::draw_text_recursive(ArrayList<BC_ListBoxItem*> *data,
                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 ) {
index f5994d53aa935322c0f522aa98bcd541d9666c23..b0e9c3e22b70a6d6ffef79870ec79670a4408d48 100644 (file)
@@ -588,6 +588,7 @@ private:
 // 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;
index e846a0408882af26aae540db01867a30efc62879..6846e58a96186762e0e1960e9c34c195f33b4e46 100644 (file)
@@ -29,7 +29,8 @@
 // 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
index 2bfedd9277b9a1465091361adafa7e1c757689a0..1f80bc470c40799c84067557e1938ba769ff4591 100644 (file)
@@ -41,9 +41,27 @@ add_image(VFrame *frm, int ww, int hh, int vcmdl)
 }
 
 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()
@@ -78,6 +96,8 @@ VIconThread(BC_WindowBase *wdw, int vw, int vh)
        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;
@@ -139,16 +159,10 @@ bool VIconThread::
 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;
 }
 
@@ -263,7 +277,7 @@ draw(VIcon *vicon)
        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 ) {
index 59758bab6c6981a5d6ea1145d31ae015ff8b941d..5e96f7117cabd93bbdb0eb0b4d22f5ccc61decf0 100644 (file)
@@ -59,7 +59,7 @@ public:
        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);
@@ -76,6 +76,8 @@ public:
        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;
 
@@ -93,6 +95,7 @@ public:
        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);