User

Difference between revisions of "Sascha"

From Guiliani

(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
<nowiki>
+
<!--
#include "ExampleControl.h"
 
#include "GfxWrap.h"
 
#include "GUIStreamReader.h"
 
#include "GUIStreamWriter.h"
 
#include "GUIStreamingException.h"
 
#include "GUIControlResource.h"
 
#include "GUIMemLeakWatcher.h" // <-- has to be the last include
 
  
#define EXAMPLE_CONTROL_CLASS_VERSION 1
+
https://developers.google.com/speed/webp/docs/riff_container
// The minimal class version allowed.
+
https://chromium.googlesource.com/webm/libvpx
#define EXAMPLE_CONTROL_CLASS_MIN_VERSION 1
 
  
ExampleControl::ExampleControl(
+
vera++ -> checkstlye output -> warnings next generation (input as logfile)
    CGUICompositeObject *const pParent,
 
    const eC_Value &vX, const eC_Value &vY,
 
    const eC_Value &vWidth, const eC_Value &vHeight,
 
    eC_UInt uiInnerColor, eC_UInt uiBorderColor,
 
    eC_Value vBorderWidth,
 
    const ObjectHandle_t &eID)
 
    : CGUICompositeObject(pParent, vX, vY, vWidth, vHeight, eID),
 
      m_uiInnerColor(uiInnerColor),
 
      m_uiBorderColor(uiBorderColor),
 
      m_vBorderWidth(vBorderWidth)
 
{
 
    SetXMLTag("ExampleControl");
 
}
 
  
ExampleControl::ExampleControl()
+
google code stylguide
: m_uiInnerColor(0), m_uiBorderColor(0), m_vBorderWidth(eC_FromInt(0))
+
https://google.github.io/styleguide/cppguide.html
{
 
    SetXMLTag("ExampleControl");
 
}
 
  
void ExampleControl::SetCenterColor(eC_UInt uiInnerColor)
+
google styleguide cpplint
{
+
https://github.com/google/styleguide
    if (uiInnerColor != m_uiInnerColor)
 
    {
 
        m_uiInnerColor = uiInnerColor;
 
        InvalidateArea();
 
    }
 
}
 
  
void ExampleControl::SetBorderColor(eC_UInt uiBorderColor)
+
find bugs plugin -> warnings next generation
{
 
    if (uiBorderColor != m_uiBorderColor)
 
    {
 
        m_uiBorderColor = uiBorderColor;
 
        InvalidateArea();
 
    }
 
}
 
  
void ExampleControl::SetBorderWidth(eC_Value vBorderWidth)
+
tags (e.g. TODO, FIXME, ...) can be found and listed
{
 
    if (vBorderWidth != m_vBorderWidth)
 
    {
 
        m_vBorderWidth = vBorderWidth;
 
        InvalidateArea();
 
    }
 
}
 
  
void ExampleControl::Flip(const eC_Bool& rbVertical)
+
-->
{
 
    if (rbVertical)
 
    {
 
        // flip vertical means swap left and right side
 
        CGUIObject* pkCurrentObject;
 
        for (int i = 0; i < GetNumberOfChildren(); ++i)
 
        {
 
            pkCurrentObject = GetChild(i);
 
            if (pkCurrentObject->IsCompositeObject())
 
                pkCurrentObject->IsAnimating(); //Flip(rbVertical);
 
            else
 
            {
 
                pkCurrentObject->SetRelXPos(GetWidth() - (pkCurrentObject->GetWidth() + pkCurrentObject->GetRelXPos()));
 
                pkCurrentObject->InvalidateArea();
 
            }
 
        }
 
    }
 
    else
 
    {
 
        // flip horizontal means swap top and bottom side
 
        CGUIObject* pkCurrentObject;
 
        for (int i = 0; i < GetNumberOfChildren(); ++i)
 
        {
 
            pkCurrentObject = GetChild(i);
 
            if (pkCurrentObject->IsCompositeObject())
 
                pkCurrentObject->IsAnimating(); //Flip(rbVertical);
 
            else
 
            {
 
                pkCurrentObject->SetRelYPos(GetHeight() - (pkCurrentObject->GetHeight() + pkCurrentObject->GetRelYPos()));
 
                pkCurrentObject->InvalidateArea();
 
            }
 
        }
 
 
 
    }
 
}
 
 
 
void ExampleControl::Rotate(const eC_Int& riDegrees)
 
{
 
    switch (riDegrees)
 
    {
 
        case 0:
 
        default:
 
            // do nothing
 
            break;
 
 
 
        case 90:
 
        {
 
            // rotate 90 degrees clockwise
 
            // width and height will be swapped
 
            // x and y of every object will be re-calculated and swapped
 
 
 
            CGUIRect r = GetRelRect();
 
            SetWidth(r.GetHeight());
 
            SetHeight(r.GetWidth());
 
            CGUIObject* pkCurrentObject;
 
            for (int i = 0; i < GetNumberOfChildren(); ++i)
 
            {
 
                pkCurrentObject = GetChild(i);
 
                r = pkCurrentObject->GetRelRect();
 
                pkCurrentObject->SetRelXPos(GetWidth() - (r.GetWidth() + r.GetY1()));
 
                pkCurrentObject->SetRelYPos(r.GetX1());
 
                pkCurrentObject->SetWidth(r.GetHeight());
 
                pkCurrentObject->SetHeight(r.GetWidth());
 
            }
 
            InvalidateArea();
 
            InvalidateChildren();
 
        }
 
            break;
 
 
 
        case 180:
 
            Flip(false);
 
            Flip(true);
 
            break;
 
 
 
        case 270:
 
        {
 
            // rotate 270 degrees clockwise
 
            // width and height will be swapped
 
            // x and y of every object will be swapped
 
 
 
            CGUIRect r = GetRelRect();
 
            SetWidth(r.GetHeight());
 
            SetHeight(r.GetWidth());
 
            CGUIObject* pkCurrentObject;
 
            for (int i = 0; i < GetNumberOfChildren(); ++i)
 
            {
 
                pkCurrentObject = GetChild(i);
 
                r = pkCurrentObject->GetRelRect();
 
                pkCurrentObject->SetRelXPos(r.GetY1());
 
                pkCurrentObject->SetRelYPos(r.GetX1());
 
                pkCurrentObject->SetWidth(r.GetHeight());
 
                pkCurrentObject->SetHeight(r.GetWidth());
 
            }
 
            InvalidateArea();
 
            InvalidateChildren();
 
        }
 
            break;
 
    }
 
}
 
 
 
eC_Bool ExampleControl::DoDraw()
 
{
 
    CGUIRect kAbsRect(GetAbsRect());
 
    if (m_vBorderWidth != eC_FromInt(0))
 
    {
 
        GETGFX.SetForegroundColor(m_uiBorderColor);
 
        GETGFX.FilledRect(kAbsRect);
 
        kAbsRect.Expand(-m_vBorderWidth);
 
    }
 
    GETGFX.SetForegroundColor(m_uiInnerColor);
 
    GETGFX.FilledRect(kAbsRect);
 
    return true;
 
}
 
 
 
#if defined(GUILIANI_STREAM_GUI)
 
void ExampleControl::ReadFromStream()
 
{
 
    ReadStreamingHeader(EXAMPLE_CONTROL_CLASS_VERSION, EXAMPLE_CONTROL_CLASS_MIN_VERSION);
 
 
 
    CGUICompositeObject::ReadFromStream();
 
 
 
    m_uiInnerColor  = GETINPUTSTREAM.READ_HEX("InnerColor");
 
    m_uiBorderColor = GETINPUTSTREAM.READ_HEX("BorderColor");
 
    m_vBorderWidth  = eC_FromFloat(GETINPUTSTREAM.READ_FLOAT("BorderWidth"));
 
}
 
#endif
 
 
 
#if defined(GUILIANI_WRITE_GUI)
 
void ExampleControl::WriteToStream(const eC_Bool bWriteClassID)
 
{
 
    WriteStreamingHeader(bWriteClassID, XMLTAG_CONTROLCLASSID, CTL_EXAMPLE, EXAMPLE_CONTROL_CLASS_VERSION);
 
 
 
    CGUICompositeObject::WriteToStream();
 
 
 
    GETOUTPUTSTREAM.WriteHex(m_uiInnerColor, "InnerColor");
 
    GETOUTPUTSTREAM.WriteHex(m_uiBorderColor, "BorderColor");
 
    GETOUTPUTSTREAM.WriteFloat(eC_ToFloat(m_vBorderWidth), "BorderWidth");
 
 
 
    WriteStreamingFooter(bWriteClassID);
 
}
 
#endif
 
 
 
----------------
 
 
 
    CGfxWrapeGML* pkWrap = dynamic_cast<CGfxWrapeGML*>(&GETGFX);
 
    if (NULL != pkWrap)
 
    {
 
        eGML_Screen* pkScreen = pkWrap->GetScreen();
 
        unsigned short* memory = (unsigned short*)pkScreen->Lock();
 
 
 
        eC_UInt uiWidth = pkScreen->GetWidth();
 
        eC_UInt uiHeight = pkScreen->GetHeight();
 
 
 
        memset(memory, 0xf1, uiWidth * uiHeight);
 
        for (eC_UInt y = 0; y < uiHeight; ++y)
 
        {
 
            for (eC_UInt x = 0; x < uiWidth; ++x)
 
            {
 
                unsigned short val = memory[y * uiWidth + x];
 
                memory[y * uiWidth + x] = (val + (x * y)) & 0xffff;
 
            }
 
        }
 
 
 
        pkScreen->Unlock();
 
 
 
//        pkScreen->DrawLine(eGML_Vector2(0, 0), eGML_Vector2(10, 10), 0xff004400, 0, 1, 1);
 
    }
 
 
 
----------------
 
</nowiki>
 

Revision as of 05:51, 15 April 2021