Some minor fixes.

--HG--
branch : dev-2.1
This commit is contained in:
Martín Lucas Golini
2018-01-27 00:44:52 -03:00
parent 6acfd50001
commit 80e04d0d5b
15 changed files with 124 additions and 69 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

View File

@@ -5,6 +5,7 @@
#include <eepp/ui/uiwindow.hpp>
#include <eepp/ui/uispinbox.hpp>
#include <eepp/ui/uilistbox.hpp>
#include <eepp/ui/uigridlayout.hpp>
#include <eepp/ui/uidropdownlist.hpp>
#include <eepp/ui/uiwinmenu.hpp>
#include <eepp/graphics/texturepacker.hpp>
@@ -52,6 +53,7 @@ class EE_API TextureAtlasEditor {
UISpinBox * mSpinDestW;
UISpinBox * mSpinDestH;
UIListBox * mTextureRegionList;
UIGridLayout * mTextureRegionGrid;
UIWinMenu * mWinMenu;
UIDropDownList * mTextureFilterList;
TextureAtlasTextureRegionEditor * mTextureRegionEditor;

View File

@@ -177,6 +177,7 @@ class EE_API UIManager {
Color mHighlightFocusColor;
Color mHighlightOverColor;
Color mHighlightInvalidationColor;
Vector2i mMousePos;
Vector2i mMouseDownPos;
bool mInit;

View File

@@ -46,59 +46,67 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos
mUIContainer = mUIWindow->getContainer();
}
std::string layout =
"<LinearLayout orientation='vertical' layout_width='match_parent' layout_height='match_parent'>"
" <WinMenu layout_width='match_parent' layout_height='wrap_content'>"
" <Menu id='fileMenu' text='File'>"
" <item text='New...' icon='document-new' />"
" <item text='Open...' icon='document-open' />"
" <separator />"
" <item text='Save' icon='document-save' />"
" <separator />"
" <item text='Close' icon='document-close' />"
" <separator />"
" <item text='Quit' icon='quit' />"
" </Menu>"
" </WinMenu>"
" <LinearLayout layout_width='match_parent' layout_height='match_parent' orientation='horizontal'>"
" <TextureAtlasTextureRegionEditor layout_width='match_parent' layout_height='match_parent' layout_weight='1' "
" flags='clip' backgroundColor='#00000032' borderWidth='1' borderColor='#000000FF' />"
" <LinearLayout orientation='vertical' layout_width='205dp' layout_height='match_parent' layout_marginLeft='8dp' layout_marginRight='8dp'>"
" <TextView text='Texture Filter:' fontStyle='shadow' layout_marginTop='4dp' layout_marginBottom='4dp' />"
" <DropDownList id='textureFilter' layout_width='match_parent' layout_height='wrap_content' layout_gravity='center_vertical' selectedText='Linear'>"
" <item>Linear</item>"
" <item>Nearest</item>"
" </DropDownList>"
" <TextView text='TextureRegion List:' fontStyle='shadow' layout_marginTop='8dp' layout_marginBottom='8dp' />"
" <ListBox id='TextureRegionList' layout_width='match_parent' layout_height='144dp' />"
" <TextView text='Current TextureRegion:' fontStyle='shadow' layout_marginTop='16dp' layout_marginBottom='16dp' />"
" <LinearLayout orientation='horizontal' layout_width='match_parent' layout_height='wrap_content'>"
" <TextView text='Offset X:' fontStyle='shadow' layout_width='match_parent' layout_height='wrap_content' layout_weight='1' "
" layout_marginRight='8dp' layout_gravity='center' gravity='right|center_vertical' />"
" <SpinBox id='offX' layout_width='100dp' layout_height='wrap_content' minValue='-32000' maxValue='32000' />"
" </LinearLayout>"
" <LinearLayout orientation='horizontal' layout_width='match_parent' layout_height='wrap_content'>"
" <TextView text='Offset Y:' fontStyle='shadow' layout_width='match_parent' layout_height='wrap_content' layout_weight='1' "
" layout_marginRight='8dp' layout_gravity='center' gravity='right|center_vertical' />"
" <SpinBox id='offY' layout_width='100dp' layout_height='wrap_content' minValue='-32000' maxValue='32000' />"
" </LinearLayout>"
" <LinearLayout orientation='horizontal' layout_width='match_parent' layout_height='wrap_content'>"
" <TextView text='Dest. Width' fontStyle='shadow' layout_width='match_parent' layout_height='wrap_content' layout_weight='1' "
" layout_marginRight='8dp' layout_gravity='center' gravity='right|center_vertical' />"
" <SpinBox id='destW' layout_width='100dp' layout_height='wrap_content' minValue='0' maxValue='32000' />"
" </LinearLayout>"
" <LinearLayout orientation='horizontal' layout_width='match_parent' layout_height='wrap_content'>"
" <TextView text='Dest. Height' fontStyle='shadow' layout_width='match_parent' layout_height='wrap_content' layout_weight='1' "
" layout_marginRight='8dp' layout_gravity='center' gravity='right|center_vertical' />"
" <SpinBox id='destH' layout_width='100dp' layout_height='wrap_content' minValue='0' maxValue='32000' />"
" </LinearLayout>"
" <PushButton id='resetDest' text='Reset Dest. Size' layout_width='match_parent' layout_height='wrap_content' layout_marginBottom='8dp' layout_marginTop='8dp' />"
" <PushButton id='resetOff' text='Reset Offset' layout_width='match_parent' layout_height='wrap_content' layout_marginBottom='8dp' />"
" <PushButton id='centerOff' text='Centered Offset' layout_width='match_parent' layout_height='wrap_content' layout_marginBottom='8dp' />"
" <PushButton id='hbotOff' text='Half-Bottom Offset' layout_width='match_parent' layout_height='wrap_content' layout_marginBottom='8dp' />"
" </LinearLayout>"
" </LinearLayout>"
"</LinearLayout>";
std::string layout = R"xml(
<LinearLayout orientation="vertical" layout_width="match_parent" layout_height="match_parent">
<WinMenu layout_width="match_parent" layout_height="wrap_content">
<Menu id="fileMenu" text="File">
<item text="New..." icon="document-new" />
<item text="Open..." icon="document-open" />
<separator />
<item text="Save" icon="document-save" />
<separator />
<item text="Close" icon="document-close" />
<separator />
<item text="Quit" icon="quit" />
</Menu>
</WinMenu>
<LinearLayout layout_width="match_parent" layout_height="0dp" layout_weight="1" orientation="horizontal">
<TextureAtlasTextureRegionEditor layout_width="match_parent" layout_height="match_parent" layout_weight="1"
flags="clip" backgroundColor="#00000032" borderWidth="1" borderColor="#000000FF" />
<LinearLayout orientation="vertical" layout_width="208dp" layout_height="match_parent" layout_marginLeft="8dp" layout_marginRight="8dp">
<TextView text="Texture Filter:" fontStyle="shadow" layout_marginTop="4dp" layout_marginBottom="4dp" />
<DropDownList id="textureFilter" layout_width="match_parent" layout_height="wrap_content" layout_gravity="center_vertical" selectedText="Linear">
<item>Linear</item>
<item>Nearest</item>
</DropDownList>
<TextView text="TextureRegion List:" fontStyle="shadow" layout_marginTop="8dp" layout_marginBottom="8dp" />
<TabWidget layout_width="match_parent" layout_height="0dp" layout_weight="1">
<ScrollView id="GridView" layout_width="match_parent" layout_height="144dp" touchdrag="true">
<GridLayout columnMode="size" rowMode="size" columnWidth="64dp" rowHeight="64dp" layout_width="match_parent" layout_height="wrap_content" id="gridlayout" />
</ScrollView>
<ListBox id="TextureRegionList" layout_width="match_parent" layout_height="144dp" touchDrag="true" />
<Tab name="List" owns="TextureRegionList" />
<Tab name="Grid" owns="GridView" />
</TabWidget>
<TextView text="Current TextureRegion:" fontStyle="shadow" layout_marginTop="16dp" layout_marginBottom="16dp" />
<LinearLayout orientation="horizontal" layout_width="match_parent" layout_height="wrap_content">
<TextView text="Offset X:" fontStyle="shadow" layout_width="match_parent" layout_height="wrap_content" layout_weight="1"
layout_marginRight="8dp" layout_gravity="center" gravity="right|center_vertical" />
<SpinBox id="offX" layout_width="100dp" layout_height="wrap_content" minValue="-32000" maxValue="32000" />
</LinearLayout>
<LinearLayout orientation="horizontal" layout_width="match_parent" layout_height="wrap_content">
<TextView text="Offset Y:" fontStyle="shadow" layout_width="match_parent" layout_height="wrap_content" layout_weight="1"
layout_marginRight="8dp" layout_gravity="center" gravity="right|center_vertical" />
<SpinBox id="offY" layout_width="100dp" layout_height="wrap_content" minValue="-32000" maxValue="32000" />
</LinearLayout>
<LinearLayout orientation="horizontal" layout_width="match_parent" layout_height="wrap_content">
<TextView text="Dest. Width" fontStyle="shadow" layout_width="match_parent" layout_height="wrap_content" layout_weight="1"
layout_marginRight="8dp" layout_gravity="center" gravity="right|center_vertical" />
<SpinBox id="destW" layout_width="100dp" layout_height="wrap_content" minValue="0" maxValue="32000" />
</LinearLayout>
<LinearLayout orientation="horizontal" layout_width="match_parent" layout_height="wrap_content">
<TextView text="Dest. Height" fontStyle="shadow" layout_width="match_parent" layout_height="wrap_content" layout_weight="1"
layout_marginRight="8dp" layout_gravity="center" gravity="right|center_vertical" />
<SpinBox id="destH" layout_width="100dp" layout_height="wrap_content" minValue="0" maxValue="32000" />
</LinearLayout>
<PushButton id="resetDest" text="Reset Dest. Size" layout_width="match_parent" layout_height="wrap_content" layout_marginBottom="8dp" layout_marginTop="8dp" />
<PushButton id="resetOff" text="Reset Offset" layout_width="match_parent" layout_height="wrap_content" layout_marginBottom="8dp" />
<PushButton id="centerOff" text="Centered Offset" layout_width="match_parent" layout_height="wrap_content" layout_marginBottom="8dp" />
<PushButton id="hbotOff" text="Half-Bottom Offset" layout_width="match_parent" layout_height="wrap_content" layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
)xml";
UIWidgetCreator::addCustomWidgetCallback( "TextureAtlasTextureRegionEditor", cb::Make1( this, &TextureAtlasEditor::createTextureAtlasTextureRegionEditor ) );
@@ -109,6 +117,8 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos
mUIContainer->bind( "TextureRegionList", mTextureRegionList );
mTextureRegionList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &TextureAtlasEditor::onTextureRegionChange ) );
mUIContainer->bind( "gridlayout", mTextureRegionGrid );
mUIContainer->bind( "offX", mSpinOffX );
mSpinOffX->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &TextureAtlasEditor::onOffXChange ) );
@@ -314,11 +324,48 @@ void TextureAtlasEditor::fillTextureRegionList() {
}
mTextureRegionList->getVerticalScrollBar()->setClickStep( 8.f / (Float)mTextureRegionList->getCount() );
if ( Res.size() > 0 ) {
mTextureRegionGrid->childsCloseAll();
for ( auto it = Res.begin(); it != Res.end(); ++it ) {
TextureRegion * tr = (*it);
UIImage::New()
->setDrawable( tr )
->setScaleType( UIScaleType::FitInside )
->setTooltipText( tr->getName() )
->setGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER )
->setParent( mTextureRegionGrid )
->addEventListener( UIEvent::MouseClick, cb::Make1( this, &TextureAtlasEditor::onTextureRegionChange ) );;
}
}
}
void TextureAtlasEditor::onTextureRegionChange( const UIEvent * Event ) {
if ( NULL != mTextureAtlasLoader && NULL != mTextureAtlasLoader->getTextureAtlas() ) {
mCurTextureRegion = mTextureAtlasLoader->getTextureAtlas()->getByName( mTextureRegionList->getItemSelectedText() );
mCurTextureRegion = Event->getControl()->isType( UI_TYPE_IMAGE ) ?
mTextureAtlasLoader->getTextureAtlas()->getByName( static_cast<UIWidget*>( Event->getControl() )->getTooltipText() ) :
mTextureAtlasLoader->getTextureAtlas()->getByName( mTextureRegionList->getItemSelectedText() );
if ( Event->getControl()->isType( UI_TYPE_IMAGE ) )
mTextureRegionList->setSelected( static_cast<UIImage*>( Event->getControl() )->getTooltipText() );
UINode * node = mTextureRegionGrid->getFirstChild();
while ( node ) {
if ( node->isType( UI_TYPE_IMAGE ) ) {
UIImage * curImage = static_cast<UIImage*>( node );
if ( curImage->getDrawable() == mCurTextureRegion ) {
curImage->setBackgroundFillEnabled( true )->setColor( Color( "#00000033" ) );
} else {
curImage->setBackgroundFillEnabled( false );
}
}
node = node->getNextNode();
};
if ( NULL != mCurTextureRegion ) {
mTextureRegionEditor->setTextureRegion( mCurTextureRegion );

View File

@@ -216,34 +216,37 @@ void UIManager::update( const Time& elapsed ) {
mControl->update( elapsed );
UINode * pOver = mControl->overFind( mKM->getMousePosFromView( mWindow->getDefaultView() ) );
Vector2f mousePosf( mKM->getMousePosFromView( mWindow->getDefaultView() ) );
mMousePos = Vector2i( mousePosf.x, mousePosf.y );
UINode * pOver = mControl->overFind( mousePosf );
if ( pOver != mOverControl ) {
if ( NULL != mOverControl ) {
sendMsg( mOverControl, UIMessage::MouseExit );
mOverControl->onMouseExit( mKM->getMousePos(), 0 );
mOverControl->onMouseExit( mMousePos, 0 );
}
mOverControl = pOver;
if ( NULL != mOverControl ) {
sendMsg( mOverControl, UIMessage::MouseEnter );
mOverControl->onMouseEnter( mKM->getMousePos(), 0 );
mOverControl->onMouseEnter( mMousePos, 0 );
}
} else {
if ( NULL != mOverControl )
mOverControl->onMouseMove( mKM->getMousePos(), mKM->getPressTrigger() );
mOverControl->onMouseMove( mMousePos, mKM->getPressTrigger() );
}
if ( mKM->getPressTrigger() ) {
if ( NULL != mOverControl ) {
mOverControl->onMouseDown( mKM->getMousePos(), mKM->getPressTrigger() );
mOverControl->onMouseDown( mMousePos, mKM->getPressTrigger() );
sendMsg( mOverControl, UIMessage::MouseDown, mKM->getPressTrigger() );
}
if ( !mFirstPress ) {
mDownControl = mOverControl;
mMouseDownPos = mKM->getMousePos();
mMouseDownPos = mMousePos;
mFirstPress = true;
}
@@ -255,16 +258,16 @@ void UIManager::update( const Time& elapsed ) {
if ( mOverControl != mFocusControl )
setFocusControl( mOverControl );
mFocusControl->onMouseUp( mKM->getMousePos(), mKM->getReleaseTrigger() );
mFocusControl->onMouseUp( mMousePos, mKM->getReleaseTrigger() );
sendMsg( mFocusControl, UIMessage::MouseUp, mKM->getReleaseTrigger() );
if ( mKM->getClickTrigger() ) {
sendMsg( mFocusControl, UIMessage::Click, mKM->getClickTrigger() );
mFocusControl->onMouseClick( mKM->getMousePos(), mKM->getClickTrigger() );
mFocusControl->onMouseClick( mMousePos, mKM->getClickTrigger() );
if ( mKM->getDoubleClickTrigger() ) {
sendMsg( mFocusControl, UIMessage::DoubleClick, mKM->getDoubleClickTrigger() );
mFocusControl->onMouseDoubleClick( mKM->getMousePos(), mKM->getDoubleClickTrigger() );
mFocusControl->onMouseDoubleClick( mMousePos, mKM->getDoubleClickTrigger() );
}
}
}
@@ -303,7 +306,7 @@ const Time& UIManager::getElapsed() const {
}
Vector2i UIManager::getMousePos() {
return mKM->getMousePos();
return mMousePos;
}
Input * UIManager::getInput() const {

View File

@@ -212,7 +212,7 @@ void UIScrollView::onTouchDragValueChange( Vector2f diff ) {
bool UIScrollView::isTouchOverAllowedChilds() {
bool ret = mViewType == Exclusive ? !mVScroll->isMouseOverMeOrChilds() && !mHScroll->isMouseOverMeOrChilds() : true;
return isMouseOverMeOrChilds() && mScrollView->isMouseOver() && ret;
return isMouseOverMeOrChilds() && mScrollView->isMouseOverMeOrChilds() && ret;
}
void UIScrollView::loadFromXmlNode( const pugi::xml_node& node ) {

View File

@@ -185,7 +185,9 @@ void UITab::loadFromXmlNode(const pugi::xml_node & node) {
std::string name = ait->name();
String::toLowerInPlace( name );
if ( "controlowned" == name || "owns" == name ) {
if ( "name" == name || "text" == name ) {
setText( ait->as_string() );
} else if ( "controlowned" == name || "owns" == name ) {
mOwnedName = ait->as_string();
setOwnedControl();
}

View File

@@ -28,7 +28,7 @@ UITabWidgetStyleConfig UIThemeDefault::getTabWidgetStyleConfig() {
tabWidgetStyleConfig.TabSeparation = -1;
tabWidgetStyleConfig.FontSelectedColor = Color( 255, 255, 255, 255 );
tabWidgetStyleConfig.DrawLineBelowTabs = true;
tabWidgetStyleConfig.LineBelowTabsColor = Color( 0, 0, 0, 255 );
tabWidgetStyleConfig.LineBelowTabsColor = Color( "#2f3030" );
tabWidgetStyleConfig.LineBelowTabsYOffset = -1;
return tabWidgetStyleConfig;
}

View File

@@ -81,8 +81,8 @@ void UITouchDragableWidget::update( const Time& time ) {
}
} else {
// Mouse Down
if ( isTouchOverAllowedChilds() && !manager->isControlDragging() ) {
if ( Press & EE_BUTTON_LMASK ) {
if ( Press & EE_BUTTON_LMASK ) {
if ( isTouchOverAllowedChilds() && !manager->isControlDragging() ) {
writeCtrlFlag( NODE_FLAG_TOUCH_DRAGGING, 1 );
mTouchDragPoint = Vector2f( manager->getMousePos().x, manager->getMousePos().y );