From: Jon A. Cruz Date: Thu, 6 May 2010 05:27:32 +0000 (-0700) Subject: Switched icons to have frames, be square, and arranged more efficiently for space... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=329e69a19720ff7ce42f77a0d063bbac873d2c95;p=inkscape.git Switched icons to have frames, be square, and arranged more efficiently for space. Addressing bug #171376. --- diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 8b93bf340..f768df4f3 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -150,8 +151,11 @@ IconPreviewPanel::IconPreviewPanel() : magBox->pack_start( magLabel, Gtk::PACK_SHRINK ); - Gtk::VBox * verts = new Gtk::VBox(); - for ( int i = 0; i < numEntries; i++ ) { + Gtk::VBox *verts = new Gtk::VBox(); + Gtk::HBox *horiz = 0; + int previous = 0; + int avail = 0; + for ( int i = numEntries - 1; i >= 0; --i ) { pixMem[i] = new guchar[4 * sizes[i] * sizes[i]]; memset( pixMem[i], 0x00, 4 * sizes[i] * sizes[i] ); @@ -161,14 +165,45 @@ IconPreviewPanel::IconPreviewPanel() : Glib::ustring label(*labels[i]); buttons[i] = new Gtk::ToggleToolButton(label); buttons[i]->set_active( i == hot ); - buttons[i]->set_icon_widget(*images[i]); + Gtk::Frame *frame = new Gtk::Frame(); + frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); + frame->add(*images[i]); + buttons[i]->set_icon_widget(*Gtk::manage(frame)); tips.set_tip((*buttons[i]), label); buttons[i]->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &IconPreviewPanel::on_button_clicked), i) ); - verts->add(*buttons[i]); + Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(0.5, 0.5, 0, 0)); + align->add(*buttons[i]); + + int pad = 12; + if ((avail == 0) && (previous == 0)) { + verts->pack_end(*align, Gtk::PACK_SHRINK); + previous = sizes[i]; + avail = sizes[i]; + } else { + if ((avail < pad) || ((sizes[i] > avail) && (sizes[i] < previous))) { + horiz = 0; + } + if ((horiz == 0) && (sizes[i] <= previous)) { + avail = previous; + } + if (sizes[i] <= avail) { + if (!horiz) { + horiz = Gtk::manage(new Gtk::HBox()); + avail = previous; + verts->pack_end(*horiz, Gtk::PACK_SHRINK); + } + horiz->pack_start(*align, Gtk::PACK_EXPAND_WIDGET); + avail -= sizes[i]; + avail -= pad; // a little extra for padding + } else { + horiz = 0; + verts->pack_end(*align, Gtk::PACK_SHRINK); + } + } } iconBox.pack_start(splitter);