[nostalgia/gfx/studio/tilesheet] Make rotate only available for square subsheets or selections
All checks were successful
Build / build (push) Successful in 3m39s
All checks were successful
Build / build (push) Successful in 3m39s
This commit is contained in:
parent
3c804bf62a
commit
b4798fd2ab
@ -248,29 +248,22 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
ImGui::EndChild();
|
||||
ImGui::BeginChild("OperationsBox", {0, 35}, ImGuiWindowFlags_NoTitleBar);
|
||||
{
|
||||
size_t i{};
|
||||
if (ig::ComboBox("##Operations", ox::SpanView<ox::CStringView>{{
|
||||
ox::CStringView{"Operations"},
|
||||
ox::CStringView{"Flip X"},
|
||||
ox::CStringView{"Flip Y"},
|
||||
ox::CStringView{"Rotate Left"},
|
||||
ox::CStringView{"Rotate Right"},
|
||||
}}, i)) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
oxLogError(m_model.flipX());
|
||||
break;
|
||||
case 2:
|
||||
oxLogError(m_model.flipY());
|
||||
break;
|
||||
case 3:
|
||||
oxLogError(m_model.rotateLeft());
|
||||
break;
|
||||
case 4:
|
||||
oxLogError(m_model.rotateRight());
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
if (ImGui::BeginCombo("##Operations", "Operations", 0)) {
|
||||
if (ImGui::Selectable("Flip X", false)) {
|
||||
oxLogError(m_model.flipX());
|
||||
}
|
||||
if (ImGui::Selectable("Flip Y", false)) {
|
||||
oxLogError(m_model.flipY());
|
||||
}
|
||||
ImGui::BeginDisabled(!m_model.rotateEligible());
|
||||
if (ImGui::Selectable("Rotate Left", false)) {
|
||||
oxLogError(m_model.rotateLeft());
|
||||
}
|
||||
if (ImGui::Selectable("Rotate Right", false)) {
|
||||
oxLogError(m_model.rotateRight());
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
@ -352,6 +352,16 @@ ox::Error TileSheetEditorModel::flipY() noexcept {
|
||||
return pushCommand(ox::make<FlipYCommand>(m_img, m_activeSubsSheetIdx, a, b));
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::rotateEligible() const noexcept {
|
||||
if (m_selection) {
|
||||
auto const w = m_selection->b.x - m_selection->a.x;
|
||||
auto const h = m_selection->b.y - m_selection->a.y;
|
||||
return w == h;
|
||||
}
|
||||
auto const &ss = activeSubSheet();
|
||||
return ss.rows == ss.columns;
|
||||
}
|
||||
|
||||
ox::Error TileSheetEditorModel::moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept {
|
||||
return pushCommand(ox::make<MoveSubSheetCommand>(m_img, std::move(src), std::move(dst)));
|
||||
}
|
||||
|
@ -138,6 +138,9 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
ox::Error flipY() noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool rotateEligible() const noexcept;
|
||||
|
||||
ox::Error moveSubSheet(TileSheet::SubSheetIdx src, TileSheet::SubSheetIdx dst) noexcept;
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user