mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-31 07:10:28 -04:00
move clipping rect fix to scrolllayer
This commit is contained in:
parent
bdc6eb1283
commit
eeeedbb9c4
3 changed files with 23 additions and 17 deletions
loader
|
@ -24,6 +24,8 @@ namespace geode {
|
|||
|
||||
bool ccTouchBegan(cocos2d::CCTouch*, cocos2d::CCEvent*) override;
|
||||
|
||||
void visit() override;
|
||||
|
||||
public:
|
||||
static ScrollLayer* create(
|
||||
cocos2d::CCRect const& rect, bool scrollWheelEnabled = true, bool vertical = true
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#include <Geode/modify/GameToolbox.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
struct MyGameToolbox : Modify<MyGameToolbox, GameToolbox> {
|
||||
GEODE_FORWARD_COMPAT_DISABLE_HOOKS("FixClippingRect disabled")
|
||||
static void preVisitWithClippingRect(CCNode* node, CCRect rect) {
|
||||
if (node->isVisible()) {
|
||||
glEnable(0xc11);
|
||||
if (node->getParent()) {
|
||||
// rob messed this up somehow causing nested ScrollLayers to be not clipped properly
|
||||
rect.origin = node->getParent()->convertToWorldSpace(rect.origin);
|
||||
}
|
||||
CCEGLView::get()->setScissorInPoints(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -24,6 +24,27 @@ void GenericContentLayer::setPosition(CCPoint const& pos) {
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollLayer::visit() {
|
||||
if (m_cutContent) {
|
||||
auto rect = CCRect(this->getPosition(), this->getScaledContentSize());
|
||||
|
||||
if (this->getParent()) {
|
||||
// rob messed this up somehow causing nested ScrollLayers to be not clipped properly
|
||||
// this: this->getParent()->convertToWorldSpace(this->getParent()->getPosition() + rect.origin);
|
||||
rect.origin = this->getParent()->convertToWorldSpace(rect.origin);
|
||||
}
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
CCEGLView::get()->setScissorInPoints(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||
}
|
||||
|
||||
CCNode::visit();
|
||||
|
||||
if (m_cutContent) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollLayer::scrollWheel(float y, float) {
|
||||
if (m_scrollWheelEnabled) {
|
||||
this->scrollLayer(y);
|
||||
|
|
Loading…
Add table
Reference in a new issue