void ChoiceForm::InitUI() { auto leftPanel = new GraphicsUI::Container(this); leftPanel->DockStyle = GraphicsUI::Control::dsLeft; leftPanel->Posit(0, 0, EM(5.2f), EM(10.0f)); leftPanel->Padding = EM(0.2f); shaderBox = new GraphicsUI::ListBox(leftPanel); shaderBox->DockStyle = GraphicsUI::Control::dsFill; shaderBox->OnChanged.Bind(this, &ChoiceForm::SelectedShaderChanged); auto toolFlowPanel = new GraphicsUI::Container(this); toolFlowPanel->SetLayout(GraphicsUI::ContainerLayoutType::Flow); toolFlowPanel->DockStyle = GraphicsUI::Control::dsTop; toolFlowPanel->AutoHeight = true; auto editButton = new GraphicsUI::Button(toolFlowPanel, L"Edit"); editButton->Margin = EM(0.2f); editButton->OnClick.Bind(this, &ChoiceForm::EditButton_Clicked); applyButton = new GraphicsUI::Button(toolFlowPanel, L"Recompile"); applyButton->Margin = EM(0.2f); applyButton->OnClick.Bind(this, &ChoiceForm::ApplyButton_Clicked); resetButton = new GraphicsUI::Button(toolFlowPanel, L"Reset"); resetButton->Margin = EM(0.2f); resetButton->OnClick.Bind(this, &ChoiceForm::ResetButton_Clicked); autoRecompileCheckBox = new GraphicsUI::CheckBox(toolFlowPanel); autoRecompileCheckBox->SetText(L"Auto Recompile"); autoRecompileCheckBox->Margin = EM(0.2f); autoRecompileCheckBox->Margin.Top = EM(0.3f); autoRecompileCheckBox->Checked = true; #ifdef ENABLE_AUTO_TUNE timeBudgetTextBox = new GraphicsUI::TextBox(toolFlowPanel); timeBudgetTextBox->SetText(L"10"); timeBudgetTextBox->Posit(0, 0, EM(3.0f), EM(1.5f)); timeBudgetTextBox->Margin = EM(0.2f); timeBudgetTextBox->Margin.Top = EM(0.3f); autoTuneButton = new GraphicsUI::Button(toolFlowPanel, L"Autotune"); autoTuneButton->Margin = EM(0.2f); autoTuneButton->OnClick.Bind(this, &ChoiceForm::AutotuneButton_Clicked); autoTuneTexButton = new GraphicsUI::Button(toolFlowPanel, L"Tune Texture"); autoTuneTexButton->Margin = EM(0.2f); autoTuneTexButton->OnClick.Bind(this, &ChoiceForm::AutotuneTexButton_Clicked); saveScheduleButton = new GraphicsUI::Button(toolFlowPanel, L"Save"); saveScheduleButton->Margin = EM(0.2f); saveScheduleButton->OnClick.Bind(this, &ChoiceForm::SaveScheduleButton_Clicked); #endif scrollPanel = new GraphicsUI::VScrollPanel(this); scrollPanel->DockStyle = GraphicsUI::Control::dsFill; }
void ChoiceForm::UpdateChoicePanel(String shaderName) { glFinish(); if (shaderName.Length()) SetText(L"Choice Control - " + shaderName); currentShaderName = shaderName; scrollPanel->ClearChildren(); existingChoices.Clear(); additionalAttribs.Clear(); auto choices = choiceControl->GetChoices(shaderName, existingChoices); int line = 0; comboBoxChoiceNames.Clear(); choiceComboBoxes.Clear(); choiceCheckBoxes.Clear(); existingChoices.Clear(); scrollPanel->SetLayout(GraphicsUI::ContainerLayoutType::Stack); for (auto & choice : choices) { if (choice.Options.Count() == 1) continue; auto wrapper = new GraphicsUI::Container(scrollPanel); wrapper->AutoHeight = true; wrapper->Padding = EM(0.1f); auto lbl = new GraphicsUI::CheckBox(wrapper); lbl->SetText(choice.ChoiceName); lbl->Top = EM(0.2f); choiceCheckBoxes.Add(choice.ChoiceName, lbl); auto cmb = new GraphicsUI::ComboBox(wrapper); cmb->AddTextItem(L"(auto) " + choice.DefaultValue); for (auto & opt : choice.Options) { cmb->AddTextItem(opt.ToString()); } comboBoxChoiceNames[cmb] = choice.ChoiceName; choiceComboBoxes[choice.ChoiceName] = cmb; cmb->SetSelectedIndex(0); cmb->OnChanged.Bind(this, &ChoiceForm::ChoiceComboBox_Changed); cmb->Posit(0, 0, EM(7.0f), EM(1.5f)); cmb->DockStyle = GraphicsUI::Control::dsRight; line++; } SizeChanged(); }
void ShaderInfoForm::Update(const Spire::Compiler::ShaderMetaData & pMetaData) { this->metaData = pMetaData; contentBox->Enabled = false; for (auto & child : contentBox->Controls) child = nullptr; contentBox->Controls.Clear(); const int leftMargin = 20; auto titleFont = GetEntry()->System->LoadDefaultFont(GraphicsUI::DefaultFontType::Title); int wid = 0; int lineHeight = (int)(GetEntry()->GetLineHeight() * 1.2f); int maxX = 0; maxY = 0; for (auto & w : metaData.Worlds) { auto worldLbl = new GraphicsUI::Label(contentBox); worldLbl->AutoSize = true; worldLbl->Posit(wid * columnWidth + 20, 10, 100, 30); worldLbl->SetText(w.Key); worldLbl->SetWidth(worldLbl->GetWidth() + 8); worldLbl->FontColor = GraphicsUI::Color(255, 255, 255); worldLbl->SetFont(titleFont); int curRow = 0; int curX = leftMargin; for (auto & comp : w.Value.Components) { auto block = metaData.InterfaceBlocks.TryGetValue(w.Value.OutputBlock); bool isInInterface = false; if (block) { for (auto & entry : block->Entries) if (entry.Name == comp) { isInInterface = true; break; } } auto compLbl = new GraphicsUI::Label(contentBox); compLbl->AutoSize = true; compLbl->BorderStyle = GraphicsUI::BS_NONE; compLbl->Posit(0, 0, 100, 30); compLbl->SetText(comp); int x, y; if (curX + compLbl->GetWidth() + 8 < columnWidth) { x = curX; } else { curRow++; x = curX = leftMargin; } y = curRow * lineHeight + 50; compLbl->BorderColor.A = 0; compLbl->BackColor = GraphicsUI::Color(90,90,90,160); compLbl->FontColor = isInInterface ? GraphicsUI::Color(255, 220, 128) : GraphicsUI::Color(255, 255, 255); compLbl->Left = curX + wid * columnWidth; compLbl->Top = y; compLbl->SetWidth(Math::Min(compLbl->GetWidth() + 4, (wid + 1) * columnWidth - 10 - compLbl->Left)); compLbl->BorderStyle = GraphicsUI::BS_FLAT_; curX += compLbl->GetWidth() + 12; maxY = Math::Max(y + lineHeight, maxY); maxX = Math::Max(compLbl->Left + compLbl->GetWidth(), maxX); } wid++; } for (int i = 1; i < metaData.Worlds.Count(); i++) { auto line = new GraphicsUI::Line(contentBox); line->Posit(i * columnWidth + 10, 0, 0, maxY); } contentBox->SetWidth(maxX); contentBox->SetHeight(maxY); }