Nux

Merge lp:~haggai-eran/nux/rtl into lp:nux

Proposed by Haggai Eran
Status: Needs review
Proposed branch: lp:~haggai-eran/nux/rtl
Merge into: lp:nux
Diff against target: 138259 lines (+28058/-67159)
532 files modified
Nux/AbstractButton.cpp (+87/-51)
Nux/AbstractButton.h (+102/-31)
Nux/AbstractCheckedButton.cpp (+217/-0)
Nux/AbstractCheckedButton.h (+110/-0)
Nux/AbstractComboBox.cpp (+57/-57)
Nux/AbstractComboBox.h (+9/-10)
Nux/AbstractPaintLayer.cpp (+28/-28)
Nux/AbstractPaintLayer.h (+11/-11)
Nux/AbstractRadioButton.cpp (+0/-41)
Nux/AbstractRadioButton.h (+0/-48)
Nux/AbstractSeparator.cpp (+0/-70)
Nux/AbstractSeparator.h (+0/-48)
Nux/AbstractThread.cpp (+5/-5)
Nux/AbstractThread.h (+11/-11)
Nux/ActionItem.cpp (+42/-42)
Nux/AnimatedTextureArea.cpp (+39/-44)
Nux/AnimatedTextureArea.h (+8/-9)
Nux/Area.cpp (+469/-442)
Nux/Area.h (+224/-180)
Nux/BaseWindow.cpp (+111/-181)
Nux/BaseWindow.h (+41/-46)
Nux/BezierCurveControl.cpp (+0/-343)
Nux/BezierCurveControl.h (+0/-105)
Nux/BezierCurveControl2.cpp (+0/-1046)
Nux/BezierCurveControl2.h (+0/-145)
Nux/Button.cpp (+421/-161)
Nux/Button.h (+215/-22)
Nux/Canvas.cpp (+17/-26)
Nux/Canvas.h (+3/-6)
Nux/CheckBox.cpp (+69/-86)
Nux/CheckBox.h (+55/-19)
Nux/ClientArea.cpp (+117/-134)
Nux/ClientArea.h (+15/-16)
Nux/ColorArea.cpp (+0/-68)
Nux/ColorArea.h (+0/-46)
Nux/ColorEditor.cpp (+609/-639)
Nux/ColorEditor.h (+84/-55)
Nux/ColorGradient.cpp (+0/-386)
Nux/ColorGradient.h (+0/-417)
Nux/ColorPickerDialog.cpp (+12/-12)
Nux/ColorPickerDialog.h (+1/-1)
Nux/ColorPreview.cpp (+47/-55)
Nux/ColorPreview.h (+5/-6)
Nux/ColorRangeValuator.cpp (+0/-77)
Nux/ColorRangeValuator.h (+0/-56)
Nux/ComboBoxComplex.cpp (+0/-337)
Nux/ComboBoxComplex.h (+0/-95)
Nux/ComboBoxSimple.cpp (+68/-185)
Nux/ComboBoxSimple.h (+19/-23)
Nux/CurveControl.cpp (+0/-172)
Nux/CurveControl.h (+0/-57)
Nux/D2DTextRenderer.cpp (+436/-0)
Nux/D2DTextRenderer.h (+100/-0)
Nux/Dialog.cpp (+23/-23)
Nux/DoubleValidator.cpp (+21/-21)
Nux/DoubleValidator.h (+14/-14)
Nux/EditTextBox.cpp (+165/-172)
Nux/EditTextBox.h (+59/-60)
Nux/FileSelector.cpp (+59/-68)
Nux/FileSelector.h (+7/-9)
Nux/FloatingWindow.cpp (+110/-185)
Nux/FloatingWindow.h (+18/-19)
Nux/Focusable.cpp (+0/-117)
Nux/Focusable.h (+0/-67)
Nux/FolderTreeItem.cpp (+0/-109)
Nux/FolderTreeItem.h (+0/-94)
Nux/FunctionGraph.cpp (+0/-201)
Nux/FunctionGraph.h (+0/-67)
Nux/GridHLayout.cpp (+405/-208)
Nux/GridHLayout.h (+33/-25)
Nux/GridVLayout.cpp (+70/-80)
Nux/GridVLayout.h (+18/-18)
Nux/GroupBox.cpp (+63/-86)
Nux/GroupBox.h (+8/-9)
Nux/GroupBox2.cpp (+73/-87)
Nux/GroupBox2.h (+8/-9)
Nux/HLayout.cpp (+268/-225)
Nux/HLayout.h (+6/-8)
Nux/HScrollBar.cpp (+152/-164)
Nux/HScrollBar.h (+33/-37)
Nux/HSeparator.cpp (+0/-95)
Nux/HSeparator.h (+0/-50)
Nux/HSplitter.cpp (+168/-168)
Nux/HSplitter.h (+19/-19)
Nux/HToolBar.cpp (+0/-204)
Nux/HToolBar.h (+0/-68)
Nux/HexRegExpValidator.cpp (+26/-26)
Nux/HexRegExpValidator.h (+10/-10)
Nux/Histogram.cpp (+0/-201)
Nux/Histogram.h (+0/-59)
Nux/HueRangeValuator.cpp (+0/-130)
Nux/HueRangeValuator.h (+0/-92)
Nux/InputArea.cpp (+78/-100)
Nux/InputArea.h (+71/-95)
Nux/IntegerValidator.cpp (+26/-26)
Nux/IntegerValidator.h (+10/-10)
Nux/KeyboardHandler.cpp (+189/-183)
Nux/KeyboardHandler.h (+36/-36)
Nux/LayeredLayout.cpp (+242/-278)
Nux/LayeredLayout.h (+70/-43)
Nux/Layout.cpp (+221/-615)
Nux/Layout.h (+114/-125)
Nux/LinearLayout.cpp (+214/-0)
Nux/LinearLayout.h (+86/-0)
Nux/ListControl.cpp (+0/-47)
Nux/ListControl.h (+0/-75)
Nux/Makefile.am (+9/-125)
Nux/Matrix3Editor.cpp (+0/-387)
Nux/Matrix3Editor.h (+0/-170)
Nux/Matrix3Preview.cpp (+0/-132)
Nux/Matrix3Preview.h (+0/-66)
Nux/Matrix4Editor.cpp (+0/-391)
Nux/Matrix4Editor.h (+0/-187)
Nux/Matrix4Preview.cpp (+0/-130)
Nux/Matrix4Preview.h (+0/-65)
Nux/MenuBar.cpp (+135/-183)
Nux/MenuBar.h (+16/-17)
Nux/MenuPage.cpp (+274/-352)
Nux/MenuPage.h (+58/-61)
Nux/MouseAreaCtrl.cpp (+30/-40)
Nux/MouseAreaCtrl.h (+10/-11)
Nux/MouseHandler.cpp (+18/-18)
Nux/MouseHandler.h (+4/-4)
Nux/NodeItem.cpp (+0/-518)
Nux/NodeItem.h (+0/-133)
Nux/NodeNetProtocol.cpp (+0/-587)
Nux/NodeNetProtocol.h (+0/-200)
Nux/NumericValuator.cpp (+54/-64)
Nux/NumericValuator.h (+5/-6)
Nux/Nux.cpp (+147/-129)
Nux/Nux.h (+39/-30)
Nux/NuxGlobalInitializer.cpp (+4/-4)
Nux/NuxGlobalInitializer.h (+1/-1)
Nux/PaintLayer.cpp (+47/-42)
Nux/PaintLayer.h (+13/-12)
Nux/Painter.cpp (+324/-282)
Nux/Painter.h (+127/-77)
Nux/Panel.cpp (+77/-139)
Nux/Panel.h (+13/-16)
Nux/PangoText.cpp (+104/-114)
Nux/PangoText.h (+26/-27)
Nux/PopUpWindow.cpp (+9/-9)
Nux/PropertyItem/CheckBoxProperty.cpp (+0/-138)
Nux/PropertyItem/CheckBoxProperty.h (+0/-51)
Nux/PropertyItem/ColorGradientPropertyItem.cpp (+0/-122)
Nux/PropertyItem/ColorGradientPropertyItem.h (+0/-51)
Nux/PropertyItem/ColorPreviewPropertyItem.cpp (+0/-164)
Nux/PropertyItem/ColorPreviewPropertyItem.h (+0/-60)
Nux/PropertyItem/ComboBoxListPropertyItem.cpp (+0/-102)
Nux/PropertyItem/ComboBoxListPropertyItem.h (+0/-48)
Nux/PropertyItem/ComboBoxPropertyItem.cpp (+0/-188)
Nux/PropertyItem/ComboBoxPropertyItem.h (+0/-51)
Nux/PropertyItem/DoubleValuatorPropertyItem.cpp (+0/-164)
Nux/PropertyItem/DoubleValuatorPropertyItem.h (+0/-50)
Nux/PropertyItem/EditTextLinePropertyItem.cpp (+0/-127)
Nux/PropertyItem/EditTextLinePropertyItem.h (+0/-50)
Nux/PropertyItem/FilePropertyItem.cpp (+0/-105)
Nux/PropertyItem/FilePropertyItem.h (+0/-48)
Nux/PropertyItem/IntegerValuatorPropertyItem.cpp (+0/-162)
Nux/PropertyItem/IntegerValuatorPropertyItem.h (+0/-49)
Nux/PropertyItem/Matrix3PreviewPropertyItem.cpp (+0/-186)
Nux/PropertyItem/Matrix3PreviewPropertyItem.h (+0/-48)
Nux/PropertyItem/Matrix4PreviewPropertyItem.cpp (+0/-187)
Nux/PropertyItem/Matrix4PreviewPropertyItem.h (+0/-48)
Nux/PropertyItem/RGBAProperty.cpp (+0/-499)
Nux/PropertyItem/RGBAProperty.h (+0/-126)
Nux/PropertyItem/RGBProperty.cpp (+0/-465)
Nux/PropertyItem/RGBProperty.h (+0/-119)
Nux/PropertyItem/RangeValueIntegerPropertyItem.cpp (+0/-167)
Nux/PropertyItem/RangeValueIntegerPropertyItem.h (+0/-52)
Nux/PropertyItem/RangeValuePropertyItem.cpp (+0/-167)
Nux/PropertyItem/RangeValuePropertyItem.h (+0/-51)
Nux/PropertyItem/SpinBoxDoublePropertyItem.cpp (+0/-141)
Nux/PropertyItem/SpinBoxDoublePropertyItem.h (+0/-50)
Nux/PropertyItem/SpinBoxPropertyItem.cpp (+0/-141)
Nux/PropertyItem/SpinBoxPropertyItem.h (+0/-51)
Nux/PropertyItem/SplineCurvePropertyItem.cpp (+0/-170)
Nux/PropertyItem/SplineCurvePropertyItem.h (+0/-48)
Nux/PropertyItem/Vector3Property.cpp (+0/-210)
Nux/PropertyItem/Vector3Property.h (+0/-86)
Nux/PropertyItem/Vector3ValuatorPropertyItem.cpp (+0/-149)
Nux/PropertyItem/Vector3ValuatorPropertyItem.h (+0/-51)
Nux/PropertyItem/Vector4Property.cpp (+0/-240)
Nux/PropertyItem/Vector4Property.h (+0/-99)
Nux/PropertyList.cpp (+0/-98)
Nux/PropertyList.h (+0/-246)
Nux/RGBValuator.cpp (+595/-610)
Nux/RGBValuator.h (+48/-36)
Nux/RadioButton.cpp (+114/-258)
Nux/RadioButton.h (+64/-60)
Nux/RadioButtonGroup.cpp (+50/-38)
Nux/RadioButtonGroup.h (+7/-7)
Nux/RangeValue.cpp (+103/-120)
Nux/RangeValue.h (+17/-18)
Nux/RangeValueInteger.cpp (+82/-99)
Nux/RangeValueInteger.h (+19/-20)
Nux/ScrollBar.cpp (+4/-4)
Nux/ScrollBar.h (+7/-7)
Nux/ScrollView.cpp (+259/-314)
Nux/ScrollView.h (+35/-33)
Nux/SpinBox.cpp (+105/-115)
Nux/SpinBox.h (+8/-9)
Nux/SpinBoxDouble.cpp (+115/-125)
Nux/SpinBoxDouble.h (+8/-9)
Nux/SpinBox_Logic.cpp (+87/-87)
Nux/SpinBox_Logic.h (+19/-20)
Nux/SplineCurveDialog.cpp (+0/-101)
Nux/SplineCurveDialog.h (+0/-73)
Nux/SplineCurveEditor.cpp (+0/-606)
Nux/SplineCurveEditor.h (+0/-384)
Nux/SplineCurvePreview.cpp (+0/-450)
Nux/SplineCurvePreview.h (+0/-121)
Nux/StaticText.cpp (+757/-270)
Nux/StaticText.h (+102/-38)
Nux/StaticTextBox.cpp (+55/-63)
Nux/StaticTextBox.h (+22/-23)
Nux/SystemThread.cpp (+53/-53)
Nux/SystemThread.h (+10/-10)
Nux/TabView.cpp (+221/-247)
Nux/TabView.h (+23/-24)
Nux/TableCtrl.cpp (+0/-2373)
Nux/TableCtrl.h (+0/-553)
Nux/TableItem.cpp (+0/-281)
Nux/TableItem.h (+0/-227)
Nux/TextEntry.cpp (+105/-204)
Nux/TextEntry.h (+26/-28)
Nux/TextView/Sequence.cpp (+0/-1134)
Nux/TextView/Sequence.h (+0/-450)
Nux/TextView/TextDocument.cpp (+0/-1047)
Nux/TextView/TextDocument.h (+0/-243)
Nux/TextView/TextView.cpp (+0/-931)
Nux/TextView/TextView.h (+0/-162)
Nux/TextView/TextViewFile.cpp (+0/-70)
Nux/TextView/TextViewFont.cpp (+0/-259)
Nux/TextView/TextViewInternal.h (+0/-384)
Nux/TextView/TextViewKeyNav.cpp (+0/-76)
Nux/TextView/TextViewMouse.cpp (+0/-823)
Nux/TextView/TextViewPaint.cpp (+0/-822)
Nux/TextView/TextViewScroll.cpp (+0/-401)
Nux/TextView/TextViewSyntax.cpp (+0/-202)
Nux/TextView/TextViewUsp.cpp (+0/-155)
Nux/TextView/TextViewWidget.cpp (+0/-808)
Nux/TextView/TextViewWidget.h (+0/-227)
Nux/TextView/Unicode.c (+0/-571)
Nux/TextView/Unicode.cpp (+0/-584)
Nux/TextView/Unicode.h (+0/-83)
Nux/TextView/codepages.h (+0/-26)
Nux/TextView/racursor.h (+0/-58)
Nux/TextViewGCC/Sequence.cpp (+0/-1130)
Nux/TextViewGCC/Sequence.h (+0/-447)
Nux/TextViewGCC/TextDocument.cpp (+0/-1055)
Nux/TextViewGCC/TextDocument.h (+0/-245)
Nux/TextViewGCC/TextView.cpp (+0/-872)
Nux/TextViewGCC/TextView.h (+0/-169)
Nux/TextViewGCC/TextViewFile.cpp (+0/-65)
Nux/TextViewGCC/TextViewInternal.h (+0/-378)
Nux/TextViewGCC/TextViewKeyNav.cpp (+0/-70)
Nux/TextViewGCC/TextViewMouse.cpp (+0/-826)
Nux/TextViewGCC/TextViewPaint.cpp (+0/-819)
Nux/TextViewGCC/TextViewScroll.cpp (+0/-396)
Nux/TextViewGCC/TextViewSyntax.cpp (+0/-198)
Nux/TextViewGCC/TextViewUsp.cpp (+0/-151)
Nux/TextViewGCC/TextViewWidget.cpp (+0/-806)
Nux/TextViewGCC/TextViewWidget.h (+0/-221)
Nux/TextViewGCC/Unicode.c (+0/-571)
Nux/TextViewGCC/Unicode.cpp (+0/-580)
Nux/TextViewGCC/Unicode.h (+0/-88)
Nux/TextViewGCC/codepages.h (+0/-26)
Nux/TextViewGCC/racursor.h (+0/-53)
Nux/TextureArea.cpp (+125/-87)
Nux/TextureArea.h (+42/-16)
Nux/Theme.cpp (+130/-130)
Nux/Theme.h (+5/-5)
Nux/TimeGraph.cpp (+0/-483)
Nux/TimeGraph.h (+0/-118)
Nux/Timeline.cpp (+47/-44)
Nux/Timeline.h (+11/-11)
Nux/TimelineEasings.cpp (+24/-24)
Nux/TimelineEasings.h (+12/-12)
Nux/TimerProc.cpp (+93/-93)
Nux/TimerProc.h (+5/-5)
Nux/ToggleButton.cpp (+22/-22)
Nux/ToggleButton.h (+9/-6)
Nux/ToolButton.cpp (+76/-84)
Nux/ToolButton.h (+11/-11)
Nux/TreeControl.cpp (+0/-274)
Nux/TreeControl.h (+0/-60)
Nux/Utils.cpp (+1/-1)
Nux/Utils.h (+2/-2)
Nux/VLayout.cpp (+185/-191)
Nux/VLayout.h (+9/-11)
Nux/VScrollBar.cpp (+156/-167)
Nux/VScrollBar.h (+31/-36)
Nux/VSeparator.cpp (+0/-96)
Nux/VSeparator.h (+0/-49)
Nux/VSplitter.cpp (+200/-200)
Nux/VSplitter.h (+19/-19)
Nux/VToolBar.cpp (+0/-189)
Nux/VToolBar.h (+0/-71)
Nux/Validator.cpp (+23/-8)
Nux/Validator.h (+10/-5)
Nux/Valuator.cpp (+0/-199)
Nux/Valuator.h (+0/-85)
Nux/ValuatorDouble.cpp (+0/-249)
Nux/ValuatorDouble.h (+0/-73)
Nux/ValuatorInt.cpp (+0/-246)
Nux/ValuatorInt.h (+0/-73)
Nux/Vector3Valuator.cpp (+0/-202)
Nux/Vector3Valuator.h (+0/-95)
Nux/Vector3ValuatorDouble.cpp (+0/-465)
Nux/Vector3ValuatorDouble.h (+0/-91)
Nux/View.cpp (+213/-430)
Nux/View.h (+63/-121)
Nux/WindowCompositor.cpp (+303/-342)
Nux/WindowCompositor.h (+26/-27)
Nux/WindowThread.cpp (+463/-490)
Nux/WindowThread.h (+122/-97)
Nux/nux.pc.in (+1/-1)
NuxCore/CPU.cpp (+1/-1)
NuxCore/CPU.h (+7/-7)
NuxCore/CRC32.cpp (+9/-9)
NuxCore/CRC32.h (+5/-5)
NuxCore/Character/NAscii.cpp (+1/-1)
NuxCore/Character/NUTF.cpp (+1/-1)
NuxCore/Character/NUTF.h (+1/-1)
NuxCore/Character/NUnicodeGNU.h (+2/-2)
NuxCore/Color.cpp (+20/-20)
NuxCore/FileIO.cpp (+9/-9)
NuxCore/FileManager/NFileManagerGNU.cpp (+31/-31)
NuxCore/FileManager/NFileManagerGNU.h (+23/-23)
NuxCore/FileManager/NFileManagerGeneric.cpp (+9/-9)
NuxCore/FileManager/NFileManagerGeneric.h (+2/-2)
NuxCore/FileManager/NFileManagerStandardAnsi.cpp (+20/-20)
NuxCore/FileManager/NFileManagerStandardAnsi.h (+27/-26)
NuxCore/FileManager/NFileManagerWindows.cpp (+25/-25)
NuxCore/FileManager/NFileManagerWindows.h (+19/-19)
NuxCore/FileManager/NSerializer.cpp (+102/-102)
NuxCore/FileManager/NSerializer.h (+80/-80)
NuxCore/FileName.cpp (+17/-17)
NuxCore/FilePath.cpp (+4/-4)
NuxCore/Logger.cpp (+9/-2)
NuxCore/Logger.h (+9/-6)
NuxCore/Math/Bezier.cpp (+7/-7)
NuxCore/Math/Bezier.h (+3/-3)
NuxCore/Math/Complex.cpp (+34/-34)
NuxCore/Math/Complex.h (+13/-13)
NuxCore/Math/MathFunctions.cpp (+7/-7)
NuxCore/Math/MathFunctions.h (+5/-5)
NuxCore/Math/MathUtility.h (+14/-14)
NuxCore/Math/Matrix2.h (+2/-2)
NuxCore/Math/Matrix3.h (+2/-2)
NuxCore/Math/Matrix4.h (+2/-2)
NuxCore/Math/Vector2.h (+10/-10)
NuxCore/Math/Vector3.h (+6/-6)
NuxCore/Math/Vector4.h (+6/-6)
NuxCore/Memory.cpp (+10/-10)
NuxCore/Memory.h (+16/-16)
NuxCore/NUniqueIndex.cpp (+1/-1)
NuxCore/NUniqueIndex.h (+1/-1)
NuxCore/NumberConversion.cpp (+8/-8)
NuxCore/NumberConversion.h (+4/-4)
NuxCore/NuxCore.cpp (+5/-5)
NuxCore/NuxCore.h (+9/-10)
NuxCore/Object.cpp (+20/-32)
NuxCore/ObjectPtr.h (+3/-3)
NuxCore/OutputDevice.cpp (+7/-7)
NuxCore/Parsing.cpp (+7/-7)
NuxCore/Parsing.h (+5/-5)
NuxCore/Platform.cpp (+2/-2)
NuxCore/Platform.h (+1/-1)
NuxCore/PropertyOperators.h (+1/-1)
NuxCore/PropertyTraits.h (+5/-0)
NuxCore/Rect.cpp (+5/-0)
NuxCore/Rect.h (+8/-6)
NuxCore/System.h (+38/-38)
NuxCore/SystemTypes.h (+40/-158)
NuxCore/TextString.cpp (+309/-309)
NuxCore/TextString.h (+163/-163)
NuxCore/ThreadGNU.cpp (+14/-14)
NuxCore/ThreadGNU.h (+16/-16)
NuxCore/ThreadWin.cpp (+16/-23)
NuxCore/ThreadWin.h (+19/-19)
NuxCore/TimeFunctions.cpp (+11/-11)
NuxCore/TimeFunctions.h (+2/-2)
NuxCore/TinyXML/tinystr.cpp (+1/-1)
NuxCore/Win32Dialogs/NWin32Clipboard.cpp (+1/-1)
NuxCore/Win32Dialogs/NWin32CustomDialog.cpp (+8/-8)
NuxCore/Win32Dialogs/NWin32CustomDialog.h (+4/-4)
NuxCore/Win32Dialogs/NWin32MessageBox.cpp (+3/-3)
NuxGraphics/Events.cpp (+16/-15)
NuxGraphics/Events.h (+9/-11)
NuxGraphics/FontRenderer.cpp (+145/-113)
NuxGraphics/FontRenderer.h (+8/-8)
NuxGraphics/FontTexture.cpp (+89/-84)
NuxGraphics/FontTexture.h (+29/-29)
NuxGraphics/GLDeviceFrameBufferObject.cpp (+98/-78)
NuxGraphics/GLDeviceFrameBufferObject.h (+19/-19)
NuxGraphics/GLDeviceObjects.cpp (+9/-9)
NuxGraphics/GLError.cpp (+15/-11)
NuxGraphics/GLError.h (+4/-4)
NuxGraphics/GLPBuffer.cpp (+4/-0)
NuxGraphics/GLPBuffer.h (+4/-0)
NuxGraphics/GLRenderStates.cpp (+185/-183)
NuxGraphics/GLRenderStates.h (+809/-772)
NuxGraphics/GLResource.cpp (+27/-21)
NuxGraphics/GLResource.h (+40/-14)
NuxGraphics/GLResourceManager.cpp (+46/-46)
NuxGraphics/GLResourceManager.h (+40/-40)
NuxGraphics/GLSh_ColorPicker.cpp (+123/-102)
NuxGraphics/GLSh_ColorPicker.h (+3/-3)
NuxGraphics/GLSh_DrawFunction.cpp (+68/-65)
NuxGraphics/GLSh_DrawFunction.h (+3/-3)
NuxGraphics/GLSh_Fill.cpp (+28/-28)
NuxGraphics/GLSh_Fill.h (+3/-3)
NuxGraphics/GLShaderParameter.cpp (+9/-9)
NuxGraphics/GLShaderParameter.h (+78/-78)
NuxGraphics/GLTemplatePrimitiveBuffer.cpp (+169/-169)
NuxGraphics/GLTemplatePrimitiveBuffer.h (+10/-10)
NuxGraphics/GLTextureResourceManager.cpp (+299/-288)
NuxGraphics/GLTextureResourceManager.h (+168/-164)
NuxGraphics/GLTextureStates.cpp (+136/-98)
NuxGraphics/GLTextureStates.h (+13/-13)
NuxGraphics/GLTimer.cpp (+10/-10)
NuxGraphics/GLVertexResourceManager.cpp (+72/-72)
NuxGraphics/GLVertexResourceManager.h (+12/-12)
NuxGraphics/GLWindowManager.cpp (+28/-22)
NuxGraphics/GLWindowManager.h (+9/-5)
NuxGraphics/GlobalGraphicsInitializer.cpp (+4/-4)
NuxGraphics/GlobalGraphicsInitializer.h (+1/-1)
NuxGraphics/GpuDevice.cpp (+386/-399)
NuxGraphics/GpuDevice.h (+126/-108)
NuxGraphics/GpuDeviceShader.cpp (+24/-24)
NuxGraphics/GpuDeviceTexture.cpp (+74/-73)
NuxGraphics/GpuDeviceVertex.cpp (+73/-71)
NuxGraphics/GraphicsDisplay.h (+2/-2)
NuxGraphics/GraphicsDisplayWin.cpp (+441/-382)
NuxGraphics/GraphicsDisplayWin.h (+58/-45)
NuxGraphics/GraphicsDisplayX11.cpp (+605/-487)
NuxGraphics/GraphicsDisplayX11.h (+79/-65)
NuxGraphics/GraphicsEngine.cpp (+455/-455)
NuxGraphics/GraphicsEngine.h (+186/-186)
NuxGraphics/IOpenGLAnimatedTexture.cpp (+25/-25)
NuxGraphics/IOpenGLAnimatedTexture.h (+10/-10)
NuxGraphics/IOpenGLAsmShader.cpp (+189/-170)
NuxGraphics/IOpenGLAsmShader.h (+31/-31)
NuxGraphics/IOpenGLBaseTexture.cpp (+131/-119)
NuxGraphics/IOpenGLBaseTexture.h (+54/-54)
NuxGraphics/IOpenGLCgShader.cpp (+50/-50)
NuxGraphics/IOpenGLCgShader.h (+13/-13)
NuxGraphics/IOpenGLCubeTexture.cpp (+29/-29)
NuxGraphics/IOpenGLCubeTexture.h (+10/-10)
NuxGraphics/IOpenGLFrameBufferObject.cpp (+74/-73)
NuxGraphics/IOpenGLFrameBufferObject.h (+12/-12)
NuxGraphics/IOpenGLGLSLShader.cpp (+552/-550)
NuxGraphics/IOpenGLGLSLShader.h (+79/-79)
NuxGraphics/IOpenGLIndexBuffer.cpp (+47/-36)
NuxGraphics/IOpenGLIndexBuffer.h (+10/-10)
NuxGraphics/IOpenGLPixelBufferOject.cpp (+44/-36)
NuxGraphics/IOpenGLPixelBufferOject.h (+5/-5)
NuxGraphics/IOpenGLQuery.cpp (+47/-38)
NuxGraphics/IOpenGLQuery.h (+10/-10)
NuxGraphics/IOpenGLRectangleTexture.cpp (+34/-31)
NuxGraphics/IOpenGLRectangleTexture.h (+11/-11)
NuxGraphics/IOpenGLResource.h (+6/-6)
NuxGraphics/IOpenGLSurface.cpp (+217/-111)
NuxGraphics/IOpenGLSurface.h (+17/-74)
NuxGraphics/IOpenGLTexture2D.cpp (+44/-33)
NuxGraphics/IOpenGLTexture2D.h (+14/-14)
NuxGraphics/IOpenGLVertexBuffer.cpp (+43/-34)
NuxGraphics/IOpenGLVertexBuffer.h (+10/-10)
NuxGraphics/IOpenGLVertexDeclaration.cpp (+5/-5)
NuxGraphics/IOpenGLVertexDeclaration.h (+1/-1)
NuxGraphics/IOpenGLVolume.cpp (+96/-90)
NuxGraphics/IOpenGLVolume.h (+10/-10)
NuxGraphics/IOpenGLVolumeTexture.cpp (+46/-43)
NuxGraphics/IOpenGLVolumeTexture.h (+13/-13)
NuxGraphics/Makefile.am (+1/-0)
NuxGraphics/MeshFileLoader-OBJ.cpp (+11/-11)
NuxGraphics/NuxGraphics.cpp (+6/-2)
NuxGraphics/NuxGraphics.h (+1/-1)
NuxGraphics/NuxGraphicsResources.cpp (+163/-163)
NuxGraphics/NuxGraphicsResources.h (+5/-5)
NuxGraphics/OpenGLMapping.h (+129/-0)
NuxGraphics/Readme.txt (+6/-6)
NuxGraphics/RenderingPipe.cpp (+218/-181)
NuxGraphics/RenderingPipe.h (+7/-7)
NuxGraphics/RenderingPipeAsm.cpp (+899/-899)
NuxGraphics/RenderingPipeGLSL.cpp (+1111/-1140)
NuxGraphics/RenderingPipeTextureBlend.cpp (+85/-85)
NuxGraphics/RunTimeStats.cpp (+51/-51)
NuxGraphics/RunTimeStats.h (+32/-32)
NuxGraphics/VirtualKeyCodes.h (+3/-3)
NuxGraphics/XInputWindow.cpp (+28/-28)
NuxGraphics/nux-graphics.pc.in (+1/-0)
NuxImage/BitmapFormats.cpp (+60/-55)
NuxImage/BitmapFormats.h (+10/-35)
NuxImage/Bmp.cpp (+168/-168)
NuxImage/Bmp.h (+4/-4)
NuxImage/CairoGraphics.cpp (+96/-87)
NuxImage/CairoGraphics.h (+10/-10)
NuxImage/DDS.cpp (+58/-58)
NuxImage/GdiImageLoader.cpp (+19/-19)
NuxImage/GdiImageLoader.h (+1/-1)
NuxImage/GdkGraphics.cpp (+1/-1)
NuxImage/ImageSurface.cpp (+548/-550)
NuxImage/ImageSurface.h (+174/-174)
NuxImage/NAnimatedTexture.cpp (+51/-51)
NuxImage/NAnimatedTexture.h (+3/-3)
NuxImage/NITX.cpp (+341/-341)
NuxImage/NITX.h (+13/-13)
NuxImage/NPng.cpp (+132/-132)
NuxImage/NPng.h (+4/-4)
NuxImage/OpenEXR.cpp (+55/-55)
NuxImage/OpenEXR.h (+1/-1)
NuxImage/RGBE.cpp (+181/-181)
NuxImage/RGBE.h (+7/-7)
NuxImage/Tga.cpp (+179/-179)
NuxImage/Tga.h (+2/-2)
configure.ac (+24/-34)
data/Makefile.am (+20/-21)
data/UITextures/Painter.xml (+17/-17)
examples/Makefile.am (+60/-58)
examples/text_entry_focus.cpp (+0/-1)
gputests/Makefile.am (+5/-1)
gputests/framebufferobject.cpp (+2/-2)
gputests/quad_2texmod.cpp (+2/-2)
gputests/texture_blur.cpp (+2/-2)
gputests/texture_copy_blur.cpp (+2/-2)
gputests/texture_data.cpp (+2/-2)
gputests/texture_power_of_2.cpp (+4/-20)
tools/Makefile.am (+1/-1)
tools/unity_support_test.c (+235/-12)
To merge this branch: bzr merge lp:~haggai-eran/nux/rtl
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Fixing
Jay Taoko Pending
Review via email: mp+71538@code.launchpad.net

Description of the change

Unity currently lacks support for right-to-left interface mirroring, for languages such as Hebrew and Arabic. These patches could facilitate such support. They add a GetDefaultDirection and SetDefaultDirection global function (modeled after GTK's gtk_widget_get_default_direction), and also GetDirection and SetDirection per Area.
The second patch implements interface mirroring for the HLayout class, when using a RightToLeft direction.

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Thank you for your patch!

Before we can accept it, we require you to agree to inalogic's contributor agreement (http://inalogic.com/license). If you accept it, send and email to <email address hidden> and state that you agree.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Okay, I've sent the email.

Revision history for this message
Jay Taoko (jaytaoko) wrote :

thanks, got it!

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Haggai,

Sorry that I haven’t been able to review your branch yet. The reason for that is Nux trunk is being stabilized in anticipation of the release of Ubuntu Oneiric. Once we branch Nux for the next release, I will review your branch.

Jay

Revision history for this message
Haggai Eran (haggai-eran) wrote :

  That's too bad. I was hoping to get my patches for unity 2d into Oneiric.

lp:~haggai-eran/nux/rtl updated
417. By Haggai Eran

Merged trunk.

418. By Haggai Eran

Merge trunk.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Hi,

Is there a chance you could review this branch for the Precise version? I would like to help Unity get RTL support in this version, especially since it is an LTS.

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Sure, your branch is on the agenda. There have been substantial changes to Nux, so I will have to adapt your branch to it.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Thanks,
Let me know if I can help.

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Haggai

From your patch, it appears that an HLayout will be able to process their content from Right to Left (rather than only from Left to Right as it is at the moment). However, I think that this will give the same result as the current processing. Or am I missing something?
Did you also meant to have elements filled inside an Hlayout from Right to Left? (Currently HLayout are filled from Left to Right).

Jay

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Jay,

My intention was to have HLayout position it's elements from right to left (when in the right locale), instead of from left to right. This is similar to how GtkHBox behaves, for example.

I think that this is also what the implementation does. It starts with the last child in the HLayout's list, and lays it at the leftmost position, and then follows on to the previous child in the list, and so on.

Haggai

Revision history for this message
Tim Penhey (thumper) wrote :

This is an absolutely massive branch. I see that some of the changes are pure whitespace changes.

Can these please be broken out separately from any actual code changes. Thanks.

review: Needs Fixing
Revision history for this message
Jay Taoko (jaytaoko) wrote :

I am working on that branch. It isn't massive actually once you re-base it with on nux trunk. Only a few files have changed.

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Haggai

In the case of the Hlayout, the first element that is added to the list will be the left-most element inside the Hlayout. You are proposing that the first element added to the Hlayout, be the right-most element inside the HLayout. And when processing the sizes of the HLayout elements, we either start from left or right depending on the direction option you have added. Is that correct?

Can you re-base this branch on Nux trunk? Your changes will be more obvious. I believe you only have a few files that are different from Nux trunk.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Jay, you are correct. In fact, when in right-to-left locale, I replaced the content distribution enum values, so that if it is set to eStackLeft, elements would actually be aligned to the right, and vice versa. Most of the changes in HLayout just change the order in which elements are packed.

I'll gladly rebase the branch. I probably should have done that in the first place, instead of merging the trunk, but I'm a little bit new to bazaar and launchpad. Should I use push --override to upload the results, or just create a new branch?

Revision history for this message
Jason Smith (jassmith) wrote :

It is almost always better to create a new branch rather than do a bzr push --override. Sorry about the delayed answer. Seems your review got lost in the holiday shuffle.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Thanks Jason. Eventually, I did create a new branch (lp:~haggai-eran/nux/rtl-rebased), but before it was merged I thought of a better way to implement the patch, so I created yet another branch (lp:~haggai-eran/nux/rtl-logical-packing). I thought I should delete this merge proposal, but launchpad said it would delete all the discussion, so I wasn't sure if that was the right thing to do.

Unmerged revisions

418. By Haggai Eran

Merge trunk.

417. By Haggai Eran

Merged trunk.

416. By Haggai Eran

Merged trunk changes.

415. By Haggai Eran

More HLayout changes toward right-to-left support.

414. By Haggai Eran

Add right-to-left mirroring support. Implement mirroring for HLayout.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Nux/AbstractButton.cpp'
--- Nux/AbstractButton.cpp 2011-10-05 20:56:39 +0000
+++ Nux/AbstractButton.cpp 2011-10-25 21:32:25 +0000
@@ -22,7 +22,7 @@
2222
23#include "Nux.h"23#include "Nux.h"
24#include "AbstractButton.h"24#include "AbstractButton.h"
25#include "HLayout.h"25#include "StaticText.h"
2626
27namespace nux27namespace nux
28{28{
@@ -30,20 +30,15 @@
3030
31 AbstractButton::AbstractButton(NUX_FILE_LINE_DECL)31 AbstractButton::AbstractButton(NUX_FILE_LINE_DECL)
32 : View(NUX_FILE_LINE_PARAM)32 : View(NUX_FILE_LINE_PARAM)
33 , state(NUX_STATE_NORMAL)33 , visual_state_(VISUAL_STATE_NORMAL)
34 {34 {
35 active = false;35 active_ = false;
36 togglable_ = false;36 mouse_pressed_ = false;
37 Init();37 static_text_ = NULL;
38 }38 label_color_ = color::White;
3939 same_size_as_content_ = false;
40 AbstractButton::~AbstractButton()40 label_font_size_ = 12;
41 {41
42
43 }
44
45 void AbstractButton::Init()
46 {
47 mouse_click.connect(sigc::mem_fun(this, &AbstractButton::RecvClick));42 mouse_click.connect(sigc::mem_fun(this, &AbstractButton::RecvClick));
48 mouse_down.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseDown));43 mouse_down.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseDown));
49 mouse_double_click.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseDown));44 mouse_double_click.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseDown));
@@ -53,50 +48,50 @@
53 mouse_leave.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseLeave));48 mouse_leave.connect(sigc::mem_fun(this, &AbstractButton::RecvMouseLeave));
54 }49 }
5550
56 long AbstractButton::ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo)51 AbstractButton::~AbstractButton()
57 {52 {
58 return PostProcessEvent2 (ievent, TraverseInfo, ProcessEventInfo);53
59 }54 }
6055
61 void AbstractButton::RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags)56 bool AbstractButton::Active() const
62 {57 {
63 if (!IsViewActive())58 return active_;
64 return;59 }
6560
66 if(togglable_)61 void AbstractButton::SetActive(bool active)
67 {62 {
68 active = !active;63 if (active)
69 }64 Activate();
70 else65 else
71 {66 Deactivate();
72 active = true;67 }
73 }68
7469 ButtonVisualState AbstractButton::GetVisualState()
75 if(togglable_ == false)70 {
76 {71 return visual_state_;
77 active = false;
78 }
79
80 activated.emit(this);
81 QueueDraw();
82 }72 }
8373
84 void AbstractButton::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)74 void AbstractButton::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
85 {75 {
86 if (!IsViewActive())76 if (IsMousePointerInside())
87 return;77 {
78 visual_state_ = VISUAL_STATE_PRELIGHT;
79 }
80 else
81 {
82 visual_state_ = VISUAL_STATE_NORMAL;
83 }
8884
89 state = NUX_STATE_PRELIGHT;85 mouse_pressed_ = false;
90 //state = 1;86 visual_state_change.emit(this);
91 QueueDraw();87 QueueDraw();
92 }88 }
9389
94 void AbstractButton::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)90 void AbstractButton::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
95 {91 {
96 if (!IsViewActive())92 visual_state_ = VISUAL_STATE_PRESSED;
97 return;93 mouse_pressed_ = true;
9894 visual_state_change.emit(this);
99 state = NUX_STATE_ACTIVE;
100 QueueDraw();95 QueueDraw();
101 }96 }
10297
@@ -107,13 +102,54 @@
107102
108 void AbstractButton::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)103 void AbstractButton::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
109 {104 {
110 state = NUX_STATE_PRELIGHT;105 if (mouse_pressed_)
106 {
107 visual_state_ = VISUAL_STATE_PRESSED;
108 }
109 else
110 {
111 visual_state_ = VISUAL_STATE_PRELIGHT;
112 }
113
114 visual_state_change.emit(this);
111 QueueDraw();115 QueueDraw();
112 }116 }
113117
114 void AbstractButton::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)118 void AbstractButton::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
115 {119 {
116 state = NUX_STATE_NORMAL;120 visual_state_ = VISUAL_STATE_NORMAL;
117 QueueDraw();121 visual_state_change.emit(this);
122 QueueDraw();
123 }
124
125 void AbstractButton::SetLabelColor(const Color &color)
126 {
127 label_color_ = color;
128 if (static_text_)
129 static_text_->SetTextColor(label_color_);
130 QueueDraw();
131 }
132
133 Color AbstractButton::GetLabelColor()
134 {
135 return label_color_;
136 }
137
138 ButtonVisualState AbstractButton::GetVisualState() const
139 {
140 return visual_state_;
141 }
142
143 void AbstractButton::SetLabelFontSize(int point)
144 {
145 if (point < 0)
146 return;
147
148 label_font_size_ = point;
149 }
150
151 int AbstractButton::GetLabelFontSize() const
152 {
153 return label_font_size_;
118 }154 }
119}155}
120156
=== modified file 'Nux/AbstractButton.h'
--- Nux/AbstractButton.h 2011-09-20 06:03:43 +0000
+++ Nux/AbstractButton.h 2011-10-25 21:32:25 +0000
@@ -27,47 +27,118 @@
2727
28namespace nux28namespace nux
29{29{
30 enum State30 class StaticText;
31
32 enum ButtonVisualState
31 {33 {
32 NUX_STATE_ACTIVE = 0,34 VISUAL_STATE_PRESSED = 0,
33 NUX_STATE_NORMAL = 1,35 VISUAL_STATE_NORMAL = 1,
34 NUX_STATE_PRELIGHT = 2,36 VISUAL_STATE_PRELIGHT = 2,
35 NUX_STATE_SELECTED = 3,37 VISUAL_STATE_DISABLED = 3
36 NUX_STATE_INSENSITIVE = 4
37 };38 };
3839
39 //! The base class of Button widgets.40 //! The base class of button type widgets.
41 /*!
42 AbstractButton is the direct base class of Button, CheckBox and RadioButton. It is a base class for ToggleButton.
43 */
40 class AbstractButton : public View44 class AbstractButton : public View
41 {45 {
42 NUX_DECLARE_OBJECT_TYPE(AbstractButton, View);46 NUX_DECLARE_OBJECT_TYPE(AbstractButton, View);
43 public:47 public:
44 AbstractButton(NUX_FILE_LINE_PROTO);48 AbstractButton(NUX_FILE_LINE_PROTO);
45 ~AbstractButton();49 virtual ~AbstractButton();
4650
47 //! Signal emitted when the button is activated.51 sigc::signal<void, AbstractButton*> visual_state_change;
48 Property<bool> active;52
4953 //! Returns the visual state of the AbstractButton
50 //! Signal emitted when the button is activated.54 /*!
51 sigc::signal<void, AbstractButton*> activated;55 Returns the visual state of the AbstractButton.
56
57 @return The visual state of the AbstractButton.
58 */
59 ButtonVisualState GetVisualState();
60
61 //! Return the active state of the button.
62 /*!
63 Return the active state of the button. A Button has a non-persistent active state. It always returns false.
64 CheckBox, RadionButton and ToggleButton return true if they are active.
65
66 @return True if the button object is in an active state.
67 */
68 bool Active() const;
69
70 //! Activate the button.
71 /*!
72 Activate the button. If this object is a Button, then it has no persistent state and the function does nothing.
73 */
74 virtual void Activate() = 0;
75
76 //! Deactivate the button.
77 /*!
78 Deactivate the button. If this object is a Button, then it has no persistent state and the function does nothing.
79 */
80 virtual void Deactivate() = 0;
81
82 //! Set the state of the button.
83 /*!
84 Set the sate of the button. The button is either activated or deactivated.
85
86 @param active The button state.
87 */
88 virtual void SetActive(bool active);
89
90 //! Set the text color.
91 /*!
92 Set the text color.
93
94 @param color the text color.
95 */
96 void SetLabelColor(const Color &color);
97
98 //! Get the text color.
99 /*!
100 Get the text color.
101
102 @return The text color.
103 */
104 Color GetLabelColor();
105
106 //! Get the button visual state.
107 /*!
108 Get the button visual state.
109
110 @return The button visual state.
111 */
112 ButtonVisualState GetVisualState() const;
113
114 virtual void SetLabelFontSize(int point);
115 int GetLabelFontSize() const;
52116
53 protected:117 protected:
54 bool togglable_;118 //! The state of the AbstractButton.
55119 bool active_;
56 //! Button state property.120
57 // FIXME: Should be read only.121 bool mouse_pressed_;
58 nux::Property<State> state;122
59123 //! Visual state of the button object.
60 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);124 ButtonVisualState visual_state_;
61125
62 void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);126
63 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);127 // Common attribute for all the classes that inherit from AbstractButton.
64 void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);128 std::string label_;
65 void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);129 Color label_color_;
66 void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);130 StaticText *static_text_;
67 void RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags);131 int label_font_size_;
68132 bool same_size_as_content_;
69 private:133 int pre_layout_width_;
70 void Init ();134 int pre_layout_height_;
135
136 virtual void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
137 virtual void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
138 virtual void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
139 virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
140 virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
141 virtual void RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags) = 0;
71 };142 };
72}143}
73144
74145
=== added file 'Nux/AbstractCheckedButton.cpp'
--- Nux/AbstractCheckedButton.cpp 1970-01-01 00:00:00 +0000
+++ Nux/AbstractCheckedButton.cpp 2011-10-25 21:32:25 +0000
@@ -0,0 +1,217 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#include "Nux.h"
24#include "HLayout.h"
25#include "AbstractCheckedButton.h"
26#include "StaticText.h"
27
28namespace nux
29{
30 NUX_IMPLEMENT_OBJECT_TYPE(AbstractCheckedButton);
31
32 AbstractCheckedButton::AbstractCheckedButton(const std::string &str, bool state, NUX_FILE_LINE_DECL)
33 : AbstractButton(NUX_FILE_LINE_PARAM)
34 {
35 label_ = str;
36 active_ = state;
37 hlayout_ = 0;
38
39 static_text_ = new StaticText(label_, NUX_TRACKER_LOCATION);
40 static_text_->SetTextColor(label_color_);
41 hlayout_ = new HLayout(NUX_TRACKER_LOCATION);
42 check_area_ = new InputArea(NUX_TRACKER_LOCATION);
43
44 check_area_->SetInputEventSensitivity(false);
45 static_text_->SetInputEventSensitivity(false);
46
47 // Set Geometry
48 check_area_->SetMinMaxSize(14, 14);
49
50 hlayout_->SetSpaceBetweenChildren(4);
51 hlayout_->SetContentDistribution(MAJOR_POSITION_LEFT);
52 hlayout_->AddView(check_area_, 0, MINOR_POSITION_CENTER, MINOR_SIZE_MATCHCONTENT);
53 hlayout_->AddView(static_text_, 1, MINOR_POSITION_CENTER, MINOR_SIZE_MATCHCONTENT);
54
55// // This is convenient to make the layout and the AbstractCheckedButton fit the check area and the caption area.
56// // Since the check area is bigger than 4x4, it will force the layout and the AbstractCheckedButton to grow.
57// // This is useful if the AbstractCheckedButton is put in a vertical layout and it has a stretch factor of 0. Then the width of the AbstractCheckedButton
58// // will be adjusted to fit the minimum width of the check area and the caption area.
59// {
60// hlayout_->SetMinimumSize(1, 1);
61// SetMinimumSize(14, 14);
62// ApplyMinWidth();
63// ApplyMinHeight();
64// }
65
66 hlayout_->SetScaleFactor(0);
67 SetLayout(hlayout_);
68
69 }
70
71 AbstractCheckedButton::~AbstractCheckedButton()
72 {
73 }
74
75 void AbstractCheckedButton::SetLabel(const std::string &checkbox_label)
76 {
77 label_ = checkbox_label;
78 static_text_->SetText(label_);
79 QueueDraw();
80 }
81
82 std::string AbstractCheckedButton::GetLabel() const
83 {
84 return label_;
85 }
86
87 void AbstractCheckedButton::Draw(GraphicsEngine &graphics_engine, bool force_draw)
88 {
89 Geometry base = GetGeometry();
90 graphics_engine.PushClippingRectangle(base);
91
92 GetPainter().PaintBackground(graphics_engine, base);
93
94 InteractState is;
95 is.is_on = active_;
96
97 if (visual_state_ == VISUAL_STATE_PRESSED)
98 {
99 is.is_focus = true;
100 }
101 else if (visual_state_ == VISUAL_STATE_PRELIGHT)
102 {
103 is.is_prelight = true;
104 }
105 else
106 {
107 is.is_focus = false;
108 is.is_prelight = false;
109 }
110
111 GetPainter().PushPaintLayerStack();
112 {
113 GetPainter().PaintCheckBox(graphics_engine, check_area_->GetGeometry(), is, Color(0xff000000));
114 static_text_->ProcessDraw(graphics_engine, true);
115 }
116 GetPainter().PopPaintLayerStack();
117
118 graphics_engine.PopClippingRectangle();
119 }
120
121 long AbstractCheckedButton::ComputeContentSize()
122 {
123 if (view_layout_)
124 {
125 PreLayoutManagement();
126
127 int old_width = GetBaseWidth();
128 int old_height = GetBaseHeight();
129
130 // Let the text view be as large as possible.
131 static_text_->SetMaximumWidth(AREA_MAX_WIDTH);
132
133 // Constrain the vertical expansion of the color selector.
134 view_layout_->SetBaseHeight(1);
135 long ret = view_layout_->ComputeContentSize();
136
137 PostLayoutManagement(ret);
138
139 {
140 // Check if the text view goes out of the AbstractCheckedButton area.
141 Geometry base = GetGeometry();
142 Geometry text_geo = static_text_->GetGeometry();
143
144 // Intersect the AbstractCheckedButton and the text view
145 Geometry intersection = base.Intersect(text_geo);
146 if (intersection != text_geo)
147 {
148 // The text view goes outside of the AbstractCheckedButton area. We have to clip it
149 static_text_->SetMaximumWidth(intersection.width);
150
151 // Assign a size of 1 to the layout and call ComputeContentSize.
152 // Inside the StaticText::ComputeContentSize there is code that takes care of size negociation.
153 view_layout_->SetBaseWidth(1);
154 ret = view_layout_->ComputeContentSize();
155
156 // Assign the layout geometry to the AbstractCheckedButton view.
157 PostLayoutManagement(ret);
158 }
159 }
160
161 int new_width = GetBaseWidth();
162 int new_height = GetBaseHeight();
163
164 long size_compliance = 0;
165
166 // The layout has been resized to tightly pack its content
167 if (new_width > old_width)
168 {
169 size_compliance |= eLargerWidth; // need scrollbar
170 }
171 else if (new_width < old_width)
172 {
173 size_compliance |= eSmallerWidth;
174 }
175 else
176 {
177 size_compliance |= eCompliantWidth;
178 }
179
180 // The layout has been resized to tightly pack its content
181 if (new_height > old_height)
182 {
183 size_compliance |= eLargerHeight; // need scrollbar
184 }
185 else if (new_height < old_height)
186 {
187 size_compliance |= eSmallerHeight;
188 }
189 else
190 {
191 size_compliance |= eCompliantHeight;
192 }
193
194 return size_compliance;
195 }
196 else
197 {
198 PreLayoutManagement();
199 int ret = PostLayoutManagement(eCompliantHeight | eCompliantWidth);
200 return ret;
201 }
202
203 return 0;
204 }
205
206 void AbstractCheckedButton::SetLabelFontSize(int point)
207 {
208 AbstractButton::SetLabelFontSize(point);
209 if (static_text_ == NULL)
210 return;
211
212 static_text_->SetTextPointSize(point);
213
214 ComputeContentSize();
215 QueueDraw();
216 }
217}
0218
=== added file 'Nux/AbstractCheckedButton.h'
--- Nux/AbstractCheckedButton.h 1970-01-01 00:00:00 +0000
+++ Nux/AbstractCheckedButton.h 2011-10-25 21:32:25 +0000
@@ -0,0 +1,110 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#ifndef ABSTRACTCHECKEDBUTTON_H
24#define ABSTRACTCHECKEDBUTTON_H
25
26#include "AbstractButton.h"
27
28namespace nux
29{
30 class HLayout;
31 class InputArea;
32 class StaticText;
33
34 //! AbstractCheckedButton class
35 /*!
36 Acts as a base class for CheckBox and radioButton.\n
37 */
38 class AbstractCheckedButton: public AbstractButton
39 {
40 NUX_DECLARE_OBJECT_TYPE(AbstractCheckedButton, AbstractButton);
41 public:
42 AbstractCheckedButton(const std::string &str, bool state = false, NUX_FILE_LINE_PROTO);
43 virtual ~AbstractCheckedButton();
44
45 //! Emitted when the button is clicked.
46 sigc::signal<void, AbstractCheckedButton*> click;
47
48 //! Emitted when the active state changes.
49 /*!
50 Emitted when the active state changes, as a result of a mouse click or an API call.\n
51 \sa Activate, Deactivate.
52 */
53 sigc::signal<void, AbstractCheckedButton*> state_change;
54
55 //! Set the label.
56 /*!
57 Set the label of this AbstractCheckedButton. If the \a label argument is an empty string, then the the AbstractCheckedButton label is destroyed,
58 and the content of the AbstractCheckedButton is re-arranged accordingly.
59
60 @param label The label of the AbstractCheckedButton.
61 */
62 void SetLabel(const std::string &checkbox_label);
63
64 //!Return the label of this AbstractCheckedButton.
65 /*!
66 Return the label of this AbstractCheckedButton.
67
68 @return The AbstractCheckedButton label string.
69 */
70 std::string GetLabel() const;
71
72 //! Activate the check box.
73 /*!
74 Activate the check box.
75 */
76 virtual void Activate() = 0;
77
78 //! Deactivate the check box.
79 /*!
80 Deactivate the check box.
81 */
82 virtual void Deactivate() = 0;
83
84 virtual void SetLabelFontSize(int point);
85
86 protected:
87 virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw) = 0;
88 virtual void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags) = 0;
89 virtual long ComputeContentSize();
90
91 HLayout *hlayout_;
92 InputArea *check_area_;
93
94 private:
95 //! Override of Area::SetMinimumHeight and made private.
96 /*!
97 Prevent changing the minimum height of the StaticText view.
98 */
99 virtual void SetMinimumHeight(){};
100
101 //! Override of Area::SetMaximumHeight and made private.
102 /*!
103 Prevent changing the maximum height of the StaticText view.
104 */
105 virtual void SetMaximumHeight(){};
106 };
107
108}
109
110#endif // ABSTRACTCHECKEDBUTTON_H
0111
=== modified file 'Nux/AbstractComboBox.cpp'
--- Nux/AbstractComboBox.cpp 2011-09-20 06:03:43 +0000
+++ Nux/AbstractComboBox.cpp 2011-10-25 21:32:25 +0000
@@ -28,94 +28,94 @@
28namespace nux28namespace nux
29{29{
3030
31 Color AbstractComboBox::m_sCOMBO_COLOR = Color (0x009F9F00);31 Color AbstractComboBox::m_sCOMBO_COLOR = Color(0x009F9F00);
32 Color AbstractComboBox::m_sCOMBO_BUTTON_COLOR = Color (0x00FFFFFF);32 Color AbstractComboBox::m_sCOMBO_BUTTON_COLOR = Color(0x00FFFFFF);
33 Color AbstractComboBox::m_sCOMBO_MOUSEOVER_COLOR = Color (0x55FFFFFF);33 Color AbstractComboBox::m_sCOMBO_MOUSEOVER_COLOR = Color(0x55FFFFFF);
3434
35 AbstractComboBox::AbstractComboBox (NUX_FILE_LINE_DECL)35 AbstractComboBox::AbstractComboBox(NUX_FILE_LINE_DECL)
36 : View (NUX_FILE_LINE_PARAM)36 : View(NUX_FILE_LINE_PARAM)
37 , m_MenuIsActive (false)37 , m_MenuIsActive(false)
38 {38 {
39 m_hlayout = new HLayout(NUX_TRACKER_LOCATION);39 m_hlayout = new HLayout(NUX_TRACKER_LOCATION);
40 _combo_box_area = new InputArea(NUX_TRACKER_LOCATION);40 _combo_box_area = new InputArea(NUX_TRACKER_LOCATION);
41 _combo_box_opening_area = new InputArea(NUX_TRACKER_LOCATION);41 _combo_box_opening_area = new InputArea(NUX_TRACKER_LOCATION);
4242
43 m_hlayout->AddView (_combo_box_area, 1);43 m_hlayout->AddView(_combo_box_area, 1);
44 m_hlayout->AddView (_combo_box_opening_area, 0);44 m_hlayout->AddView(_combo_box_opening_area, 0);
45 m_hlayout->SetHorizontalExternalMargin (0);45 m_hlayout->SetHorizontalExternalMargin(0);
46 m_hlayout->SetVerticalExternalMargin (0);46 m_hlayout->SetVerticalExternalMargin(0);
47 SetLayout (m_hlayout);47 SetLayout(m_hlayout);
4848
49 _combo_box_area->mouse_enter.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseEnter) );49 _combo_box_area->mouse_enter.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseEnter));
50 _combo_box_area->mouse_leave.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseLeave) );50 _combo_box_area->mouse_leave.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseLeave));
5151
52 _combo_box_opening_area->mouse_enter.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseEnter) );52 _combo_box_opening_area->mouse_enter.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseEnter));
53 _combo_box_opening_area->mouse_leave.connect (sigc::mem_fun (this, &AbstractComboBox::RecvMouseLeave) );53 _combo_box_opening_area->mouse_leave.connect(sigc::mem_fun(this, &AbstractComboBox::RecvMouseLeave));
5454
55 SetTextColor (color::Black);55 SetTextColor(color::Black);
5656
57 _pango_static_text = new StaticText (TEXT(""), NUX_TRACKER_LOCATION);57 _pango_static_text = new StaticText("", NUX_TRACKER_LOCATION);
58 }58 }
5959
60 AbstractComboBox::~AbstractComboBox()60 AbstractComboBox::~AbstractComboBox()
61 {61 {
62 if (_pango_static_text)62 if (_pango_static_text)
63 _pango_static_text->Dispose ();63 _pango_static_text->Dispose();
64 _pango_static_text = 0;64 _pango_static_text = 0;
65 }65 }
6666
67 void AbstractComboBox::Draw (GraphicsEngine &GfxContext, bool force_draw)67 void AbstractComboBox::Draw(GraphicsEngine &graphics_engine, bool force_draw)
68 {68 {
69 Geometry base = GetGeometry();69 Geometry base = GetGeometry();
70 70
71 GfxContext.PushClippingRectangle (base);71 graphics_engine.PushClippingRectangle(base);
72 GetPainter().PaintBackground (GfxContext, base);72 GetPainter().PaintBackground(graphics_engine, base);
73 GetPainter().PaintShape (GfxContext, base, m_sCOMBO_COLOR, eSHAPE_CORNER_ROUND4);73 GetPainter().PaintShape(graphics_engine, base, m_sCOMBO_COLOR, eSHAPE_CORNER_ROUND4);
7474
75 {75 {
76 //GetPainter().PaintTextLineStatic (GfxContext, GetFont (), _combo_box_area->GetGeometry(), _combo_box_area->GetBaseString().GetTCharPtr(), GetTextColor(), eAlignTextLeft);76 //GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), _combo_box_area->GetGeometry(), _combo_box_area->GetBaseString().GetTCharPtr(), GetTextColor(), eAlignTextLeft);
77 _pango_static_text->SetGeometry (_combo_box_area->GetGeometry ());77 _pango_static_text->SetGeometry(_combo_box_area->GetGeometry());
78 _pango_static_text->ProcessDraw (GfxContext, true);78 _pango_static_text->ProcessDraw(graphics_engine, true);
79 }79 }
80 80
81 Geometry button_geo = _combo_box_opening_area->GetGeometry();81 Geometry button_geo = _combo_box_opening_area->GetGeometry();
82 button_geo.OffsetSize (-5, -2);82 button_geo.OffsetSize(-5, -2);
83 button_geo.OffsetPosition (+4, +1);83 button_geo.OffsetPosition(+4, +1);
8484
85 if (_combo_box_area->IsMouseInside() || _combo_box_opening_area->IsMouseInside() || GetFocused ())85 if (_combo_box_area->IsMouseInside() || _combo_box_opening_area->IsMouseInside())
86 GetPainter().PaintShape (GfxContext, button_geo, m_sCOMBO_MOUSEOVER_COLOR, eSHAPE_CORNER_ROUND4);86 GetPainter().PaintShape(graphics_engine, button_geo, m_sCOMBO_MOUSEOVER_COLOR, eSHAPE_CORNER_ROUND4);
87 else87 else
88 GetPainter().PaintShape (GfxContext, button_geo, m_sCOMBO_BUTTON_COLOR, eSHAPE_CORNER_ROUND4);88 GetPainter().PaintShape(graphics_engine, button_geo, m_sCOMBO_BUTTON_COLOR, eSHAPE_CORNER_ROUND4);
8989
90 GeometryPositioning gp (eHACenter, eVACenter);90 GeometryPositioning gp(eHACenter, eVACenter);
91 Geometry GeoPo = ComputeGeometryPositioning (button_geo, GetTheme().GetImageGeometry (eCOMBOBOX_OPEN_BUTTON), gp);91 Geometry GeoPo = ComputeGeometryPositioning(button_geo, GetTheme().GetImageGeometry(eCOMBOBOX_OPEN_BUTTON), gp);
92 GetPainter().PaintShape (GfxContext, GeoPo, Color (0xFFFFFFFF), eCOMBOBOX_OPEN_BUTTON);92 GetPainter().PaintShape(graphics_engine, GeoPo, Color(0xFFFFFFFF), eCOMBOBOX_OPEN_BUTTON);
9393
94 Geometry popup_geometry;94 Geometry popup_geometry;
95 popup_geometry.SetX (_combo_box_area->GetBaseX() );95 popup_geometry.SetX(_combo_box_area->GetBaseX());
96 popup_geometry.SetY (_combo_box_area->GetBaseY() + _combo_box_area->GetBaseHeight() );96 popup_geometry.SetY(_combo_box_area->GetBaseY() + _combo_box_area->GetBaseHeight());
97 popup_geometry.SetWidth (_combo_box_area->GetBaseWidth() );97 popup_geometry.SetWidth(_combo_box_area->GetBaseWidth());
98 popup_geometry.SetHeight (_combo_box_area->GetBaseHeight() );98 popup_geometry.SetHeight(_combo_box_area->GetBaseHeight());
9999
100 GfxContext.PopClippingRectangle ();100 graphics_engine.PopClippingRectangle();
101 }101 }
102102
103 void AbstractComboBox::DrawContent (GraphicsEngine &GfxContext, bool force_draw)103 void AbstractComboBox::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
104 {104 {
105105
106 }106 }
107107
108 void AbstractComboBox::PostDraw (GraphicsEngine &GfxContext, bool force_draw)108 void AbstractComboBox::PostDraw(GraphicsEngine &graphics_engine, bool force_draw)
109 {109 {
110110
111 }111 }
112112
113 void AbstractComboBox::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)113 void AbstractComboBox::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
114 {114 {
115 QueueDraw();115 QueueDraw();
116 }116 }
117117
118 void AbstractComboBox::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)118 void AbstractComboBox::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
119 {119 {
120 QueueDraw();120 QueueDraw();
121 }121 }
122122
=== modified file 'Nux/AbstractComboBox.h'
--- Nux/AbstractComboBox.h 2011-04-06 21:54:09 +0000
+++ Nux/AbstractComboBox.h 2011-10-25 21:32:25 +0000
@@ -31,18 +31,17 @@
31 class AbstractComboBox: public View31 class AbstractComboBox: public View
32 {32 {
33 public:33 public:
34 AbstractComboBox (NUX_FILE_LINE_PROTO);34 AbstractComboBox(NUX_FILE_LINE_PROTO);
35 virtual ~AbstractComboBox();35 virtual ~AbstractComboBox();
3636
37 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) = 0;37 virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
38 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);38 virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
39 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);39 virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
40 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);40
4141 void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
42 void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);42 void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
43 void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);43
4444 StaticText * GetStaticText()
45 StaticText * GetStaticText ()
46 {45 {
47 return _pango_static_text;46 return _pango_static_text;
48 }47 }
4948
=== modified file 'Nux/AbstractPaintLayer.cpp'
--- Nux/AbstractPaintLayer.cpp 2011-09-20 06:03:43 +0000
+++ Nux/AbstractPaintLayer.cpp 2011-10-25 21:32:25 +0000
@@ -4,33 +4,33 @@
44
5namespace nux5namespace nux
6{6{
7 AbstractPaintLayer::AbstractPaintLayer ()7 AbstractPaintLayer::AbstractPaintLayer()
8 {8 {
99
10 }10 }
1111
12 AbstractPaintLayer::~AbstractPaintLayer ()12 AbstractPaintLayer::~AbstractPaintLayer()
13 {13 {
1414
15 }15 }
1616
17 void AbstractPaintLayer::SetGeometry (const Geometry &geo)17 void AbstractPaintLayer::SetGeometry(const Geometry &geo)
18 {18 {
19 _geometry = geo;19 geometry_ = geo;
20 }20 }
2121
22 Geometry const& AbstractPaintLayer::GetGeometry () const22 Geometry const& AbstractPaintLayer::GetGeometry() const
23 {23 {
24 return _geometry;24 return geometry_;
25 }25 }
2626
27 void AbstractPaintLayer::SetModelViewMatrix (const Matrix4 &mat)27 void AbstractPaintLayer::SetModelViewMatrix(const Matrix4 &mat)
28 {28 {
29 _model_view_matrix = mat;29 model_view_matrix_ = mat;
30 }30 }
3131
32 Matrix4 AbstractPaintLayer::GetModelViewMatrix ()32 Matrix4 AbstractPaintLayer::GetModelViewMatrix()
33 {33 {
34 return _model_view_matrix;34 return model_view_matrix_;
35 }35 }
36}36}
3737
=== modified file 'Nux/AbstractPaintLayer.h'
--- Nux/AbstractPaintLayer.h 2011-09-20 06:03:43 +0000
+++ Nux/AbstractPaintLayer.h 2011-10-25 21:32:25 +0000
@@ -40,24 +40,24 @@
40 PaintLayer_ImageStyle,40 PaintLayer_ImageStyle,
41 };41 };
4242
43 AbstractPaintLayer ();43 AbstractPaintLayer();
44 virtual ~AbstractPaintLayer ();44 virtual ~AbstractPaintLayer();
45 virtual AbstractPaintLayer *Clone () const = 0; //Virtual Constructor Idiom45 virtual AbstractPaintLayer *Clone() const = 0; //Virtual Constructor Idiom
4646
47 virtual void Renderlayer (GraphicsEngine &GfxContext) = 0;47 virtual void Renderlayer(GraphicsEngine &graphics_engine) = 0;
4848
49 virtual void SetGeometry (const Geometry &geo);49 virtual void SetGeometry(const Geometry &geo);
5050
51 //! Preserve the model view matrix at the moment layer is pushed on the paint layer stack. See Painter class.51 //! Preserve the model view matrix at the moment layer is pushed on the paint layer stack. See Painter class.
52 void SetModelViewMatrix (const Matrix4 &mat);52 void SetModelViewMatrix(const Matrix4 &mat);
5353
54 Matrix4 GetModelViewMatrix ();54 Matrix4 GetModelViewMatrix();
5555
56 Geometry const& GetGeometry() const;56 Geometry const& GetGeometry() const;
5757
58 protected:58 protected:
59 Geometry _geometry;59 Geometry geometry_;
60 Matrix4 _model_view_matrix;60 Matrix4 model_view_matrix_;
61 };61 };
6262
63}63}
6464
=== removed file 'Nux/AbstractRadioButton.cpp'
--- Nux/AbstractRadioButton.cpp 2011-08-17 02:27:23 +0000
+++ Nux/AbstractRadioButton.cpp 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22#include "Nux.h"
23
24#include "AbstractRadioButton.h"
25#include "HLayout.h"
26
27namespace nux
28{
29 NUX_IMPLEMENT_OBJECT_TYPE(AbstractRadioButton);
30
31 AbstractRadioButton::AbstractRadioButton (const TCHAR *Caption, NUX_FILE_LINE_DECL)
32 : View (NUX_FILE_LINE_PARAM)
33 {
34 _state = false;
35 }
36
37 AbstractRadioButton::~AbstractRadioButton()
38 {
39
40 }
41}
420
=== removed file 'Nux/AbstractRadioButton.h'
--- Nux/AbstractRadioButton.h 2011-08-17 02:27:23 +0000
+++ Nux/AbstractRadioButton.h 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#ifndef ABSTRACTRADIOBUTTON_H
24#define ABSTRACTRADIOBUTTON_H
25
26namespace nux
27{
28 //! The base class of Button, CheckBox, RadioButton and PushButton.
29 class AbstractRadioButton : public View
30 {
31 NUX_DECLARE_OBJECT_TYPE (AbstractRadioButton, View);
32 public:
33 AbstractRadioButton (const TCHAR *Caption = TEXT (""), NUX_FILE_LINE_PROTO);
34 ~AbstractRadioButton();
35
36 virtual void SetCaption (const TCHAR *Caption) = 0;
37 virtual const NString &GetCaption() const = 0;
38
39 virtual void SetState (bool b) = 0;
40 virtual void SetState (bool State, bool EmitSignal) = 0;
41 virtual bool GetState() const = 0;
42
43 protected:
44 bool _state;
45 };
46}
47
48#endif // ABSTRACTRADIOBUTTON_H
490
=== removed file 'Nux/AbstractSeparator.cpp'
--- Nux/AbstractSeparator.cpp 2011-04-06 21:54:09 +0000
+++ Nux/AbstractSeparator.cpp 1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#include "Nux.h"
24
25#include "AbstractSeparator.h"
26
27namespace nux
28{
29
30 AbstractSeparator::AbstractSeparator (NUX_FILE_LINE_DECL)
31 : View (NUX_FILE_LINE_PARAM)
32 , m_Color (0xFF888888)
33 , m_Alpha0 (0.0f)
34 , m_Alpha1 (0.592f)
35 , m_BorderSize (10)
36 {
37
38 }
39
40 AbstractSeparator::AbstractSeparator (const Color &color, float Alpha0, float Alpha1, int Border, NUX_FILE_LINE_DECL)
41 : View (NUX_FILE_LINE_PARAM)
42 , m_Color (color)
43 , m_Alpha0 (Alpha0)
44 , m_Alpha1 (Alpha1)
45 , m_BorderSize (Border)
46 {
47
48 }
49
50 AbstractSeparator::~AbstractSeparator()
51 {
52
53 }
54
55 void AbstractSeparator::SetColor (const Color &color)
56 {
57 m_Color = color;
58 }
59
60 void AbstractSeparator::SetAlpha (float Alpha0, float Alpha1)
61 {
62 m_Alpha0 = Alpha0;
63 m_Alpha1 = Alpha1;
64 }
65
66 void AbstractSeparator::SetBorderSize (int Border)
67 {
68 m_BorderSize = Border;
69 }
70}
710
=== removed file 'Nux/AbstractSeparator.h'
--- Nux/AbstractSeparator.h 2011-04-06 21:54:09 +0000
+++ Nux/AbstractSeparator.h 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#ifndef ABSTRACTSEPARATOR_H
24#define ABSTRACTSEPARATOR_H
25
26namespace nux
27{
28
29 class AbstractSeparator: public View
30 {
31 public:
32 AbstractSeparator (NUX_FILE_LINE_PROTO);
33 AbstractSeparator (const Color &color, float Alpha0, float Alpha1, int Border, NUX_FILE_LINE_PROTO);
34 ~AbstractSeparator();
35 void SetColor (const Color &color);
36 void SetAlpha (float Alpha0, float Alpha1);
37 void SetBorderSize (int Border);
38
39 protected:
40 Color m_Color;
41 float m_Alpha0;
42 float m_Alpha1;
43 int m_BorderSize;
44 };
45
46}
47
48#endif // ABSTRACTSEPARATOR_H
490
=== modified file 'Nux/AbstractThread.cpp'
--- Nux/AbstractThread.cpp 2011-04-06 21:54:09 +0000
+++ Nux/AbstractThread.cpp 2011-10-25 21:32:25 +0000
@@ -26,12 +26,12 @@
26namespace nux26namespace nux
27{27{
2828
29 NUX_IMPLEMENT_OBJECT_TYPE (AbstractThread);29 NUX_IMPLEMENT_OBJECT_TYPE(AbstractThread);
3030
31 AbstractThread::AbstractThread (AbstractThread *Parent)31 AbstractThread::AbstractThread(AbstractThread *Parent)
32 : m_Parent (Parent)32 : m_Parent(Parent)
33 , m_UserInitFunc (0)33 , m_UserInitFunc(0)
34 , m_UserExitFunc (0)34 , m_UserExitFunc(0)
35 {35 {
3636
37 }37 }
3838
=== modified file 'Nux/AbstractThread.h'
--- Nux/AbstractThread.h 2011-04-06 21:54:09 +0000
+++ Nux/AbstractThread.h 2011-10-25 21:32:25 +0000
@@ -26,25 +26,25 @@
26namespace nux26namespace nux
27{27{
2828
29 typedef void (*ThreadUserInitFunc) (NThread *, void *InitData);29 typedef void(*ThreadUserInitFunc) (NThread *, void *InitData);
30 typedef void (*ThreadUserExitFunc) (NThread *, void *ExitData);30 typedef void(*ThreadUserExitFunc) (NThread *, void *ExitData);
31 typedef void (*ThreadMainFunc) (NThread *, void *MainData);31 typedef void(*ThreadMainFunc) (NThread *, void *MainData);
3232
33 class AbstractThread: public NThread, public sigc::trackable33 class AbstractThread: public NThread, public sigc::trackable
34 {34 {
35 NUX_DECLARE_OBJECT_TYPE (AbstractThread, NThread);35 NUX_DECLARE_OBJECT_TYPE(AbstractThread, NThread);
3636
37 public:37 public:
38 AbstractThread (AbstractThread *Parent);38 AbstractThread(AbstractThread *Parent);
39 virtual ~AbstractThread();39 virtual ~AbstractThread();
4040
41 protected:41 protected:
42 virtual unsigned int Run (void *) = 0;42 virtual unsigned int Run(void *) = 0;
4343
44 virtual ThreadState StartChildThread (NThread *thread, bool Modal) = 0;44 virtual ThreadState StartChildThread(NThread *thread, bool Modal) = 0;
45 virtual void AddChildThread (NThread *) = 0;45 virtual void AddChildThread(NThread *) = 0;
46 virtual void RemoveChildThread (NThread *) = 0;46 virtual void RemoveChildThread(NThread *) = 0;
47 virtual void ChildHasFinished (NThread *app) = 0;47 virtual void ChildHasFinished(NThread *app) = 0;
48 virtual void TerminateAllChildThread() = 0;48 virtual void TerminateAllChildThread() = 0;
4949
50 std::list<NThread *> m_ChildThread;50 std::list<NThread *> m_ChildThread;
@@ -61,7 +61,7 @@
61 std::list<NThread *> m_ThreadList;61 std::list<NThread *> m_ThreadList;
6262
63 private:63 private:
64 AbstractThread (const AbstractThread &);64 AbstractThread(const AbstractThread &);
65 // Does not make sense for a singleton. This is a self assignment.65 // Does not make sense for a singleton. This is a self assignment.
66 AbstractThread &operator= (const AbstractThread &);66 AbstractThread &operator= (const AbstractThread &);
67 // Declare operator adress-of as private67 // Declare operator adress-of as private
6868
=== modified file 'Nux/ActionItem.cpp'
--- Nux/ActionItem.cpp 2011-09-20 06:03:43 +0000
+++ Nux/ActionItem.cpp 2011-10-25 21:32:25 +0000
@@ -27,86 +27,86 @@
27namespace nux27namespace nux
28{28{
2929
30 NUX_IMPLEMENT_OBJECT_TYPE (ActionItem);30 NUX_IMPLEMENT_OBJECT_TYPE(ActionItem);
3131
32 ActionItem::ActionItem (const TCHAR *label, int UserValue, NUX_FILE_LINE_DECL)32 ActionItem::ActionItem(const char *label, int UserValue, NUX_FILE_LINE_DECL)
33 : Object (true, NUX_FILE_LINE_PARAM)33 : Object(true, NUX_FILE_LINE_PARAM)
34 , m_UserValue (UserValue)34 , m_UserValue(UserValue)
35 , m_Label (TEXT ("") )35 , m_Label("")
36 , m_IsActivated (true)36 , m_IsActivated(true)
37 , m_Menu (0)37 , m_Menu(0)
38 , m_Enable (true)38 , m_Enable(true)
39 {39 {
40 m_Icon = 0;40 m_Icon = 0;
41 SetLabel (label);41 SetLabel(label);
42 }42 }
4343
44 ActionItem::~ActionItem()44 ActionItem::~ActionItem()
45 {45 {
46 if(m_Icon)46 if (m_Icon)
47 m_Icon->UnReference();47 m_Icon->UnReference();
48 }48 }
4949
50 void ActionItem::DrawAsMenuItem (GraphicsEngine &GfxContext, InputArea &area, bool is_highlighted, bool draw_icone)50 void ActionItem::DrawAsMenuItem(GraphicsEngine &graphics_engine, InputArea &area, bool is_highlighted, bool draw_icone)
51 {51 {
52 Geometry geo = area.GetGeometry();52 Geometry geo = area.GetGeometry();
53 Geometry icon_geo (0, 0, 20, 20);53 Geometry icon_geo(0, 0, 20, 20);
54 Geometry text_geo = geo;54 Geometry text_geo = geo;
5555
56 text_geo.OffsetPosition (24, 2);56 text_geo.OffsetPosition(24, 2);
57 text_geo.OffsetSize (2 * 24, 2 * 2);57 text_geo.OffsetSize(2 * 24, 2 * 2);
5858
59 icon_geo.SetX (geo.x + 2);59 icon_geo.SetX(geo.x + 2);
60 icon_geo.SetY (geo.y + 2);60 icon_geo.SetY(geo.y + 2);
6161
62 const TCHAR *label = GetLabel();62 const char *label = GetLabel();
6363
64 if (is_highlighted)64 if (is_highlighted)
65 {65 {
66 GetPainter().Paint2DQuadColor (GfxContext, geo, Color (COLOR_FOREGROUND_SECONDARY) );66 GetPainter().Paint2DQuadColor(graphics_engine, geo, Color(COLOR_FOREGROUND_SECONDARY));
67 }67 }
6868
69 if(m_Icon)69 if (m_Icon)
70 GetPainter().Draw2DTextureAligned (GfxContext, m_Icon, icon_geo, TextureAlignmentStyle (eTACenter, eTACenter) );70 GetPainter().Draw2DTextureAligned(graphics_engine, m_Icon, icon_geo, TextureAlignmentStyle(eTACenter, eTACenter));
7171
72 GetPainter().PaintTextLineStatic (GfxContext, GetSysFont(), text_geo, std::string (label), Color (0xFF000000), eAlignTextLeft);72 GetPainter().PaintTextLineStatic(graphics_engine, GetSysFont(), text_geo, std::string(label), Color(0xFF000000), eAlignTextLeft);
73 }73 }
7474
75 void ActionItem::DrawAsToolButton (GraphicsEngine &GfxContext, InputArea &area)75 void ActionItem::DrawAsToolButton(GraphicsEngine &graphics_engine, InputArea &area)
76 {76 {
77 Geometry base = area.GetGeometry();77 Geometry base = area.GetGeometry();
7878
79 if (area.IsMouseOwner() )79 if (area.IsMouseOwner())
80 {80 {
81 if (area.IsMouseInside() )81 if (area.IsMouseInside())
82 {82 {
83 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);83 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
84 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BLACK), eSTROKE_CORNER_ROUND2);84 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
85 }85 }
86 else86 else
87 {87 {
88 GetPainter().PaintShape (GfxContext, base, Color (COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);88 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
89 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BLACK), eSTROKE_CORNER_ROUND2);89 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
90 }90 }
91 }91 }
92 else92 else
93 {93 {
94 if (area.IsMouseInside() && (!area.MouseFocusOnOtherArea() ) )94 if (area.IsMouseInside() && (!area.MouseFocusOnOtherArea()))
95 {95 {
96 GetPainter().PaintShape (GfxContext, base, Color (COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);96 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
97 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BLACK), eSTROKE_CORNER_ROUND2);97 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
98 }98 }
99 else99 else
100 {100 {
101 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);101 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
102 GetPainter().PaintShape (GfxContext, base, Color (COLOR_BLACK), eSTROKE_CORNER_ROUND2);102 GetPainter().PaintShape(graphics_engine, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
103 }103 }
104 }104 }
105105
106 GetPainter().Draw2DTextureAligned (GfxContext, m_Icon, base, TextureAlignmentStyle (eTACenter, eTACenter) );106 GetPainter().Draw2DTextureAligned(graphics_engine, m_Icon, base, TextureAlignmentStyle(eTACenter, eTACenter));
107 }107 }
108108
109 void ActionItem::Activate (bool b)109 void ActionItem::Activate(bool b)
110 {110 {
111 m_IsActivated = b;111 m_IsActivated = b;
112 }112 }
@@ -116,7 +116,7 @@
116 sigAction.emit();116 sigAction.emit();
117 }117 }
118118
119 void ActionItem::Enable (bool b)119 void ActionItem::Enable(bool b)
120 {120 {
121 m_Enable = b;121 m_Enable = b;
122 }122 }
@@ -126,19 +126,19 @@
126 return m_Enable;126 return m_Enable;
127 }127 }
128128
129 void ActionItem::SetLabel (const TCHAR *label)129 void ActionItem::SetLabel(const char *label)
130 {130 {
131 m_Label = label;131 m_Label = label;
132 }132 }
133133
134 const TCHAR *ActionItem::GetLabel() const134 const char *ActionItem::GetLabel() const
135 {135 {
136 return m_Label.GetTCharPtr();136 return m_Label.GetTCharPtr();
137 }137 }
138138
139 void ActionItem::SetIcon (const BaseTexture* icon)139 void ActionItem::SetIcon(const BaseTexture* icon)
140 {140 {
141 if(m_Icon)141 if (m_Icon)
142 m_Icon->UnReference();142 m_Icon->UnReference();
143 m_Icon = icon->Clone();143 m_Icon = icon->Clone();
144 }144 }
145145
=== modified file 'Nux/AnimatedTextureArea.cpp'
--- Nux/AnimatedTextureArea.cpp 2011-09-20 06:03:43 +0000
+++ Nux/AnimatedTextureArea.cpp 2011-10-25 21:32:25 +0000
@@ -27,113 +27,108 @@
27namespace nux27namespace nux
28{28{
2929
30 AnimatedTextureArea::AnimatedTextureArea (NUX_FILE_LINE_DECL)30 AnimatedTextureArea::AnimatedTextureArea(NUX_FILE_LINE_DECL)
31 : View (NUX_FILE_LINE_PARAM)31 : View(NUX_FILE_LINE_PARAM)
32 , m_UserTexture (0)32 , m_UserTexture(0)
33 {33 {
34 SetMinMaxSize (32, 32);34 SetMinMaxSize(32, 32);
3535
36 mouse_down.connect (sigc::mem_fun (this, &AnimatedTextureArea::RecvMouseDown) );36 mouse_down.connect(sigc::mem_fun(this, &AnimatedTextureArea::RecvMouseDown));
37 mouse_drag.connect (sigc::mem_fun (this, &AnimatedTextureArea::RecvMouseDrag) );37 mouse_drag.connect(sigc::mem_fun(this, &AnimatedTextureArea::RecvMouseDrag));
3838
39 m_TimerFunctor = new TimerFunctor();39 m_TimerFunctor = new TimerFunctor();
40 m_TimerFunctor->OnTimerExpired.connect (sigc::mem_fun (this, &AnimatedTextureArea::TimerNextFrame) );40 m_TimerFunctor->time_expires.connect(sigc::mem_fun(this, &AnimatedTextureArea::TimerNextFrame));
41 }41 }
4242
43 AnimatedTextureArea::~AnimatedTextureArea()43 AnimatedTextureArea::~AnimatedTextureArea()
44 {44 {
45 GetTimer().RemoveTimerHandler (m_TimerHandler);45 GetTimer().RemoveTimerHandler(m_TimerHandler);
46 m_TimerHandler = 0;46 m_TimerHandler = 0;
47 delete m_TimerFunctor;47 delete m_TimerFunctor;
48 m_TimerFunctor = 0;48 m_TimerFunctor = 0;
49 }49 }
5050
51 long AnimatedTextureArea::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)51 void AnimatedTextureArea::Draw(GraphicsEngine &graphics_engine, bool force_draw)
52 {
53 return PostProcessEvent2 (ievent, TraverseInfo, ProcessEventInfo);
54 }
55
56 void AnimatedTextureArea::Draw (GraphicsEngine &GfxContext, bool force_draw)
57 {52 {
58 if (m_UserTexture)53 if (m_UserTexture)
59 {54 {
60 GetPainter().PaintBackground (GfxContext, GetGeometry() );55 GetPainter().PaintBackground(graphics_engine, GetGeometry());
61 GfxContext.GetRenderStates().SetBlend (true, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);56 graphics_engine.GetRenderStates().SetBlend(true, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
62 nux::Geometry base = GetGeometry();57 nux::Geometry base = GetGeometry();
63 nux::TexCoordXForm texxform;58 nux::TexCoordXForm texxform;
64 GfxContext.QRP_1Tex (base.x, base.y, base.width, base.height, m_UserTexture->GetDeviceTexture(), texxform, nux::color::White);59 graphics_engine.QRP_1Tex(base.x, base.y, base.width, base.height, m_UserTexture->GetDeviceTexture(), texxform, nux::color::White);
6560
66 GfxContext.GetRenderStates().SetBlend (false);61 graphics_engine.GetRenderStates().SetBlend(false);
67 }62 }
68 }63 }
69 void AnimatedTextureArea::DrawContent (GraphicsEngine &GfxContext, bool force_draw)64 void AnimatedTextureArea::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
70 {65 {
7166
72 }67 }
7368
74 void AnimatedTextureArea::PostDraw (GraphicsEngine &GfxContext, bool force_draw)69 void AnimatedTextureArea::PostDraw(GraphicsEngine &graphics_engine, bool force_draw)
75 {70 {
7671
77 }72 }
7873
79 void AnimatedTextureArea::SetTexture (TextureFrameAnimation *Texture)74 void AnimatedTextureArea::SetTexture(TextureFrameAnimation *Texture)
80 {75 {
81 m_UserTexture = Texture;76 m_UserTexture = Texture;
8277
83 if (m_UserTexture)78 if (m_UserTexture)
84 {79 {
85 ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource (m_UserTexture);80 ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(m_UserTexture);
86 ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();81 ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
87 ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();82 ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
8883
89 AnimatedTexture->SetFiltering (GL_LINEAR, GL_LINEAR);84 AnimatedTexture->SetFiltering(GL_LINEAR, GL_LINEAR);
90 AnimatedTexture->SetWrap (GL_CLAMP, GL_CLAMP, GL_CLAMP);85 AnimatedTexture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP);
91 }86 }
9287
93 QueueDraw();88 QueueDraw();
94 }89 }
9590
96 void AnimatedTextureArea::RecvMouseDown (int x, int y, long button_flags, long key_flags)91 void AnimatedTextureArea::RecvMouseDown(int x, int y, long button_flags, long key_flags)
97 {92 {
98 sigMouseDown.emit (x, y);93 sigMouseDown.emit(x, y);
99 }94 }
10095
101 void AnimatedTextureArea::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)96 void AnimatedTextureArea::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
102 {97 {
103 sigMouseDrag.emit (x, y);98 sigMouseDrag.emit(x, y);
104 }99 }
105100
106 void AnimatedTextureArea::StartAnimation()101 void AnimatedTextureArea::StartAnimation()
107 {102 {
108 if (m_TimerHandler.IsValid() )103 if (m_TimerHandler.IsValid())
109 {104 {
110 GetTimer().RemoveTimerHandler (m_TimerHandler);105 GetTimer().RemoveTimerHandler(m_TimerHandler);
111 m_TimerHandler = 0;106 m_TimerHandler = 0;
112 }107 }
113108
114 m_TimerHandler = GetTimer().AddTimerHandler (41, m_TimerFunctor, 0);109 m_TimerHandler = GetTimer().AddTimerHandler(41, m_TimerFunctor, 0);
115 QueueDraw();110 QueueDraw();
116 }111 }
117112
118 void AnimatedTextureArea::StopAnimation()113 void AnimatedTextureArea::StopAnimation()
119 {114 {
120 if (m_TimerHandler.IsValid() )115 if (m_TimerHandler.IsValid())
121 {116 {
122 GetTimer().RemoveTimerHandler (m_TimerHandler);117 GetTimer().RemoveTimerHandler(m_TimerHandler);
123 m_TimerHandler = 0;118 m_TimerHandler = 0;
124 }119 }
125 }120 }
126121
127 void AnimatedTextureArea::TimerNextFrame (void *v)122 void AnimatedTextureArea::TimerNextFrame(void *v)
128 {123 {
129 if (m_UserTexture)124 if (m_UserTexture)
130 {125 {
131 ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource (m_UserTexture);126 ObjectPtr< CachedTextureFrameAnimation > Texture = GetGraphicsDisplay()->GetGraphicsEngine()->CacheResource(m_UserTexture);
132 ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();127 ObjectPtr<IOpenGLAnimatedTexture> AnimatedTexture = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
133 ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();128 ObjectPtr<IOpenGLBaseTexture> Texture2D = Texture->m_Texture; //Texture->m_Texture.CastRef<IOpenGLAnimatedTexture>();
134129
135 AnimatedTexture->PresentNextFrame();130 AnimatedTexture->PresentNextFrame();
136 m_TimerHandler = GetTimer().AddTimerHandler (41, m_TimerFunctor, 0);131 m_TimerHandler = GetTimer().AddTimerHandler(41, m_TimerFunctor, 0);
137 }132 }
138133
139 QueueDraw();134 QueueDraw();
140135
=== modified file 'Nux/AnimatedTextureArea.h'
--- Nux/AnimatedTextureArea.h 2011-09-20 06:03:43 +0000
+++ Nux/AnimatedTextureArea.h 2011-10-25 21:32:25 +0000
@@ -32,16 +32,15 @@
32 class AnimatedTextureArea : public View32 class AnimatedTextureArea : public View
33 {33 {
34 public:34 public:
35 AnimatedTextureArea (NUX_FILE_LINE_PROTO);35 AnimatedTextureArea(NUX_FILE_LINE_PROTO);
36 ~AnimatedTextureArea();36 ~AnimatedTextureArea();
37 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);37 virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
38 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);38 virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
39 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);39 virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
40 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
4140
42 void SetTexture (TextureFrameAnimation *Texture);41 void SetTexture(TextureFrameAnimation *Texture);
43 void RecvMouseDown (int x, int y, long button_flags, long key_flags);42 void RecvMouseDown(int x, int y, long button_flags, long key_flags);
44 void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);43 void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
4544
46 sigc::signal<void, int, int> sigMouseDown;45 sigc::signal<void, int, int> sigMouseDown;
47 sigc::signal<void, int, int> sigMouseDrag;46 sigc::signal<void, int, int> sigMouseDrag;
@@ -51,7 +50,7 @@
5150
5251
53 private:52 private:
54 void TimerNextFrame (void *v);53 void TimerNextFrame(void *v);
55 TimerFunctor *m_TimerFunctor;54 TimerFunctor *m_TimerFunctor;
56 TimerHandle m_TimerHandler;55 TimerHandle m_TimerHandler;
5756
5857
=== modified file 'Nux/Area.cpp'
--- Nux/Area.cpp 2011-09-20 06:03:43 +0000
+++ Nux/Area.cpp 2011-10-25 21:32:25 +0000
@@ -32,38 +32,37 @@
32namespace nux32namespace nux
33{33{
3434
35 NUX_IMPLEMENT_OBJECT_TYPE (Area);35 NUX_IMPLEMENT_OBJECT_TYPE(Area);
3636
37 Area::Area (NUX_FILE_LINE_DECL)37 Area::Area (NUX_FILE_LINE_DECL)
38 : InitiallyUnownedObject (NUX_FILE_LINE_PARAM)38 : InitiallyUnownedObject(NUX_FILE_LINE_PARAM)
39 , _is_focused (0)39 , geometry_(0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT)
40 , _geometry (0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT)40 , min_size_(AREA_MIN_WIDTH, AREA_MIN_HEIGHT)
41 , _min_size (AREA_MIN_WIDTH, AREA_MIN_HEIGHT)41 , max_size_(AREA_MAX_WIDTH, AREA_MAX_HEIGHT)
42 , _max_size (AREA_MAX_WIDTH, AREA_MAX_HEIGHT)42 , _direction (GetDefaultDirection())
43 {43 {
44 _parent_area = NULL;44 visible_ = true;
45 view_enabled_ = true;
46 parent_area_ = NULL;
47
45 next_object_to_key_focus_area_ = NULL;48 next_object_to_key_focus_area_ = NULL;
46 has_key_focus_ = false;49 has_key_focus_ = false;
4750
48 _stretch_factor = 1;51 scale_factor_ = 1;
49 _layout_properties = NULL;52 sensitive_ = true;
50 _visible = true;
51 _sensitive = true;
5253
53 _on_geometry_changeg_reconfigure_parent_layout = true;54 on_geometry_change_reconfigure_parent_layout_ = true;
54 _accept_mouse_wheel_event = false;55 _accept_mouse_wheel_event = false;
55 _accept_keyboard_event = false;56 _accept_keyboard_event = false;
5657
57 _2d_xform.Identity ();58 _2d_xform.Identity();
58 _3d_xform.Identity ();59 _3d_xform.Identity();
59 _3d_area = false;60 _3d_area = false;
60 }61 }
6162
6263
63 Area::~Area()64 Area::~Area()
64 {65 {
65 if (_layout_properties)
66 delete _layout_properties;
67 }66 }
6867
69 const NString &Area::GetBaseString() const68 const NString &Area::GetBaseString() const
@@ -71,362 +70,360 @@
71 return _base_string;70 return _base_string;
72 }71 }
7372
74 void Area::SetBaseString (const TCHAR *Caption)73 void Area::SetBaseString(const char *Caption)
75 {74 {
76 _base_string = Caption;75 _base_string = Caption;
77 }76 }
7877
79 void Area::CheckMinSize()78 void Area::CheckMinSize()
80 {79 {
81 int w = _min_size.width;80 int w = min_size_.width;
82 w = Max<int>(AREA_MIN_WIDTH, w);81 w = Max<int>(AREA_MIN_WIDTH, w);
83 int h = _min_size.height;82 int h = min_size_.height;
84 h = Max<int>(AREA_MIN_HEIGHT, h);83 h = Max<int>(AREA_MIN_HEIGHT, h);
8584
86 _min_size = Size(w, h);85 min_size_ = Size(w, h);
8786
88 if (_min_size.width > _max_size.width)87 if (min_size_.width > max_size_.width)
89 {88 {
90 _max_size.width = _min_size.width;89 max_size_.width = min_size_.width;
91 }90 }
9291
93 if (_min_size.height > _max_size.height)92 if (min_size_.height > max_size_.height)
94 {93 {
95 _max_size.height = _min_size.height;94 max_size_.height = min_size_.height;
96 }95 }
9796
98 if (_geometry.width < _min_size.width)97 if (geometry_.width < min_size_.width)
99 {98 {
100 _geometry.width = _min_size.width;99 geometry_.width = min_size_.width;
101 }100 }
102101
103 if (_geometry.height < _min_size.height )102 if (geometry_.height < min_size_.height )
104 {103 {
105 _geometry.height = _min_size.height;104 geometry_.height = min_size_.height;
106 }105 }
107 }106 }
108107
109 void Area::CheckMaxSize()108 void Area::CheckMaxSize()
110 {109 {
111 int w = _max_size.width;110 int w = max_size_.width;
112 w = Min<int>(AREA_MAX_WIDTH, w);111 w = w <= AREA_MAX_WIDTH ? w : AREA_MAX_WIDTH;
113 int h = _max_size.height;112 int h = max_size_.height;
114 h = Min<int>(AREA_MAX_HEIGHT, h);113 h = h <= AREA_MAX_HEIGHT ? h: AREA_MAX_HEIGHT;
115114
116 _max_size = Size(w, h);115 max_size_ = Size(w, h);
117116
118 if (_min_size.width > _max_size.width)117 if (min_size_.width > max_size_.width)
119 {118 {
120 _min_size.width = _max_size.width;119 min_size_.width = max_size_.width;
121 }120 }
122121
123 if (_min_size.height > _max_size.height)122 if (min_size_.height > max_size_.height)
124 {123 {
125 _min_size.height = _max_size.height;124 min_size_.height = max_size_.height;
126 }125 }
127126
128 if (_geometry.width > _max_size.width)127 if (geometry_.width > max_size_.width)
129 {128 {
130 _geometry.width = _max_size.width;129 geometry_.width = max_size_.width;
131 }130 }
132131
133 if (_geometry.height > _max_size.height)132 if (geometry_.height > max_size_.height)
134 {133 {
135 _geometry.height = _max_size.height;134 geometry_.height = max_size_.height;
136 }135 }
137 }136 }
138137
139 void Area::SetMinimumSize (int w, int h)138 void Area::SetMinimumSize(int w, int h)
140 {139 {
141 nuxAssert (w >= 0);140 nuxAssert(w >= 0);
142 nuxAssert (h >= 0);141 nuxAssert(h >= 0);
143 _min_size = Size(w, h);142 min_size_ = Size(w, h);
144143
145 CheckMinSize();144 CheckMinSize();
146145
147 ReconfigureParentLayout();146 ReconfigureParentLayout();
148 }147 }
149148
150 void Area::SetMaximumSize (int w, int h)149 void Area::SetMaximumSize(int w, int h)
151 {150 {
152 nuxAssert (w >= 0);151 nuxAssert(w >= 0);
153 nuxAssert (h >= 0);152 nuxAssert(h >= 0);
154 _max_size = Size(w, h);153 max_size_ = Size(w, h);
155154
156 CheckMaxSize();155 CheckMaxSize();
157156
158 ReconfigureParentLayout();157 ReconfigureParentLayout();
159 }158 }
160159
161 void Area::SetMinMaxSize (int w, int h)160 void Area::SetMinMaxSize(int w, int h)
162 {161 {
163 nuxAssert (w >= 0);162 nuxAssert(w >= 0);
164 nuxAssert (h >= 0);163 nuxAssert(h >= 0);
165 SetMinimumSize (w, h);164 SetMinimumSize(w, h);
166 SetMaximumSize (w, h);165 SetMaximumSize(w, h);
167166
168 //ReconfigureParentLayout();167 //ReconfigureParentLayout();
169 }168 }
170169
171 void Area::ApplyMinWidth()170 void Area::ApplyMinWidth()
172 {171 {
173 _geometry.width = _min_size.width;172 geometry_.width = min_size_.width;
174173
175 ReconfigureParentLayout();174 ReconfigureParentLayout();
176 }175 }
177176
178 void Area::ApplyMinHeight()177 void Area::ApplyMinHeight()
179 {178 {
180 _geometry.height = _min_size.height;179 geometry_.height = min_size_.height;
181180
182 ReconfigureParentLayout();181 ReconfigureParentLayout();
183 }182 }
184183
185 void Area::ApplyMaxWidth()184 void Area::ApplyMaxWidth()
186 {185 {
187 _geometry.width = _max_size.width;186 geometry_.width = max_size_.width;
188187
189 ReconfigureParentLayout();188 ReconfigureParentLayout();
190 }189 }
191190
192 void Area::ApplyMaxHeight()191 void Area::ApplyMaxHeight()
193 {192 {
194 _geometry.height = _max_size.height;193 geometry_.height = max_size_.height;
195194
196 ReconfigureParentLayout();195 ReconfigureParentLayout();
197 }196 }
198197
199 Size Area::GetMinimumSize() const198 Size Area::GetMinimumSize() const
200 {199 {
201 return _min_size;200 return min_size_;
202 }201 }
203202
204 Size Area::GetMaximumSize() const203 Size Area::GetMaximumSize() const
205 {204 {
206 return _max_size;205 return max_size_;
207 }206 }
208207
209 void Area::SetMinimumWidth (int w)208 void Area::SetMinimumWidth(int w)
210 {209 {
211 nuxAssert (w >= 0);210 nuxAssert(w >= 0);
212 _min_size.width = w;211 min_size_.width = w;
213 CheckMinSize();212 CheckMinSize();
214 ReconfigureParentLayout();213 ReconfigureParentLayout();
215 }214 }
216215
217 void Area::SetMaximumWidth (int w)216 void Area::SetMaximumWidth(int w)
218 {217 {
219 nuxAssert (w >= 0);218 nuxAssert(w >= 0);
220 _max_size.width = w;219 max_size_.width = w;
221 CheckMaxSize();220 CheckMaxSize();
222 ReconfigureParentLayout();221 ReconfigureParentLayout();
223 }222 }
224223
225 void Area::SetMinimumHeight (int h)224 void Area::SetMinimumHeight(int h)
226 {225 {
227 nuxAssert (h >= 0);226 nuxAssert(h >= 0);
228 _min_size.height = h;227 min_size_.height = h;
229 CheckMinSize();228 CheckMinSize();
230 ReconfigureParentLayout();229 ReconfigureParentLayout();
231 }230 }
232231
233 void Area::SetMaximumHeight (int h)232 void Area::SetMaximumHeight(int h)
234 {233 {
235 nuxAssert (h >= 0);234 nuxAssert(h >= 0);
236 _max_size.height = h;235 max_size_.height = h;
237 CheckMaxSize();236 CheckMaxSize();
238 ReconfigureParentLayout();237 ReconfigureParentLayout();
239 }238 }
240239
241 int Area::GetMinimumWidth() const240 int Area::GetMinimumWidth() const
242 {241 {
243 return _min_size.width;242 return min_size_.width;
244 }243 }
245244
246 int Area::GetMaximumWidth() const245 int Area::GetMaximumWidth() const
247 {246 {
248 return _max_size.width;247 return max_size_.width;
249 }248 }
250249
251 int Area::GetMinimumHeight() const250 int Area::GetMinimumHeight() const
252 {251 {
253 return _min_size.height;252 return min_size_.height;
254 }253 }
255254
256 int Area::GetMaximumHeight() const255 int Area::GetMaximumHeight() const
257 {256 {
258 return _max_size.height;257 return max_size_.height;
259 }258 }
260259
261 unsigned int Area::GetStretchFactor()260 unsigned int Area::GetScaleFactor()
262 {261 {
263 return _stretch_factor;262 return scale_factor_;
264 }263 }
265264
266 void Area::SetStretchFactor (unsigned int sf)265 void Area::SetScaleFactor(unsigned int sf)
267 {266 {
268 // re implemented by Layout267 // re implemented by Layout
269 _stretch_factor = sf;268 scale_factor_ = sf;
270 }269 }
271270
272 void Area::SetParentObject (Area *bo)271 bool Area::SetParentObject(Area *parent)
273 {272 {
274 if (bo == 0)273 if (parent == 0)
275 {274 {
276 nuxAssertMsg (0, TEXT ("[Area::SetParentObject] Invalid parent obejct.") );275 nuxAssertMsg(0, "[Area::SetParentObject] Invalid parent obejct.");
277 return;276 return false;
278 }277 }
279278
280 if (_parent_area)279 if (parent_area_ && (parent_area_ != parent))
281 {280 {
282 nuxAssertMsg (0, TEXT ("[Area::SetParentObject] Object already has a parent. You must UnParent the object before you can parenting again.") );281 nuxAssertMsg(0, "[Area::SetParentObject] Object already has a parent. You must UnParent the object before you can parenting again.");
283 return;282 return false;
284 }283 }
285284
286 _parent_area = bo;285 if (parent_area_)
286 {
287 // Already parented to the same area. Return.
288 return true;
289 }
290
291 parent_area_ = parent;
287 Reference();292 Reference();
293
294 return true;
288 }295 }
289296
290 void Area::UnParentObject()297 void Area::UnParentObject()
291 {298 {
292 if (_parent_area)299 if (parent_area_)
293 {300 {
294 _parent_area = 0;301 parent_area_ = 0;
295 UnReference();302 UnReference();
296 }303 }
297 }304 }
298305
299 Area *Area::GetParentObject() const306 Area *Area::GetParentObject() const
300 {307 {
301 return _parent_area;308 return parent_area_;
302 }309 }
303310
304 int Area::GetBaseX () const311 int Area::GetBaseX () const
305 {312 {
306 return _geometry.x;313 return geometry_.x;
307 }314 }
308315
309 int Area::GetBaseY () const316 int Area::GetBaseY () const
310 {317 {
311 return _geometry.y;318 return geometry_.y;
312 }319 }
313320
314 int Area::GetBaseWidth () const321 int Area::GetBaseWidth () const
315 {322 {
316 return _geometry.width;323 return geometry_.width;
317 }324 }
318325
319 int Area::GetBaseHeight () const326 int Area::GetBaseHeight () const
320 {327 {
321 return _geometry.height;328 return geometry_.height;
322 }329 }
323330
324 void Area::SetGeometry(int x, int y, int w, int h)331 void Area::SetGeometry(int x, int y, int w, int h)
325 {332 {
326 h = nux::Clamp<int> (h, _min_size.height, _max_size.height);333 h = nux::Clamp<int> (h, min_size_.height, max_size_.height);
327 w = nux::Clamp<int> (w, _min_size.width, _max_size.width);334 w = nux::Clamp<int> (w, min_size_.width, max_size_.width);
328335
329 nux::Geometry geometry(x, y, w, h);336 nux::Geometry geometry(x, y, w, h);
330 if (_geometry == geometry)337 if (geometry_ == geometry)
331 return;338 return;
332339
333 GeometryChangePending();340 GeometryChangePending();
334 _geometry = geometry;341 geometry_ = geometry;
335 ReconfigureParentLayout();342 ReconfigureParentLayout();
336 GeometryChanged();343 GeometryChanged();
337344
338 OnGeometryChanged.emit(this, _geometry);345 OnGeometryChanged.emit(this, geometry_);
339 }346 }
340347
341 void Area::SetGeometry (const Geometry &geo)348 void Area::SetGeometry(const Geometry &geo)
342 {349 {
343 SetGeometry (geo.x, geo.y, geo.width, geo.height);350 SetGeometry(geo.x, geo.y, geo.width, geo.height);
344 }351 }
345352
346 Geometry const& Area::GetGeometry() const353 Geometry const& Area::GetGeometry() const
347 {354 {
348 return _geometry;355 return geometry_;
349 }356 }
350357
351 void Area::SetBaseX(int x)358 void Area::SetBaseX(int x)
352 {359 {
353 SetGeometry(x, _geometry.y, _geometry.width, _geometry.height);360 SetGeometry(x, geometry_.y, geometry_.width, geometry_.height);
354 }361 }
355362
356 void Area::SetBaseY (int y)363 void Area::SetBaseY (int y)
357 {364 {
358 SetGeometry (_geometry.x, y, _geometry.width, _geometry.height);365 SetGeometry(geometry_.x, y, geometry_.width, geometry_.height);
359 }366 }
360367
361 void Area::SetBaseXY (int x, int y)368 void Area::SetBaseXY (int x, int y)
362 {369 {
363 SetGeometry (x, y, _geometry.width, _geometry.height);370 SetGeometry(x, y, geometry_.width, geometry_.height);
364 }371 }
365372
366 void Area::SetBaseSize (int w, int h)373 void Area::SetBaseSize(int w, int h)
367 {374 {
368 SetGeometry (_geometry.x, _geometry.y, w, h);375 SetGeometry(geometry_.x, geometry_.y, w, h);
369 }376 }
370377
371 void Area::SetBaseWidth (int w)378 void Area::SetBaseWidth(int w)
372 {379 {
373 SetGeometry (_geometry.x, _geometry.y, w, _geometry.height);380 SetGeometry(geometry_.x, geometry_.y, w, geometry_.height);
374 }381 }
375382
376 void Area::SetBaseHeight (int h)383 void Area::SetBaseHeight(int h)
377 {384 {
378 SetGeometry (_geometry.x, _geometry.y, _geometry.width, h);385 SetGeometry(geometry_.x, geometry_.y, geometry_.width, h);
379 }386 }
380387
381 void Area::IncreaseSize (int x, int y)388 void Area::IncreaseSize(int x, int y)
382 {389 {
383 _geometry.OffsetPosition (x, y);390 geometry_.OffsetPosition(x, y);
384 OnResize.emit (_geometry.x, _geometry.y, _geometry.width, _geometry.height );391 OnResize.emit(geometry_.x, geometry_.y, geometry_.width, geometry_.height );
385 }392 }
386393
387 long Area::ComputeChildLayout()394 long Area::ComputeContentSize()
388 {
389 return 0;
390 }
391
392 void Area::PositionChildLayout (float offsetX, float offsetY)
393 {
394
395 }
396
397 long Area::ComputeLayout2()
398 {395 {
399 return (eCompliantWidth | eCompliantHeight);396 return (eCompliantWidth | eCompliantHeight);
400 }397 }
401398
402 void Area::ComputePosition2 (float offsetX, float offsetY)399 void Area::ComputeContentPosition(float offsetX, float offsetY)
403 {400 {
404401
405 }402 }
406403
407 void Area::SetReconfigureParentLayoutOnGeometryChange(bool reconfigure_parent_layout)404 void Area::SetReconfigureParentLayoutOnGeometryChange(bool reconfigure_parent_layout)
408 {405 {
409 _on_geometry_changeg_reconfigure_parent_layout = reconfigure_parent_layout;406 on_geometry_change_reconfigure_parent_layout_ = reconfigure_parent_layout;
410 }407 }
411 408
412 bool Area::ReconfigureParentLayoutOnGeometryChange()409 bool Area::ReconfigureParentLayoutOnGeometryChange()
413 {410 {
414 return _on_geometry_changeg_reconfigure_parent_layout;411 return on_geometry_change_reconfigure_parent_layout_;
415 }412 }
416413
417 void Area::ReconfigureParentLayout(Area *child)414 void Area::ReconfigureParentLayout(Area *child)
418 {415 {
419 if(_on_geometry_changeg_reconfigure_parent_layout == false)416 if (on_geometry_change_reconfigure_parent_layout_ == false)
420 return;417 return;
421418
422 if (GetWindowThread ()->IsComputingLayout() )419 if (GetWindowThread() && GetWindowThread()->IsComputingLayout())
423 {420 {
424 // there is no need to do the following while we are already computing the layout.421 // there is no need to do the following while we are already computing the layout.
425 // If we do, we will end up in an infinite loop.422 // If we do, we will end up in an infinite loop.
426 return;423 return;
427 }424 }
428425
429 if (this->Type().IsDerivedFromType (View::StaticObjectType) )426 if (this->Type().IsDerivedFromType(View::StaticObjectType))
430 {427 {
431 // The object that is being resized is a View object and it has a parent.428 // The object that is being resized is a View object and it has a parent.
432 if (this->OwnsTheReference() == false && this->GetParentObject())429 if (this->OwnsTheReference() == false && this->GetParentObject())
@@ -437,29 +434,29 @@
437434
438 View *ic = static_cast<View *>(this);435 View *ic = static_cast<View *>(this);
439436
440 if (ic->CanBreakLayout() )437 if (ic->CanBreakLayout())
441 {438 {
442439
443 if ( (child != 0) &&440 if ((child != 0) &&
444 (ic->Type().IsObjectType (VSplitter::StaticObjectType) || ic->Type().IsObjectType (HSplitter::StaticObjectType) ) )441 (ic->Type().IsObjectType(VSplitter::StaticObjectType) || ic->Type().IsObjectType(HSplitter::StaticObjectType)))
445 {442 {
446 // If this element is a Splitter, then we submit its child to the refresh list. We don't want to submit the443 // If this element is a Splitter, then we submit its child to the refresh list. We don't want to submit the
447 // splitter because this will cause a redraw of all parts of the splitter (costly and unnecessary).444 // splitter because this will cause a redraw of all parts of the splitter(costly and unnecessary).
448 GetWindowThread ()->QueueObjectLayout (child);445 GetWindowThread()->QueueObjectLayout(child);
449 }446 }
450 else447 else
451 {448 {
452 GetWindowThread ()->QueueObjectLayout (ic);449 GetWindowThread()->QueueObjectLayout(ic);
453 }450 }
454 }451 }
455 else if (ic->_parent_area)452 else if (ic->parent_area_)
456 ic->_parent_area->ReconfigureParentLayout (this);453 ic->parent_area_->ReconfigureParentLayout(this);
457 else454 else
458 {455 {
459 GetWindowThread ()->QueueObjectLayout (ic);456 GetWindowThread()->QueueObjectLayout(ic);
460 }457 }
461 }458 }
462 else if (this->Type().IsDerivedFromType (Layout::StaticObjectType) )459 else if (this->Type().IsDerivedFromType(Layout::StaticObjectType))
463 {460 {
464 // The object that is being resized is a View object and it has a parent.461 // The object that is being resized is a View object and it has a parent.
465 if (this->OwnsTheReference() == false && this->GetParentObject())462 if (this->OwnsTheReference() == false && this->GetParentObject())
@@ -470,47 +467,47 @@
470467
471 Layout *layout = static_cast<Layout *>(this);468 Layout *layout = static_cast<Layout *>(this);
472469
473 if (layout->_parent_area)470 if (layout->parent_area_)
474 {471 {
475 if (layout->_parent_area->Type().IsDerivedFromType (View::StaticObjectType) )472 if (layout->parent_area_->Type().IsDerivedFromType(View::StaticObjectType))
476 {473 {
477 View *ic = (View *) (layout->_parent_area);474 View *ic = (View *) (layout->parent_area_);
478475
479 if (ic->CanBreakLayout() )476 if (ic->CanBreakLayout())
480 {477 {
481 if ( (child != 0) &&478 if ((child != 0) &&
482 (ic->Type().IsObjectType (VSplitter::StaticObjectType) || ic->Type().IsObjectType (HSplitter::StaticObjectType) ) )479 (ic->Type().IsObjectType(VSplitter::StaticObjectType) || ic->Type().IsObjectType(HSplitter::StaticObjectType)))
483 {480 {
484 // If the parent of this element is a splitter, then we submit its child to the refresh list. We don't want to submit the481 // If the parent of this element is a splitter, then we submit its child to the refresh list. We don't want to submit the
485 // splitter because this will cause a redraw of all parts of the splitter (costly and unnecessary).482 // splitter because this will cause a redraw of all parts of the splitter(costly and unnecessary).
486 GetWindowThread ()->QueueObjectLayout (this);483 GetWindowThread()->QueueObjectLayout(this);
487 }484 }
488 else485 else
489 {486 {
490 GetWindowThread ()->QueueObjectLayout (ic);487 GetWindowThread()->QueueObjectLayout(ic);
491 }488 }
492 }489 }
493 else490 else
494 {491 {
495 // The parent object of an object of type View is a Layout object type.492 // The parent object of an object of type View is a Layout object type.
496 layout->_parent_area->ReconfigureParentLayout (this);493 layout->parent_area_->ReconfigureParentLayout(this);
497 }494 }
498 }495 }
499 else496 else
500 {497 {
501 layout->_parent_area->ReconfigureParentLayout (this);498 layout->parent_area_->ReconfigureParentLayout(this);
502 }499 }
503 }500 }
504 else501 else
505 {502 {
506 // This is possibly the Main layout or the layout of a floating object (popup for example) unless the layout is not part of the object tree.503 // This is possibly the Main layout or the layout of a floating object(popup for example) unless the layout is not part of the object tree.
507 GetWindowThread ()->QueueObjectLayout (layout);504 GetWindowThread()->QueueObjectLayout(layout);
508 }505 }
509 }506 }
510 else507 else
511 {508 {
512 // The object that is being resized is a InputArea object.509 // The object that is being resized is a InputArea object.
513 if (this->_parent_area)510 if (this->parent_area_)
514 {511 {
515 // The object that is being resized is a View object and it has a parent.512 // The object that is being resized is a View object and it has a parent.
516 if (this->OwnsTheReference() == false && this->GetParentObject())513 if (this->OwnsTheReference() == false && this->GetParentObject())
@@ -520,125 +517,128 @@
520 }517 }
521518
522 // The parent object of an object of type InputArea is a Layout object type.519 // The parent object of an object of type InputArea is a Layout object type.
523 this->_parent_area->ReconfigureParentLayout (this);520 this->parent_area_->ReconfigureParentLayout(this);
524 }521 }
525 }522 }
526 }523 }
527524
528 void Area::RequestBottomUpLayoutComputation (Area *bo_initiator)525 void Area::RequestBottomUpLayoutComputation(Area *bo_initiator)
529 {526 {
530 if (_parent_area && _parent_area->IsLayout() )527 if (parent_area_ && parent_area_->IsLayout())
531 {528 {
532 _parent_area->RequestBottomUpLayoutComputation (bo_initiator);529 parent_area_->RequestBottomUpLayoutComputation(bo_initiator);
533 }530 }
534 }531 }
535532
536 void Area::SetLayoutProperties (LayoutProperties *properties)533 void Area::SetVisible(bool visible)
537 {534 {
538 if (_layout_properties)535 if (IsLayout())
539 delete _layout_properties;536 return;
540537
541 _layout_properties = properties;538 if (visible_ == visible)
542 }539 return;
543540
544 Area::LayoutProperties * Area::GetLayoutProperties ()541 visible_ = visible;
545 {542
546 return _layout_properties;543 OnVisibleChanged.emit(this, visible_);
547 }544 }
548545
549 void Area::SetVisible (bool visible)546 bool Area::IsVisible()
550 {547 {
551 if (_visible == visible)548 return visible_;
552 return;549 }
553550
554 _visible = visible;551 void Area::SetSensitive(bool sensitive)
555552 {
556 OnVisibleChanged.emit (this, _visible);553 SetInputEventSensitivity(sensitive);
557 }554 }
558555
559 bool Area::IsVisible ()556 void Area::SetInputEventSensitivity(bool sensitive)
560 {557 {
561 return _visible;558 if (IsLayout())
562 }559 return;
563560
564 void Area::SetSensitive (bool sensitive)561 if (sensitive_ == sensitive)
565 {562 return;
566 if (_sensitive == sensitive)563
567 return;564 sensitive_ = sensitive;
568565
569 _sensitive = sensitive;566 OnSensitiveChanged.emit(this, sensitive_);
570567 }
571 OnSensitiveChanged.emit (this, _sensitive);568
572 }569 bool Area::IsSensitive() const
573570 {
574 bool Area::IsSensitive ()571 return GetInputEventSensitivity();
575 {572 }
576 return _sensitive;573
574 bool Area::GetInputEventSensitivity() const
575 {
576 return sensitive_;
577 }577 }
578578
579 MinorDimensionPosition Area::GetPositioning()579 MinorDimensionPosition Area::GetPositioning()
580 {580 {
581 return _positioning;581 return minor_axis_position_;
582 }582 }
583583
584 void Area::SetPositioning (MinorDimensionPosition p)584 void Area::SetPositioning(MinorDimensionPosition p)
585 {585 {
586 _positioning = p;586 minor_axis_position_ = p;
587 }587 }
588588
589 MinorDimensionSize Area::GetExtend()589 MinorDimensionSize Area::GetExtend()
590 {590 {
591 return _extend;591 return minor_axis_size_;
592 }592 }
593593
594 void Area::SetExtend (MinorDimensionSize ext)594 void Area::SetExtend(MinorDimensionSize ext)
595 {595 {
596 _extend = ext;596 minor_axis_size_ = ext;
597 }597 }
598598
599 float Area::GetPercentage()599 float Area::GetPercentage()
600 {600 {
601 return _percentage;601 return minor_axis_size_scale_;
602 }602 }
603603
604 void Area::SetPercentage (float p)604 void Area::SetPercentage(float p)
605 {605 {
606 _percentage = p;606 minor_axis_size_scale_ = p;
607 }607 }
608608
609 bool Area::IsLayoutDone()609 bool Area::IsLayoutDone()
610 {610 {
611 return _layout_done;611 return layout_done_;
612 }612 }
613613
614 void Area::SetLayoutDone (bool b)614 void Area::SetLayoutDone(bool b)
615 {615 {
616 _layout_done = b;616 layout_done_ = b;
617 }617 }
618618
619 bool Area::IsArea () const619 bool Area::IsArea() const
620 {620 {
621 return this->Type ().IsDerivedFromType (Area::StaticObjectType);;621 return this->Type().IsDerivedFromType(Area::StaticObjectType);;
622 }622 }
623623
624 bool Area::IsInputArea () const624 bool Area::IsInputArea() const
625 {625 {
626 return this->Type ().IsDerivedFromType (InputArea::StaticObjectType);;626 return this->Type().IsDerivedFromType(InputArea::StaticObjectType);;
627 }627 }
628628
629 bool Area::IsView () const629 bool Area::IsView() const
630 {630 {
631 return this->Type ().IsDerivedFromType (View::StaticObjectType);;631 return this->Type().IsDerivedFromType(View::StaticObjectType);;
632 }632 }
633633
634 bool Area::IsLayout () const634 bool Area::IsLayout() const
635 {635 {
636 return this->Type ().IsDerivedFromType (Layout::StaticObjectType);636 return this->Type().IsDerivedFromType(Layout::StaticObjectType);
637 }637 }
638638
639 bool Area::IsViewWindow () const639 bool Area::IsViewWindow() const
640 {640 {
641 return this->Type ().IsDerivedFromType (BaseWindow::StaticObjectType);641 return this->Type().IsDerivedFromType(BaseWindow::StaticObjectType);
642 }642 }
643643
644 bool Area::IsSpaceLayout() const644 bool Area::IsSpaceLayout() const
@@ -646,113 +646,113 @@
646 return this->Type().IsDerivedFromType(SpaceLayout::StaticObjectType);;646 return this->Type().IsDerivedFromType(SpaceLayout::StaticObjectType);;
647 }647 }
648648
649 void Area::Set2DMatrix (const Matrix4 &mat)649 void Area::Set2DMatrix(const Matrix4 &mat)
650 {650 {
651 _2d_xform = mat;651 _2d_xform = mat;
652 }652 }
653653
654 void Area::Set2DTranslation (float tx, float ty, float tz)654 void Area::Set2DTranslation(float tx, float ty, float tz)
655 {655 {
656 _2d_xform.Translate (tx, ty, tz);656 _2d_xform.Translate(tx, ty, tz);
657 }657 }
658658
659 Matrix4 Area::Get2DMatrix () const659 Matrix4 Area::Get2DMatrix() const
660 {660 {
661 return _2d_xform;661 return _2d_xform;
662 }662 }
663663
664 Matrix4 Area::Get3DMatrix () const664 Matrix4 Area::Get3DMatrix() const
665 {665 {
666 return _3d_xform;666 return _3d_xform;
667 }667 }
668668
669 bool Area::Is3DArea () const669 bool Area::Is3DArea() const
670 {670 {
671 return _3d_area;671 return _3d_area;
672 }672 }
673673
674 static void MatrixXFormGeometry (const Matrix4 &matrix, Geometry &geo)674 static void MatrixXFormGeometry(const Matrix4 &matrix, Geometry &geo)
675 {675 {
676 Vector4 in (geo.x, geo.y, 0, 1);676 Vector4 in(geo.x, geo.y, 0, 1);
677 // This is mean only for translation matrices. It will not work with matrices containing rotations or scalings.677 // This is mean only for translation matrices. It will not work with matrices containing rotations or scalings.
678 Vector4 out = matrix * in;678 Vector4 out = matrix * in;
679 geo.x = out.x;679 geo.x = out.x;
680 geo.y = out.y;680 geo.y = out.y;
681 }681 }
682682
683 void Area::InnerGetAbsoluteGeometry (Geometry &geometry)683 void Area::InnerGetAbsoluteGeometry(Geometry &geometry)
684 {684 {
685 if (this->Type ().IsDerivedFromType (BaseWindow::StaticObjectType) || (this == GetWindowThread ()->GetMainLayout ()))685 if (this->Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == GetWindowThread()->GetMainLayout()))
686 {686 {
687 geometry.OffsetPosition (_geometry.x, _geometry.y);687 geometry.OffsetPosition(geometry_.x, geometry_.y);
688 return;688 return;
689 }689 }
690690
691 MatrixXFormGeometry (_2d_xform, geometry);691 MatrixXFormGeometry(_2d_xform, geometry);
692692
693 Area *parent = GetParentObject ();693 Area *parent = GetParentObject();
694 if (parent)694 if (parent)
695 parent->InnerGetAbsoluteGeometry (geometry);695 parent->InnerGetAbsoluteGeometry(geometry);
696 }696 }
697697
698 Geometry Area::GetAbsoluteGeometry () const698 Geometry Area::GetAbsoluteGeometry() const
699 {699 {
700 if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) ||700 if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) ||
701 Type().IsDerivedFromType(MenuPage::StaticObjectType) ||701 Type().IsDerivedFromType(MenuPage::StaticObjectType) ||
702 (this == GetWindowThread()->GetMainLayout()))702 (this == GetWindowThread()->GetMainLayout()))
703 {703 {
704 // Do not apply the _2D_xform matrix to a BaseWindow or the main layout704 // Do not apply the _2D_xform matrix to a BaseWindow or the main layout
705 return _geometry;705 return geometry_;
706 }706 }
707 else707 else
708 {708 {
709 nux::Geometry geo = _geometry;709 nux::Geometry geo = geometry_;
710 MatrixXFormGeometry (_2d_xform, geo);710 MatrixXFormGeometry(_2d_xform, geo);
711711
712 Area *parent = GetParentObject ();712 Area *parent = GetParentObject();
713 if (parent)713 if (parent)
714 parent->InnerGetAbsoluteGeometry (geo);714 parent->InnerGetAbsoluteGeometry(geo);
715715
716 return geo;716 return geo;
717 }717 }
718 }718 }
719719
720 int Area::GetAbsoluteX () const720 int Area::GetAbsoluteX() const
721 {721 {
722 return GetAbsoluteGeometry ().x;722 return GetAbsoluteGeometry().x;
723 }723 }
724724
725 int Area::GetAbsoluteY () const725 int Area::GetAbsoluteY() const
726 {726 {
727 return GetAbsoluteGeometry ().y;727 return GetAbsoluteGeometry().y;
728 }728 }
729729
730 int Area::GetAbsoluteWidth () const730 int Area::GetAbsoluteWidth() const
731 {731 {
732 return GetAbsoluteGeometry ().width;732 return GetAbsoluteGeometry().width;
733 }733 }
734734
735 int Area::GetAbsoluteHeight () const735 int Area::GetAbsoluteHeight() const
736 {736 {
737 return GetAbsoluteGeometry ().height;737 return GetAbsoluteGeometry().height;
738 }738 }
739739
740 void Area::InnerGetRootGeometry (Geometry &geometry)740 void Area::InnerGetRootGeometry(Geometry &geometry)
741 {741 {
742 if (this->Type ().IsDerivedFromType (BaseWindow::StaticObjectType) || (this == GetWindowThread ()->GetMainLayout ()))742 if (this->Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == GetWindowThread()->GetMainLayout()))
743 return;743 return;
744744
745 MatrixXFormGeometry (_2d_xform, geometry);745 MatrixXFormGeometry(_2d_xform, geometry);
746746
747 Area *parent = GetParentObject ();747 Area *parent = GetParentObject();
748 if (parent)748 if (parent)
749 parent->InnerGetRootGeometry (geometry);749 parent->InnerGetRootGeometry(geometry);
750 }750 }
751751
752 Geometry Area::GetRootGeometry () const752 Geometry Area::GetRootGeometry() const
753 {753 {
754 nux::Geometry geo = _geometry;754 nux::Geometry geo = geometry_;
755 MatrixXFormGeometry (_2d_xform, geo);755 MatrixXFormGeometry(_2d_xform, geo);
756756
757 if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == GetWindowThread()->GetMainLayout()))757 if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == GetWindowThread()->GetMainLayout()))
758 {758 {
@@ -760,62 +760,67 @@
760 }760 }
761 else761 else
762 {762 {
763 Area *parent = GetParentObject ();763 Area *parent = GetParentObject();
764 if (parent)764 if (parent)
765 parent->InnerGetRootGeometry (geo);765 parent->InnerGetRootGeometry(geo);
766766
767 return geo;767 return geo;
768 }768 }
769 }769 }
770770
771 int Area::GetRootX () const771 int Area::GetRootX() const
772 {772 {
773 return GetRootGeometry ().x;773 return GetRootGeometry().x;
774 }774 }
775775
776 int Area::GetRootY () const776 int Area::GetRootY() const
777 {777 {
778 return GetRootGeometry ().y;778 return GetRootGeometry().y;
779 }779 }
780780
781 int Area::GetRootWidth () const781 int Area::GetRootWidth() const
782 {782 {
783 return GetRootGeometry ().width;783 return GetRootGeometry().width;
784 }784 }
785785
786 int Area::GetRootHeight () const786 int Area::GetRootHeight() const
787 {787 {
788 return GetRootGeometry ().height;788 return GetRootGeometry().height;
789 }789 }
790790
791 Area* Area::GetToplevel ()791 Area* Area::GetToplevel()
792 {792 {
793 if (Type ().IsDerivedFromType (BaseWindow::StaticObjectType) || (this == GetWindowThread ()->GetMainLayout ()))793 return GetRootParent();
794 }
795
796 Area* Area::GetRootParent()
797 {
798 if (Type().IsDerivedFromType(BaseWindow::StaticObjectType) || (this == GetWindowThread()->GetMainLayout()))
794 {799 {
795 return this;800 return this;
796 }801 }
797802
798 Area* parent = GetParentObject ();803 Area* parent = GetParentObject();
799 if (!parent) //we didn't find a way to salvation!804 if (!parent) //we didn't find a way to salvation!
800 {805 {
801 return 0;806 return 0;
802 }807 }
803 return parent->GetToplevel ();808 return parent->GetRootParent();
804 }809 }
805810
806 Area* Area::GetTopLevelViewWindow ()811 Area* Area::GetTopLevelViewWindow()
807 {812 {
808 Area* area = GetToplevel ();813 Area* area = GetRootParent();
809814
810 if (area && area->IsViewWindow ())815 if (area && area->IsViewWindow())
811 return area;816 return area;
812817
813 return NULL;818 return NULL;
814 }819 }
815820
816 bool Area::HasTopLevelParent ()821 bool Area::HasTopLevelParent()
817 {822 {
818 if (GetToplevel ())823 if (GetRootParent())
819 {824 {
820 return true;825 return true;
821 }826 }
@@ -827,42 +832,15 @@
827 if (this == parent)832 if (this == parent)
828 return true;833 return true;
829834
830 if (!parent || !_parent_area)835 if (!parent || !parent_area_)
831 return false;836 return false;
832837
833 return _parent_area->IsChildOf(parent); 838 return parent_area_->IsChildOf(parent);
834 }839 }
835840
836 /* handles our focusable code */841 void Area::QueueRelayout()
837 bool Area::DoGetFocused ()842 {
838 {843 nux::GetWindowThread()->QueueObjectLayout(this);
839 return _is_focused;
840 }
841
842 /* Pretty much everything is going to have to override this */
843 void Area::DoSetFocused (bool focused)
844 {
845 if (_is_focused == focused)
846 return;
847
848 _is_focused = focused;
849 FocusChanged.emit (this);
850 }
851
852 bool Area::DoCanFocus ()
853 {
854 return true;
855 }
856
857 /* override me! */
858 void Area::DoActivateFocus ()
859 {
860 FocusActivated.emit (this);
861 }
862
863 void Area::QueueRelayout ()
864 {
865 nux::GetWindowThread ()->QueueObjectLayout (this);
866 }844 }
867 845
868 void Area::SetAcceptKeyboardEvent(bool accept_keyboard_event)846 void Area::SetAcceptKeyboardEvent(bool accept_keyboard_event)
@@ -885,45 +863,70 @@
885 return _accept_mouse_wheel_event;863 return _accept_mouse_wheel_event;
886 }864 }
887865
888 bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type)866 bool Area::TestMousePointerInclusion(const Point& mouse_position, NuxEventType event_type)
889 {867 {
890 bool mouse_pointer_inside_area = false;868 if ((IsLayout() == false) && ((visible_ == false) ||
891869 (sensitive_ == false) ||
892 if (Type().IsDerivedFromType(MenuPage::StaticObjectType))870 (view_enabled_ == false)))
893 {871 {
894 // A MenuPage geometry is already in absolute coordinates.872 // If this area is not a view and:
895 mouse_pointer_inside_area = _geometry.IsInside(mouse_position);873 // - it is insensitive to input event
896 }874 // - it is not enabled
897 else875 // - it is not visible
898 {876 // then return false.
899 mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);877 return false;
900 }878 }
901879
902 if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)880 bool mouse_pointer_inside_area = false;
903 {881
904 if (_accept_mouse_wheel_event == false)882 if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
905 return NULL;883 {
906 }884 // A MenuPage geometry is already in absolute coordinates.
907885 mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
908 return mouse_pointer_inside_area;886 }
909 }887 else
910888 {
911 bool Area::TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event_type)889 mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
912 {890 }
913 bool mouse_pointer_inside_area = false;891
914892 if ((event_type == NUX_MOUSE_WHEEL) && mouse_pointer_inside_area)
915 if (Type().IsDerivedFromType(MenuPage::StaticObjectType))893 {
916 {894 if (_accept_mouse_wheel_event == false)
917 // A MenuPage geometry is already in absolute coordinates.895 return NULL;
918 mouse_pointer_inside_area = _geometry.IsInside(mouse_position);896 }
919 }897
920 else898 return mouse_pointer_inside_area;
921 {899 }
922 mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);900
923 }901 bool Area::TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event_type)
924902 {
925 return mouse_pointer_inside_area;903 if ((IsLayout() == false) && ((visible_ == false) ||
926 }904 (sensitive_ == false) ||
905 (view_enabled_ == false)))
906 {
907 // If this area is not a view and:
908 // - it is insensitive to input event
909 // - it is not enabled
910 // - it is not visible
911 // then return false.
912
913 return false;
914 }
915
916 bool mouse_pointer_inside_area = false;
917
918 if (Type().IsDerivedFromType(MenuPage::StaticObjectType))
919 {
920 // A MenuPage geometry is already in absolute coordinates.
921 mouse_pointer_inside_area = geometry_.IsInside(mouse_position);
922 }
923 else
924 {
925 mouse_pointer_inside_area = GetAbsoluteGeometry().IsInside(mouse_position);
926 }
927
928 return mouse_pointer_inside_area;
929 }
927930
928 Area* Area::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)931 Area* Area::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
929 {932 {
@@ -970,7 +973,7 @@
970 {973 {
971 next_object_to_key_focus_area_->ResetDownwardPathToKeyFocusArea();974 next_object_to_key_focus_area_->ResetDownwardPathToKeyFocusArea();
972 }975 }
973 if(next_object_to_key_focus_area_)976 if (next_object_to_key_focus_area_)
974 next_object_to_key_focus_area_->UnReference();977 next_object_to_key_focus_area_->UnReference();
975978
976 next_object_to_key_focus_area_ = NULL;979 next_object_to_key_focus_area_ = NULL;
@@ -979,11 +982,11 @@
979 void Area::ResetUpwardPathToKeyFocusArea()982 void Area::ResetUpwardPathToKeyFocusArea()
980 {983 {
981 has_key_focus_ = false;984 has_key_focus_ = false;
982 if (_parent_area)985 if (parent_area_)
983 {986 {
984 _parent_area->ResetUpwardPathToKeyFocusArea();987 parent_area_->ResetUpwardPathToKeyFocusArea();
985 }988 }
986 if(next_object_to_key_focus_area_)989 if (next_object_to_key_focus_area_)
987 next_object_to_key_focus_area_->UnReference();990 next_object_to_key_focus_area_->UnReference();
988991
989 next_object_to_key_focus_area_ = NULL;992 next_object_to_key_focus_area_ = NULL;
@@ -998,6 +1001,9 @@
9981001
999 bool Area::AcceptKeyNavFocus()1002 bool Area::AcceptKeyNavFocus()
1000 {1003 {
1004 if (GetInputEventSensitivity() == false)
1005 return false;
1006
1001 return true;1007 return true;
1002 }1008 }
10031009
@@ -1010,5 +1016,26 @@
1010 {1016 {
1011 return has_key_focus_;1017 return has_key_focus_;
1012 }1018 }
1019
1020 Direction Area::GetDirection() const
1021 {
1022 return _direction;
1023 }
1024
1025 void Area::SetDirection(Direction direction)
1026 {
1027 _direction = direction;
1028 }
1029
1030 bool Area::IsMousePointerInside() const
1031 {
1032 Geometry geo = GetAbsoluteGeometry();
1033 Point position = GetWindowCompositor().GetMousePosition();
1034
1035 if (geo.IsInside(position))
1036 return true;
1037
1038 return false;
1039 }
1013}1040}
10141041
10151042
=== modified file 'Nux/Area.h'
--- Nux/Area.h 2011-09-20 06:03:43 +0000
+++ Nux/Area.h 2011-10-25 21:32:25 +0000
@@ -26,7 +26,6 @@
26#include <sigc++/sigc++.h>26#include <sigc++/sigc++.h>
27#include "NuxCore/InitiallyUnownedObject.h"27#include "NuxCore/InitiallyUnownedObject.h"
28#include "NuxGraphics/Events.h"28#include "NuxGraphics/Events.h"
29#include "Focusable.h"
30#include "Utils.h"29#include "Utils.h"
31#include "WidgetMetrics.h"30#include "WidgetMetrics.h"
3231
@@ -65,11 +64,14 @@
65//! Policy for and element position in the minor dimension of a layout.64//! Policy for and element position in the minor dimension of a layout.
66 typedef enum65 typedef enum
67 {66 {
68 MINOR_POSITION_TOP, //!< Place the element on the top side of the layout (Hlayout)67 MINOR_POSITION_START, //!< Place the element at the start of the layout(Hlayout and VLayout)
69 MINOR_POSITION_BOTTOM, //!< Place the element on the bottom side of the layout (Hlayout)68 MINOR_POSITION_CENTER, //!< Place the element at the center of the layout(Hlayout and VLayout)
70 MINOR_POSITION_LEFT, //!< Place the element on the left side of the layout (Vlayout)69 MINOR_POSITION_END, //!< Place the element at the end of the layout(Hlayout and VLayout)
71 MINOR_POSITION_RIGHT, //!< Place the element on the right side of the layout (Hlayout)70 MINOR_POSITION_TOP = MINOR_POSITION_START, //!< Deprecated.
72 MINOR_POSITION_CENTER, //!< Place the element at the center of the layout (Hlayout and VLayout)71 MINOR_POSITION_LEFT = MINOR_POSITION_START, //!< Deprecated.
72 MINOR_POSITION_BOTTOM = MINOR_POSITION_END, //!< Deprecated.
73 MINOR_POSITION_RIGHT = MINOR_POSITION_END, //!< Deprecated.
74
73 eAbove = MINOR_POSITION_TOP, //!< Deprecated.75 eAbove = MINOR_POSITION_TOP, //!< Deprecated.
74 eBelow = MINOR_POSITION_BOTTOM, //!< Deprecated.76 eBelow = MINOR_POSITION_BOTTOM, //!< Deprecated.
75 eLeft = MINOR_POSITION_LEFT, //!< Deprecated.77 eLeft = MINOR_POSITION_LEFT, //!< Deprecated.
@@ -84,19 +86,23 @@
84 */86 */
85 typedef enum87 typedef enum
86 {88 {
87 MAJOR_POSITION_TOP, //!< Stack elements at the top (for VLayout only).89 MAJOR_POSITION_CENTER, //!< Stack elements in the center of the layout(for HLayout and VLayout).
88 MAJOR_POSITION_BOTTOM, //!< Stack elements at the bottom (for VLayout only).90 MAJOR_POSITION_START, //!< Stack elements at the begining of the layout(for HLayout and VLayout).
89 MAJOR_POSITION_LEFT, //!< Stack elements at the left (for HLayout only).91 MAJOR_POSITION_END, //!< Stack elements at the end of the layout(for HLayout and VLayout).
90 MAJOR_POSITION_RIGHT, //!< Stack elements at the right (for HLayout only).92 MAJOR_POSITION_SPREAD, //!< Spread elements evenly inside the layout(for HLayout and VLayout).
91 MAJOR_POSITION_CENTER, //!< Stack elements in the center of the layout (for HLayout and VLayout).93
92 MAJOR_POSITION_EXPAND, //!< Spread elements evenly inside the layout (for HLayout and VLayout).94 MAJOR_POSITION_TOP = MAJOR_POSITION_START, //!< Deprecated.
95 MAJOR_POSITION_BOTTOM = MAJOR_POSITION_END, //!< Deprecated.
96 MAJOR_POSITION_LEFT = MAJOR_POSITION_START, //!< Deprecated.
97 MAJOR_POSITION_RIGHT = MAJOR_POSITION_END, //!< Deprecated.
98
9399
94 eStackTop = MAJOR_POSITION_TOP, //!< Deprecated.100 eStackTop = MAJOR_POSITION_TOP, //!< Deprecated.
95 eStackBottom = MAJOR_POSITION_BOTTOM, //!< Deprecated.101 eStackBottom = MAJOR_POSITION_BOTTOM, //!< Deprecated.
96 eStackLeft = MAJOR_POSITION_LEFT, //!< Deprecated.102 eStackLeft = MAJOR_POSITION_LEFT, //!< Deprecated.
97 eStackRight = MAJOR_POSITION_RIGHT, //!< Deprecated.103 eStackRight = MAJOR_POSITION_RIGHT, //!< Deprecated.
98 eStackCenter = MAJOR_POSITION_CENTER, //!< Deprecated.104 eStackCenter = MAJOR_POSITION_CENTER, //!< Deprecated.
99 eStackExpand = MAJOR_POSITION_EXPAND, //!< Deprecated.105 eStackExpand = MAJOR_POSITION_SPREAD, //!< Deprecated.
100 } LayoutContentDistribution;106 } LayoutContentDistribution;
101107
102 //! For internal use only.108 //! For internal use only.
@@ -134,25 +140,21 @@
134 KEY_NAV_ENTER,140 KEY_NAV_ENTER,
135 };141 };
136142
143 typedef enum
144 {
145 LeftToRight,
146 RightToLeft
147 } Direction;
148
137 class Layout;149 class Layout;
138 class View;150 class View;
139 class Area;151 class Area;
140152
141 class Area: public InitiallyUnownedObject, public Focusable153 class Area: public InitiallyUnownedObject
142 {154 {
143 NUX_DECLARE_OBJECT_TYPE (Area, InitiallyUnownedObject);155 NUX_DECLARE_OBJECT_TYPE(Area, InitiallyUnownedObject);
144 public:156 public:
145 class LayoutProperties157 Area(NUX_FILE_LINE_DECL);
146 {
147 public:
148 virtual ~LayoutProperties ()
149 {
150
151 }
152 };
153
154 public:
155 Area (NUX_FILE_LINE_DECL);
156 virtual ~Area();158 virtual ~Area();
157159
158 int GetBaseX() const;160 int GetBaseX() const;
@@ -171,29 +173,29 @@
171 The size is adjusted to respect the min and max size policy173 The size is adjusted to respect the min and max size policy
172 \sa SetWidth(), SetHeight(), SetMinimumSize(), SetMaximumSize().174 \sa SetWidth(), SetHeight(), SetMinimumSize(), SetMaximumSize().
173 */175 */
174 void SetBaseSize (int w, int h);176 virtual void SetBaseSize(int w, int h);
175177
176 void SetMinimumSize(int w, int h);178 virtual void SetMinimumSize(int w, int h);
177 void SetMaximumSize(int w, int h);179 virtual void SetMaximumSize(int w, int h);
178 void SetMinMaxSize(int w, int h);180 virtual void SetMinMaxSize(int w, int h);
179181
180 void SetMinimumWidth(int w);182 virtual void SetMinimumWidth(int w);
181 void SetMaximumWidth(int w);183 virtual void SetMaximumWidth(int w);
182 void SetMinimumHeight(int h);184 virtual void SetMinimumHeight(int h);
183 void SetMaximumHeight(int h);185 virtual void SetMaximumHeight(int h);
184186
185 int GetMinimumWidth() const;187 virtual int GetMinimumWidth() const;
186 int GetMaximumWidth() const;188 virtual int GetMaximumWidth() const;
187 int GetMinimumHeight() const;189 virtual int GetMinimumHeight() const;
188 int GetMaximumHeight() const;190 virtual int GetMaximumHeight() const;
189191
190 void ApplyMinWidth();192 virtual void ApplyMinWidth();
191 void ApplyMinHeight();193 virtual void ApplyMinHeight();
192 void ApplyMaxWidth();194 virtual void ApplyMaxWidth();
193 void ApplyMaxHeight();195 virtual void ApplyMaxHeight();
194196
195 Size GetMinimumSize() const;197 virtual Size GetMinimumSize() const;
196 Size GetMaximumSize() const;198 virtual Size GetMaximumSize() const;
197199
198 //! Get the geometry of the object.200 //! Get the geometry of the object.
199 /*!201 /*!
@@ -212,7 +214,7 @@
212214
213 \sa SetBaseWidth(), SetBaseHeight(), SetBaseX(), SetBaseY().215 \sa SetBaseWidth(), SetBaseHeight(), SetBaseX(), SetBaseY().
214 */216 */
215 void SetGeometry (int x, int y, int w, int h);217 void SetGeometry(int x, int y, int w, int h);
216218
217 //! Set the geometry of the object.219 //! Set the geometry of the object.
218 /*!220 /*!
@@ -222,32 +224,36 @@
222 @param geo Geometry object.224 @param geo Geometry object.
223 \sa SetWidth(), SetHeight(), SetX(), SetY().225 \sa SetWidth(), SetHeight(), SetX(), SetY().
224 */226 */
225 void SetGeometry (const Geometry &geo);227 void SetGeometry(const Geometry &geo);
226228
227 void IncreaseSize (int x, int y);229 void IncreaseSize(int x, int y);
228230
229 void SetBaseString (const TCHAR *Caption);231 void SetBaseString(const char *Caption);
230 const NString &GetBaseString() const;232 const NString &GetBaseString() const;
231233
232 //! Return the Top level parent of this area.234 //! Deprecated. Use GetToplevel.
235 Area* GetToplevel();
236
237 //! Return the root parent of the rendering tree for this area.
233 /*!238 /*!
234 The top Level parent is either a BaseWindow or the main layout.239 The root parent of the rendering tree is either a BaseWindow or the main layout.
240 If the object isn't hooked to the rendering tree the function returns NULL.
235241
236 @return The top level parent or Null.242 @return The root parent of the rendering tree or NULL.
237 */243 */
238 Area * GetToplevel ();244 Area* GetRootParent();
239245
240 //! Return the Top level BaseWindow of this area.246 //! Return the Top level BaseWindow of this area.
241 /*!247 /*!
242 @return The top level BaseWindow or NULL.248 @return The top level BaseWindow or NULL.
243 */249 */
244 Area * GetTopLevelViewWindow ();250 Area* GetTopLevelViewWindow();
245251
246 //! Return true is this area has a top level parent.252 //! Return true is this area has a top level parent.
247 /*!253 /*!
248 @return True if this area has a top level parent.254 @return True if this area has a top level parent.
249 */255 */
250 bool HasTopLevelParent ();256 bool HasTopLevelParent();
251257
252 //! Return true is area is a child of the given parent in the widget tree.258 //! Return true is area is a child of the given parent in the widget tree.
253 /*!259 /*!
@@ -260,7 +266,7 @@
260 Test if a point is inside the area.266 Test if a point is inside the area.
261267
262 @param p A 2D point.268 @param p A 2D point.
263 @param event_type The type of mouse event (a parameter of FindAreaUnderMouse).269 @param event_type The type of mouse event(a parameter of FindAreaUnderMouse).
264270
265 @return True if p is located inside the Area.271 @return True if p is located inside the Area.
266 */272 */
@@ -270,7 +276,7 @@
270 Test if a point is inside the area and if the area accepts mouse wheel events.276 Test if a point is inside the area and if the area accepts mouse wheel events.
271277
272 @param p A 2D point.278 @param p A 2D point.
273 @param event_type The type of mouse event (a parameter of FindAreaUnderMouse).279 @param event_type The type of mouse event(a parameter of FindAreaUnderMouse).
274 @param filter_mouse_wheel_event If the event type is NUX_MOUSE_WHEEL and the mouse is over this area and this280 @param filter_mouse_wheel_event If the event type is NUX_MOUSE_WHEEL and the mouse is over this area and this
275 area does not accept mouse wheel events, then return false.281 area does not accept mouse wheel events, then return false.
276282
@@ -278,34 +284,23 @@
278 */284 */
279 bool TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event);285 bool TestMousePointerInclusionFilterMouseWheel(const Point& mouse_position, NuxEventType event);
280286
281 virtual long ComputeChildLayout ();287 //! Test if the muse pointer is inside the area.
282 virtual void PositionChildLayout (float offsetX, float offsetY);288 /*!
283 virtual long ComputeLayout2 ();289 Return true if the mouse pointer is inside the area.
284 virtual void ComputePosition2 (float offsetX, float offsetY);290
285291 @return True if the mouse pointer is inside the area.
286 virtual bool IsArea () const;292 */
287 virtual bool IsInputArea () const;293 bool IsMousePointerInside() const;
288 virtual bool IsView () const;294
289 virtual bool IsLayout () const;295 virtual long ComputeContentSize();
290 virtual bool IsSpaceLayout () const;296 virtual void ComputeContentPosition(float offsetX, float offsetY);
291 virtual bool IsViewWindow () const;297
292298 virtual bool IsArea() const;
293 //! Set the layout properties for this area299 virtual bool IsInputArea() const;
294 /*!300 virtual bool IsView() const;
295 Allows the Layout managing this area to store the properties specifc to this area. Layouts301 virtual bool IsLayout() const;
296 should create a sub-class of LayoutProperties. The LayoutProperties of an area will302 virtual bool IsSpaceLayout() const;
297 be deleted upon destruction.303 virtual bool IsViewWindow() const;
298 @param properties the LayoutProperties sub-class associated with this area. Can be NULL to
299 unset.
300 */
301 void SetLayoutProperties (LayoutProperties *properties);
302
303 //! Get the layout properties for this area
304 /*!
305 Retrieves the LayoutProperties sub-class with this area. See SetLayoutProperties
306 @return LayoutProperties sub-class associated with this area.
307 */
308 LayoutProperties * GetLayoutProperties ();
309304
310 Area * GetParentObject() const;305 Area * GetParentObject() const;
311306
@@ -314,36 +309,41 @@
314 If visible, an area will be drawn. Default: true.309 If visible, an area will be drawn. Default: true.
315 @param visible if the area is visible to the user310 @param visible if the area is visible to the user
316 */311 */
317 void SetVisible (bool visible);312 void SetVisible(bool visible);
318313
319 //! Get the visibility of the area314 //! Get the visibility of the area
320 /*!315 /*!
321 Gets whether the area is visible to the user and will be visible to the user. Default is true.316 Gets whether the area is visible to the user and will be visible to the user. Default is true.
322 @return whether the area is visible317 @return whether the area is visible
323 */318 */
324 bool IsVisible ();319 bool IsVisible();
325320
326 //! Set sensitivity of the area321 //! Deprecated. Use SetInputEventSensitivity.
322 void SetSensitive(bool);
323
324 //! Set input event sensitivity of the area.
327 /*!325 /*!
328 If sensitive, an area will receive input events. Default is true.326 A insensitive Area will not receive input events.\n
329 @param if the area should receive input events327 If the Area has a layout, the event will be passed down to it. Sensitivity only control an area's ability to receive input events(keyboard, mouse, touch).
328 An area that is not sensitive will return false in \a TestMousePointerInclusion, \a TestMousePointerInclusionFilterMouseWheel and \a AcceptKeyNavFocus.\n
329 Sensitivity does not affect layouts since they do not process events.
330
331 By default, an area is sensitive.
332
333 @param sensitive If the area should receive input events
330 */334 */
331 void SetSensitive (bool sensitive);335 void SetInputEventSensitivity(bool sensitive);
332336
333 //! Get whether the area is sensitive337 //! Deprecated. Use GetInputEventSensitivity.
338 bool IsSensitive() const;
339
340 //! Get input event sensitivity of the area is sensitive
334 /*!341 /*!
335 Gets whether the area is sensitive to input events342 Gets whether the area is sensitive to input events
336 @return whether the area is visible343 @return whether the area is visible
337 */344 */
338 bool IsSensitive ();345 bool GetInputEventSensitivity() const;
339346
340 virtual bool DoGetFocused ();
341 virtual void DoSetFocused (bool focused);
342 virtual bool DoCanFocus ();
343 virtual void DoActivateFocus ();
344
345 sigc::signal<void, Area *> FocusActivated;
346 sigc::signal<void, Area *> FocusChanged;
347 sigc::signal<void, Area*> ChildFocusChanged; // sends parent + child347 sigc::signal<void, Area*> ChildFocusChanged; // sends parent + child
348348
349 /*!349 /*!
@@ -358,106 +358,132 @@
358 /*!358 /*!
359 Queues a relayout before the next paint cycle. This is safe to call multiple times within a cycle.359 Queues a relayout before the next paint cycle. This is safe to call multiple times within a cycle.
360 */360 */
361 void QueueRelayout ();361 void QueueRelayout();
362362
363 virtual unsigned int GetStretchFactor();363 //! Get the area scale factor.
364 virtual void SetStretchFactor (unsigned int sf);364 /*!
365 The scale factor is used to control the layout of area objects inside HLayout and VLayout.
366 \sa HLayout, VLayout.
367
368 @return the Area scale factor.
369 */
370 virtual unsigned int GetScaleFactor();
371
372 //! Set the area scale factor.
373 /*!
374 The scale factor is used to control the layout of area objects inside HLayout and VLayout.
375 \sa HLayout, VLayout.
376
377 @param the scale factor.
378 */
379 virtual void SetScaleFactor(unsigned int sf);
365380
366 virtual MinorDimensionPosition GetPositioning();381 virtual MinorDimensionPosition GetPositioning();
367 virtual void SetPositioning (MinorDimensionPosition p);382 virtual void SetPositioning(MinorDimensionPosition p);
368383
369 virtual MinorDimensionSize GetExtend();384 virtual MinorDimensionSize GetExtend();
370 virtual void SetExtend (MinorDimensionSize ext);385 virtual void SetExtend(MinorDimensionSize ext);
371386
372 virtual float GetPercentage();387 virtual float GetPercentage();
373 virtual void SetPercentage (float f);388 virtual void SetPercentage(float f);
374 virtual bool IsLayoutDone();389 virtual bool IsLayoutDone();
375 virtual void SetLayoutDone (bool b);390 virtual void SetLayoutDone(bool b);
376391
377 void Set2DMatrix (const Matrix4 &mat);392 void Set2DMatrix(const Matrix4 &mat);
378 void Set2DTranslation (float tx, float ty, float tz);393 void Set2DTranslation(float tx, float ty, float tz);
379 Matrix4 Get2DMatrix () const;394 Matrix4 Get2DMatrix() const;
380395
381 Matrix4 Get3DMatrix () const;396 Matrix4 Get3DMatrix() const;
382 bool Is3DArea () const;397 bool Is3DArea() const;
383398
384 //! Return the position of this object with regard to its top left corner of the physical window.399 //! Return the position of this object with regard to its top left corner of the physical window.
385 /*!400 /*!
386 Return the position of the Area inside the physical window.401 Return the position of the Area inside the physical window.
387 For the main layout set in WindowThread, The following functions are equivalent:402 For the main layout set in WindowThread, The following functions are equivalent:
388 \li GetGeometry ()403 \li GetGeometry()
389 \li GetRootGeometry ()404 \li GetRootGeometry()
390 \li GetAbsoluteGeometry ()405 \li GetAbsoluteGeometry()
391 */406 */
392 virtual Geometry GetAbsoluteGeometry () const;407 virtual Geometry GetAbsoluteGeometry() const;
393408
394 //! Return the area absolute x coordinate.409 //! Return the area absolute x coordinate.
395 int GetAbsoluteX () const;410 int GetAbsoluteX() const;
396 411
397 //! Return the area absolute y coordinate.412 //! Return the area absolute y coordinate.
398 int GetAbsoluteY () const;413 int GetAbsoluteY() const;
399 414
400 //! Return the area absolute width.415 //! Return the area absolute width.
401 /*!416 /*!
402 As long as _2d_xform contains only translations, the absolute width is the same as value returned by GetBaseWidth ();417 As long as _2d_xform contains only translations, the absolute width is the same as value returned by GetBaseWidth();
403 */418 */
404 int GetAbsoluteWidth () const;419 int GetAbsoluteWidth() const;
405 420
406 //! Return the area absolute height.421 //! Return the area absolute height.
407 /*!422 /*!
408 As long as _2d_xform contains only translations, the absolute height is the same as value returned by GetBaseHeight ();423 As long as _2d_xform contains only translations, the absolute height is the same as value returned by GetBaseHeight();
409 */424 */
410 int GetAbsoluteHeight () const;425 int GetAbsoluteHeight() const;
411426
412 //! Return the position of this object with regard to its top level parent (the main layout or a BaseWindow).427 //! Return the position of this object with regard to its top level parent(the main layout or a BaseWindow).
413 /*!428 /*!
414 Return the position of the Area inside the physical window.429 Return the position of the Area inside the physical window.
415 For the main layout set in WindowThread or for a BaseWindow, GetRootGeometry () is equivalent to GetGeometry ().430 For the main layout set in WindowThread or for a BaseWindow, GetRootGeometry() is equivalent to GetGeometry().
416 */431 */
417 virtual Geometry GetRootGeometry () const;432 virtual Geometry GetRootGeometry() const;
418433
419 //! Return the area root x coordinate.434 //! Return the area root x coordinate.
420 int GetRootX () const;435 int GetRootX() const;
421436
422 //! Return the area root y coordinate.437 //! Return the area root y coordinate.
423 int GetRootY () const;438 int GetRootY() const;
424439
425 //! Return the area root width.440 //! Return the area root width.
426 /*!441 /*!
427 As long as _2d_xform contains only translations, the root width is the same as value returned by GetBaseWidth ();442 As long as _2d_xform contains only translations, the root width is the same as value returned by GetBaseWidth();
428 */443 */
429 int GetRootWidth () const;444 int GetRootWidth() const;
430445
431 //! Return the area root height.446 //! Return the area root height.
432 /*!447 /*!
433 As long as _2d_xform contains only translations, the root width is the same as value returned by GetBaseWidth ();448 As long as _2d_xform contains only translations, the root width is the same as value returned by GetBaseWidth();
434 */449 */
435 int GetRootHeight () const;450 int GetRootHeight() const;
436451
437 sigc::signal<void, int, int, int, int> OnResize; //!< Signal emitted when an area is resized.452 sigc::signal<void, int, int, int, int> OnResize; //!< Signal emitted when an area is resized.
438 sigc::signal<void, Area *, bool> OnVisibleChanged;453 sigc::signal<void, Area *, bool> OnVisibleChanged;
439 sigc::signal<void, Area *, bool> OnSensitiveChanged;454 sigc::signal<void, Area *, bool> OnSensitiveChanged;
455
456 /*!
457 This signal is only meant to inform of a change of size. When receiving this signal don't do anything
458 that could change the size of this object. Or you risk creating an infinite loop.
459 */
440 sigc::signal<void, Area *, Geometry&> OnGeometryChanged;460 sigc::signal<void, Area *, Geometry&> OnGeometryChanged;
441461
442 /*!462 /*!
443 SetParentObject/UnParentObject are protected API. it is not meant to be used directly by users.463 SetParentObject/UnParentObject are protected API. They are not meant to be used directly by users.
444 Users add widgets to layouts and layout have to be attached to a composition for objects to be rendered.464 Users add widgets to layouts and layout have to be attached to a composition for objects to be rendered.
445 Setting a parent to and child widget does not mean that when the parent is rendered, the child is also rendered.465 Setting a parent to and child widget does not mean that when the parent is rendered, the child is also rendered.
446 For instance, setting a button the be the child of a check-box means absolutely nothing is terms of rendering.466 For instance, setting a button to be the child of a check-box means absolutely nothing is terms of rendering.
447 A widget with a parent cannot be added to a added to a layout for rendering. The widget has to be un-parented first.467 The check-box draw function would have to be aware of the existence of the button in order to render it.\n
448 A layout with a parent cannot be added to a widget or another layout for rendering. The layout has to be un-parented first.468 A view with a parent cannot be parented to another area for rendering. It has to be un-parented first.\n
449 In essence only View and Layouts should be calling SetParentObject/UnParentObject.469 A layout with a parent cannot be parented to another area for rendering. It has to be un-parented first.\n
470 In essence only View and Layouts should be calling SetParentObject/UnParentObject.\n
471 SetParentObject returns true if it was successful.
472
473
474 @param parent The object that will become the parent of this area.
475 @return True if the object is successfully parented.
450 */476 */
451 virtual void SetParentObject (Area *);477 virtual bool SetParentObject(Area *parent);
452478
453 //! Un-parent and area479 //! Un-parent and area
454 /*!480 /*!
455 For un-parented areas the following functions are equivalent:481 For un-parented areas the following functions are equivalent:
456 \li GetGeometry ()482 \li GetGeometry()
457 \li GetRootGeometry ()483 \li GetRootGeometry()
458 \li GetAbsoluteGeometry ()484 \li GetAbsoluteGeometry()
459 */485 */
460 virtual void UnParentObject ();486 virtual void UnParentObject();
461487
462 /*!488 /*!
463 Return the area under the mouse pointer.489 Return the area under the mouse pointer.
@@ -491,7 +517,7 @@
491 When the geometry of an area changes, the new geometry can be recursively propagated to all its 517 When the geometry of an area changes, the new geometry can be recursively propagated to all its
492 parent so a layout reconfiguration is initiated.518 parent so a layout reconfiguration is initiated.
493 \sa ReconfigureParentLayout()519 \sa ReconfigureParentLayout()
494 \sa _on_geometry_changeg_reconfigure_parent_layout520 \sa on_geometry_change_reconfigure_parent_layout_
495521
496 @param reconfigure_parent_layout Set it to True to reconfigure this area parent layouts.522 @param reconfigure_parent_layout Set it to True to reconfigure this area parent layouts.
497 */523 */
@@ -527,37 +553,53 @@
527 */553 */
528 bool AcceptMouseWheelEvent() const;554 bool AcceptMouseWheelEvent() const;
529555
556 //! Return the direction of the area.
557 Direction GetDirection() const;
558 //! Sets the direction of the area.
559 /*!
560 @param direction Either nux::LeftToRight or nux::RightToLeft
561 */
562 void SetDirection(Direction direction);
563
530 protected:564 protected:
531 bool _is_focused;
532 /*565 /*
533 This function is reimplemented in Layout as it need to perform some special operations.566 This function is reimplemented in Layout as it need to perform some special operations.
534 It does nothing for Area and View classes.567 It does nothing for Area and View classes.
535 */568 */
536 //virtual void RemoveChildObject(smptr(Area));569 //virtual void RemoveChildObject(smptr(Area));
537570
538 virtual void GeometryChangePending () {}571 /*!
539 virtual void GeometryChanged () {}572 This signal is only meant to inform that the size is about to change. When overriding this function,
573 don't do anything that could change the size of this object. Or you risk creating an infinite loop.
574 */
575 virtual void GeometryChangePending() {}
576
577 /*!
578 This signal is only meant to inform that the size has changed. When overriding this function,
579 don't do anything that could change the size of this object. Or you risk creating an infinite loop.
580 */
581 virtual void GeometryChanged() {}
540582
541 //! Request a Layout recompute after a change of size583 //! Request a Layout recompute after a change of size
542 /*584 /*
543 When an object size changes, it is necessary for its parent structure to initiate a layout585 When an object size changes, it is necessary for its parent structure to initiate a layout
544 re computation in order preserve the layout structure defined by the user through the API.586 re computation in order preserve the layout structure defined by the user through the API.
545 */587 */
546 virtual void RequestBottomUpLayoutComputation (Area *bo_initiator);588 virtual void RequestBottomUpLayoutComputation(Area *bo_initiator);
547589
548 //! Return the absolute geometry starting with a relative geometry passed as argument.590 //! Return the absolute geometry starting with a relative geometry passed as argument.
549 void InnerGetAbsoluteGeometry (Geometry &geometry);591 void InnerGetAbsoluteGeometry(Geometry &geometry);
550592
551 //! Return the absolute geometry starting with a relative geometry passed as argument.593 //! Return the absolute geometry starting with a relative geometry passed as argument.
552 void InnerGetRootGeometry (Geometry &geometry);594 void InnerGetRootGeometry(Geometry &geometry);
553595
554// //! Add a "secondary" child to this Area. The596// //! Add a "secondary" child to this Area. The
555// /*!597// /*!
556// @return True if the child has been added; False otherwise;598// @return True if the child has been added; False otherwise;
557// */599// */
558// bool Secondary (Area *child);600// bool Secondary(Area *child);
559 601
560 bool _on_geometry_changeg_reconfigure_parent_layout;602 bool on_geometry_change_reconfigure_parent_layout_;
561603
562 bool has_key_focus_;604 bool has_key_focus_;
563605
@@ -568,32 +610,32 @@
568 void CheckMaxSize();610 void CheckMaxSize();
569611
570612
571 Geometry _geometry; //!< The area geometry.613 Geometry geometry_; //!< The area geometry.
572614
573 //! Define a parent child structure615 //! Define a parent child structure
574 /*616 /*
575 An object of the class Area may have another of the class Layout as Parent.617 An object of the class Area may have another of the class Layout as Parent.
576 An object of the class View may have an object of the class Layout as parent.618 An object of the class View may have an object of the class Layout as parent.
577 An object of the class Layout may have a parent of the class Layout or View as parent.619 An object of the class Layout may have a parent of the class Layout or View as parent.
578 A Area cannot have children (that may change later).620 A Area cannot have children(that may change later).
579 */621 */
580 Area *_parent_area;622 Area *parent_area_;
581
582623
583 LayoutProperties *_layout_properties;624 bool visible_; //!< Visible state of the area.
584 bool _visible;625 bool sensitive_; //!< Input sensitive state of the area
585 bool _sensitive;626 bool view_enabled_; //!< The enable state of a view.
586627
587 NString _base_string; //!< A text string property for this area.628 NString _base_string; //!< A text string property for this area.
588629
589 Size _min_size; //!< A text string property for this area.630 Size min_size_; //!< A text string property for this area.
590 Size _max_size; //!< A text string property for this area.631 Size max_size_; //!< A text string property for this area.
591632
592 unsigned int _stretch_factor; //!< Factor for element expansion.633 // Parameters used in layouts
593 MinorDimensionPosition _positioning; //!< Area position hint634 unsigned int scale_factor_; //!< Factor for element expansion.
594 MinorDimensionSize _extend; //!< Area dimension hint635 MinorDimensionPosition minor_axis_position_; //!< Area position hint
595 float _percentage; //!< Area size percentage value.636 MinorDimensionSize minor_axis_size_; //!< Area dimension hint
596 bool _layout_done; //!< Area layout status flag.637 float minor_axis_size_scale_; //!< Area size percentage value.
638 bool layout_done_; //!< Area layout status flag.
597639
598640
599 Matrix4 _2d_xform; //!< 2D transformation matrix for this area and its children. Contains only translations.641 Matrix4 _2d_xform; //!< 2D transformation matrix for this area and its children. Contains only translations.
@@ -605,6 +647,8 @@
605 bool _accept_mouse_wheel_event;647 bool _accept_mouse_wheel_event;
606 bool _accept_keyboard_event;648 bool _accept_keyboard_event;
607649
650 Direction _direction;
651
608 friend class Layout;652 friend class Layout;
609 friend class View;653 friend class View;
610 friend class WindowThread;654 friend class WindowThread;
611655
=== modified file 'Nux/BaseWindow.cpp'
--- Nux/BaseWindow.cpp 2011-09-20 06:03:43 +0000
+++ Nux/BaseWindow.cpp 2011-10-25 21:32:25 +0000
@@ -32,7 +32,7 @@
32namespace nux32namespace nux
33{33{
3434
35 NUX_IMPLEMENT_OBJECT_TYPE (BaseWindow);35 NUX_IMPLEMENT_OBJECT_TYPE(BaseWindow);
3636
37 const int SizeGripWidth = 20;37 const int SizeGripWidth = 20;
38 const int SizeGripHeight = 20;38 const int SizeGripHeight = 20;
@@ -44,10 +44,10 @@
44 pass the top-left corner position of the window. When drawing, make a similar adjustment.44 pass the top-left corner position of the window. When drawing, make a similar adjustment.
45 */45 */
4646
47 BaseWindow::BaseWindow (const TCHAR *WindowName, NUX_FILE_LINE_DECL)47 BaseWindow::BaseWindow(const char *WindowName, NUX_FILE_LINE_DECL)
48 : View (NUX_FILE_LINE_PARAM)48 : View(NUX_FILE_LINE_PARAM)
49 , _paint_layer(new ColorLayer(Color(0xFF707070)))49 , _paint_layer(new ColorLayer(Color(0xFF707070)))
50 , _opacity (1.0f)50 , _opacity(1.0f)
51 {51 {
52 premultiply = true;52 premultiply = true;
53 _name = WindowName;53 _name = WindowName;
@@ -70,9 +70,9 @@
70 accept_key_nav_focus_ = false;70 accept_key_nav_focus_ = false;
7171
72 // Should be at the end of the constructor72 // Should be at the end of the constructor
73 GetWindowCompositor().RegisterWindow (this);73 GetWindowCompositor().RegisterWindow(this);
7474
75 SetMinimumSize (1, 1);75 SetMinimumSize(1, 1);
76 SetGeometry(Geometry(100, 100, 320, 200));76 SetGeometry(Geometry(100, 100, 320, 200));
77 }77 }
7878
@@ -80,7 +80,7 @@
80 {80 {
81 if (_enter_focus_input_area)81 if (_enter_focus_input_area)
82 {82 {
83 _enter_focus_input_area->UnReference ();83 _enter_focus_input_area->UnReference();
84 }84 }
8585
86#if defined(NUX_OS_LINUX)86#if defined(NUX_OS_LINUX)
@@ -89,160 +89,90 @@
89#endif89#endif
90 }90 }
9191
92 long BaseWindow::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
93 {
94 long ret = TraverseInfo;
95 long ProcEvInfo = 0;
96
97 IEvent window_event = ievent;
98 Geometry base = GetGeometry();
99 window_event.e_x_root = base.x;
100 window_event.e_y_root = base.y;
101
102 // The child layout get the Mouse down button only if the MouseDown happened inside the client view Area
103 Geometry viewGeometry = GetGeometry();
104
105 if (ievent.e_event == NUX_MOUSE_PRESSED)
106 {
107 if (!viewGeometry.IsPointInside (ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root) )
108 {
109 ProcEvInfo = eDoNotProcess;
110 }
111 }
112
113 if (m_layout)
114 ret = m_layout->ProcessEvent (window_event, ret, ProcEvInfo);
115
116 // PostProcessEvent2 must always have its last parameter set to 0
117 // because the m_BackgroundArea is the real physical limit of the window.
118 // So the previous test about IsPointInside do not prevail over m_BackgroundArea
119 // testing the event by itself.
120 ret = PostProcessEvent2 (ievent, ret, 0);
121 return ret;
122 }
123
124 Area* BaseWindow::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)92 Area* BaseWindow::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
125 {93 {
126 bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);94 bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
12795
128 if(mouse_inside == false)96 if (mouse_inside == false)
129 return NULL;97 return NULL;
13098
131 if(m_layout)99 if (m_layout)
132 {100 {
133 nuxAssert(m_layout->IsLayout());101 nuxAssert(m_layout->IsLayout());
134 Area* found_area = m_layout->FindAreaUnderMouse(mouse_position, event_type);102 Area* found_area = m_layout->FindAreaUnderMouse(mouse_position, event_type);
135 if(found_area)103 if (found_area)
136 return found_area;104 return found_area;
137 }105 }
138106
139 if((event_type == NUX_MOUSE_WHEEL) && (!AcceptMouseWheelEvent()))107 if ((event_type == NUX_MOUSE_WHEEL) && (!AcceptMouseWheelEvent()))
140 return NULL;108 return NULL;
141 return this;109 return this;
142 }110 }
143111
144 void BaseWindow::Draw (GraphicsEngine &GfxContext, bool force_draw)112 void BaseWindow::Draw(GraphicsEngine &graphics_engine, bool force_draw)
145 {113 {
146 Geometry base = GetGeometry();114 Geometry base = GetGeometry();
147 // The elements position inside the window are referenced to top-left window corner. So bring base to (0, 0).115 // The elements position inside the window are referenced to top-left window corner. So bring base to(0, 0).
148 base.SetX (0);116 base.SetX(0);
149 base.SetY (0);117 base.SetY(0);
150 GfxContext.PushClippingRectangle (base);118 graphics_engine.PushClippingRectangle(base);
151119
152 GetPainter().PushDrawLayer(GfxContext, base, _paint_layer.get());120 GetPainter().PushDrawLayer(graphics_engine, base, _paint_layer.get());
153121
154 GetPainter().PopBackground();122 GetPainter().PopBackground();
155 GfxContext.PopClippingRectangle();123 graphics_engine.PopClippingRectangle();
156 }124 }
157125
158 void BaseWindow::DrawContent (GraphicsEngine &GfxContext, bool force_draw)126 void BaseWindow::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
159 {127 {
160128
161 Geometry base = GetGeometry();129 Geometry base = GetGeometry();
162 // The elements position inside the window are referenced to top-left window corner. So bring base to (0, 0).130 // The elements position inside the window are referenced to top-left window corner. So bring base to(0, 0).
163 base.SetX (0);131 base.SetX(0);
164 base.SetY (0);132 base.SetY(0);
165133
166134
167 GetPainter().PushLayer(GfxContext, base, _paint_layer.get());135 GetPainter().PushLayer(graphics_engine, base, _paint_layer.get());
168136
169 if (m_layout)137 if (m_layout)
170 {138 {
171 GfxContext.PushClippingRectangle (base);139 graphics_engine.PushClippingRectangle(base);
172 m_layout->ProcessDraw (GfxContext, force_draw);140 m_layout->ProcessDraw(graphics_engine, force_draw);
173 GfxContext.PopClippingRectangle();141 graphics_engine.PopClippingRectangle();
174 }142 }
175143
176 GetPainter().PopBackground();144 GetPainter().PopBackground();
177 }145 }
178146
179 void BaseWindow::PostDraw (GraphicsEngine &GfxContext, bool force_draw)147 void BaseWindow::PostDraw(GraphicsEngine &graphics_engine, bool force_draw)
180 {148 {
181149
182 }150 }
183151
184 void BaseWindow::SetConfigureNotifyCallback (ConfigureNotifyCallback Callback, void *Data)152 void BaseWindow::SetConfigureNotifyCallback(ConfigureNotifyCallback Callback, void *Data)
185 {153 {
186 m_configure_notify_callback = Callback;154 m_configure_notify_callback = Callback;
187 m_configure_notify_callback_data = Data;155 m_configure_notify_callback_data = Data;
188 }156 }
189157
190 void BaseWindow::AddWidget (View *ic)158 Layout* BaseWindow::GetLayout()
191 {
192 if (ic && m_layout)
193 {
194 m_layout->AddView (ic, 0);
195 // 0: the WidgetLayout geometry will be set to SetGeometry(0,0,1,1);
196 // and the children will take their natural size by expending WidgetLayout.
197 // If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
198
199 ComputeChildLayout();
200 }
201 }
202
203 void BaseWindow::AddWidget (View *ic, int stretchfactor)
204 {
205 if (ic && m_layout)
206 {
207 m_layout->AddView (ic, stretchfactor);
208 // if(stretchfactor ==0): the WidgetLayout geometry will be set to SetGeometry(0,0,1,1);
209 // and the children will take their natural size by expending WidgetLayout.
210 // If the parent of WidgetLayout offers more space, it won't be used by WidgetLayout.
211
212 ComputeChildLayout();
213 }
214 }
215
216 void BaseWindow::AddWidget (std::list<View *> *ViewList)
217 {
218 m_CompositionLayout->Clear();
219
220 std::list<View *>::iterator it;
221
222 for (it = ViewList->begin(); it != ViewList->end(); it++)
223 {
224 AddWidget ( (*it) );
225 }
226 }
227
228 Layout* BaseWindow::GetLayout ()
229 {159 {
230 return m_layout;160 return m_layout;
231 }161 }
232162
233 bool BaseWindow::SetLayout (Layout *layout)163 bool BaseWindow::SetLayout(Layout *layout)
234 {164 {
235 if (View::SetLayout (layout) == false)165 if (View::SetLayout(layout) == false)
236 return false;166 return false;
237167
238 m_layout = layout;168 m_layout = layout;
239 Geometry geo = GetGeometry();169 Geometry geo = GetGeometry();
240 Geometry layout_geo = Geometry (geo.x + m_Border, geo.y + m_TopBorder,170 Geometry layout_geo = Geometry(geo.x + m_Border, geo.y + m_TopBorder,
241 geo.GetWidth() - 2 * m_Border, geo.GetHeight() - m_Border - m_TopBorder);171 geo.GetWidth() - 2 * m_Border, geo.GetHeight() - m_Border - m_TopBorder);
242 m_layout->SetGeometry (layout_geo);172 m_layout->SetGeometry(layout_geo);
243173
244 // When this call returns the layout computation is done.174 // When this call returns the layout computation is done.
245 ComputeChildLayout();175 ComputeContentSize();
246 // or use176 // or use
247 //GetWindowThread()->QueueObjectLayout(m_layout);177 //GetWindowThread()->QueueObjectLayout(m_layout);
248178
@@ -257,16 +187,16 @@
257187
258 if (m_configure_notify_callback)188 if (m_configure_notify_callback)
259 {189 {
260 (*m_configure_notify_callback) (GetGraphicsDisplay()->GetWindowWidth(), GetGraphicsDisplay()->GetWindowHeight(), geo, m_configure_notify_callback_data);190 (*m_configure_notify_callback)(GetGraphicsDisplay()->GetWindowWidth(), GetGraphicsDisplay()->GetWindowHeight(), geo, m_configure_notify_callback_data);
261191
262 if (geo.IsNull() )192 if (geo.IsNull())
263 {193 {
264 nuxDebugMsg (TEXT ("[BaseWindow::PreLayoutManagement] Received an invalid Geometry.") );194 nuxDebugMsg("[BaseWindow::PreLayoutManagement] Received an invalid Geometry.");
265 geo = GetGeometry();195 geo = GetGeometry();
266 }196 }
267 else197 else
268 {198 {
269 Area::SetGeometry (geo);199 Area::SetGeometry(geo);
270 // Get the geometry adjusted with respect to min and max dimension of this area.200 // Get the geometry adjusted with respect to min and max dimension of this area.
271 geo = GetGeometry();201 geo = GetGeometry();
272 }202 }
@@ -274,30 +204,30 @@
274204
275 if (m_layout)205 if (m_layout)
276 {206 {
277 Geometry layout_geo = Geometry (m_Border, m_TopBorder,207 Geometry layout_geo = Geometry(m_Border, m_TopBorder,
278 geo.GetWidth() - 2 * m_Border, geo.GetHeight() - m_Border - m_TopBorder);208 geo.GetWidth() - 2 * m_Border, geo.GetHeight() - m_Border - m_TopBorder);
279209
280 if (IsSizeMatchContent ())210 if (IsSizeMatchContent())
281 m_layout->SetGeometry (Geometry (0, 0, 1, 1));211 m_layout->SetGeometry(Geometry(0, 0, 1, 1));
282 else212 else
283 m_layout->SetGeometry (layout_geo);213 m_layout->SetGeometry(layout_geo);
284 }214 }
285 }215 }
286216
287// Get a change to do any work on an element.217// Get a change to do any work on an element.
288// Here we need to position the header by hand because it is not under the control of vlayout.218// Here we need to position the header by hand because it is not under the control of vlayout.
289 long BaseWindow::PostLayoutManagement (long LayoutResult)219 long BaseWindow::PostLayoutManagement(long LayoutResult)
290 {220 {
291 if (IsSizeMatchContent() && m_layout)221 if (IsSizeMatchContent() && m_layout)
292 {222 {
293 Geometry layout_geometry = m_layout->GetGeometry();223 Geometry layout_geometry = m_layout->GetGeometry();
294224
295 Geometry WindowGeometry = Geometry (GetGeometry().x,225 Geometry WindowGeometry = Geometry(GetGeometry().x,
296 GetGeometry().y,226 GetGeometry().y,
297 layout_geometry.GetWidth() + 2 * m_Border,227 layout_geometry.GetWidth() + 2 * m_Border,
298 layout_geometry.GetHeight() + m_Border + m_TopBorder);228 layout_geometry.GetHeight() + m_Border + m_TopBorder);
299229
300 Area::SetGeometry (WindowGeometry);230 Area::SetGeometry(WindowGeometry);
301 }231 }
302232
303 // A BaseWindow must kill the result of the management and pass it to the parent Layout.233 // A BaseWindow must kill the result of the management and pass it to the parent Layout.
@@ -307,13 +237,13 @@
307237
308// Get a change to do any work on an element.238// Get a change to do any work on an element.
309// Here we need to position the header by hand because it is not under the control of vlayout.239// Here we need to position the header by hand because it is not under the control of vlayout.
310 void BaseWindow::PositionChildLayout (float offsetX, float offsetY)240 void BaseWindow::ComputeContentPosition(float offsetX, float offsetY)
311 {241 {
312242
313 }243 }
314 244
315 #if defined(NUX_OS_LINUX)245 #if defined(NUX_OS_LINUX)
316 void BaseWindow::EnableInputWindow (bool b,246 void BaseWindow::EnableInputWindow(bool b,
317 const char* title,247 const char* title,
318 bool take_focus,248 bool take_focus,
319 bool override_redirect)249 bool override_redirect)
@@ -321,62 +251,62 @@
321 if (b)251 if (b)
322 {252 {
323 if (m_input_window == 0)253 if (m_input_window == 0)
324 m_input_window = new XInputWindow (title, take_focus, override_redirect);254 m_input_window = new XInputWindow(title, take_focus, override_redirect);
325 255
326 m_input_window->Show ();256 m_input_window->Show();
327 m_input_window->SetGeometry (GetGeometry());257 m_input_window->SetGeometry(GetGeometry());
328 m_input_window_enabled = true;258 m_input_window_enabled = true;
329 }259 }
330 else260 else
331 {261 {
332 if (m_input_window)262 if (m_input_window)
333 m_input_window->Hide ();263 m_input_window->Hide();
334 m_input_window_enabled = false;264 m_input_window_enabled = false;
335 }265 }
336 }266 }
337267
338 bool BaseWindow::InputWindowEnabled ()268 bool BaseWindow::InputWindowEnabled()
339 {269 {
340 return m_input_window_enabled;270 return m_input_window_enabled;
341 }271 }
342 272
343 void BaseWindow::InputWindowEnableStruts (bool enable)273 void BaseWindow::InputWindowEnableStruts(bool enable)
344 {274 {
345 if (m_input_window)275 if (m_input_window)
346 m_input_window->EnableStruts (enable);276 m_input_window->EnableStruts(enable);
347 }277 }
348 278
349 bool BaseWindow::InputWindowStrutsEnabled ()279 bool BaseWindow::InputWindowStrutsEnabled()
350 {280 {
351 return m_input_window_enabled && m_input_window->StrutsEnabled ();281 return m_input_window_enabled && m_input_window->StrutsEnabled();
352 }282 }
353 283
354 void BaseWindow::SetInputFocus ()284 void BaseWindow::SetInputFocus()
355 {285 {
356 if (m_input_window)286 if (m_input_window)
357 m_input_window->SetInputFocus ();287 m_input_window->SetInputFocus();
358 }288 }
359289
360 Window BaseWindow::GetInputWindowId ()290 Window BaseWindow::GetInputWindowId()
361 {291 {
362 if (m_input_window)292 if (m_input_window)
363 return m_input_window->GetWindow ();293 return m_input_window->GetWindow();
364 else294 else
365 return 0;295 return 0;
366 }296 }
367297
368 #endif298 #endif
369299
370 void BaseWindow::SetGeometry (const Geometry &geo)300 void BaseWindow::SetGeometry(const Geometry &geo)
371 {301 {
372 Area::SetGeometry (geo);302 Area::SetGeometry(geo);
373 303
374 #if defined(NUX_OS_LINUX)304 #if defined(NUX_OS_LINUX)
375 if (m_input_window)305 if (m_input_window)
376 m_input_window->SetGeometry (geo);306 m_input_window->SetGeometry(geo);
377 #endif307 #endif
378 //LayoutWindowElements();308 //LayoutWindowElements();
379 //ComputeChildLayout();309 //ComputeContentSize();
380 }310 }
381311
382 void BaseWindow::LayoutWindowElements()312 void BaseWindow::LayoutWindowElements()
@@ -386,7 +316,7 @@
386 Geometry base = GetGeometry();316 Geometry base = GetGeometry();
387 }317 }
388318
389 void BaseWindow::SetBorder (int border)319 void BaseWindow::SetBorder(int border)
390 {320 {
391 if (m_Border != border)321 if (m_Border != border)
392 {322 {
@@ -394,7 +324,7 @@
394 }324 }
395 }325 }
396326
397 void BaseWindow::SetTopBorder (int border)327 void BaseWindow::SetTopBorder(int border)
398 {328 {
399 if (m_TopBorder != border)329 if (m_TopBorder != border)
400 {330 {
@@ -432,7 +362,7 @@
432 sigVisible.emit(this);362 sigVisible.emit(this);
433 GetWindowCompositor().sigVisibleViewWindow.emit(this);363 GetWindowCompositor().sigVisibleViewWindow.emit(this);
434364
435 ComputeChildLayout();365 ComputeContentSize();
436 }366 }
437 else367 else
438 {368 {
@@ -459,7 +389,7 @@
459 _is_visible = false;389 _is_visible = false;
460 _is_modal = false;390 _is_modal = false;
461 //ShowWindow(false);391 //ShowWindow(false);
462 GetWindowCompositor().StopModalWindow (ObjectWeakPtr<BaseWindow> (this));392 GetWindowCompositor().StopModalWindow(ObjectWeakPtr<BaseWindow> (this));
463 }393 }
464394
465 bool BaseWindow::IsModal() const395 bool BaseWindow::IsModal() const
@@ -467,7 +397,7 @@
467 return _is_modal;397 return _is_modal;
468 }398 }
469399
470 void BaseWindow::NotifyConfigurationChange (int Width, int Height)400 void BaseWindow::NotifyConfigurationChange(int Width, int Height)
471 {401 {
472 Geometry geo = GetGeometry();402 Geometry geo = GetGeometry();
473403
@@ -475,14 +405,14 @@
475 {405 {
476 (*m_configure_notify_callback) (GetGraphicsDisplay()->GetWindowWidth(), GetGraphicsDisplay()->GetWindowHeight(), geo, m_configure_notify_callback_data);406 (*m_configure_notify_callback) (GetGraphicsDisplay()->GetWindowWidth(), GetGraphicsDisplay()->GetWindowHeight(), geo, m_configure_notify_callback_data);
477407
478 if (geo.IsNull() )408 if (geo.IsNull())
479 {409 {
480 nuxDebugMsg (TEXT ("[BaseWindow::NotifyConfigurationChange] Received an invalid Geometry.") );410 nuxDebugMsg("[BaseWindow::NotifyConfigurationChange] Received an invalid Geometry.");
481 geo = GetGeometry();411 geo = GetGeometry();
482 }412 }
483 else413 else
484 {414 {
485 Area::SetGeometry (geo);415 Area::SetGeometry(geo);
486 // Get the geometry adjusted with respect to min and max dimension of this area.416 // Get the geometry adjusted with respect to min and max dimension of this area.
487 geo = GetGeometry();417 geo = GetGeometry();
488 }418 }
@@ -493,68 +423,68 @@
493 }423 }
494 }424 }
495425
496 void BaseWindow::SetBackgroundLayer (AbstractPaintLayer *layer)426 void BaseWindow::SetBackgroundLayer(AbstractPaintLayer *layer)
497 {427 {
498 NUX_RETURN_IF_NULL (layer);428 NUX_RETURN_IF_NULL(layer);
499 _paint_layer.reset(layer->Clone());429 _paint_layer.reset(layer->Clone());
500 }430 }
501431
502 void BaseWindow::SetBackgroundColor (const Color &color)432 void BaseWindow::SetBackgroundColor(const Color &color)
503 {433 {
504 _paint_layer.reset(new ColorLayer(color));434 _paint_layer.reset(new ColorLayer(color));
505 }435 }
506436
507 void BaseWindow::PushHigher (BaseWindow* floating_view)437 void BaseWindow::PushHigher(BaseWindow* floating_view)
508 {438 {
509 GetWindowCompositor().PushHigher (this, floating_view);439 GetWindowCompositor().PushHigher(this, floating_view);
510 }440 }
511441
512 void BaseWindow::PushToFront ()442 void BaseWindow::PushToFront()
513 {443 {
514 GetWindowCompositor().PushToFront (this);444 GetWindowCompositor().PushToFront(this);
515 }445 }
516446
517 void BaseWindow::PushToBack ()447 void BaseWindow::PushToBack()
518 {448 {
519 GetWindowCompositor().PushToBack (this);449 GetWindowCompositor().PushToBack(this);
520 }450 }
521451
522 bool BaseWindow::ChildNeedsRedraw ()452 bool BaseWindow::ChildNeedsRedraw()
523 {453 {
524 return _child_need_redraw;454 return _child_need_redraw;
525 }455 }
526456
527 void* BaseWindow::GetBackupTextureData (int &width, int &height, int &format)457 void* BaseWindow::GetBackupTextureData(int &width, int &height, int &format)
528 {458 {
529 return GetWindowCompositor ().GetBackupTextureData (this, width, height, format);459 return GetWindowCompositor().GetBackupTextureData(this, width, height, format);
530 }460 }
531461
532 void BaseWindow::SetEnterFocusInputArea (InputArea *input_area)462 void BaseWindow::SetEnterFocusInputArea(InputArea *input_area)
533 {463 {
534 if (_enter_focus_input_area)464 if (_enter_focus_input_area)
535 {465 {
536 _enter_focus_input_area->UnReference ();466 _enter_focus_input_area->UnReference();
537 }467 }
538468
539 _enter_focus_input_area = input_area;469 _enter_focus_input_area = input_area;
540 if (_enter_focus_input_area)470 if (_enter_focus_input_area)
541 _enter_focus_input_area->Reference ();471 _enter_focus_input_area->Reference();
542472
543 }473 }
544474
545 void BaseWindow::SetOpacity (float opacity)475 void BaseWindow::SetOpacity(float opacity)
546 {476 {
547 if (_opacity == opacity)477 if (_opacity == opacity)
548 return;478 return;
549479
550 _opacity = opacity;480 _opacity = opacity;
551481
552 _opacity = CLAMP (_opacity, 0.0f, 1.0f);482 _opacity = CLAMP(_opacity, 0.0f, 1.0f);
553483
554 QueueDraw ();484 QueueDraw();
555 }485 }
556486
557 float BaseWindow::GetOpacity ()487 float BaseWindow::GetOpacity()
558 {488 {
559 return _opacity;489 return _opacity;
560 }490 }
561491
=== modified file 'Nux/BaseWindow.h'
--- Nux/BaseWindow.h 2011-09-20 06:03:43 +0000
+++ Nux/BaseWindow.h 2011-10-25 21:32:25 +0000
@@ -58,7 +58,7 @@
58 @param int The height of the window.58 @param int The height of the window.
59 @param Geometry& The tentative size of the window.59 @param Geometry& The tentative size of the window.
60 */60 */
61 typedef void (*ConfigureNotifyCallback) (int, int, Geometry &, void *);61 typedef void(*ConfigureNotifyCallback) (int, int, Geometry &, void *);
6262
63 /*!63 /*!
64 A floating area on top of the main window.64 A floating area on top of the main window.
@@ -66,23 +66,18 @@
66 */66 */
67 class BaseWindow: public View67 class BaseWindow: public View
68 {68 {
69 NUX_DECLARE_OBJECT_TYPE (BaseWindow, View);69 NUX_DECLARE_OBJECT_TYPE(BaseWindow, View);
70 public:70 public:
71 BaseWindow (const TCHAR *WindowName = TEXT (""), NUX_FILE_LINE_PROTO);71 BaseWindow(const char *WindowName = "", NUX_FILE_LINE_PROTO);
72 virtual ~BaseWindow();72 virtual ~BaseWindow();
7373
74 nux::Property<bool> premultiply;74 nux::Property<bool> premultiply;
7575
76 virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);76 virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
77 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);77 virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
78 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);78 virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
79 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);79 virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
80 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
8180
82 void AddWidget (View *ic);
83 void AddWidget (View *ic, int stretchfactor);
84 void AddWidget (std::list<View *> *ViewList);
85
86 virtual Layout* GetLayout();81 virtual Layout* GetLayout();
87 virtual bool SetLayout(Layout *layout);82 virtual bool SetLayout(Layout *layout);
8883
@@ -90,37 +85,37 @@
90 /*!85 /*!
91 Push this view one level up the ViewWindow stack. Does it even if the view is hidden.86 Push this view one level up the ViewWindow stack. Does it even if the view is hidden.
92 */87 */
93 void PushHigher (BaseWindow* floating_view);88 void PushHigher(BaseWindow* floating_view);
9489
95 //! Push the view one level down the ViewWindow stack.90 //! Push the view one level down the ViewWindow stack.
96 /*!91 /*!
97 Push this view one level down the ViewWindow stack. Does it even if the view is hidden.92 Push this view one level down the ViewWindow stack. Does it even if the view is hidden.
98 */93 */
99 void PushLower (BaseWindow* floating_view);94 void PushLower(BaseWindow* floating_view);
10095
101 //! Push the view to the front of the ViewWindow stack.96 //! Push the view to the front of the ViewWindow stack.
102 /*!97 /*!
103 Push this view to the top of the ViewWindow stack. Does it even if the view is hidden.98 Push this view to the top of the ViewWindow stack. Does it even if the view is hidden.
104 If a valid ViewWindow has been forced at the top of the stack with a call to WindowCompositor::SetAlwaysOnFrontWindow(),99 If a valid ViewWindow has been forced at the top of the stack with a call to WindowCompositor::SetAlwaysOnFrontWindow(),
105 then this view will be positioned one level below that view.100 then this view will be positioned one level below that view.
106 \sa SetAlwaysOnFrontWindow ();101 \sa SetAlwaysOnFrontWindow();
107 */102 */
108 void PushToFront ();103 void PushToFront();
109 104
110 //! Push the view to the back of the ViewWindow stack.105 //! Push the view to the back of the ViewWindow stack.
111 /*!106 /*!
112 Push this view to the back of the ViewWindow stack. Does it even if the view is hidden.107 Push this view to the back of the ViewWindow stack. Does it even if the view is hidden.
113 */108 */
114 void PushToBack ();109 void PushToBack();
115110
116 //! Set the window size to respect the layout container.111 //! Set the window size to respect the layout container.
117 /*!112 /*!
118 Set the window size to be such that the container layout size remains the same after ComputeSizeLayout2 is113 Set the window size to be such that the container layout size remains the same after ComputeSizeLayout2 is
119 called on the layout. The window elements (title bar, minimize and close buttons) are positioned accordingly.114 called on the layout. The window elements(title bar, minimize and close buttons) are positioned accordingly.
120 The size grip is not responding anymore.115 The size grip is not responding anymore.
121 @param b If b is true, the window size respect the size the layout container.116 @param b If b is true, the window size respect the size the layout container.
122 */117 */
123 virtual void SetWindowSizeMatchLayout (bool b)118 virtual void SetWindowSizeMatchLayout(bool b)
124 {119 {
125 _size_match_layout = b;120 _size_match_layout = b;
126 }121 }
@@ -134,12 +129,12 @@
134 return _size_match_layout;129 return _size_match_layout;
135 }130 }
136131
137 virtual void ShowWindow (bool b, bool StartModal = false);132 virtual void ShowWindow(bool b, bool StartModal = false);
138 void StopModal ();133 void StopModal();
139 bool IsModal () const;134 bool IsModal() const;
140 bool IsVisible () const;135 bool IsVisible() const;
141136
142 virtual void SetGeometry (const Geometry &geo);137 virtual void SetGeometry(const Geometry &geo);
143138
144 /*!139 /*!
145 Call this function to set a callback function that is called when this object is need to be resized or re-positioned.140 Call this function to set a callback function that is called when this object is need to be resized or re-positioned.
@@ -147,24 +142,24 @@
147 @param Data The callback data.142 @param Data The callback data.
148 */143 */
149144
150 void SetConfigureNotifyCallback (ConfigureNotifyCallback Callback, void *Data);145 void SetConfigureNotifyCallback(ConfigureNotifyCallback Callback, void *Data);
151146
152 void SetBackgroundLayer (AbstractPaintLayer *layer);147 void SetBackgroundLayer(AbstractPaintLayer *layer);
153 void SetBackgroundColor (const Color &color);148 void SetBackgroundColor(const Color &color);
154149
155 void SetOpacity (float opacity);150 void SetOpacity(float opacity);
156 float GetOpacity ();151 float GetOpacity();
157152
158 #if defined(NUX_OS_LINUX)153 #if defined(NUX_OS_LINUX)
159 void EnableInputWindow (bool b,154 void EnableInputWindow(bool b,
160 const char* title = "nux input window",155 const char* title = "nux input window",
161 bool take_focus = False,156 bool take_focus = False,
162 bool override_redirect = False);157 bool override_redirect = False);
163 bool InputWindowEnabled ();158 bool InputWindowEnabled();
164 void InputWindowEnableStruts (bool enable);159 void InputWindowEnableStruts(bool enable);
165 bool InputWindowStrutsEnabled ();160 bool InputWindowStrutsEnabled();
166 void SetInputFocus ();161 void SetInputFocus();
167 Window GetInputWindowId ();162 Window GetInputWindowId();
168 #endif163 #endif
169164
170 //! Set an InputArea to receive the keyboard focus when the BaseWIndow receives the NUX_WINDOW_ENTER_FOCUS event.165 //! Set an InputArea to receive the keyboard focus when the BaseWIndow receives the NUX_WINDOW_ENTER_FOCUS event.
@@ -172,18 +167,18 @@
172 \sa _enter_focus_input_area.167 \sa _enter_focus_input_area.
173 @param input_area An InputArea pointer object. Must be a child of this BaseWindow.168 @param input_area An InputArea pointer object. Must be a child of this BaseWindow.
174 */169 */
175 void SetEnterFocusInputArea (InputArea *input_area);170 void SetEnterFocusInputArea(InputArea *input_area);
176171
177172
178 //! Get the backup texture data of this BaseWindow,173 //! Get the backup texture data of this BaseWindow,
179 void* GetBackupTextureData (int &width, int &height, int &format);174 void* GetBackupTextureData(int &width, int &height, int &format);
180175
181 //! Emit a signal when the BaseWindow becomes visible.176 //! Emit a signal when the BaseWindow becomes visible.
182 sigc::signal<void, BaseWindow*> sigVisible;177 sigc::signal<void, BaseWindow*> sigVisible;
183 //! Emit a signal when the BaseWindow becomes hidden.178 //! Emit a signal when the BaseWindow becomes hidden.
184 sigc::signal<void, BaseWindow*> sigHidden;179 sigc::signal<void, BaseWindow*> sigHidden;
185180
186 NString GetWindowName ()181 NString GetWindowName()
187 {182 {
188 return _name;183 return _name;
189 }184 }
@@ -204,9 +199,9 @@
204199
205 friend class ComboBox_Logic_WindowView;200 friend class ComboBox_Logic_WindowView;
206201
207 virtual void PreLayoutManagement ();202 virtual void PreLayoutManagement();
208 virtual long PostLayoutManagement (long LayoutResult);203 virtual long PostLayoutManagement(long LayoutResult);
209 virtual void PositionChildLayout (float offsetX, float offsetY);204 virtual void ComputeContentPosition(float offsetX, float offsetY);
210 //! Layout the window elements.205 //! Layout the window elements.
211 /*!206 /*!
212 Layout elements such as button on the title bar, and the resize widget according to the current207 Layout elements such as button on the title bar, and the resize widget according to the current
@@ -220,12 +215,12 @@
220 @param Width New width of the window.215 @param Width New width of the window.
221 @param Height New height of the window.216 @param Height New height of the window.
222 */217 */
223 virtual void NotifyConfigurationChange (int Width, int Height);218 virtual void NotifyConfigurationChange(int Width, int Height);
224219
225 int GetBorder() const;220 int GetBorder() const;
226 int GetTopBorder() const;221 int GetTopBorder() const;
227 void SetBorder (int border);222 void SetBorder(int border);
228 void SetTopBorder (int border);223 void SetTopBorder(int border);
229 int m_TopBorder;224 int m_TopBorder;
230 int m_Border;225 int m_Border;
231 boost::scoped_ptr<AbstractPaintLayer> _paint_layer;226 boost::scoped_ptr<AbstractPaintLayer> _paint_layer;
@@ -233,7 +228,7 @@
233 bool _entering_visible_state; //!< the window is about to be made visible during event processing228 bool _entering_visible_state; //!< the window is about to be made visible during event processing
234 bool _entering_hidden_state; //!< the window is about to be made hidden during event processing229 bool _entering_hidden_state; //!< the window is about to be made hidden during event processing
235 230
236 bool ChildNeedsRedraw ();231 bool ChildNeedsRedraw();
237232
238 #if defined(NUX_OS_LINUX)233 #if defined(NUX_OS_LINUX)
239 bool m_input_window_enabled;234 bool m_input_window_enabled;
240235
=== removed file 'Nux/BezierCurveControl.cpp'
--- Nux/BezierCurveControl.cpp 2011-09-20 06:03:43 +0000
+++ Nux/BezierCurveControl.cpp 1970-01-01 00:00:00 +0000
@@ -1,343 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#include "Nux.h"
24#include "NuxCore/Math/Constants.h"
25#include "NuxCore/Math/Spline.h"
26#include "NuxCore/Math/Bezier.h"
27#include "BezierCurveControl.h"
28
29namespace nux
30{
31
32 const int KNOT_SIZE = 2;
33 const int KNOT_HIT_TEST = 4;
34
35 BezierCurveControl::BezierCurveControl (NUX_FILE_LINE_DECL)
36 : View (NUX_FILE_LINE_PARAM)
37 , m_minX (0.0f),
38 m_minY (0.0f),
39 m_maxX (1.0f),
40 m_maxY (1.0f),
41 m_FunctionCallback (0)
42 {
43 SetMinimumSize (400, 300);
44 SetBaseSize (400, 300);
45
46 m_control_knot.push_back (Knot (0.0f, 0.0f) );
47 m_control_knot.push_back (Knot (0.1f, 0.0f) );
48 m_control_knot.push_back (Knot (0.7f, 0.9f) );
49 m_control_knot.push_back (Knot (1.0f, 1.0f) );
50
51 mouse_down.connect (sigc::mem_fun (this, &BezierCurveControl::RecvMouseDown) );
52 mouse_up.connect (sigc::mem_fun (this, &BezierCurveControl::RecvMouseUp) );
53 mouse_drag.connect (sigc::mem_fun (this, &BezierCurveControl::RecvMouseDrag) );
54
55 }
56
57 BezierCurveControl::~BezierCurveControl()
58 {
59
60
61 }
62
63
64 long BezierCurveControl::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
65 {
66 long ret = TraverseInfo;
67
68 if (ievent.e_event == NUX_MOUSE_PRESSED)
69 {
70 if (!GetGeometry().IsPointInside (ievent.e_x, ievent.e_y) )
71 {
72 //ProcEvInfo = eDoNotProcess;
73 //return TraverseInfo;
74 }
75 }
76
77 ret = PostProcessEvent2 (ievent, ret, 0);
78 return ret;
79 }
80
81
82 void BezierCurveControl::Draw (GraphicsEngine &GfxContext, bool force_draw)
83 {
84 Geometry base = GetGeometry();
85
86 GetPainter().PaintBackground (GfxContext, base);
87 GetPainter().Paint2DQuadWireframe (GfxContext, base, Color (COLOR_BACKGROUND_SECONDARY) );
88
89#define N 3
90 t_u32 i;
91 t_u32 nsample = 30;
92 double t;
93 t_u32 nbKnot = (t_u32) m_control_knot.size();
94
95 if (nbKnot > 0)
96 {
97 double *xcon = new double[nbKnot];
98 double xval;
99 double *ycon = new double[nbKnot];
100 double yval;
101
102
103 for (i = 0; i < nbKnot; i++)
104 {
105 xcon[i] = m_control_knot[i].m_X;
106 ycon[i] = m_control_knot[i].m_Y;
107 }
108
109 int W = GetBaseWidth() - 2;
110 int H = GetBaseHeight() - 2;
111 int X = GetBaseX() + 1;
112 int Y = GetBaseY() + 1;
113
114 double xprev, yprev;
115 Bezier_XY (N, 0.0, xcon, ycon, &xprev, &yprev);
116
117 //GetPainter().Draw2DLine(X, Y, X+W, Y+H, Color(0xFFFF0000));
118
119 base.OffsetPosition (1, 1);
120 base.OffsetSize (-2, -2);
121
122 GfxContext.PushClippingRectangle (base);
123
124 GfxContext.GetRenderStates().EnableLineSmooth (TRUE, 1, GL_FASTEST);
125 GfxContext.GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
126
127 for (i = 1; i < nsample; i++)
128 {
129 t = ( double ) ( i ) / ( double ) ( nsample - 1 );
130 Bezier_XY ( N, t, xcon, ycon, &xval, &yval );
131
132 int X0, Y0, X1, Y1;
133 X0 = X + W * (xprev - m_minX) / (m_maxX - m_minX);
134 Y0 = Y + H * ( 1 - (yprev - m_minY) / (m_maxY - m_minY) );
135 X1 = X + W * (xval - m_minX) / (m_maxX - m_minX);
136 Y1 = Y + H * ( 1 - (yval - m_minY) / (m_maxY - m_minY) );
137
138 GetPainter().Draw2DLine (GfxContext, X0, Y0, X1, Y1, Color (0xFFFF0000) );
139
140 xprev = xval;
141 yprev = yval;
142 }
143
144 GfxContext.GetRenderStates().EnableLineSmooth (FALSE);
145 GfxContext.GetRenderStates().SetBlend (GL_FALSE);
146
147 for (i = 0; i < nbKnot - 1; i++)
148 {
149 int X0, Y0, X1, Y1;
150 X0 = X + W * (m_control_knot[i].m_X - m_minX) / (m_maxX - m_minX);
151 Y0 = Y + H * ( 1 - (m_control_knot[i].m_Y - m_minY) / (m_maxY - m_minY) );
152 X1 = X + W * (m_control_knot[i+1].m_X - m_minX) / (m_maxX - m_minX);
153 Y1 = Y + H * ( 1 - (m_control_knot[i+1].m_Y - m_minY) / (m_maxY - m_minY) );
154
155 GetPainter().Draw2DLine (GfxContext, X0, Y0, X1, Y1, Color (0xFF0000FF) );
156
157 }
158
159 for (i = 0; i < nbKnot; i++)
160 {
161 int X0, Y0;
162 X0 = X + W * (m_control_knot[i].m_X - m_minX) / (m_maxX - m_minX);
163 Y0 = Y + H * ( 1 - (m_control_knot[i].m_Y - m_minY) / (m_maxY - m_minY) );
164
165 if (m_control_knot[i].m_IsSelected)
166 GetPainter().Paint2DQuadColor (GfxContext, X0 - KNOT_SIZE, Y0 - KNOT_SIZE, 2 * KNOT_SIZE, 2 * KNOT_SIZE, Color (0xFF00FF00) );
167 else
168 GetPainter().Paint2DQuadColor (GfxContext, X0 - KNOT_SIZE, Y0 - KNOT_SIZE, 2 * KNOT_SIZE, 2 * KNOT_SIZE, Color (0xFF777777) );
169 }
170
171 delete[] xcon;
172 delete[] ycon;
173 }
174
175// for(int i = 1; i < GetWidth(); i++)
176// {
177// float x1, y1;
178//
179// x1 = x0 + dX;
180// y1 = EvalFunction(x1);
181//
182// int X0, Y0, X1, Y1;
183// X0 = X + W * (x0 - m_minX) / (m_maxX - m_minX);
184// Y0 = Y - H * (y0 + m_minY) / (m_maxY - m_minY);
185// X1 = X + W * (x1 - m_minX) / (m_maxX - m_minX);
186// Y1 = Y - H * (y1 + m_minY) / (m_maxY - m_minY);
187// GetPainter().Draw2DLine(X0, Y0, X1, Y1, Color(0xFFFF0000));
188//
189// x0 = x1;
190// y0 = y1;
191//
192// }
193 GfxContext.PopClippingRectangle();
194 }
195
196
197 void BezierCurveControl::DrawContent (GraphicsEngine &GfxContext, bool force_draw)
198 {
199
200 }
201
202 void BezierCurveControl::PostDraw (GraphicsEngine &GfxContext, bool force_draw)
203 {
204
205 }
206
207
208 void BezierCurveControl::SetXAxisBounds (float minX, float maxX)
209 {
210 m_minX = minX;
211 m_maxX = maxX;
212 QueueDraw();
213 }
214
215 void BezierCurveControl::SetYAxisBounds (float minY, float maxY)
216 {
217 m_minY = minY;
218 m_maxY = maxY;
219 QueueDraw();
220 }
221
222 void BezierCurveControl::SetFunctionCallback (FunctionCallback f)
223 {
224 m_FunctionCallback = f;
225 QueueDraw();
226 }
227
228 float BezierCurveControl::EvalFunction (float x)
229 {
230 if (m_FunctionCallback != 0)
231 return (*m_FunctionCallback) (x);
232
233 return 0;
234 }
235
236 void BezierCurveControl::UpdateGraph()
237 {
238 QueueDraw();
239 }
240
241
242// check if a value lies within a closed interval
243#ifndef INSIDE_BOUNDS
244#define INSIDE_BOUNDS( x, lo, hi ) ( (x) >= (lo) && (x) <= (hi) )
245#endif
246
247//check if a 2D point lies within a 2D box
248#ifndef PT_INSIDE_BOX
249#define PT_INSIDE_BOX( x, y, lo_x, hi_x, lo_y, hi_y ) ( INSIDE_BOUNDS(x,lo_x,hi_x) && INSIDE_BOUNDS(y,lo_y,hi_y) )
250#endif
251
252 void BezierCurveControl::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
253 {
254 QueueDraw();
255 }
256
257 void BezierCurveControl::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
258 {
259 t_u32 nbKnot = (t_u32) m_control_knot.size();
260
261 for (t_u32 i = 0; i < nbKnot; i++)
262 {
263 m_control_knot[i].m_IsSelected = false;
264 }
265
266 int W = GetBaseWidth() - 2;
267 int H = GetBaseHeight() - 2;
268 int X = GetBaseX() + 1;
269 int Y = GetBaseY() + 1;
270
271 bool b = PT_INSIDE_BOX (X + x, Y + y, X, X + W, Y, Y + H);
272
273 if (b == false)
274 return;
275
276 X = GetBaseX();
277 Y = GetBaseY();
278
279 for (t_u32 i = 0; i < nbKnot; i++)
280 {
281 int Xp, Yp;
282 Xp = X + W * (m_control_knot[i].m_X - m_minX) / (m_maxX - m_minX);
283 Yp = Y + H * ( 1 - (m_control_knot[i].m_Y - m_minY) / (m_maxY - m_minY) );
284
285 if (PT_INSIDE_BOX (X + x, Y + y, Xp - KNOT_HIT_TEST, Xp + KNOT_HIT_TEST, Yp - KNOT_HIT_TEST, Yp + KNOT_HIT_TEST) )
286 {
287 m_control_knot[i].m_IsSelected = true;
288 break;
289 }
290 }
291
292 QueueDraw();
293 }
294
295 void BezierCurveControl::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
296 {
297 float xp, yp;
298
299 int W = GetBaseWidth();
300 int H = GetBaseHeight();
301 t_u32 nbKnot = (t_u32) m_control_knot.size();
302
303 xp = m_minX + (m_maxX - m_minX) * dx / W;
304 yp = m_minY + (m_maxY - m_minY) * dy / H;
305
306
307
308 for (t_u32 i = 0; i < nbKnot; i++)
309 {
310 if (m_control_knot[i].m_IsSelected)
311 {
312 m_control_knot[i].m_X += xp;
313 m_control_knot[i].m_Y -= yp;
314
315 if (m_control_knot[i].m_X < m_minX)
316 {
317 m_control_knot[i].m_X = m_minX;
318 }
319
320 if (m_control_knot[i].m_X > m_maxX)
321 {
322 m_control_knot[i].m_X = m_maxX;
323 }
324
325 if (m_control_knot[i].m_Y < m_minY)
326 {
327 m_control_knot[i].m_Y = m_minY;
328 }
329
330 if (m_control_knot[i].m_Y > m_maxY)
331 {
332 m_control_knot[i].m_Y = m_maxY;
333 }
334
335 break;
336 }
337 }
338
339 QueueDraw();
340 }
341
342
343}
3440
=== removed file 'Nux/BezierCurveControl.h'
--- Nux/BezierCurveControl.h 2011-04-06 21:54:09 +0000
+++ Nux/BezierCurveControl.h 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#ifndef BEZIERCURVECONTROL_H
24#define BEZIERCURVECONTROL_H
25
26namespace nux
27{
28
29 class Knot
30 {
31 public :
32
33 float m_X;
34 float m_Y;
35
36 bool m_IsSelected;
37
38 public :
39
40 Knot()
41 : m_X (0)
42 , m_Y (0)
43 , m_IsSelected (false)
44 {} //Constructors
45 Knot (float ptX, float ptY)
46 : m_X (ptX)
47 , m_Y (ptY)
48 , m_IsSelected (false)
49 {}
50
51 void setPoint (float x, float y)
52 {
53 m_X = x; //Setting
54 m_Y = y;
55 }
56
57
58 //Operator overloading
59 void operator = (Knot knot)
60 {
61 m_X = knot.m_X;
62 m_Y = knot.m_Y;
63 }
64 bool operator != (Knot knot)
65 {
66 bool b;
67 b = ( (m_X != knot.m_X) || (m_Y != knot.m_Y) ) ? true : false;
68 return b;
69 }
70 };
71
72
73 typedef float (*FunctionCallback) (float);
74
75 class BezierCurveControl : public View
76 {
77 public:
78 BezierCurveControl (NUX_FILE_LINE_PROTO);
79 ~BezierCurveControl();
80 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
81 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
82 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
83 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
84
85
86 void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
87 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
88 void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
89 private:
90 void SetXAxisBounds (float minX, float maxX);
91 void SetYAxisBounds (float minY, float maxY);
92 void SetFunctionCallback (FunctionCallback f);
93 float EvalFunction (float x);
94 void UpdateGraph();
95
96 std::vector<Knot> m_control_knot;
97
98 float m_minX, m_minY, m_maxX, m_maxY;
99 FunctionCallback m_FunctionCallback;
100 };
101
102
103}
104
105#endif // BEZIERCURVECONTROL_H
1060
=== removed file 'Nux/BezierCurveControl2.cpp'
--- Nux/BezierCurveControl2.cpp 2011-09-20 06:03:43 +0000
+++ Nux/BezierCurveControl2.cpp 1970-01-01 00:00:00 +0000
@@ -1,1046 +0,0 @@
1/*
2 * Copyright 2010 Inalogic® Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
19 *
20 */
21
22
23#include "Nux.h"
24
25#include "BezierCurveControl2.h"
26#include "NuxCore/Math/Bezier.h"
27
28namespace nux
29{
30
31 static const int KNOT_SIZE = 2;
32 static const int KNOT_HIT_TEST = 4;
33 static const int CURVE_DEGREE = 3;
34 static const int GRAPH_MARGIN = 2;
35 static const int UNIT_REFERENCE = 15;
36
37 unsigned long S_KEY = 0;
38
39 BezierCurveControl2::BezierCurveControl2 (NUX_FILE_LINE_DECL)
40 : View (NUX_FILE_LINE_PARAM)
41 , m_minX (-0.10f),
42 m_minY (-0.100f),
43 m_maxX (1.100f),
44 m_maxY (1.100f),
45 m_FunctionCallback (0),
46 m_bControlPointSelected (0),
47 m_bPanningEnabled (true),
48 m_bZoomingEnabled (true)
49 {
50 SetMinimumSize (180, 180);
51
52 m_control_knot.push_back (Knot2 (0.0f, 0.0f) );
53 m_control_knot.push_back (Knot2 (0.1f, 0.0f) );
54 m_control_knot.push_back (Knot2 (0.7f, 0.9f) );
55 m_control_knot.push_back (Knot2 (1.0f, 1.0f) );
56
57 mouse_down.connect (sigc::mem_fun (this, &BezierCurveControl2::RecvMouseDown) );
58 mouse_up.connect (sigc::mem_fun (this, &BezierCurveControl2::RecvMouseUp) );
59 mouse_drag.connect (sigc::mem_fun (this, &BezierCurveControl2::RecvMouseDrag) );
60
61 key_down.connect (sigc::mem_fun (this, &BezierCurveControl2::RecvKeyEvent) );
62
63 NTextureData image;
64 MakeCheckBoardImage (image.GetSurface (0), 64, 64, Color (0xff323232), Color (0xff535353), 8, 8);
65 BaseTexture* m_CheckboardPattern = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture ();
66 m_CheckboardPattern->Update (&image);
67
68 TexCoordXForm texxform;
69 texxform.SetTexCoordType (TexCoordXForm::OFFSET_COORD);
70 texxform.SetWrap (TEXWRAP_REPEAT, TEXWRAP_REPEAT);
71 m_Background = new TextureLayer (m_CheckboardPattern->GetDeviceTexture(), texxform, color::White);
72
73 m_CheckboardPattern->UnReference ();
74 }
75
76 BezierCurveControl2::~BezierCurveControl2()
77 {
78 delete m_Background;
79 }
80
81 long BezierCurveControl2::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
82 {
83 long ret = TraverseInfo;
84
85 if (ievent.e_event == NUX_MOUSE_PRESSED)
86 {
87 if (!GetGeometry().IsPointInside (ievent.e_x, ievent.e_y) )
88 {
89 //ProcEvInfo = eDoNotProcess;
90 //return TraverseInfo;
91 }
92 }
93
94 S_KEY = ievent.GetVirtualKeyState (NUX_VK_S);
95 ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
96 return ret;
97 }
98
99
100 void BezierCurveControl2::Draw (GraphicsEngine &GfxContext, bool force_draw)
101 {
102 Geometry base = GetGeometry();
103
104 GetPainter().PaintBackground (GfxContext, base);
105 GetPainter().Paint2DQuadColor (GfxContext, base, Color (COLOR_BACKGROUND_PRIMARY) );
106 base.OffsetPosition (GRAPH_MARGIN, GRAPH_MARGIN);
107 base.OffsetSize (-2 * GRAPH_MARGIN, -2 * GRAPH_MARGIN);
108
109 int W = GetBaseWidth() - 2 * GRAPH_MARGIN;
110 int H = GetBaseHeight() - 2 * GRAPH_MARGIN;
111 int X = GetBaseX() + GRAPH_MARGIN;
112 int Y = GetBaseY() + GRAPH_MARGIN;
113
114 t_u32 i;
115 int nsample = base.GetWidth();
116 double t;
117 t_u32 nbKnot = (t_u32) m_control_knot.size();
118
119 GfxContext.PushClippingRectangle (base);
120
121 GetPainter().PushDrawLayer (GfxContext, base, m_Background);
122 GetPainter().PopBackground();
123
124 //DrawGrid(GfxContext);
125 DrawCoordinateSystem (GfxContext);
126
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches