Skip to content

Commit

Permalink
Merge pull request #1 from nieznanysprawiciel/Rendering
Browse files Browse the repository at this point in the history
Rendering - new media
  • Loading branch information
nieznanysprawiciel authored Apr 4, 2020
2 parents aad9406 + ab3a803 commit 9e55351
Show file tree
Hide file tree
Showing 65 changed files with 2,505 additions and 86 deletions.
2 changes: 2 additions & 0 deletions swCommonLib/Common/Buffers/BufferRaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ inline BufferRaw& BufferRaw::operator= ( BufferRaw&& bufferRaw )

bufferRaw.m_data = nullptr;
bufferRaw.m_size = 0;

return *this;
}

// ================================ //
Expand Down
1 change: 1 addition & 0 deletions swGUI/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Documentation/
*.log
*.scc
*.html
*.orig

# Visual C++ cache files
ipch/
Expand Down
68 changes: 68 additions & 0 deletions swGUI/Core/Controls/Shapes/Ellipse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
@file Ellipse.cpp
@author nieznanysprawiciel
@copyright File is part of Sleeping Wombat Libraries.
*/
#include "swGUI/Core/stdafx.h"

#include "Ellipse.h"
#include "swGUI/Core/Media/Geometry/EllipseGeometry.h"


namespace sw {
namespace gui
{


// ================================ //
//
Ellipse::Ellipse()
: m_strokeThickness( 1 )
{
Shape::SetWidth( 100 );
Shape::SetHeight( 100 );

auto rectGeom = std::make_shared< EllipseGeometry >();
rectGeom->SetWidth( GetSize().x );
rectGeom->SetHeight( GetSize().y );
rectGeom->SetThickness( m_strokeThickness );

SetGeometry( rectGeom );
}

// ================================ //
//
void Ellipse::SetWidth ( float width )
{
Shape::SetWidth( width );

auto geom = std::static_pointer_cast< EllipseGeometry >( GetGeometry() );
geom->SetWidth( GetSize().x );
}

// ================================ //
//
void Ellipse::SetHeight ( float height )
{
Shape::SetHeight( height );

auto geom = std::static_pointer_cast< EllipseGeometry >( GetGeometry() );
geom->SetHeight( GetSize().y );
}

// ================================ //
//
void Ellipse::SetThickness ( float thickness )
{
m_strokeThickness = thickness;

auto geom = std::static_pointer_cast< EllipseGeometry >( GetGeometry() );
geom->SetThickness( m_strokeThickness );
}



} // gui
} // sw


47 changes: 47 additions & 0 deletions swGUI/Core/Controls/Shapes/Ellipse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once
/**
@file Ellipse.h
@author nieznanysprawiciel
@copyright File is part of Sleeping Wombat Libraries.
*/

#include "Shape.h"




namespace sw {
namespace gui
{

/**@brief Draws ellipse shape.
@ingroup Shapes
@ingroup Controls*/
class Ellipse : public Shape
{
RTTR_ENABLE( Shape );
RTTR_REGISTRATION_FRIEND;
private:

float m_strokeThickness;

protected:
public:

explicit Ellipse ();
virtual ~Ellipse () = default;


virtual void SetWidth ( float width ) override;
virtual void SetHeight ( float height ) override;
void SetThickness ( float thickness );

};

DEFINE_OPTR_TYPE( Ellipse );


} // gui
} // sw


21 changes: 12 additions & 9 deletions swGUI/Core/Controls/Shapes/Rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ namespace gui
// ================================ //
//
Rectangle::Rectangle()
: m_width( 100 )
, m_height( 100 )
, m_strokeThickness( 1 )
: m_strokeThickness( 1 )
{
Shape::SetWidth( 100 );
Shape::SetHeight( 100 );

auto rectGeom = std::make_shared< RectangleGeometry >();
rectGeom->SetWidth( m_width );
rectGeom->SetHeight( m_height );
rectGeom->SetWidth( GetSize().x );
rectGeom->SetHeight( GetSize().y );
rectGeom->SetThickness( m_strokeThickness );

SetGeometry( rectGeom );
Expand All @@ -33,20 +34,22 @@ Rectangle::Rectangle()
//
void Rectangle::SetWidth ( float width )
{
m_width = width;
Shape::SetWidth( width );

auto geom = std::static_pointer_cast< RectangleGeometry >( GetGeometry() );
geom->SetWidth( m_width );
geom->SetWidth( GetSize().x );


}

// ================================ //
//
void Rectangle::SetHeight ( float height )
{
m_height = height;
Shape::SetHeight( height );

auto geom = std::static_pointer_cast< RectangleGeometry >( GetGeometry() );
geom->SetHeight( m_height );
geom->SetHeight( GetSize().y );
}

// ================================ //
Expand Down
8 changes: 3 additions & 5 deletions swGUI/Core/Controls/Shapes/Rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Rectangle : public Shape
RTTR_REGISTRATION_FRIEND;
private:

float m_width; ///< Remove in future. This should be implemented in ArrangeCore.
float m_height; ///< Remove in future. This should be implemented in ArrangeCore.
float m_strokeThickness;

protected:
Expand All @@ -34,9 +32,9 @@ class Rectangle : public Shape
virtual ~Rectangle () = default;


void SetWidth ( float width );
void SetHeight ( float height );
void SetThickness ( float thickness );
virtual void SetWidth ( float width ) override;
virtual void SetHeight ( float height ) override;
void SetThickness ( float thickness );

};

Expand Down
14 changes: 14 additions & 0 deletions swGUI/Core/Controls/Visual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ Visual::Visual()
: m_offset( Position( 0.0f, 0.0f ) )
{}

// ================================ //
//
void Visual::SetWidth ( float width )
{
m_size.x = width;
}

// ================================ //
//
void Visual::SetHeight ( float height )
{
m_size.y = height;
}


} // gui
} // sw
Expand Down
4 changes: 4 additions & 0 deletions swGUI/Core/Controls/Visual.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Visual : public DependencyObject
private:

Position m_offset; ///< Control position relative to parent.
Size2D m_size; ///< Size of control (bounding box).

protected:

Expand Down Expand Up @@ -61,10 +62,13 @@ class Visual : public DependencyObject


Position GetVisualOffset () const { return m_offset; }
Size2D GetSize () const { return m_size; }

public:
// Temporary
void SetOffset ( Position pos ) { m_offset = pos; }
virtual void SetWidth ( float width );
virtual void SetHeight ( float height );
};


Expand Down
58 changes: 58 additions & 0 deletions swGUI/Core/Media/Brushes/AngleGradientBrush.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
@file AngleGradientBrush.cpp
@author nieznanysprawiciel
@copyright File is part of Sleeping Wombat Libraries.
*/


#include "swGUI/Core/stdafx.h"
#include "AngleGradientBrush.h"



namespace sw {
namespace gui
{

// ================================ //
//
AngleGradientBrush::AngleGradientBrush()
: GradientBrush( AngleGradientBrush::ConstantsSize() )
{
m_constants.GradientCenter = Position( 0.5f, 0.5f );
}


// ================================ //
//
BufferRange AngleGradientBrush::BufferData ()
{
return PrepareBuffer( m_constants.GetView() );
}

// ================================ //
//
filesystem::Path AngleGradientBrush::ShaderFunctionFile ()
{
return "$(CoreGUI-Shader-Dir)/Brush/AngleGradientBrush.psh";
}

// ================================ //
//
void AngleGradientBrush::SetGradientCenter ( Point center )
{
m_constants.GradientCenter = center;

InvalidateConstants();
}

// ================================ //
//
Size AngleGradientBrush::ConstantsSize () const
{
return sizeof( m_constants );
}


} // gui
} // sw
61 changes: 61 additions & 0 deletions swGUI/Core/Media/Brushes/AngleGradientBrush.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once
/**
@file AngleGradientBrush.h
@author nieznanysprawiciel
@copyright File is part of Sleeping Wombat Libraries.
*/



#include "GradientBrush.h"

#include "swCommonLib/Common/Buffers/StackBuffer.h"
#include "swCommonLib/System/Path.h"
#include "swGUI/Core/System/CommonTypes/CommonTypes.h"



namespace sw {
namespace gui
{


/**@brief Draws angle gradient on @ref Geometry.
@ingroup Brushes*/
class AngleGradientBrush : public GradientBrush
{
RTTR_ENABLE( GradientBrush );
RTTR_REGISTRATION_FRIEND;
public:

struct Constants
{
Point GradientCenter;
};

private:
protected:

StackBuffer< Constants > m_constants;

public:
explicit AngleGradientBrush ();
virtual ~AngleGradientBrush () = default;


virtual BufferRange BufferData () override;
virtual filesystem::Path ShaderFunctionFile () override;

void SetGradientCenter ( Point center );

protected:

virtual Size ConstantsSize () const override;
};

DEFINE_PTR_TYPE( AngleGradientBrush );


} // gui
} // sw

Loading

0 comments on commit 9e55351

Please sign in to comment.