Changeset 4504


Ignore:
Timestamp:
Dec 16, 2009, 9:20:29 PM (14 years ago)
Author:
ronosman
Message:

Feature 1332 added : new list and thumbnail display mode for photo selection.

Location:
extensions/pLoader/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/locale/fr_FR/pLoader.po

    r4476 r4504  
    578578msgstr "Gestion de la mise à jour des photos"
    579579
    580 msgid "Who can see the photo? :"
    581 msgstr "Qui peut voir la photo ? :"
     580msgid "Who can see the photo?"
     581msgstr "Qui peut voir la photo ?"
    582582
    583583msgid "everybody"
     
    598598msgid "What shall we do with privacy level?"
    599599msgstr "Que faire pour le niveau de confidentialité ?"
     600
     601msgid "Thumbnail and caption"
     602msgstr "Miniature et titre"
     603
     604msgid "Property list"
     605msgstr "Liste de propriétés"
     606
     607msgid "How photo selection is displayed"
     608msgstr "Comment la sélection de photos est affichée"
     609
  • extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm

    r4479 r4504  
    134134    # to check if we can use stored cache
    135135    $self->imagelist_version(
    136         '10'
     136        '11'
    137137    );
    138138
     
    560560                reupload_action_properties => 2,
    561561                reupload_action_properties_m => 1,
     562                display_mode => $self->user_defined_properties->{display_mode}||'Thumbnail and caption'
    562563    };
    563564
     
    693694            $self->imagelist->wx_thumb_size,
    694695            $self->imagelist->wx_thumb_size,
    695             1,
     696            0,
    696697            0
    697698        )
  • extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm

    r4490 r4504  
    7171    $self->_init_panel;
    7272    $self->_init_properties($params);
    73 printf("%s, %s\n", $self, $self->GetId);
     73
    7474    $self->Refresh;
    7575
     
    164164    my ( $self, $choices ) = @_;
    165165
     166        $self->listchoices->Freeze;
    166167    $self->listchoices->Clear;
    167168    $self->id_lookup({});
     
    181182        $row++;
    182183    }@{$choices};
     184        $self->listchoices->Thaw;
    183185
    184186}
     
    205207   
    206208    my $choices = $self->choices->();
     209    $self->listchoices->Freeze;
    207210    map {
    208211        $self->listchoices->Check($row, 0) ;   
    209212        $row++;
    210213    }@$choices;
    211 
    212        
     214    $self->listchoices->Thaw;
    213215}
    214216
     
    220222    push @$selection, $self->id_from_name->{$selected} if defined $selected;
    221223
     224    $self->listchoices->Freeze;
    222225    map {
    223226        $self->listchoices->Check(
     
    228231    }
    229232    @{$selection};     
     233    $self->listchoices->Thaw;
    230234}
    231235
  • extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r4478 r4504  
    8484          upload_progressdlg
    8585          imageviewer
     86                  imageviewer_img
    8687          tree
    8788          tree_root
     
    130131                  dlg_piwigo_photo_properties
    131132                  piwigo_photo_properties_tags
     133                  image_preview_refresh
     134                  imageviewer_refresh
     135                  imageviewer_item_refresh
    132136      /;
    133137__PACKAGE__->mk_accessors( @properties );
     
    180184        $params->{perspective}
    181185    );
     186
    182187   
    183188    $self->current_imageviewer_index(
     
    297302    $self->_initImgTypes;   
    298303
     304        # only refresh when calling event is finished
     305        Wx::Event::EVT_UPDATE_UI(
     306            $self,
     307            $self,
     308                sub {
     309            my ( $self, $event ) = @_;
     310                if ( $self->image_preview_refresh and $self->image_preview->IsShown ){
     311                $self->_image_preview_refresh;
     312                $self->image_preview->Refresh;
     313                                $self->image_preview_refresh(0);
     314                    }
     315                       
     316                        if($self->imageviewer_refresh){
     317                            $self->imageviewer->Refresh;
     318                                $self->imageviewer_refresh(0);
     319                        }
     320
     321                        if($self->imageviewer_item_refresh){
     322                            $self->imageviewer->ItemRefresh(
     323                                    $self->current_imageviewer_index
     324                                );
     325                                $self->imageviewer_item_refresh(0);
     326                        }
     327                },
     328        );
    299329
    300330    $self->imageviewer->SelectItem(
     
    333363                        $main::PHOTO_PROPERTIES_CAPTION => {
    334364                                                               value => sub { $self->imagelist->current_image->site_name(@_) },
    335                                                                                                    frame_callback => sub { $self->imageviewer->Refresh() },
     365                                                                                                   frame_callback => sub { $self->imageviewer_item_refresh(1); },
    336366                                                           },
    337367                    $main::COMMENT => { label=>gettext("Comment :")},
    338368                        $main::PHOTO_PROPERTIES_COMMENT => {
    339369                                                               value => sub { $self->imagelist->current_image->site_comment(@_) },
     370                                                                                                   frame_callback => sub { $self->imageviewer_item_refresh(1); },
    340371                                                           },
    341372                    $main::AUTHOR => { label=>gettext("Author :")},
    342373                        $main::PHOTO_PROPERTIES_AUTHOR => {
    343374                                                               value => sub { $self->imagelist->current_image->site_author(@_) },
     375                                                                                                   frame_callback => sub { $self->imageviewer_item_refresh(1); },
    344376                                                           },
    345377                    $main::TAGS => { label=>gettext("Tags :")},
     
    347379                        $main::PHOTO_PROPERTIES_CREATE_DATE => {
    348380                                                               value => sub { $self->imagelist->current_image->create_date(@_) },
     381                                                                                                   frame_callback => sub { $self->imageviewer_item_refresh(1); },
    349382                                                           },
    350                     $main::PRIVACY_LEVEL => { label=>gettext("Who can see the photo? :")},
     383                    $main::PRIVACY_LEVEL => { label=>gettext("Who can see the photo?")},
    351384                        $main::PHOTO_PROPERTIES_PRIVACY_LEVEL => {
    352385                                                         selection => sub { $self->imagelist->current_image->privacy_level(@_)},
     
    361394                label          => gettext("Photo caption :"),
    362395                value          => sub { $self->imagelist->current_image->site_name(@_) },
    363                 frame_callback => sub { $self->imageviewer->Refresh() },
     396                frame_callback => sub { $self->imageviewer_item_refresh(1) },
    364397            },
    365398            {
     
    700733}
    701734
    702 
    703 sub _destroy_settings_panels {
    704     my ( $self ) = @_;
    705 
    706 
    707 
    708     map {
    709         $self->manager->DetachPane(
    710             $_
    711         );
    712         $_->Show(0);
    713         $_->Destroy;
    714     }(
    715         $self->notebook_global_settings,
    716         $self->notebook_image_properties,
    717     );
    718 }
    719 
    720735#
    721736sub _initFrame {
     
    934949                parentwnd => $self,
    935950                imagelist => $self->imagelist,
     951                                image_size => $self->imagelist->wx_thumb_size,
     952                                columns => $self->piwigo_properties,
    936953            }
    937954        )
     
    14521469    Wx::Event::EVT_MENU( $self, 104, \&OnGlobalSettings );
    14531470    Wx::Event::EVT_MENU( $self, 105, \&OnChooseLanguage );
     1471    Wx::Event::EVT_CHOICE( $self, 106, \&OnPhotoSelMode );
    14541472    EVT_TREE_SEL_CHANGED( $self, $self->tree, \&OnTreeSelChanged );
    14551473    EVT_TREE_ITEM_RIGHT_CLICK( $self, $self->tree, \&OnTreeItemRightClick );
     
    17481766    );
    17491767       
     1768    $self->dlg_piwigo_photo_properties->SetProperties;
    17501769    $self->image_prop_piwigo->Refresh;
    17511770}
     
    17641783sub OnImageViewerItemSelected {
    17651784    my( $self, $event ) = @_;
     1785
    17661786    my $bc = Wx::BusyCursor->new;
    1767 
    17681787    my $indx = $event->GetIndex;
    1769 
    17701788    $self->_on_imageviewer_item_selected($indx);
    17711789
     
    17831801    );
    17841802       
    1785         # image preview has a cost, don't do if useless.
    1786         if ( $self->image_preview->IsShown ){
    1787         $self->_image_preview_refresh;
    1788         $self->image_preview->Refresh;
    1789         }
     1803        # process image_preview in idle time
     1804        # and when current event is processed
     1805        # see call to EVT_IDLE
     1806    $self->image_preview_refresh(1);
    17901807
    17911808    $self->dlg_piwigo_photo_properties->SetProperties;
     
    21072124    my( $self ) = @_;
    21082125
    2109     my $tb = Wx::ToolBar->new( $self, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT );
     2126    my $tb = Wx::ToolBar->new( $self, -1, wxDefaultPosition, [600, -1], wxTB_FLAT );
    21102127    $tb->SetToolBitmapSize( wxSIZE( 32, 32 ) );
    21112128    map {
     
    21832200   
    21842201    );
    2185 
    2186     if($@){
    2187         undef $tb;
    2188     }
    2189     else{
    2190         $tb->Realize;
    2191     }
     2202       
     2203        $tb->AddSeparator;
     2204       
     2205        $tb->AddControl(
     2206            Wx::Choice->new(
     2207                    $tb,
     2208                        106,
     2209                        wxDefaultPosition,
     2210                        wxDefaultSize,
     2211                        [],
     2212                )
     2213        );
     2214        my $ch = $tb->FindWindow(106);
     2215    $ch->SetToolTip(gettext("How photo selection is displayed"));
     2216        map {
     2217            $ch->Append(gettext($_), $_);
     2218        }(
     2219            "Thumbnail and caption",
     2220                "Thumbnail",
     2221                "Property list"
     2222        );
     2223       
     2224        $ch->SetStringSelection(gettext($self->imagelist->display_mode));
     2225    $tb->Realize;
    21922226
    21932227    return $tb;
    21942228}
    21952229
     2230sub OnPhotoSelMode {
     2231    my ( $self, $event )= @_;
     2232       
     2233        $self->imagelist->display_mode(
     2234            $event->GetClientData
     2235        );
     2236
     2237        $self->imageviewer->change_display_mode(1);
     2238}
    21962239
    21972240sub _create_textctrl {
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r4324 r4504  
    2222use Wx;
    2323use Wx::DND;
     24use POSIX qw(ceil floor);
    2425use Wx qw/
    2526             wxDefaultPosition
     
    2930             wxLC_EDIT_LABELS
    3031             wxLC_ICON
     32                         wxLC_REPORT
    3133             wxLC_SMALL_ICON
    3234             wxIMAGE_LIST_NORMAL
     
    3638             wxLC_VIRTUAL
    3739             wxLC_REPORT
     40                         wxLC_AUTOARRANGE
    3841             wxBORDER_THEME
    3942             wxLIST_HITTEST_ONITEM
     
    4245             wxLIST_STATE_DONTCARE
    4346             wxLIST_STATE_FOCUSED
     47                         wxIMAGE_LIST_SMALL
    4448         /;
    4549use Wx::Event qw/
    4650                    EVT_LIST_BEGIN_DRAG
    4751                    EVT_LIST_ITEM_SELECTED
     52                                        EVT_SIZE
    4853                /;
    4954         
     
    5459          imagenames
    5560          imagelist
     61          wx_imagelist
     62                  image_size
     63                  arrange_items
     64                  styles
     65                  insert_items
     66                  initialize
     67                  columns
     68                  change_display_mode
     69                  wx_img
     70                  item_refresh
    5671      /
    5772);
    5873use Data::Dumper;
     74
     75
    5976sub new {
    60   my( $class, $params ) = @_;
    61   my( $self ) = $class->SUPER::new(
    62                                        $params->{parentwnd},
    63                                        -1,
    64                                        wxDefaultPosition,
    65                                        wxDefaultSize,
    66                                        wxNO_BORDER|
    67                                        wxLC_ICON|
    68                                        wxLC_EDIT_LABELS
    69                                   );
    70 
    71   $self->imagelist(
    72       $params->{imagelist}
    73   );
    74 
    75                                  
    76   $self->prevItemCount(-1);
    77 
    78   EVT_LIST_BEGIN_DRAG( $self, $self, \&OnBeginDrag);
    79 
    80 
    81   $self;
     77    my( $class, $params ) = @_;
     78
     79 
     80    my( $self ) = $class->SUPER::new(
     81        $params->{parentwnd},
     82        -1,
     83        wxDefaultPosition,
     84        wxDefaultSize,
     85                wxNO_BORDER
     86    );
     87       
     88        $self->wx_img(
     89        Wx::ImageList->new( 16, 16, 1 )
     90        );
     91        $self->wx_img->Add(
     92        Wx::Bitmap->new( '../res/image.png', wxBITMAP_TYPE_PNG )       
     93        );
     94
     95    $self->imagelist(
     96        $params->{imagelist}
     97    );
     98    # bitmap container for photo selection
     99    $self->wx_imagelist(
     100        $params->{wx_imagelist}||$self->imagelist->wx_thumb_imglist
     101    );
     102
     103    $self->image_size(
     104        $params->{image_size}
     105    );
     106
     107        $self->columns(
     108            $params->{columns}
     109        );
     110        print Dumper $self->columns;
     111    $self->prevItemCount(-1);
     112
     113    EVT_LIST_BEGIN_DRAG( $self, $self, \&OnBeginDrag);
     114
     115    EVT_SIZE($self, sub {
     116            my ( $this, $event ) = @_;
     117   
     118                        $this->arrange_items(1);
     119            $event->Skip();
     120        }
     121    );
     122       
     123        Wx::Event::EVT_IDLE(
     124            $self,
     125                sub {
     126                    my ($self, $event)=@_;
     127
     128                        if($self->arrange_items){
     129                            $self->Refresh;
     130                            $self->arrange_items(0);
     131                        }
     132                        if($self->change_display_mode){
     133                            my $dm = $self->imagelist->display_mode;
     134                    $self->initialize->{$dm}->($self) if exists $self->initialize->{$dm};
     135                            $self->Refresh;
     136                $self->change_display_mode(0);
     137                        }
     138                }
     139        );
     140       
     141        $self->initialize(
     142            {
     143
     144            'Thumbnail' => sub {  my ( $self ) = @_;
     145                                                                $self->Freeze;
     146                                                                $self->ClearAll;
     147                                                                $self->SetSingleStyle(wxLC_ICON);
     148                                                                $self->SetSingleStyle(wxLC_EDIT_LABELS, 0);
     149                                $self->SetImageList( $self->wx_imagelist, wxIMAGE_LIST_NORMAL ) ;
     150                                                                $self->Thaw;
     151                     },                 
     152            'Thumbnail and caption' => sub {  my ( $self ) = @_;
     153                                                                $self->Freeze;
     154                                                                $self->ClearAll;
     155                                                                $self->SetSingleStyle(wxLC_ICON);
     156                                                                $self->SetSingleStyle(wxLC_EDIT_LABELS);
     157                                $self->SetImageList( $self->wx_imagelist, wxIMAGE_LIST_NORMAL ) ;
     158                                                                $self->Thaw;
     159                     },                 
     160                'Property list' => sub { my ( $self ) = @_;
     161                                            my $i=0;
     162                                                               
     163                                                                $self->Freeze;
     164                                                                $self->ClearAll;
     165                                                                $self->SetSingleStyle(wxLC_REPORT);
     166                                                                $self->SetSingleStyle(wxLC_EDIT_LABELS);
     167                                $self->SetImageList( $self->wx_img, wxIMAGE_LIST_SMALL ) ;
     168                                map     {
     169                                                                    $self->InsertColumn($i, $_->{label});
     170                                                                        $i++;
     171                                }@{$self->columns};                                                             
     172                                                                $self->Thaw;
     173                                        },
     174                }
     175        );
     176
     177        $self->item_refresh(
     178            {
     179                    'Thumbnail' => sub {},
     180                    'Thumbnail and caption' => sub { my ( $self, $index ) = @_;
     181                                        my $image = $self->imagelist->GetImage($index);
     182                                        $self->SetItem(
     183                                                    $index,
     184                                                        0,
     185                                                        $image->site_name,
     186                                        ) if defined $image;
     187                                                },
     188            'Property list' => sub { my ( $self, $index ) = @_;
     189                                my $col = 0;
     190                                my $image = $self->imagelist->GetImage($index);
     191                                map{
     192                                    $self->SetItem(
     193                                        $index,
     194                                        $col,
     195                                        $image->$_
     196                                    ) if defined $image;
     197                                    $col++;
     198                                }
     199                                qw/site_name site_comment site_author file create_date/;
     200                            },
     201                }
     202        );
     203       
     204        $self->insert_items(
     205            {
     206                    'Thumbnail' => sub { my ( $self, $index ) = @_; $self->InsertImageItem($index, $index);},
     207                    'Thumbnail and caption' => sub { my ( $self, $index ) = @_;
     208                                                       $self->InsertImageStringItem(
     209                                               $index,
     210                                               $self->imagelist->GetImage($index)->site_name,
     211                                               $index,
     212                                           );
     213                                     },
     214            'Property list' => sub { my ( $self, $index ) = @_;
     215                                                   
     216                                                            $self->InsertImageStringItem(
     217                                    $index,
     218                                    "",
     219                                                                        0
     220                                                                );
     221                                                                $self->ItemRefresh($index);
     222
     223                                        },
     224                }
     225        );
     226
     227       
     228        $self->initialize->{$self->imagelist->display_mode}->($self) if exists $self->initialize->{$self->imagelist->display_mode};
     229
     230    $self;
     231}
     232
     233sub ItemRefresh {
     234    my ( $self, $index ) = @_;
     235       
     236        $self->item_refresh->{$self->imagelist->display_mode}->($self, $index) if exists $self->item_refresh->{$self->imagelist->display_mode};
    82237}
    83238
     
    141296
    142297sub Refresh {
    143     my ( $self, $wximagelist ) = @_;   
    144 
    145    $self->SetImageList( $wximagelist, wxIMAGE_LIST_NORMAL ) if defined $wximagelist ;
     298    my ( $self ) = @_; 
     299
     300   $self->Freeze();
    146301   $self->DeleteAllItems;
    147302   eval {
    148        for( my $i = 0 ; $i < $self->GetImageList(wxIMAGE_LIST_NORMAL)->GetImageCount ; $i++){
    149             my $indx = $self->InsertImageStringItem(
    150                 $i,
    151                 $self->imagelist->GetImage($i)->site_name,
    152                 $i,
    153             );
     303       my $y0 = 0;
     304       my $x0 = 0;
     305
     306       my $x_spacing = $self->image_size + 2;
     307       my $y_spacing = $self->image_size + 2;
     308       my $ipr = floor(($self->GetClientSize->GetWidth - 0.20*$x_spacing)/$x_spacing)||1;
     309       for( my $i = 0 ; $i < $self->imagelist->count ; $i++){
     310                # call the method corresponding to the display mode
     311            my $indx = $self->insert_items->{$self->imagelist->display_mode}->($self, $i);
     312                        if( 'Thumbnail' eq $self->imagelist->display_mode){
     313                my $row = floor($i/$ipr);
     314                my $col = $i%$ipr;
     315                $self->SetItemPosition(
     316                    $i,
     317                    Wx::Point->new(
     318                        $x0 + $x_spacing*$col,
     319                        $y0 + $y_spacing*$row,
     320                    ),
     321                );
     322                        }
    154323       }   
    155324   };
     325
     326   map{
     327       $self->SelectItem(
     328           $_
     329       );
     330           
     331           $self->EnsureVisible($_);
     332   } @{$self->imagelist->image_selection||[]};
     333
     334   $self->Thaw();
     335   $self->SetFocus;
    156336}
    157337
  • extensions/pLoader/trunk/src/Uploader/ImageList.pm

    r4478 r4504  
    126126                                reupload_action_properties_m
    127127                                reupload_not_ask
     128                                display_mode
    128129     /
    129130);
     
    156157   
    157158}
    158 
    159 
    160 
    161 # save exif preview image if available
    162 # otherwise create a preview image
    163 sub _write_preview_image {
    164     my ( $self, $imagedata ) = @_;
    165 
    166 
    167     # If PreviewImage is available, we use it
    168     if(defined $imagedata ) {
    169         print "_write_preview_image, use exif PreviewImage\n";
    170         eval {
    171             open PREVIEW_FILE, ">", $self->current_image->preview_file ;
    172             binmode PREVIEW_FILE;
    173             print PREVIEW_FILE $$imagedata;
    174             close PREVIEW_FILE;
    175         };
    176         $self->last_error_msg($@) if $@;
    177     }
    178    
    179 }
    180 
    181159
    182160sub _set_exif_tag {
     
    492470    );
    493471
    494     printf("%sx%s%s\n", $size, $size, '^');
    495472
    496473        # maximize size and keep aspect ratio
     
    516493        gravity=>'center',
    517494    );
    518 
     495       
    519496    $image->Set(
    520497        quality=>$self->wx_quality||90
     
    774751                                reupload_action_properties
    775752                                reupload_action_properties_m
     753                                display_mode
    776754            /
    777755        ]
  • extensions/pLoader/trunk/src/ploader.pl

    r4322 r4504  
    2727use Data::Dumper;
    2828
    29 #$SIG{__DIE__} = \&OnDieHandler;
     29$SIG{__DIE__} = \&OnDieHandler;
    3030
    3131require '../res/progress_wdr.pl';
    3232require '../res/login_wdr.pl';
     33require '../res/reupload_wdr.pl';
     34require '../res/photo_properties_wdr.pl';
    3335print Dumper \@INC;
    3436eval {
Note: See TracChangeset for help on using the changeset viewer.