Add traits for customizing RpWidgetWrap instances.
This commit is contained in:
parent
b5fb343d6c
commit
120a52c143
2 changed files with 14 additions and 8 deletions
|
|
@ -160,8 +160,10 @@ bool RpWidgetMethods::handleEvent(QEvent *event) {
|
||||||
return eventHook(event);
|
return eventHook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
RpWidgetMethods::Initer::Initer(QWidget *parent) {
|
RpWidgetMethods::Initer::Initer(QWidget *parent, bool setZeroGeometry) {
|
||||||
parent->setGeometry(0, 0, 0, 0);
|
if (setZeroGeometry) {
|
||||||
|
parent->setGeometry(0, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RpWidgetMethods::visibilityChangedHook(bool wasVisible, bool nowVisible) {
|
void RpWidgetMethods::visibilityChangedHook(bool wasVisible, bool nowVisible) {
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ using RpWidgetParent = std::conditional_t<
|
||||||
TWidget,
|
TWidget,
|
||||||
TWidgetHelper<Widget>>;
|
TWidgetHelper<Widget>>;
|
||||||
|
|
||||||
template <typename Widget>
|
template <typename Widget, typename Traits>
|
||||||
class RpWidgetWrap;
|
class RpWidgetWrap;
|
||||||
|
|
||||||
class RpWidgetMethods {
|
class RpWidgetMethods {
|
||||||
|
|
@ -281,7 +281,7 @@ protected:
|
||||||
virtual bool eventHook(QEvent *event) = 0;
|
virtual bool eventHook(QEvent *event) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename Widget>
|
template <typename Widget, typename Traits>
|
||||||
friend class RpWidgetWrap;
|
friend class RpWidgetWrap;
|
||||||
|
|
||||||
struct EventStreams {
|
struct EventStreams {
|
||||||
|
|
@ -292,7 +292,7 @@ private:
|
||||||
rpl::event_stream<> alive;
|
rpl::event_stream<> alive;
|
||||||
};
|
};
|
||||||
struct Initer {
|
struct Initer {
|
||||||
Initer(QWidget *parent);
|
Initer(QWidget *parent, bool setZeroGeometry);
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void callSetVisible(bool visible) = 0;
|
virtual void callSetVisible(bool visible) = 0;
|
||||||
|
|
@ -310,11 +310,15 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Widget>
|
struct RpWidgetDefaultTraits {
|
||||||
|
static constexpr bool kSetZeroGeometry = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Widget, typename Traits = RpWidgetDefaultTraits>
|
||||||
class RpWidgetWrap
|
class RpWidgetWrap
|
||||||
: public RpWidgetParent<Widget>
|
: public RpWidgetParent<Widget>
|
||||||
, public RpWidgetMethods {
|
, public RpWidgetMethods {
|
||||||
using Self = RpWidgetWrap<Widget>;
|
using Self = RpWidgetWrap<Widget, Traits>;
|
||||||
using Parent = RpWidgetParent<Widget>;
|
using Parent = RpWidgetParent<Widget>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -362,7 +366,7 @@ private:
|
||||||
return this->isHidden();
|
return this->isHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
Initer _initer = { this };
|
Initer _initer = { this, Traits::kSetZeroGeometry };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue