summaryrefslogtreecommitdiff
path: root/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m
blob: f709fc420be823a89083d60549d8e35810087241 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// -*- Mode: Objective-C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
//
// This file is part of the LibreOffice project.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#import "MLOTestingTile.h"
#import "MLOTestingTileParametersViewController.h"
#import "MLOTestingTileRendererViewController.h"
#import "MLOAppRoleTileTester.h"
#include <touch/touch.h>

@interface MLOTestingTile ()
@property MLOAppRoleTileTester * tester;
@end

@implementation MLOTestingTile


-(id)initWithTester:(MLOAppRoleTileTester *)tester{
    
    self = [self initWithFrame:[MLOTestingTile resized:tester]];
    if(self){
        self.tester =tester;
        self.backgroundColor =[UIColor greenColor];
    }
    return self;

}

+(CGRect)resized:(MLOAppRoleTileTester *)tester{
    return CGRectMake(  (tester.renderer.view.frame.size.width -tester.params.contextWidth)/2.0f,
                        (tester.renderer.view.frame.size.height -tester.params.contextHeight)/2.0f,
                        tester.params.contextWidth,
                        tester.params.contextHeight);
}

-(void)resize{
    self.frame = [MLOTestingTile resized:self.tester];
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSaveGState(context);
    CGContextTranslateCTM(context, 0, self.tester.params.contextHeight);
    CGContextScaleCTM(context, 1, -1);
    CGContextScaleCTM(context, 1, 1);

    touch_lo_draw_tile(context,
                       self.tester.params.contextWidth,
                       self.tester.params.contextHeight,
                       self.tester.params.tilePosX,
                       self.tester.params.tilePosY,
                       self.tester.params.tileWidth,
                       self.tester.params.tileHeight);

    CGContextRestoreGState(context);

    MLOContentSize size = touch_lo_get_content_size();
    NSLog(@"MLOContentSize: width=%lld, height=%lld",size.width, size.height);
}

@end