-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
view: add ResizeArea class #15752
Merged
Merged
view: add ResizeArea class #15752
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2018 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "atom/browser/api/views/atom_api_resize_area.h" | ||
|
||
#include "atom/common/api/constructor.h" | ||
#include "native_mate/dictionary.h" | ||
|
||
#include "atom/common/node_includes.h" | ||
|
||
namespace atom { | ||
|
||
namespace api { | ||
|
||
ResizeArea::ResizeArea() : View(new views::ResizeArea(this)) { | ||
view()->set_owned_by_client(); | ||
} | ||
|
||
ResizeArea::~ResizeArea() {} | ||
|
||
void ResizeArea::OnResize(int resize_amount, bool done_resizing) { | ||
Emit("resize", resize_amount, done_resizing); | ||
} | ||
|
||
// static | ||
mate::WrappableBase* ResizeArea::New(mate::Arguments* args) { | ||
// Constructor call. | ||
auto* view = new ResizeArea(); | ||
view->InitWith(args->isolate(), args->GetThis()); | ||
return view; | ||
} | ||
|
||
// static | ||
void ResizeArea::BuildPrototype(v8::Isolate* isolate, | ||
v8::Local<v8::FunctionTemplate> prototype) { | ||
prototype->SetClassName(mate::StringToV8(isolate, "ResizeArea")); | ||
} | ||
|
||
} // namespace api | ||
|
||
} // namespace atom | ||
|
||
namespace { | ||
|
||
using atom::api::ResizeArea; | ||
|
||
void Initialize(v8::Local<v8::Object> exports, | ||
v8::Local<v8::Value> unused, | ||
v8::Local<v8::Context> context, | ||
void* priv) { | ||
v8::Isolate* isolate = context->GetIsolate(); | ||
mate::Dictionary dict(isolate, exports); | ||
dict.Set("ResizeArea", mate::CreateConstructor<ResizeArea>( | ||
isolate, base::Bind(&ResizeArea::New))); | ||
} | ||
|
||
} // namespace | ||
|
||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2018 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ATOM_BROWSER_API_VIEWS_ATOM_API_RESIZE_AREA_H_ | ||
#define ATOM_BROWSER_API_VIEWS_ATOM_API_RESIZE_AREA_H_ | ||
|
||
#include "atom/browser/api/atom_api_view.h" | ||
#include "native_mate/handle.h" | ||
#include "ui/views/controls/resize_area.h" | ||
#include "ui/views/controls/resize_area_delegate.h" | ||
|
||
namespace atom { | ||
|
||
namespace api { | ||
|
||
class ResizeArea : public View, protected views::ResizeAreaDelegate { | ||
public: | ||
static mate::WrappableBase* New(mate::Arguments* args); | ||
|
||
static void BuildPrototype(v8::Isolate* isolate, | ||
v8::Local<v8::FunctionTemplate> prototype); | ||
|
||
protected: | ||
void OnResize(int resize_amount, bool done_resizing) override; | ||
|
||
private: | ||
ResizeArea(); | ||
~ResizeArea() override; | ||
|
||
views::ResizeArea* resize_area() const { | ||
return static_cast<views::ResizeArea*>(view()); | ||
} | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(ResizeArea); | ||
}; | ||
|
||
} // namespace api | ||
|
||
} // namespace atom | ||
|
||
#endif // ATOM_BROWSER_API_VIEWS_ATOM_API_RESIZE_AREA_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict' | ||
|
||
const electron = require('electron') | ||
|
||
const { View } = electron | ||
const { ResizeArea } = process.atomBinding('resize_area') | ||
|
||
Object.setPrototypeOf(ResizeArea.prototype, View.prototype) | ||
|
||
ResizeArea.prototype._init = function () { | ||
// Call parent class's _init. | ||
View.prototype._init.call(this) | ||
} | ||
|
||
module.exports = ResizeArea |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused how
ResizeArea
can be cast tomate::WrappableBase
given that it doesn't inherit frommate::Wrappable
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class inherits from
api::View
, which inherits frommate::Wrappable
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, d'oh, I thought
View
wasviews::View
. Confusing.