-
Notifications
You must be signed in to change notification settings - Fork 0
DrawAssembly Class
DrawAssembly is used to generate and define positions for the frame of widgets and graphs. From there, it calls the appropriate functions and classes, so they can follow this pattern of positions.
_coordinateNum (int)
CoordinateNum is by default set to 2, since we need two values to define where an object is - X and Y.
_frameWidth (int)
FrameWidth is set in the setup(), and describes how many positions you'd want from left to right.
_frameHeight (int)
FrameHeight is set in the setup(), and describes how many positions you'd want from Top to Bottom.
[,,] _frameCoordinates (int)
These previous four parameters is the foundation of the framework or grid. _coordinateNum, _frameWidth and _frameHeight is used to create the array of positions stored in _frameCoordinates.
GraphPosition (enum)
A more descriptive setting for where the graph is put.
These properties is set by SetGraphPosition().
RowStart (int)
If the graph needs to be in top, RowStart is 1 to jump one row down.
RowJump (int)
If the graph is in the middle, RowJump skips one row after taking the first one.
RowStop (int)
If the graph is in the bottom, the row of widgets should stop at 2nd row.
PutGraph (int)
PutGraph tells the subclasses what the graph position is.
CountWidgets (int)
Defines the widget number that needs to be drawn.
The swipe function, enables the possibility of jumping to another page of widgets, but basically the widgets are already placed, the surface is just pushed infront of the drawing area view.
SwipeLength (float)
Contains the perspective position, therefore by default 0.
SwipeMargin (float)
Contains the distance of the widgets being placed.
SwipeAmount (float)
Defines how many times you need to be able to swipe to a new page.
GlobalRadius (int)
Defines the radius of a widget.
ContentHeight (float)
Is defined from allocation.width in the Main Window, and is the width of the drawing area.
ContentWidth (float)
Is defined from allocation.height in the Main Window, and is the height of the drawing area.
These properties is only created so that it is easier for other classes to get the direct measurement of the grid, widthout calculating or knowing the exact grid size.
FrameAreaMarginLEFT (int)
Gives the margin from top side to frame.
FrameAreaMarginTOP (int)
Gives the margin from left side to frame.
FrameAreaHeight (int)
Gives a proportional measure of how much area each frame has.
FrameAreaWidth (int)
Gives a proportional measure of how much area each frame has.
WidgetMarginTOP (int)
Gives the margin from top side to frame, minus the radius of widgets.
WidgetMarginLEFT (int)
Gives the margin from left side to frame, minus the radius of widgets.
MainDrawingArea (Gdk.Window)
Includes the drawing area in the DrawAssembly to reference each surface to this one.
The setup works like the DrawAssembly's constructor, and sets these default values.
SwipeLength = 0;
SwipeAmount = SwipeAmountSend;
_frameWidth = frameSize;
_frameHeight = frameHeigh;
GlobalRadius = 50;
GraphPosition = (int)SECTIONS.BOT;
_frameCoordinates = new int[_frameHeight,_frameWidth,_coordinatesNum];
UpdateDrawingContext is the function that updates all the properties in the DrawAssembly, so that the frame will dynamically to what windows size you choose to have. These properties are set:
MainDrawingArea = context2;
ContentHeight = height;
ContentWidth = width;
FrameAreaWidth = (int)ContentWidth;
FrameAreaHeight = (int)ContentHeight / _frameHeight;
FrameAreaMarginLEFT = ((int)ContentWidth / _frameWidth/2);
FrameAreaMarginTOP = ((int)ContentHeight / _frameWidth /2);
WidgetMarginTOP = (int)FrameAreaMarginTOP - (int)GlobalRadius;
WidgetMarginLEFT = (int)FrameAreaMarginLEFT - (int)GlobalRadius;
DrawFramework is the overall function that initiates these functions:
SetCoordinates()
Setting coordinates.
DrawElements()
Drawing the elements based on these coordinates.
Set coordinates has 3 for loops which generates the positions.
- One that divides
_frameCoordinates
in two, since X and Y will be set at the same time. - One that, depending on _frameHeight, runs once for each section downwards.
- One that, depending on _frameWidth, runs once for each section to the right.
DrawElements starts by setting the graph position to either 0 = Bottom, 1 = Middle or 2 = Top, and afterwards resets the count widget.
Then it looks at the times it needs to swipe, and initiates...
DrawWidgets()
DrawGraphArea()
...for each swipe.
DrawWidgets consists of a double for loop, which sets each drawn widget to the correct coordinate in _frameCoordinates.
- The first for loop looks at the positions from left to right.
- The next looks at the positions from top to bottom.
Inside the for loop setup, it draws a surface called "SurfaceWidget" on the Gdk.Window drawing area we imported earlier MainDrawingArea
.
Then it calls the WidgetContainer.widgetArray for a specific widget and CountWidgets
starts at 0 and then just takes the next in line for each loop. Each widget also receives a set of coordinates, set from the two for loops.
DrawGraphArea is the function that creates the graph, and passes on the correct coordinates, depending on the Putgraph
property. All graphs are linked to the middle _frameWidth.
There is no loop system here, since all widgets need to go to the same graph.
This function is limited to having 3 rows of widgets, but works as a temporary solution to including the graph in the widget setup. Depending on where the graph needs to be, the properties below is changed to the correct value.
RowStart (int)
If the graph needs to be in top, RowStart is 1 to jump one row down.
RowJump (int)
If the graph is in the middle, RowJump skips one row after taking the first one.
RowStop (int)
If the graph is in the bottom, the row of widgets should stop at 2nd row.
PutGraph (int)
PutGraph tells the subclasses what the graph position is.
This function draws the background. It creates a separate surface linked to the Gdk.Window MainDrawingArea, and then sets the color of the background to r
,g
and b
, which then can be changed from the PreferencesWidget
class. Basically the background is just a rectangle drawn in the background, and changed to the same dimensions as the window size.