From 901ec7b0da68c2f97ea201d71ed4733e9b99c277 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 8 May 2014 17:38:19 +0000 Subject: [PATCH] Merge revision 4812:4822 from trunk to ogl-es: - Fix compile troubles on VS. Thx @Foaly for reporting. - Animated dwarfes are more fun. - Reset group-page as well when calling CGUIProfiler::firstPage. - Ignore binary 17. - Add examples 17 and 30+ to Linux build support. - Fix warnings. - Fix typo in comment. - CGUIProfiler can now handle it when a group doesn't fit on a single page. - Add interface for easier access to scrollbars for IGUIListBox, IGUITreeView and IGUITable - Add IGUITable::getItemHeight git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4853 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 + examples/17.HelloWorld_Mobile/Makefile | 39 +++++++++++ examples/21.Quake3Explorer/main.cpp | 13 ++-- examples/30.Profiling/main.cpp | 2 +- examples/Makefile | 2 +- include/IGUIListBox.h | 4 ++ include/IGUITable.h | 10 +++ include/IGUITreeView.h | 7 ++ source/Irrlicht/CGUIListBox.cpp | 5 ++ source/Irrlicht/CGUIListBox.h | 3 + source/Irrlicht/CGUIProfiler.cpp | 91 +++++++++++++++++++++----- source/Irrlicht/CGUIProfiler.h | 2 + source/Irrlicht/CGUITable.cpp | 18 +++++ source/Irrlicht/CGUITable.h | 9 +++ source/Irrlicht/CGUITreeView.cpp | 12 ++++ source/Irrlicht/CGUITreeView.h | 6 ++ 16 files changed, 197 insertions(+), 28 deletions(-) create mode 100644 examples/17.HelloWorld_Mobile/Makefile diff --git a/changes.txt b/changes.txt index 478e5bd9..a651cc8f 100644 --- a/changes.txt +++ b/changes.txt @@ -7,6 +7,7 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point) -------------------------- Changes in 1.9 (not yet released) +- Add interface for easier access to scrollbars for IGUIListBox, IGUITreeView and IGUITable - Fix serializing colors as strings. Was previously mixing up strings with number-arrays and hex color values. Now using hex color values always, but also fixed the the handling when it get's number-array strings. - Fix IAttributes::setAttribute implementation for textures (did do nothing before). - Added support for separate blending in OpenGL and D3D9 drivers. @@ -14,6 +15,7 @@ Changes in 1.9 (not yet released) - Added BlendFactor field to SMaterial which allow user to set blending factor per SMaterial set call without use EMT_ONETEXTURE_BLEND type. - Fixed issue with blending operation set to EBO_NONE and some transparent material types. - Add a code profiler (stop-watch style) +- Add IGUITable::getItemHeight to access item (row) height - Add override font to IGUITable - IGUITable can now disable the active column. - IGUIElement::getElementFromPoint now virtual diff --git a/examples/17.HelloWorld_Mobile/Makefile b/examples/17.HelloWorld_Mobile/Makefile new file mode 100644 index 00000000..a29ccaa2 --- /dev/null +++ b/examples/17.HelloWorld_Mobile/Makefile @@ -0,0 +1,39 @@ +# Makefile for Irrlicht Examples +# It's usually sufficient to change just the target name and source file list +# and be sure that CXX is set to a valid compiler +Target = 17.HelloWorld_Mobile +Sources = main.cpp + +# general compiler settings +CPPFLAGS = -I../../include -I/usr/X11R6/include +CXXFLAGS = -O3 -ffast-math +#CXXFLAGS = -g -Wall + +#default target is Linux +all: all_linux + +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif + +# target specific settings +all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor +all_linux clean_linux: SYSTEM=Linux +all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm +all_win32: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL +all_win32 clean_win32: SYSTEM=Win32-gcc +all_win32 clean_win32: SUF=.exe +# name of the binary - only valid for targets which set SYSTEM +DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) + +all_linux all_win32: + $(warning Building...) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS) + +clean: clean_linux clean_win32 + $(warning Cleaning...) + +clean_linux clean_win32: + @$(RM) $(DESTPATH) + +.PHONY: all all_win32 clean clean_linux clean_win32 diff --git a/examples/21.Quake3Explorer/main.cpp b/examples/21.Quake3Explorer/main.cpp index 822611b2..2634aafa 100644 --- a/examples/21.Quake3Explorer/main.cpp +++ b/examples/21.Quake3Explorer/main.cpp @@ -378,13 +378,11 @@ void Q3Player::respawn () Device->getLogger()->log( "respawn" ); - if ( StartPositionCurrent >= Q3StartPosition ( - Mesh, camera,StartPositionCurrent++, - cam ()->getEllipsoidTranslation() ) - ) - { + if (StartPositionCurrent >= Q3StartPosition(Mesh, camera, + StartPositionCurrent, cam()->getEllipsoidTranslation())) StartPositionCurrent = 0; - } + else + ++StartPositionCurrent; } /* @@ -2023,12 +2021,11 @@ void CQuake3EventHandler::Animate() // Query Scene Manager attributes if ( player->Anim[0].flags & FIRED ) { - ISceneManager *smgr = Game->Device->getSceneManager (); wchar_t msg[128]; IVideoDriver * driver = Game->Device->getVideoDriver(); - IAttributes * attr = smgr->getParameters(); #ifdef _IRR_SCENEMANAGER_DEBUG + IAttributes * attr = Game->Device->getSceneManager()->getParameters(); swprintf ( msg, 128, L"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)", Game->CurrentMapName.c_str(), diff --git a/examples/30.Profiling/main.cpp b/examples/30.Profiling/main.cpp index e2b3e4b1..98cc2817 100644 --- a/examples/30.Profiling/main.cpp +++ b/examples/30.Profiling/main.cpp @@ -255,7 +255,7 @@ public: { irr::f32 gapZ = z > 0 ? (z-1)*GAP : 0.f; irr::f32 posZ = -halfSizeZ + z*extent.Z + gapZ; - scene::IMeshSceneNode * node = SceneManager->addMeshSceneNode (mesh, NULL, -1, vector3df(posX, posY, posZ) ); + scene::IAnimatedMeshSceneNode * node = SceneManager->addAnimatedMeshSceneNode(aniMesh, NULL, -1, vector3df(posX, posY, posZ) ); node->setMaterialFlag(video::EMF_LIGHTING, false); } } diff --git a/examples/Makefile b/examples/Makefile index da658814..e187a005 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,4 +1,4 @@ -DIRS = $(wildcard [012]* Demo) +DIRS = $(wildcard [0123]* Demo) all: $(DIRS) diff --git a/include/IGUIListBox.h b/include/IGUIListBox.h index 0af7d7cf..227e4449 100644 --- a/include/IGUIListBox.h +++ b/include/IGUIListBox.h @@ -13,6 +13,7 @@ namespace irr namespace gui { class IGUISpriteBank; + class IGUIScrollBar; //! Enumeration for listbox colors enum EGUI_LISTBOX_COLOR @@ -128,6 +129,9 @@ namespace gui //! Sets whether to draw the background virtual void setDrawBackground(bool draw) = 0; + + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const = 0; }; diff --git a/include/IGUITable.h b/include/IGUITable.h index 5b4d6890..e9531c5c 100644 --- a/include/IGUITable.h +++ b/include/IGUITable.h @@ -13,6 +13,7 @@ namespace irr namespace gui { class IGUIFont; + class IGUIScrollBar; //! modes for ordering used when a column header is clicked enum EGUI_COLUMN_ORDERING @@ -208,6 +209,15 @@ namespace gui /** Currently this is the override font when one is set and the font of the active skin otherwise */ virtual IGUIFont* getActiveFont() const = 0; + + //! Get the height of items/rows + virtual s32 getItemHeight() const = 0; + + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const = 0; + + //! Access the horizontal scrollbar + virtual IGUIScrollBar* getHorizontalScrollBar() const = 0; }; diff --git a/include/IGUITreeView.h b/include/IGUITreeView.h index 31991b05..95bf5857 100644 --- a/include/IGUITreeView.h +++ b/include/IGUITreeView.h @@ -15,6 +15,7 @@ namespace gui { class IGUIFont; class IGUITreeView; + class IGUIScrollBar; //! Node for gui tree view @@ -268,6 +269,12 @@ namespace gui //! Returns the node which is associated to the last event. /** This pointer is only valid inside the OnEvent call! */ virtual IGUITreeViewNode* getLastEventNode() const = 0; + + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const = 0; + + //! Access the horizontal scrollbar + virtual IGUIScrollBar* getHorizontalScrollBar() const = 0; }; diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 67501200..3cc008ef 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -906,6 +906,11 @@ void CGUIListBox::setDrawBackground(bool draw) DrawBack = draw; } +//! Access the vertical scrollbar +IGUIScrollBar* CGUIListBox::getVerticalScrollBar() const +{ + return ScrollBar; +} } // end namespace gui } // end namespace irr diff --git a/source/Irrlicht/CGUIListBox.h b/source/Irrlicht/CGUIListBox.h index 4b64898d..a94b7932 100644 --- a/source/Irrlicht/CGUIListBox.h +++ b/source/Irrlicht/CGUIListBox.h @@ -131,6 +131,9 @@ namespace gui //! Sets whether to draw the background virtual void setDrawBackground(bool draw) _IRR_OVERRIDE_; + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const _IRR_OVERRIDE_; + private: struct ListItem diff --git a/source/Irrlicht/CGUIProfiler.cpp b/source/Irrlicht/CGUIProfiler.cpp index 5fa3d61f..d929b120 100644 --- a/source/Irrlicht/CGUIProfiler.cpp +++ b/source/Irrlicht/CGUIProfiler.cpp @@ -2,14 +2,11 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h // Written by Michael Zeilfelder -// TODO: We should have more pages for groups that don't fit into the display area. -// So additional to CurrentGroupIdx we would also have a current-page-for-current-group thing. -// The interface doesn't have to be changed for that - just the implementation. - #include "CGUIProfiler.h" #ifdef _IRR_COMPILE_WITH_GUI_ #include "IGUITable.h" +#include "IGUIScrollBar.h" #include "IGUIEnvironment.h" #include "CProfiler.h" @@ -21,7 +18,7 @@ namespace gui //! constructor CGUIProfiler::CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) : IGUIProfiler(environment, parent, id, rectangle) - , DisplayTable(0), CurrentGroupIdx(0), IgnoreUncalled(false) + , DisplayTable(0), CurrentGroupIdx(0), CurrentGroupPage(0), NumGroupPages(1), IgnoreUncalled(false) { Profiler = &getProfiler(); @@ -118,6 +115,49 @@ void CGUIProfiler::updateDisplay() } } } + + // IGUITable has no page-wise scrolling yet. The following code can be replaced when we add that. + // For now we use some CGUITable implementation info to figure this out. + // (If you wonder why I didn't code page-scrolling directly in CGUITable ... because then it needs to be a + // public interface and I don't have enough time currently to design & implement that well) + s32 itemsTotalHeight = DisplayTable->getRowCount() * DisplayTable->getItemHeight(); + s32 tableHeight = DisplayTable->getAbsolutePosition().getHeight(); + s32 heightTitleRow = DisplayTable->getItemHeight()+1; + if ( itemsTotalHeight+heightTitleRow < tableHeight ) + { + NumGroupPages = 1; + } + else + { + s32 heightHScrollBar = DisplayTable->getHorizontalScrollBar() ? DisplayTable->getHorizontalScrollBar()->getAbsolutePosition().getHeight() : 0; + s32 pageHeight = tableHeight - (heightTitleRow+heightHScrollBar); + if ( pageHeight > 0 ) + { + NumGroupPages = (itemsTotalHeight/pageHeight); + if ( itemsTotalHeight % pageHeight ) + ++NumGroupPages; + } + else // won't see anything, but that's up to the user + { + NumGroupPages = DisplayTable->getRowCount(); + } + if ( NumGroupPages < 1 ) + NumGroupPages = 1; + } + if ( CurrentGroupPage < 0 ) + CurrentGroupPage = (s32)NumGroupPages-1; + + IGUIScrollBar* vScrollBar = DisplayTable->getVerticalScrollBar(); + if ( vScrollBar ) + { + if ( NumGroupPages < 2 ) + vScrollBar->setPos(0); + else + { + f32 factor = (f32)CurrentGroupPage/(f32)(NumGroupPages-1); + vScrollBar->setPos( s32(factor * (f32)vScrollBar->getMax()) ); + } + } } } @@ -133,27 +173,41 @@ void CGUIProfiler::draw() void CGUIProfiler::nextPage(bool includeOverview) { - if ( ++CurrentGroupIdx >= Profiler->getGroupCount() ) + if ( CurrentGroupPage < NumGroupPages-1 ) + ++CurrentGroupPage; + else { - if ( includeOverview ) - CurrentGroupIdx = 0; - else - CurrentGroupIdx = 1; // can be invalid + CurrentGroupPage = 0; + if ( ++CurrentGroupIdx >= Profiler->getGroupCount() ) + { + if ( includeOverview ) + CurrentGroupIdx = 0; + else + CurrentGroupIdx = 1; // can be invalid + } } } void CGUIProfiler::previousPage(bool includeOverview) { - if ( CurrentGroupIdx > 0 ) - --CurrentGroupIdx; - else - CurrentGroupIdx = Profiler->getGroupCount()-1; - if ( CurrentGroupIdx == 0 && !includeOverview ) + if ( CurrentGroupPage > 0 ) { - if ( Profiler->getGroupCount() ) + --CurrentGroupPage; + } + else + { + CurrentGroupPage = -1; // unknown because NumGroupPages has to be re-calculated first + if ( CurrentGroupIdx > 0 ) + --CurrentGroupIdx; + else CurrentGroupIdx = Profiler->getGroupCount()-1; - if ( CurrentGroupIdx == 0 ) - CurrentGroupIdx = 1; // invalid to avoid showing the overview + if ( CurrentGroupIdx == 0 && !includeOverview ) + { + if ( Profiler->getGroupCount() ) + CurrentGroupIdx = Profiler->getGroupCount()-1; + if ( CurrentGroupIdx == 0 ) + CurrentGroupIdx = 1; // invalid to avoid showing the overview + } } } @@ -163,6 +217,7 @@ void CGUIProfiler::firstPage(bool includeOverview) CurrentGroupIdx = 0; else CurrentGroupIdx = 1; // can be invalid + CurrentGroupPage = 0; } diff --git a/source/Irrlicht/CGUIProfiler.h b/source/Irrlicht/CGUIProfiler.h index e2c5616c..847296b8 100644 --- a/source/Irrlicht/CGUIProfiler.h +++ b/source/Irrlicht/CGUIProfiler.h @@ -69,6 +69,8 @@ namespace gui IProfiler * Profiler; irr::gui::IGUITable* DisplayTable; irr::u32 CurrentGroupIdx; + irr::s32 CurrentGroupPage; + irr::s32 NumGroupPages; bool IgnoreUncalled; }; diff --git a/source/Irrlicht/CGUITable.cpp b/source/Irrlicht/CGUITable.cpp index 336685ba..bde36e05 100644 --- a/source/Irrlicht/CGUITable.cpp +++ b/source/Irrlicht/CGUITable.cpp @@ -1099,6 +1099,24 @@ IGUIFont* CGUITable::getActiveFont() const return 0; } +//! Get the height of items/rows +s32 CGUITable::getItemHeight() const +{ + return ItemHeight; +} + +//! Access the vertical scrollbar +IGUIScrollBar* CGUITable::getVerticalScrollBar() const +{ + return VerticalScrollBar; +} + +//! Access the horizontal scrollbar +IGUIScrollBar* CGUITable::getHorizontalScrollBar() const +{ + return HorizontalScrollBar; +} + //! Writes attributes of the element. void CGUITable::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const { diff --git a/source/Irrlicht/CGUITable.h b/source/Irrlicht/CGUITable.h index 3520367d..46ac059f 100644 --- a/source/Irrlicht/CGUITable.h +++ b/source/Irrlicht/CGUITable.h @@ -152,6 +152,15 @@ namespace gui //! Get the font which is used right now for drawing virtual IGUIFont* getActiveFont() const _IRR_OVERRIDE_; + //! Get the height of items/rows + virtual s32 getItemHeight() const _IRR_OVERRIDE_; + + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const _IRR_OVERRIDE_; + + //! Access the horizontal scrollbar + virtual IGUIScrollBar* getHorizontalScrollBar() const _IRR_OVERRIDE_; + //! Writes attributes of the object. //! Implement this to expose the attributes of your scene node animator for //! scripting languages, editors, debuggers or xml serialization purposes. diff --git a/source/Irrlicht/CGUITreeView.cpp b/source/Irrlicht/CGUITreeView.cpp index 7fca465f..25e18a0a 100644 --- a/source/Irrlicht/CGUITreeView.cpp +++ b/source/Irrlicht/CGUITreeView.cpp @@ -1081,6 +1081,18 @@ void CGUITreeView::setImageList( IGUIImageList* imageList ) } } +//! Access the vertical scrollbar +IGUIScrollBar* CGUITreeView::getVerticalScrollBar() const +{ + return ScrollBarV; +} + +//! Access the horizontal scrollbar +IGUIScrollBar* CGUITreeView::getHorizontalScrollBar() const +{ + return ScrollBarH; +} + } // end namespace gui } // end namespace irr diff --git a/source/Irrlicht/CGUITreeView.h b/source/Irrlicht/CGUITreeView.h index 56c52a5f..0408a911 100644 --- a/source/Irrlicht/CGUITreeView.h +++ b/source/Irrlicht/CGUITreeView.h @@ -297,6 +297,12 @@ namespace gui virtual IGUITreeViewNode* getLastEventNode() const _IRR_OVERRIDE_ { return LastEventNode; } + //! Access the vertical scrollbar + virtual IGUIScrollBar* getVerticalScrollBar() const _IRR_OVERRIDE_; + + //! Access the horizontal scrollbar + virtual IGUIScrollBar* getHorizontalScrollBar() const _IRR_OVERRIDE_; + private: //! calculates the heigth of an node and of all visible nodes. void recalculateItemHeight();