Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: tools/iOSShell.cpp

Issue 373383003: ios fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: give shell its own gyp file Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« tools/Resources.h ('K') | « tools/iOSShell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "iOSShell.h"
9
10 #include "Resources.h"
11 #include "SkCanvas.h"
12 #include "SkCommandLineFlags.h"
13 #include "SkGraphics.h"
14 #include "SkWindow.h"
15 #include "sk_tool_utils.h"
16
17 //////////////////////////////////////////////////////////////////////////////
18
19 static SkView* curr_view(SkWindow* wind) {
20 SkView::F2BIter iter(wind);
21 return iter.next();
22 }
23
24 ShellWindow::ShellWindow(void* hwnd, int argc, char** argv)
25 : INHERITED(hwnd) {
26 SkCommandLineFlags::Parse(argc, argv);
27 }
28
29 ShellWindow::~ShellWindow() {
30 }
31
32 ///////////////////////////////////////////////////////////////////////////////
33
34 bool ShellWindow::onDispatchClick(int x, int y, Click::State state,
35 void* owner, unsigned modi) {
36 int w = SkScalarRoundToInt(this->width());
37 int h = SkScalarRoundToInt(this->height());
38
39 // check for the resize-box
40 if (w - x < 16 && h - y < 16) {
41 return false; // let the OS handle the click
42 } else {
43 return this->INHERITED::onDispatchClick(x, y, state, owner, modi);
44 }
45 }
46
47 void ShellWindow::onSizeChange() {
48 this->INHERITED::onSizeChange();
49
50 SkView::F2BIter iter(this);
51 SkView* view = iter.next();
52 view->setSize(this->width(), this->height());
53 }
54
55 void tool_main(int argc, char *argv[]);
56
57 bool save_args(int argc, char *argv[], const char* resourceDir) {
58 for (int index = 0; index < argc; ++index) {
59 SkDebugf("%s\n", argv[index]);
60 if (!strcmp("--test", argv[index])) {
61 SetResourcePath(resourceDir);
62 tool_main(argc - 1, argv);
63 return true;
64 }
65 }
66 return false;
67 }
68
69 // FIXME: this should be in a header
70 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);
71 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
72 return new ShellWindow(hwnd, argc, argv);
73 }
74
75 // FIXME: this should be in a header
76 void get_preferred_size(int* x, int* y, int* width, int* height);
77 void get_preferred_size(int* x, int* y, int* width, int* height) {
78 *x = 10;
79 *y = 50;
80 *width = 640;
81 *height = 480;
82 }
83
84 // FIXME: this should be in a header
85 void application_init();
86 void application_init() {
87 SkGraphics::Init();
88 SkEvent::Init();
89 }
90
91 // FIXME: this should be in a header
92 void application_term();
93 void application_term() {
94 SkEvent::Term();
95 SkGraphics::Term();
96 }
OLDNEW
« tools/Resources.h ('K') | « tools/iOSShell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698