Skip to content

Commit

Permalink
ICON_Manager: Adjust size of loaded icon from file (#919)
Browse files Browse the repository at this point in the history
キャッシュディレクトリから読み込んだアイコン画像のうちサイズが
大きいものは`24x24`に縮小して表示するように変更します。修正前は
読み込んだ画像のサイズでそのまま表示されたためUIのレイアウトが
崩れることがありました。

大きな画像を組み込みのアイコン画像(`16x16`)に合わせて縮小すると
細かい部分が潰れて視認性が低下するのでサイズを一回り大きめにとり
利用できる画像を増やします。
  • Loading branch information
ma8ma committed Feb 19, 2022
1 parent 7b0e4e8 commit dae6f39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/manual/skin.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ Res.htmlでは次のように定義済み要素を指定して文字列の置換
アイコン画像を変更したときはJDimを再起動する。

- 画像形式は一般的な物なら大体使用可能 ( png, jpg, svg, gif, bmp, その他)
- 画像サイズは任意のサイズで良い( 16x16 がデフォルトサイズ)
- 画像ファイルのサイズは任意で良い
- ツールバーボタンのアイコンより大きな画像は 24x24 にサイズ調整される[^1] <small>(V0.7.0+から変更)</small>
- ファイル名は「アイコン名.拡張子 」(例) reload.jpg、 quit.png
- ファイル名の一覧はgitリポジトリにある [ヘッダファイル(iconfiles.h)][iconfiles] を参照すること

[^1]: 視認性を良くするため組み込みのアイコン( 16x16 )よりサイズを一回り大きくとる

---

Expand Down
11 changes: 10 additions & 1 deletion src/icons/iconmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,16 @@ void ICON_Manager::load_theme()
#ifdef _DEBUG
std::cout << "hit : " << iconfiles[ id ] << " id = " << id << std::endl;
#endif
m_list_icons[ id ] = Gdk::Pixbuf::create_from_file( CACHE::path_theme_icon_root() + filename );
// ツールバーボタンのアイコンより大きな画像はサイズ調整する
// 視認性を良くするため組み込みのアイコンよりサイズを一回り大きめにとる
auto pixbuf = Gdk::Pixbuf::create_from_file( CACHE::path_theme_icon_root() + filename );
constexpr int size_menu = 24; // Gtk::ICON_SIZE_LARGE_TOOLBAR
if( pixbuf->get_width() > size_menu || pixbuf->get_height() > size_menu ) {
m_list_icons[id] = pixbuf->scale_simple( size_menu, size_menu, Gdk::INTERP_HYPER );
}
else {
m_list_icons[id] = pixbuf;
}
break;
}

Expand Down

0 comments on commit dae6f39

Please sign in to comment.