spvessel / spacevil

Simple examples of SpaceVIL implementation for C# / .NET Framework, C# / .NET Core and Java.
https://spvessel.com
MIT License
55 stars 7 forks source link

C# documentation is out of date #5

Closed spektro37 closed 4 years ago

spektro37 commented 4 years ago

I have found that documentation located at https://spvessel.com/spacevil/docs/csharp/html/class_space_v_i_l_1_1_core_window.html seems to be out of date. At least it doesn't mention CoreWindow.ToggleFullScreen() anywhere.

spvessel commented 4 years ago

Yeah, the documentation is out of date. Sorry. We are working on it. I will notice you here when it is done. PS. I understand that this can be inconvenient, but if you have questions, I will be happy to answer you. I will try to update the documentation as soon as possible.

spvessel commented 4 years ago

I tried to show how to do a most things in examples that are provided by this repository, but of course that examples (demo apps, tutorials, simple examples) does not cover all frameworks features.

spektro37 commented 4 years ago

Thank you for your quick response and agreeing to answer questions I might have.

I have to admit that I didn't look through all the examples you have provided, so maybe answers to some of my questions are already there, but it requires significant amount time to analyse and digest these examples and flesh out examples of using separate elements and their properties. For example, I know exactly what I want to build and I am interested in how I can position a Label element in the main window or do certain things with other elements. Using SetX() and SetY() did not have the expected effect and then I had to go into some of the examples looking for any information about positioning elements.

I have read your article on Habr and I agree that having a fully working application as an example is good for understanding how the framework works in the real world. However, I feel that documentation also needs to have comprehensive description of the element, it's properties, public methods (not only list them, though I admit that their names are very descriptive) and a couple of examples of how it can be used with only necessary context. Having this would make the learning curve less steep.

I don't want to look to picky, sorry if this is the case. :) At the moment I can say that I like SpaceVIL and I simply want it to be easier to learn and use.

If I will have questions, should I ask them by creating a separate issue per question here?

spvessel commented 4 years ago

Yes, I agree that need a solid documentation for framework. And about your question of positioning elements... hmmm... Using SetX () and SetY () will definitely not give the expected effect because of SpaceVIL markup system and default Label style. Common markup system works with the following properties:

  1. SizePolicy (Fixed, Expand)
  2. ItemAlignment (Left, Right, Top, Bottom, HCenter, VCenter)
  3. Container Padding
  4. Item Margin
  5. Item Size (size, max size, min size) In that markup system, methods like SetX(), SetY() do not work (work only in FreeArea, IFloatingItem and any others that implement IFreeLayout or IHLayout, IVLayout). And if you even set a desired ItemAlignment properties you still see that the Label stays in the same place. It because of default Label style that has SizePolicy property is set to Expand.

Examples:

public class MyWindow : ActiveWindow
{
    // implement ActiveWindow class
    public override void InitWindow()
    {
        // window parameters
        SetParameters("MyWindow", "MyWindow", 300, 300);
        Label label = new Label("Hello World!");
        label.SetAlignment(ItemAlignment.Bottom, ItemAlignment.Right);
        AddItem(label);
    }
}

You get the result: image That happens because of Label SizePolicy property by default is set to Expand. To make sure we can change the background color of label:

public class MyWindow : ActiveWindow
{
    // implement ActiveWindow class
    public override void InitWindow()
    {
        // window parameters
        SetParameters("MyWindow", "MyWindow", 300, 300);
        Label label = new Label("Hello World!");
        label.SetAlignment(ItemAlignment.Bottom, ItemAlignment.Right);
        label.SetBackground(Color.Chocolate); // bg color
        AddItem(label);
    }
}

Result: image

But we can change SizePolicy property to Fixed:

public class MyWindow : ActiveWindow
{
    // implement ActiveWindow class
    public override void InitWindow()
    {
        // window parameters
        SetParameters("MyWindow", "MyWindow", 300, 300);
        Label label = new Label("Hello World!");
        label.SetAlignment(ItemAlignment.Bottom, ItemAlignment.Right);
        label.SetBackground(Color.Chocolate); // bg color

        // change SizePolicy
        label.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed);
        label.SetSize(label.GetTextWidth() + 30, 60);

        AddItem(label);
    }
}

Result: image

And the last thing (optionally). Label can change position of text via method SetTextAlignment():

public class MyWindow : ActiveWindow
{
    // implement ActiveWindow class
    public override void InitWindow()
    {
        // window parameters
        SetParameters("MyWindow", "MyWindow", 300, 300);
        Label label = new Label("Hello World!");
        label.SetAlignment(ItemAlignment.Bottom, ItemAlignment.Right);
        label.SetBackground(Color.Chocolate); // bg color

        // change SizePolicy
        label.SetSizePolicy(SizePolicy.Fixed, SizePolicy.Fixed);
        label.SetSize(label.GetTextWidth() + 30, 60);

        // change text alignment
        label.SetTextAlignment(ItemAlignment.Bottom, ItemAlignment.Right);

        AddItem(label);
    }
}

Result: image

So what are the conclusions?

  1. Common markup system is very useful.
  2. I really need to provide all the default styles of items via some sort of documentation...

Thanks for letting me know about my mistakes!

PS. "If I will have questions, should I ask them by creating a separate issue per question here?" If you think that it will be useful question that can help others peoples then you can create a new issue. If you need to report about bugs or common suggestions then you can write a email to feedback@spvessel.com

spektro37 commented 4 years ago

Thank you very much for the detailed answer! The picture is becoming more clear now. :)