OpenSiv3D
                                
                                 OpenSiv3D copied to clipboard
                                
                                    OpenSiv3D copied to clipboard
                            
                            
                            
                        SimpleGUI名前空間の要素を分割する
追加する機能の内容 | Describe the solution you'd like
v0.6.9で追加されたSimpleTableのサンプルを拝見したのですが、SimpleTableクラスでは他のSimpleGUI要素にはなかったStyleを導入しており、カスタマイズ性があって良いと思いました。
そこでなのですが、現在SimpleGUI名前空間に存在するボタンやスライダーなどの要素も、別クラスとして切り分けてStyleを導入するのはいかがでしょうか?
OpenSiv3DでGUIを作る場合、ほとんどの場合SimpleGUI名前空間のメソッドを使用しますが、個人的にはこれらにもう少しカスタマイズ性があっても良いのではないかと感じています。
その機能の追加によって解決する問題 | Is your feature request related to a problem? Please describe.
現状、SimpleGUIでGUIを作ると、良くも悪くもOpenSiv3Dらしさがどうしても出てしまい、カスタマイズしようにも(単に背景色を変えたいだけの場合でも)クラスを自前で作る必要がある。 →SimpleTableクラスと同様にStyleを導入し、大きさ、色、フォントサイズなど、外見の基本的な部分だけはカスタマイズできるようにする。
備考 | Additional context
フォークリポジトリでとりあえずボタンをSimpleButtonとして試作してみました。使用感的には以下のようになります。
# include <Siv3D.hpp>
void Main()
{
	SimpleButton button1;
	SimpleButton button2{ {
			.borderThickness = 5,
			.borderColor = Palette::Red,
	} };
	SimpleButton button3{ {
			.roundRadius = 20,
			.backgroundColor = Color{ 62, 168, 255 },
			.hoveredColor = Color{ 62, 168, 255 }.gamma(0.7),
			.borderThickness = 0,
			.labelColor = Palette::White,
	} };
	SimpleButton button4{ {
			.backgroundColor = Color{ 35, 134, 54 },
			.hoveredColor = Color{ 35, 134, 54 }.gamma(1.5),
			.borderThickness = 0,
			.fontSize = 40,
			.labelColor = Palette::White,
	} };
	SimpleButton button5{ {
			.paddingLR = 10,
			.paddingTB = 50,
	} };
	SimpleButton button6{ {
			.width = 120,
			.height = 120,
			.roundRadius = 60,
			.backgroundColor = Color{ 190, 255, 0 },
			.hoveredColor = Color{ 190, 255, 0 }.gamma(1.5),
			.borderThickness = 3,
			.borderColor = Palette::Black,
			.labelColor = Palette::Black,
	} };
	SimpleButton button7{ {
			.width = 200,
			.roundRadius = 0,
			.backgroundColor = Color{ 253, 95, 94 },
			.disabledBackgroundColor = Color{ 253, 95, 94 }.gamma(0.01),
			.hoveredColor = Color{ 253, 95, 94 }.gamma(1.5),
			.borderThickness = 0,
			.labelColor = Palette::White,
	} };
	bool enabledButton7 = false;
	while (System::Update())
	{
		if (button1(U"Button1", { 100, 100 })) {
			Print << U"Button1: classic button";
		}
		if (button2(U"Button2", { 300, 100 })) {
			Print << U"Button2: button with thick border";
		}
		if (button3(U"Button3", { 500, 100 })) {
			Print << U"Button3: rounded button";
		}
		if (button4(U"Button4", { 100, 200 })) {
			Print << U"Button4: big button";
		}
		if (button5(U"Button5", { 350, 200 })) {
			Print << U"Button5: Vertical long button";
		}
		if (button6(U"Button6", { 510, 200 })) {
			Print << U"Button6: circular button";
		}
		if (button7(U"Button7: {}"_fmt(enabledButton7 ? U"enabled" : U"disabled"), {100, 310}, enabledButton7)) {
			Print << U"Button7: disabled button";
		}
		SimpleGUI::CheckBox(enabledButton7, U"Enable Button7", Vec2{ 100, 360 });
	}
}
(また、あまりこの件とは関係がないかもしれませんが、SimpleTableクラス内でSimpleGUI名前空間のメソッドを使用していたりするので、テーブルをGUIとして解釈していると思うのですが(自分はそう解釈しています)、SimpleTableクラスをSimpleGUI名前空間に含めなかった意図が汲み取れませんでした。)
ご提案ありがとうございます。将来の Siv3D では、s3d::Button, s3d::Slider, s3d::Table といった、カスタマイズ性の高い独立したクラスを提供することを目指していて、SimpleGUI:: はそれに向けた minimum viable な GUI 実装という位置づけです。
v0.6.9 で追加された SimpleTable は SimpleGUI:: と比べて、クラス化によって一段階その目標に近づいた実験的機能です。SimpleTable の実装の知見を反映した SimpleButton クラスや SimpleSlider クラスを提供することも検討しています。
SimpleButton に関しては、ご提案の実装よりもいくつか進んだ追加の機能(自由形状、9-slice など)を提供することが考えられ、その実装を容易にするためのクラスを先に Siv3D で提供する必要があり、マイルストーン的にはまだ先にあります。
ご提案の内容を直接マージして受け入れることはできませんが、こうした機能に対するニーズはあるため、Siv3D 向けのライブラリとして .hpp / .cpp を公開されるとユーザにとって有益だと思います。ぜひご検討ください。
なるほど、そういう意図があってSimpleTableがクラス化されていたのですね。
返信ありがとうございます!
新しい UI システム(#1046)の一環で、カスタマイズ性の高いボタンに関する検討を進めます。