mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 10:06:35 +03:00
Some minor fixes in URI and http_request demo.
Fixed a crash in UIDropDownList. Some fixes in all UILayouts.
This commit is contained in:
@@ -122,7 +122,7 @@ class EE_API URI {
|
||||
const std::string& getHost() const;
|
||||
|
||||
/** Sets the host part of the URI. */
|
||||
void getHost( const std::string& host );
|
||||
void setHost( const std::string& host );
|
||||
|
||||
/** @returns the port number part of the URI.
|
||||
* If no port number (0) has been specified, the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef EE_UI_UIGRIDLAYOUT
|
||||
#ifndef EE_UI_UIGRIDLAYOUT
|
||||
#define EE_UI_UIGRIDLAYOUT
|
||||
|
||||
#include <eepp/ui/uilayout.hpp>
|
||||
@@ -63,6 +63,8 @@ class EE_API UIGridLayout : public UILayout {
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
virtual void onParentSizeChange( const Vector2f& size );
|
||||
|
||||
Sizef getTargetElementSize() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class EE_API UILayout : public UIWidget {
|
||||
|
||||
std::unordered_set<UILayout*> mLayouts;
|
||||
bool mDirtyLayout;
|
||||
bool mPacking;
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -36,7 +36,6 @@ class EE_API UILinearLayout : public UILayout {
|
||||
|
||||
protected:
|
||||
UIOrientation mOrientation;
|
||||
bool mPacking;
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ void URI::setUserInfo( const std::string& userInfo ) {
|
||||
decode( userInfo, mUserInfo );
|
||||
}
|
||||
|
||||
void URI::getHost( const std::string& host ) {
|
||||
void URI::setHost( const std::string& host ) {
|
||||
mHost = host;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,8 +347,7 @@ Texture* UIColorPicker::createHueTexture( const Sizef& size ) {
|
||||
hsva.hsv.h = 360.f - 360.f * y / image.getHeight();
|
||||
hsva.hsv.s = 1.f;
|
||||
hsva.hsv.v = 1.f;
|
||||
Color color( Color::fromHsv( hsva ) );
|
||||
image.setPixel( 0, y, color );
|
||||
image.setPixel( 0, y, Color::fromHsv( hsva ) );
|
||||
}
|
||||
|
||||
TextureFactory* TF = TextureFactory::instance();
|
||||
|
||||
@@ -46,6 +46,9 @@ UIDropDownList::UIDropDownList( const std::string& tag ) :
|
||||
mListBox->addEventListener( Event::KeyDown, cb::Make1( this, &UIDropDownList::onItemKeyDown ) );
|
||||
mListBox->addEventListener( Event::OnControlClear,
|
||||
cb::Make1( this, &UIDropDownList::onControlClear ) );
|
||||
mListBox->addEventListener( Event::OnClose, [&]( const Event*) {
|
||||
mListBox = NULL;
|
||||
} );
|
||||
}
|
||||
|
||||
UIDropDownList::~UIDropDownList() {
|
||||
@@ -99,7 +102,7 @@ UIListBox* UIDropDownList::getListBox() const {
|
||||
}
|
||||
|
||||
Uint32 UIDropDownList::onMouseUp( const Vector2i& Pos, const Uint32& Flags ) {
|
||||
if ( mEnabled && mVisible && isMouseOver() ) {
|
||||
if ( mEnabled && mVisible && isMouseOver() && NULL != mListBox ) {
|
||||
if ( Flags & EE_BUTTONS_WUWD ) {
|
||||
if ( Flags & EE_BUTTON_WUMASK ) {
|
||||
mListBox->selectPrev();
|
||||
@@ -128,6 +131,9 @@ Uint32 UIDropDownList::onMouseClick( const Vector2i& Pos, const Uint32& Flags )
|
||||
}
|
||||
|
||||
void UIDropDownList::showList() {
|
||||
if ( NULL == mListBox )
|
||||
return;
|
||||
|
||||
if ( !mListBox->isVisible() ) {
|
||||
if ( !mStyleConfig.PopUpToRoot )
|
||||
mListBox->setParent( getWindowContainer() );
|
||||
@@ -196,8 +202,9 @@ void UIDropDownList::setMaxNumVisibleItems( const Uint32& maxNumVisibleItems ) {
|
||||
if ( maxNumVisibleItems != mStyleConfig.MaxNumVisibleItems ) {
|
||||
mStyleConfig.MaxNumVisibleItems = maxNumVisibleItems;
|
||||
|
||||
mListBox->setSize( getSize().getWidth(),
|
||||
mStyleConfig.MaxNumVisibleItems * mListBox->getRowHeight() );
|
||||
if ( NULL != mListBox )
|
||||
mListBox->setSize( getSize().getWidth(),
|
||||
mStyleConfig.MaxNumVisibleItems * mListBox->getRowHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +258,9 @@ void UIDropDownList::onItemSelected( const Event* ) {
|
||||
}
|
||||
|
||||
void UIDropDownList::show() {
|
||||
if ( NULL == mListBox )
|
||||
return;
|
||||
|
||||
mListBox->setEnabled( true );
|
||||
mListBox->setVisible( true );
|
||||
|
||||
@@ -264,6 +274,9 @@ void UIDropDownList::show() {
|
||||
}
|
||||
|
||||
void UIDropDownList::hide() {
|
||||
if ( NULL == mListBox )
|
||||
return;
|
||||
|
||||
if ( NULL != getUISceneNode() &&
|
||||
getUISceneNode()->getUIThemeManager()->getDefaultEffectsEnabled() ) {
|
||||
mListBox->runAction( Actions::Sequence::New(
|
||||
@@ -293,13 +306,14 @@ Uint32 UIDropDownList::onMouseLeave( const Vector2i& position, const Uint32& fla
|
||||
}
|
||||
|
||||
Uint32 UIDropDownList::onKeyDown( const KeyEvent& Event ) {
|
||||
mListBox->onKeyDown( Event );
|
||||
if ( NULL != mListBox )
|
||||
mListBox->onKeyDown( Event );
|
||||
|
||||
return UITextInput::onKeyDown( Event );
|
||||
}
|
||||
|
||||
void UIDropDownList::destroyListBox() {
|
||||
if ( !SceneManager::instance()->isShootingDown() ) {
|
||||
if ( !SceneManager::instance()->isShootingDown() && NULL != mListBox ) {
|
||||
mListBox->close();
|
||||
}
|
||||
}
|
||||
@@ -321,7 +335,10 @@ bool UIDropDownList::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::RowHeight:
|
||||
case PropertyId::VScrollMode:
|
||||
case PropertyId::HScrollMode:
|
||||
return mListBox->applyProperty( attribute );
|
||||
if ( NULL != mListBox )
|
||||
return mListBox->applyProperty( attribute );
|
||||
else
|
||||
return false;
|
||||
default:
|
||||
return UITextInput::applyProperty( attribute );
|
||||
}
|
||||
@@ -345,16 +362,20 @@ std::string UIDropDownList::getPropertyString( const PropertyDefinition* propert
|
||||
case PropertyId::RowHeight:
|
||||
case PropertyId::VScrollMode:
|
||||
case PropertyId::HScrollMode:
|
||||
return mListBox->getPropertyString( propertyDef, propertyIndex );
|
||||
if ( NULL != mListBox )
|
||||
return mListBox->getPropertyString( propertyDef, propertyIndex );
|
||||
default:
|
||||
return UITextInput::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void UIDropDownList::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginAttributesTransaction();
|
||||
|
||||
mListBox->loadItemsFromXmlNode( node );
|
||||
if ( NULL != mListBox )
|
||||
mListBox->loadItemsFromXmlNode( node );
|
||||
|
||||
UITextInput::loadFromXmlNode( node );
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ UIGridLayout* UIGridLayout::setRowWeight( const Float& rowWeight ) {
|
||||
}
|
||||
|
||||
void UIGridLayout::updateLayout() {
|
||||
if ( mPacking )
|
||||
return;
|
||||
mPacking = true;
|
||||
Sizef oldSize( getSize() );
|
||||
|
||||
if ( getParent()->isUINode() && !getParent()->asType<UINode>()->ownsChildPosition() ) {
|
||||
@@ -191,6 +194,7 @@ void UIGridLayout::updateLayout() {
|
||||
|
||||
invalidateDraw();
|
||||
mDirtyLayout = false;
|
||||
mPacking = false;
|
||||
}
|
||||
|
||||
Uint32 UIGridLayout::onMessage( const NodeMessage* Msg ) {
|
||||
@@ -204,6 +208,11 @@ Uint32 UIGridLayout::onMessage( const NodeMessage* Msg ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UIGridLayout::onParentSizeChange( const Vector2f& size ) {
|
||||
tryUpdateLayout();
|
||||
UILayout::onParentSizeChange( size );
|
||||
}
|
||||
|
||||
Sizef UIGridLayout::getTargetElementSize() const {
|
||||
return Sizef( mColumnMode == Size ? mColumnWidth
|
||||
: ( ( getLayoutHeightPolicy() == SizePolicy::WrapContent
|
||||
|
||||
@@ -7,11 +7,12 @@ UILayout* UILayout::New() {
|
||||
return eeNew( UILayout, () );
|
||||
}
|
||||
|
||||
UILayout::UILayout() : UIWidget( "layout" ), mDirtyLayout( false ) {
|
||||
UILayout::UILayout() : UIWidget( "layout" ), mDirtyLayout( false ), mPacking( false ) {
|
||||
mNodeFlags |= NODE_FLAG_LAYOUT;
|
||||
}
|
||||
|
||||
UILayout::UILayout( const std::string& tag ) : UIWidget( tag ), mDirtyLayout( false ) {
|
||||
UILayout::UILayout( const std::string& tag ) :
|
||||
UIWidget( tag ), mDirtyLayout( false ), mPacking( false ) {
|
||||
mNodeFlags |= NODE_FLAG_LAYOUT;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,10 @@ void UILayout::onPaddingChange() {
|
||||
|
||||
void UILayout::onParentSizeChange( const Vector2f& ) {
|
||||
UIWidget::onParentChange();
|
||||
tryUpdateLayout();
|
||||
if ( !getParent()->isLayout() ) {
|
||||
mPacking = false;
|
||||
tryUpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void UILayout::onLayoutUpdate() {
|
||||
|
||||
@@ -17,7 +17,7 @@ UILinearLayout* UILinearLayout::NewHorizontal() {
|
||||
}
|
||||
|
||||
UILinearLayout::UILinearLayout() :
|
||||
UILayout( "linearlayout" ), mOrientation( UIOrientation::Vertical ), mPacking( false ) {
|
||||
UILayout( "linearlayout" ), mOrientation( UIOrientation::Vertical ) {
|
||||
mFlags |= UI_OWNS_CHILDS_POSITION;
|
||||
clipEnable();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ UIListBox::UIListBox( const std::string& tag ) :
|
||||
mSmoothScroll( true ) {
|
||||
setFlags( UI_AUTO_PADDING );
|
||||
|
||||
auto cb = [&]( const Event* event ) { containerResize(); };
|
||||
auto cb = [&]( const Event* ) { containerResize(); };
|
||||
|
||||
mContainer = eeNew( UIItemContainer<UIListBox>, () );
|
||||
mContainer->setParent( this );
|
||||
@@ -84,7 +84,9 @@ UIListBox::UIListBox( const std::string& tag ) :
|
||||
|
||||
UIListBox::UIListBox() : UIListBox( "listbox" ) {}
|
||||
|
||||
UIListBox::~UIListBox() {}
|
||||
UIListBox::~UIListBox() {
|
||||
onClose();
|
||||
}
|
||||
|
||||
Uint32 UIListBox::getType() const {
|
||||
return UI_TYPE_LISTBOX;
|
||||
|
||||
@@ -25,6 +25,9 @@ UIRelativeLayout* UIRelativeLayout::add( UIWidget* widget ) {
|
||||
}
|
||||
|
||||
void UIRelativeLayout::updateLayout() {
|
||||
if ( mPacking )
|
||||
return;
|
||||
mPacking = true;
|
||||
if ( getParent()->isUINode() && !getParent()->asType<UINode>()->ownsChildPosition() ) {
|
||||
setInternalPosition( Vector2f( mLayoutMargin.Left, mLayoutMargin.Top ) );
|
||||
}
|
||||
@@ -64,6 +67,7 @@ void UIRelativeLayout::updateLayout() {
|
||||
}
|
||||
|
||||
mDirtyLayout = false;
|
||||
mPacking = false;
|
||||
}
|
||||
|
||||
void UIRelativeLayout::fixChildPos( UIWidget* widget ) {
|
||||
|
||||
@@ -150,7 +150,8 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
totalBytes != currentBytes )
|
||||
return true;
|
||||
tickElapsed.restart();
|
||||
double progress = currentBytes / static_cast<double>( totalBytes );
|
||||
double progress =
|
||||
totalBytes > 0 ? currentBytes / static_cast<double>( totalBytes ) : 0;
|
||||
Time eta( elapsed.getElapsedTime() / progress - elapsed.getElapsedTime() );
|
||||
int percent = static_cast<int>( eefloor( progress * 100. ) );
|
||||
std::string bytesProgress( String::format(
|
||||
@@ -194,7 +195,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
httpProxy = proxy.Get();
|
||||
}
|
||||
|
||||
if ( httpProxy.find( "://" ) == std::string::npos ) {
|
||||
if ( !httpProxy.empty() && httpProxy.find( "://" ) == std::string::npos ) {
|
||||
httpProxy = "http://" + httpProxy;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user