mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Fix layout issues, misc cleanup and comments
This commit is contained in:
parent
aed5d76fbc
commit
39b627c0c1
@ -814,7 +814,7 @@ void AbstractChoiceWithValueDisplay::GetContentDimensionsBySpec(const UIContext
|
||||
const std::string valueText = ValueText();
|
||||
int paddingX = 12;
|
||||
// Assume we want at least 20% of the size for the label, at a minimum.
|
||||
float availWidth = (horiz.size - paddingX * 2) * 0.8f;
|
||||
float availWidth = (horiz.size - paddingX * 2) * (text_.empty() ? 1.0f : 0.8f);
|
||||
if (availWidth < 0) {
|
||||
availWidth = 65535.0f;
|
||||
}
|
||||
@ -826,11 +826,15 @@ void AbstractChoiceWithValueDisplay::GetContentDimensionsBySpec(const UIContext
|
||||
valueW += paddingX;
|
||||
|
||||
// Give the choice itself less space to grow in, so it shrinks if needed.
|
||||
MeasureSpec horizLabel = horiz;
|
||||
horizLabel.size -= valueW;
|
||||
// MeasureSpec horizLabel = horiz;
|
||||
// horizLabel.size -= valueW;
|
||||
Choice::GetContentDimensionsBySpec(dc, horiz, vert, w, h);
|
||||
|
||||
w += valueW;
|
||||
// Fill out anyway if there's space.
|
||||
if (horiz.type == AT_MOST && w < horiz.size) {
|
||||
w = horiz.size;
|
||||
}
|
||||
h = std::max(h, valueH);
|
||||
}
|
||||
|
||||
|
@ -463,8 +463,8 @@ public:
|
||||
private:
|
||||
std::string ValueText() const override;
|
||||
|
||||
int *iValue_ = nullptr;
|
||||
std::string *sValue_ = nullptr;
|
||||
int *iValue_ = nullptr;
|
||||
const char *category_ = nullptr;
|
||||
std::string (*translateCallback_)(const char *value) = nullptr;
|
||||
};
|
||||
|
@ -414,7 +414,8 @@ void ClickableItem::GetContentDimensions(const UIContext &dc, float &w, float &h
|
||||
}
|
||||
|
||||
ClickableItem::ClickableItem(LayoutParams *layoutParams) : Clickable(layoutParams) {
|
||||
if (!layoutParams && autoExpand_) {
|
||||
if (!layoutParams) {
|
||||
// The default LayoutParams assigned by View::View defaults to WRAP_CONTENT/WRAP_CONTENT.
|
||||
if (layoutParams_->width == WRAP_CONTENT)
|
||||
layoutParams_->width = FILL_PARENT;
|
||||
}
|
||||
|
@ -692,11 +692,6 @@ public:
|
||||
|
||||
// Draws the item background.
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
void SetAutoExpand(bool autoExpand) { autoExpand_ = autoExpand; }
|
||||
|
||||
private:
|
||||
bool autoExpand_ = true;
|
||||
};
|
||||
|
||||
// Use to trigger something or open a submenu screen.
|
||||
|
@ -514,8 +514,9 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
|
||||
float sum = 0.0f;
|
||||
float maxOther = 0.0f;
|
||||
float totalWeight = 0.0f;
|
||||
float weightSum = 0.0f;
|
||||
float weightZeroSum = 0.0f;
|
||||
|
||||
float weightSum = 0.0f; // Total sum of weights
|
||||
float weightZeroSum = 0.0f; // Sum of sizes of things with weight 0.0, a bit confusingly named
|
||||
|
||||
int numVisible = 0;
|
||||
|
||||
@ -593,8 +594,11 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
|
||||
for (View *view : views_) {
|
||||
if (view->GetVisibility() == V_GONE)
|
||||
continue;
|
||||
const LinearLayoutParams *linLayoutParams = view->GetLayoutParams()->As<LinearLayoutParams>();
|
||||
// FILL_PARENT is not appropriate in this direction. It gets ignored though.
|
||||
// We have a bit too many of these due to the hack in the ClickableItem constructor.
|
||||
// _dbg_assert_(view->GetLayoutParams()->width != UI::FILL_PARENT);
|
||||
|
||||
const LinearLayoutParams *linLayoutParams = view->GetLayoutParams()->As<LinearLayoutParams>();
|
||||
if (linLayoutParams && linLayoutParams->weight > 0.0f) {
|
||||
Margins margins = defaultMargins_;
|
||||
if (linLayoutParams->HasMargins())
|
||||
@ -638,8 +642,11 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
|
||||
for (View *view : views_) {
|
||||
if (view->GetVisibility() == V_GONE)
|
||||
continue;
|
||||
const LinearLayoutParams *linLayoutParams = view->GetLayoutParams()->As<LinearLayoutParams>();
|
||||
// FILL_PARENT is not appropriate in this direction. It gets ignored though.
|
||||
// We have a bit too many of these due to the hack in the ClickableItem constructor.
|
||||
// _dbg_assert_(view->GetLayoutParams()->height != UI::FILL_PARENT);
|
||||
|
||||
const LinearLayoutParams *linLayoutParams = view->GetLayoutParams()->As<LinearLayoutParams>();
|
||||
if (linLayoutParams && linLayoutParams->weight > 0.0f) {
|
||||
Margins margins = defaultMargins_;
|
||||
if (linLayoutParams->HasMargins())
|
||||
@ -649,6 +656,7 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v
|
||||
h = MeasureSpec(AT_MOST, measuredWidth_);
|
||||
float unit = (allowedHeight - weightZeroSum) / weightSum;
|
||||
if (weightSum == 0.0f) {
|
||||
// We must have gotten an inf.
|
||||
unit = 1.0f;
|
||||
}
|
||||
MeasureSpec v(AT_MOST, unit * linLayoutParams->weight - margins.vert());
|
||||
|
@ -271,13 +271,11 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
// Vector element pointer get invalidated on resize, cache name to have always a valid reference in the rendering thread
|
||||
shaderNames_[i] = i == g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[i];
|
||||
|
||||
// TODO: I want to set UI::FILL_PARENT or an explicit width here, but breaks badly???
|
||||
LinearLayout *shaderRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT));
|
||||
LinearLayout *shaderRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(UI::FILL_PARENT, UI::WRAP_CONTENT));
|
||||
shaderRow->SetSpacing(4.0f);
|
||||
leftColumn->Add(shaderRow);
|
||||
|
||||
postProcChoice_ = shaderRow->Add(new ChoiceWithValueDisplay(&shaderNames_[i], "", &PostShaderTranslateName, new LinearLayoutParams(1.0f)));
|
||||
postProcChoice_->SetAutoExpand(false);
|
||||
postProcChoice_->OnClick.Add([=](EventParams &e) {
|
||||
auto gr = GetI18NCategory("Graphics");
|
||||
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i, false);
|
||||
@ -305,7 +303,7 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
}
|
||||
}
|
||||
if (hasSettings) {
|
||||
auto settingsButton = shaderRow->Add(new Choice(ImageID("I_SLIDERS")));
|
||||
auto settingsButton = shaderRow->Add(new Choice(ImageID("I_SLIDERS"), new LinearLayoutParams(0.0f)));
|
||||
settingsButton->OnClick.Add([=](EventParams &e) {
|
||||
settingsVisible_[i] = !settingsVisible_[i];
|
||||
RecreateViews();
|
||||
@ -315,7 +313,7 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
}
|
||||
|
||||
if (i > 0 && i < g_Config.vPostShaderNames.size()) {
|
||||
auto upButton = shaderRow->Add(new Choice(ImageID("I_ARROW_UP")));
|
||||
auto upButton = shaderRow->Add(new Choice(ImageID("I_ARROW_UP"), new LinearLayoutParams(0.0f)));
|
||||
upButton->OnClick.Add([=](EventParams &e) {
|
||||
std::swap(g_Config.vPostShaderNames[i - 1], g_Config.vPostShaderNames[i]);
|
||||
RecreateViews();
|
||||
@ -323,7 +321,7 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
});
|
||||
}
|
||||
if (i < g_Config.vPostShaderNames.size() - 1) {
|
||||
auto downButton = shaderRow->Add(new Choice(ImageID("I_ARROW_DOWN")));
|
||||
auto downButton = shaderRow->Add(new Choice(ImageID("I_ARROW_DOWN"), new LinearLayoutParams(0.0f)));
|
||||
downButton->OnClick.Add([=](EventParams &e) {
|
||||
std::swap(g_Config.vPostShaderNames[i], g_Config.vPostShaderNames[i + 1]);
|
||||
RecreateViews();
|
||||
@ -331,7 +329,7 @@ void DisplayLayoutScreen::CreateViews() {
|
||||
});
|
||||
}
|
||||
if (i < g_Config.vPostShaderNames.size()) {
|
||||
auto deleteButton = shaderRow->Add(new Choice(ImageID("I_TRASHCAN")));
|
||||
auto deleteButton = shaderRow->Add(new Choice(ImageID("I_TRASHCAN"), new LinearLayoutParams(0.0f)));
|
||||
deleteButton->OnClick.Add([=](EventParams &e) {
|
||||
g_Config.vPostShaderNames.erase(g_Config.vPostShaderNames.begin() + i);
|
||||
RecreateViews();
|
||||
|
@ -1064,7 +1064,7 @@ void TakeScreenshot() {
|
||||
}
|
||||
|
||||
void RenderOverlays(UIContext *dc, void *userdata) {
|
||||
// Thin bar at the top of the screen like Chrome.
|
||||
// Thin bar at the top of the screen.
|
||||
std::vector<float> progress = g_DownloadManager.GetCurrentProgress();
|
||||
if (!progress.empty()) {
|
||||
static const uint32_t colors[4] = {
|
||||
@ -1091,8 +1091,8 @@ void RenderOverlays(UIContext *dc, void *userdata) {
|
||||
}
|
||||
|
||||
void NativeRender(GraphicsContext *graphicsContext) {
|
||||
_assert_(graphicsContext != nullptr);
|
||||
_assert_(screenManager != nullptr);
|
||||
_dbg_assert_(graphicsContext != nullptr);
|
||||
_dbg_assert_(screenManager != nullptr);
|
||||
|
||||
g_GameManager.Update();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user