Placing Layer Order buttons.
This commit is contained in:
@@ -13,6 +13,7 @@ using namespace JUI::UDimLiterals;
|
||||
class LayerView : public JUI::Window
|
||||
{
|
||||
public:
|
||||
float layer_entry_height = 30;
|
||||
Event<std::string, bool> LayerVisibilityToggled;
|
||||
Event<std::string> ActiveLayerSelected;
|
||||
LayerView() : JUI::Window()
|
||||
@@ -33,6 +34,8 @@ public:
|
||||
void UpdateComponents(const Level* level)
|
||||
{
|
||||
|
||||
|
||||
|
||||
for (auto entry : entry_elements) {
|
||||
entry->Parent(nullptr);
|
||||
delete entry;
|
||||
@@ -42,13 +45,13 @@ public:
|
||||
for (auto layer : level->layers)
|
||||
{
|
||||
auto* rect = new JUI::Rect(layout);
|
||||
rect->Size({100_percent, 20_px});
|
||||
rect->Size({100_percent, JUI::UDim(layer_entry_height, 0)});
|
||||
auto* vis_chk = new JUI::Checkbox(rect);
|
||||
vis_chk->Size({20_px, 20_px});
|
||||
vis_chk->Size({JUI::UDim(layer_entry_height, 0), JUI::UDim(layer_entry_height, 0)});
|
||||
auto* label = new JUI::TextButton(rect);
|
||||
label->Name("Label");
|
||||
label->Position({20_px, 0_px});
|
||||
label->Size({100_percent-20_px, 20_px});
|
||||
label->Position({JUI::UDim(layer_entry_height, 0), 0_px});
|
||||
label->Size({100_percent-JUI::UDim(layer_entry_height*2, 0), JUI::UDim(layer_entry_height, 0)});
|
||||
label->Content(layer->name);
|
||||
label->TextColor(Colors::Black);
|
||||
|
||||
@@ -61,6 +64,35 @@ public:
|
||||
LayerVisibilityToggled.Invoke(layer->name, !layer->visible);
|
||||
};
|
||||
|
||||
auto* layer_order_shift_box = new JUI::Rect(rect);
|
||||
layer_order_shift_box->Size({JUI::UDim(layer_entry_height, 0), JUI::UDim(layer_entry_height, 0)});
|
||||
layer_order_shift_box->Position({100_percent-JUI::UDim(layer_entry_height, 0), 0_px});
|
||||
|
||||
|
||||
auto layer_up = new JUI::TextButton(layer_order_shift_box);
|
||||
layer_up->Size({100_percent, 50_percent});
|
||||
layer_up->TextColor(Colors::Black);
|
||||
layer_up->Content("/\\");
|
||||
layer_up->Center();
|
||||
|
||||
layer_up->OnReleaseEvent += [this, layer] (auto a, auto b, auto c) mutable {
|
||||
if (layer->order > 0)
|
||||
layer->order--;
|
||||
};
|
||||
|
||||
|
||||
auto* layer_down = new JUI::TextButton(layer_order_shift_box);
|
||||
layer_down->Size({100_percent, 50_percent});
|
||||
layer_down->Content("\\/");
|
||||
layer_down->TextColor(Colors::Black);
|
||||
layer_down->Position({0_percent, 50_percent});
|
||||
layer_down->Center();
|
||||
|
||||
layer_down->OnReleaseEvent += [this, level, layer] (auto a, auto b, auto c) mutable {
|
||||
const int layer_count = level->layers.size();
|
||||
if (layer->order <= layer_count)
|
||||
layer->order++;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@@ -280,7 +280,7 @@ JUI::Window* EditorApp::CreateTilesetViewerWindow(JUI::Widget* parent)
|
||||
wind->Size(JUI::UDim2::FromPixels(loaded_tilesheet->GetDimensions().x, loaded_tilesheet->GetDimensions().y+20));
|
||||
wind->SetResizable(false);
|
||||
|
||||
wind->Content()->BGColor(Colors::Black);
|
||||
wind->Content()->BGColor(Colors::Black);
|
||||
|
||||
auto* img = new Image(wind->Content());
|
||||
img->Content(loaded_tilesheet);
|
||||
@@ -970,4 +970,7 @@ void EditorApp::OnKeyDown(const KeyDownEvent& e)
|
||||
void EditorApp::OnKeyUp(const KeyUpEvent& e)
|
||||
{
|
||||
if (scene->ObserveKeyInput(e.key, false)) return;
|
||||
|
||||
if (e.key == Keys::T)
|
||||
tileset_viewer->Visible(!tileset_viewer->IsVisible());
|
||||
}
|
||||
|
Reference in New Issue
Block a user