Minor initialization cleanups

This commit is contained in:
Henrik Rydgård 2022-12-15 09:30:47 +01:00
parent 976190cd4d
commit f68ba55f96
5 changed files with 17 additions and 26 deletions

View File

@ -28,7 +28,7 @@ struct Point {
// Resolved bounds on screen after layout. // Resolved bounds on screen after layout.
struct Bounds { struct Bounds {
Bounds() : x(0), y(0), w(0), h(0) {} Bounds() : x(0.0f), y(0.0f), w(0.0f), h(0.0f) {}
Bounds(float x_, float y_, float w_, float h_) : x(x_), y(y_), w(w_), h(h_) {} Bounds(float x_, float y_, float w_, float h_) : x(x_), y(y_), w(w_), h(h_) {}
bool Contains(float px, float py) const { bool Contains(float px, float py) const {

View File

@ -372,7 +372,7 @@ class CallbackColorTween;
class View { class View {
public: public:
View(LayoutParams *layoutParams = 0) : layoutParams_(layoutParams), visibility_(V_VISIBLE), measuredWidth_(0), measuredHeight_(0), enabledPtr_(0), enabled_(true), enabledMeansDisabled_(false) { View(LayoutParams *layoutParams = 0) : layoutParams_(layoutParams) {
if (!layoutParams) if (!layoutParams)
layoutParams_.reset(new LayoutParams()); layoutParams_.reset(new LayoutParams());
} }
@ -481,22 +481,22 @@ protected:
std::unique_ptr<LayoutParams> layoutParams_; std::unique_ptr<LayoutParams> layoutParams_;
std::string tag_; std::string tag_;
Visibility visibility_; Visibility visibility_ = V_VISIBLE;
// Results of measure pass. Set these in Measure. // Results of measure pass. Set these in Measure.
float measuredWidth_; float measuredWidth_ = 0.0f;
float measuredHeight_; float measuredHeight_ = 0.0f;
// Outputs of layout. X/Y are absolute screen coordinates, hierarchy is "gone" here. // Outputs of layout. X/Y are absolute screen coordinates, hierarchy is "gone" here.
Bounds bounds_; Bounds bounds_{};
std::vector<Tween *> tweens_; std::vector<Tween *> tweens_;
private: private:
std::function<bool()> enabledFunc_; std::function<bool()> enabledFunc_;
bool *enabledPtr_; bool *enabledPtr_ = nullptr;
bool enabled_; bool enabled_ = true;
bool enabledMeansDisabled_; bool enabledMeansDisabled_ = false;
DISALLOW_COPY_AND_ASSIGN(View); DISALLOW_COPY_AND_ASSIGN(View);
}; };

View File

@ -46,7 +46,7 @@ private:
int lastNonDeadzoneDeviceID_[2]{}; int lastNonDeadzoneDeviceID_[2]{};
float history[2][2] = {}; float history[2][2]{};
// Mappable auto-rotation. Useful for keyboard/dpad->analog in a few games. // Mappable auto-rotation. Useful for keyboard/dpad->analog in a few games.
bool autoRotatingAnalogCW_ = false; bool autoRotatingAnalogCW_ = false;

View File

@ -34,7 +34,7 @@ class SingleControlMapper;
class ControlMappingScreen : public UIDialogScreenWithGameBackground { class ControlMappingScreen : public UIDialogScreenWithGameBackground {
public: public:
ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
const char *tag() const override { return "ControlMapping"; } const char *tag() const override { return "ControlMapping"; }
protected: protected:
@ -49,7 +49,7 @@ private:
void dialogFinished(const Screen *dialog, DialogResult result) override; void dialogFinished(const Screen *dialog, DialogResult result) override;
UI::ScrollView *rightScroll_; UI::ScrollView *rightScroll_ = nullptr;
std::vector<SingleControlMapper *> mappers_; std::vector<SingleControlMapper *> mappers_;
int keyMapGeneration_ = -1; int keyMapGeneration_ = -1;
}; };
@ -57,9 +57,7 @@ private:
class KeyMappingNewKeyDialog : public PopupScreen { class KeyMappingNewKeyDialog : public PopupScreen {
public: public:
explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n) explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
: PopupScreen(i18n->T("Map Key"), "Cancel", ""), callback_(callback) { : PopupScreen(i18n->T("Map Key"), "Cancel", ""), pspBtn_(btn), callback_(callback) {}
pspBtn_ = btn;
}
const char *tag() const override { return "KeyMappingNewKey"; } const char *tag() const override { return "KeyMappingNewKey"; }
@ -85,9 +83,7 @@ private:
class KeyMappingNewMouseKeyDialog : public PopupScreen { class KeyMappingNewMouseKeyDialog : public PopupScreen {
public: public:
KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n) KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
: PopupScreen(i18n->T("Map Mouse"), "", ""), callback_(callback), mapped_(false) { : PopupScreen(i18n->T("Map Mouse"), "", ""), pspBtn_(btn), callback_(callback), mapped_(false) {}
pspBtn_ = btn;
}
const char *tag() const override { return "KeyMappingNewMouseKey"; } const char *tag() const override { return "KeyMappingNewMouseKey"; }

View File

@ -308,13 +308,8 @@ private:
class SnapGrid : public UI::View { class SnapGrid : public UI::View {
public: public:
SnapGrid(int leftMargin, int rightMargin, int topMargin, int bottomMargin, u32 color) { SnapGrid(int leftMargin, int rightMargin, int topMargin, int bottomMargin, u32 color)
x1 = leftMargin; : UI::View(), x1(leftMargin), x2(rightMargin), y1(topMargin), y2(bottomMargin), col(color) {}
x2 = rightMargin;
y1 = topMargin;
y2 = bottomMargin;
col = color;
}
void Draw(UIContext &dc) override { void Draw(UIContext &dc) override {
if (g_Config.bTouchSnapToGrid) { if (g_Config.bTouchSnapToGrid) {
@ -602,7 +597,7 @@ UI::EventReturn TouchControlLayoutScreen::OnMode(UI::EventParams &e) {
} }
void TouchControlLayoutScreen::update() { void TouchControlLayoutScreen::update() {
UIDialogScreenWithBackground::update(); UIDialogScreenWithGameBackground::update();
// TODO: We really, really need a cleaner solution for creating sub-views // TODO: We really, really need a cleaner solution for creating sub-views
// of custom compound controls. // of custom compound controls.