diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-01-08 09:28:38 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-01-12 10:31:59 +0100 |
commit | e964ffb3010eace108944a87f8957a34dda9f121 (patch) | |
tree | 215174c7d8efdf4ee0e4f449d130145f0c866719 /svx | |
parent | a1549c122724733f51096611486a26dcad7321fe (diff) |
Fontwork dialog: use iconview
Change-Id: I5bb35407ca83c9b0cda6f6355e6e25c21fecb459
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108960
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/tbxctrls/fontworkgallery.cxx | 54 | ||||
-rw-r--r-- | svx/uiconfig/ui/fontworkgallerydialog.ui | 37 |
2 files changed, 39 insertions, 52 deletions
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx index 1b2483f11e4e..036060109918 100644 --- a/svx/source/tbxctrls/fontworkgallery.cxx +++ b/svx/source/tbxctrls/fontworkgallery.cxx @@ -63,29 +63,21 @@ using namespace ::com::sun::star::beans; namespace svx { -const int nColCount = 4; -const int nLineCount = 4; - FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSdrView) : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog") , mnThemeId(0xffff) , mrSdrView(rSdrView) , mppSdrObject(nullptr) , mpDestModel(nullptr) - , maCtlFavorites(m_xBuilder->weld_scrolled_window("ctlFavoriteswin")) - , mxCtlFavorites(new weld::CustomWeld(*m_xBuilder, "ctlFavorites", maCtlFavorites)) + , maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin")) , mxOKButton(m_xBuilder->weld_button("ok")) { - Size aSize(maCtlFavorites.GetDrawingArea()->get_ref_device().LogicToPixel(Size(200, 200), MapMode(MapUnit::MapAppFont))); - mxCtlFavorites->set_size_request(aSize.Width(), aSize.Height()); + Size aSize(530, 400); + maCtlFavorites->set_size_request(aSize.Width(), aSize.Height()); - maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) ); + maCtlFavorites->connect_item_activated( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) ); mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl)); - maCtlFavorites.SetColCount( nColCount ); - maCtlFavorites.SetLineCount( nLineCount ); - maCtlFavorites.SetExtraSpacing( 3 ); - initFavorites( GALLERY_THEME_FONTWORK ); fillFavorites( GALLERY_THEME_FONTWORK ); } @@ -111,7 +103,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId) if (GalleryExplorer::GetSdrObj(nThemeId, nModelPos, pModel, &aThumb) && !!aThumb) { - ScopedVclPtrInstance< VirtualDevice > pVDev; + VclPtr< VirtualDevice > pVDev = VclPtr<VirtualDevice>::Create(); const Point aNull(0, 0); if (pVDev->GetDPIScaleFactor() > 1) @@ -128,7 +120,7 @@ void FontWorkGalleryDialog::initFavorites(sal_uInt16 nThemeId) pVDev->DrawCheckered(aNull, aSize, nLen, aW, aG); pVDev->DrawBitmapEx(aNull, aThumb); - maFavoritesHorizontal.emplace_back(pVDev->GetBitmapEx(aNull, aSize)); + maFavoritesHorizontal.emplace_back(pVDev); } } @@ -140,33 +132,18 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId) { mnThemeId = nThemeId; - Size aThumbSize(maCtlFavorites.GetOutputSizePixel()); - aThumbSize.setWidth( aThumbSize.Width() / nColCount ); - aThumbSize.setHeight( aThumbSize.Height() / nLineCount ); - aThumbSize.AdjustWidth( -12 ); - aThumbSize.AdjustHeight( -12 ); - auto nFavCount = maFavoritesHorizontal.size(); - // ValueSet favorites - if( nFavCount > (nColCount * nLineCount) ) - { - WinBits nWinBits = maCtlFavorites.GetStyle(); - nWinBits |= WB_VSCROLL; - maCtlFavorites.SetStyle( nWinBits ); - } - - maCtlFavorites.Clear(); + maCtlFavorites->clear(); for( size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ ) { - OUString aStr = SvxResId(RID_SVXFLOAT3D_FAVORITE) + " " + OUString::number(nFavorite); - Image aThumbImage( maFavoritesHorizontal[nFavorite-1] ); - maCtlFavorites.InsertItem( static_cast<sal_uInt16>(nFavorite), aThumbImage, aStr ); + OUString sId = OUString::number(static_cast<sal_uInt16>(nFavorite)); + maCtlFavorites->append(sId, "", maFavoritesHorizontal[nFavorite-1]); } - if (maCtlFavorites.GetItemCount()) - maCtlFavorites.SelectItem(1); + if (maCtlFavorites->n_children()) + maCtlFavorites->select(0); } void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel ) @@ -177,14 +154,14 @@ void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* void FontWorkGalleryDialog::insertSelectedFontwork() { - sal_uInt16 nItemId = maCtlFavorites.GetSelectedItemId(); + OUString nItemId = maCtlFavorites->get_selected_id(); - if( nItemId > 0 ) + if( !nItemId.isEmpty() ) { std::unique_ptr<FmFormModel> pModel(new FmFormModel()); pModel->GetItemPool().FreezeIdRanges(); - if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) ) + if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId.toInt32()-1, pModel.get() ) ) { SdrPage* pPage = pModel->GetPage(0); if( pPage && pPage->GetObjCount() ) @@ -257,10 +234,11 @@ IMPL_LINK_NOARG(FontWorkGalleryDialog, ClickOKHdl, weld::Button&, void) m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, SvtValueSet*, void) +IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, weld::IconView&, bool) { insertSelectedFontwork(); m_xDialog->response(RET_OK); + return true; } class FontworkAlignmentWindow : public ToolbarMenu diff --git a/svx/uiconfig/ui/fontworkgallerydialog.ui b/svx/uiconfig/ui/fontworkgallerydialog.ui index 1ead11bc1fdd..3d7a81687f1b 100644 --- a/svx/uiconfig/ui/fontworkgallerydialog.ui +++ b/svx/uiconfig/ui/fontworkgallerydialog.ui @@ -2,6 +2,16 @@ <!-- Generated with glade 3.22.1 --> <interface domain="svx"> <requires lib="gtk+" version="3.18"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="FontworkGalleryDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -97,25 +107,24 @@ </packing> </child> <child> - <object class="GtkScrolledWindow" id="ctlFavoriteswin"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="hscrollbar_policy">never</property> - <property name="vscrollbar_policy">never</property> + <property name="vexpand">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkViewport"> + <object class="GtkIconView" id="ctlFavoriteswin"> <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkDrawingArea" id="ctlFavorites"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> - <property name="hexpand">True</property> - </object> - </child> + <property name="can_focus">True</property> + <property name="margin">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="columns">3</property> + <property name="item_width">100</property> + <property name="pixbuf-column">0</property> + <property name="text-column">1</property> </object> </child> </object> |