summaryrefslogtreecommitdiff
path: root/ios/shared/ios_sharedlo/objective_c/view_controllers/role/MLOAppRoleLoApp.m
blob: fc3fb4ce004af5d4d48aee6f9dd871b40f161c28 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// -*- Mode: ObjC; 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 "MLOAppRoleLoApp.h"
#import "MLOMainViewController_Private.h"
#import "MLORenderManager.h"
#import "MLOGestureEngine.h"
#import "MLOToolbarViewController.h"
#import "MLOSelectionViewController.h"
#import "MLOScrollerViewController.h"
#import "MLOTopbarViewController.h"
#import "MLOKeyboardManager.h"

static const NSTimeInterval ROTATE_FLASH_DURATION=0.5f;

@implementation MLOAppRoleLoApp

-(NSString *)description{
    return @"MLOAppRoleLoApp";
}

-(void)initSubviews{
    MLOMainViewController * main = [self mainViewController];
    main.scroller = [[MLOScrollerViewController alloc] initWithMainViewController:main];
    main.selection = [[MLOSelectionViewController alloc] initWithMainViewController: main];
    main.toolbar = [[MLOToolbarViewController alloc] initWithMainViewController:main];
    main.keyboard = [[MLOKeyboardManager alloc]initWithMainViewController:main];
    main.flasher =[[UIView alloc] initWithFrame:CGRECT_ZERO];
    main.flasher.alpha = 0.0f;
    main.flasher.backgroundColor = [UIColor whiteColor];
    main.gestureEngine = nil;
}

-(void)setWidth:(CGFloat) width height:(CGFloat) height{

    [[self mainViewController].renderManager setWidth:width  height:height];
}

-(void)addSubviews{

    MLOMainViewController * main = [self mainViewController];
    main.renderManager = [MLORenderManager getInstance];

    [main resize];

    [main.canvas addSubview: main.renderManager.view];

    main.gestureEngine = [[MLOGestureEngine alloc] initWithMainViewController:main];
    [main.toolbar addToMainViewController];
    [main.scroller addToMainViewController];
    [main.selection addToMainViewController];
    [main.keyboard addToMainViewController];
}

-(void)rotate{

    MLOMainViewController * main = self.mainViewController;
    
    NSLog(@"MLO rotate");

    main.renderManager.view.alpha= 0.0f;

    [main resize];

    [main.gestureEngine onRotate];

    [main.topbar onRotate];

    [main.scroller reset];

    [main.scroller showLibreOffice];

    [main.selection onRotate];

    [main.toolbar onRotate];

    [UIView animateWithDuration:ROTATE_FLASH_DURATION animations:^(void){
        main.renderManager.view.alpha=1.0f;
    }];
}


-(void)showLibreOffice{

    [self.mainViewController.toolbar showLibreOffice];
    [self.mainViewController.keyboard showLibreOffice];
}

-(void)hideLibreOffice{
    MLOMainViewController * main = self.mainViewController;
    
    [main.toolbar hideLibreOffice];
    [main resetSubviews];
    [main.gestureEngine hideLibreOffice];
    [main.scroller hideLibreOffice];
    [main.selection reset];
    [main.keyboard hideLibreOffice];
}

-(void)initWindow:(UIWindow *) window{
    MLOMainViewController * main = self.mainViewController;
    [main.renderManager setWidth:main.view.frame.size.width height:main.view.frame.size.height];

    [main.gestureEngine showLibreOffice:window];
}

@end