Files
dl_old/dltest/ui_gfx.h
T
2024-01-03 15:16:54 +08:00

89 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <dl.h>
using namespace dl;
class UIGfx
{
public:
UIGfx()
{
_panel = g_ui->CreatePanel();
_panel->SetPosScale({ 0.0f, 0.0f });
_panel->SetPosPixel(POS_CONTENT);
_panel->SetAutoRun(false);
UI::Panel* panel_menu = g_ui->CreatePanel();
panel_menu->SetLocator(createLocatorX(128));
g_ui->SetPanelParent(panel_menu, _panel);
{
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
UI::Manager::ButtonStyle::LONG);
btn->SetMode(UI::ButtonMode::RADIO);
btn->SetString("点(dot)");
panel_menu->Add(btn);
}
{
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
UI::Manager::ButtonStyle::LONG);
btn->SetMode(UI::ButtonMode::RADIO);
btn->SetString("线(line)");
panel_menu->Add(btn);
}
{
UI::ButtonSprite* btn = g_ui->CreateButtonSpriteDefault(
UI::Manager::ButtonStyle::LONG);
btn->SetMode(UI::ButtonMode::RADIO);
btn->SetString("三角形(line)");
panel_menu->Add(btn);
}
_panelMenu = panel_menu;
_coorRender = Coor::Create(_panelMenu->GetCoorRef());
_coorRender->SetPosition({ 200, 150 });
}
void Update()
{
_panel->Update();
}
void Render()
{
_panel->Render();
g_gfx->RenderCoor(_coorRender, false);
g_gfx->SetCoor(_coorRender);
std::size_t i = _panelMenu->GetSelectIndex();
if (i == 0)
{
for (int j = -10; j < 10; ++j)
{
for (int i = -10; i < 10; ++i)
{
g_gfx->SetColor(createColorRandom());
g_gfx->Dot({ 10.0f * i, 10.0f * j });
}
}
}
else if (i == 1)
{
g_gfx->SetColor({ ColorDef::RED, ColorDef::GREEN });
g_gfx->Line({ -100, -100 }, { 100, 100 });
g_gfx->SetColor({ ColorDef::WHITE, ColorDef::WHITE });
g_gfx->Line({ 100, -100 }, { -100, 100 });
}
else if (i == 2)
{
g_gfx->SetColor({ ColorDef::RED, ColorDef::GREEN });
g_gfx->Love();
}
}
~UIGfx()
{
delete _coorRender;
}
private:
UI::Panel* _panel;
UI::Panel* _panelMenu;
Coor* _coorRender;
};