forked from lapce/lapce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
379 additions
and
40 deletions.
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
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
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,107 @@ | ||
use std::sync::Arc; | ||
|
||
use druid::{ | ||
piet::{Text, TextAttribute, TextLayout as PietTextLayout, TextLayoutBuilder}, | ||
theme, | ||
widget::{CrossAxisAlignment, Flex, FlexParams, Label, Scroll, SvgData}, | ||
Affine, BoxConstraints, Color, Command, Cursor, Data, Env, Event, EventCtx, | ||
FontFamily, FontWeight, LayoutCtx, LifeCycle, LifeCycleCtx, MouseEvent, | ||
PaintCtx, Point, Rect, RenderContext, Size, Target, TextLayout, UpdateCtx, Vec2, | ||
Widget, WidgetExt, WidgetId, WidgetPod, WindowId, | ||
}; | ||
|
||
use crate::{ | ||
command::{LapceUICommand, LAPCE_UI_COMMAND}, | ||
data::{FocusArea, LapceTabData, PanelKind}, | ||
}; | ||
|
||
pub struct ProblemData { | ||
pub widget_id: WidgetId, | ||
} | ||
|
||
impl ProblemData { | ||
pub fn new() -> Self { | ||
Self { | ||
widget_id: WidgetId::next(), | ||
} | ||
} | ||
} | ||
|
||
pub struct Problem { | ||
pub widget_id: WidgetId, | ||
} | ||
|
||
impl Problem { | ||
pub fn new(data: &LapceTabData) -> Self { | ||
Self { | ||
widget_id: data.problem.widget_id, | ||
} | ||
} | ||
|
||
pub fn request_focus(&self, ctx: &mut EventCtx, data: &mut LapceTabData) { | ||
ctx.request_focus(); | ||
data.focus = self.widget_id; | ||
data.focus_area = FocusArea::Panel(PanelKind::Problem); | ||
} | ||
} | ||
|
||
impl Widget<LapceTabData> for Problem { | ||
fn id(&self) -> Option<WidgetId> { | ||
Some(self.widget_id) | ||
} | ||
|
||
fn event( | ||
&mut self, | ||
ctx: &mut EventCtx, | ||
event: &Event, | ||
data: &mut LapceTabData, | ||
env: &Env, | ||
) { | ||
match event { | ||
Event::MouseDown(mouse_event) => { | ||
self.request_focus(ctx, data); | ||
} | ||
Event::Command(cmd) if cmd.is(LAPCE_UI_COMMAND) => { | ||
let command = cmd.get_unchecked(LAPCE_UI_COMMAND); | ||
match command { | ||
LapceUICommand::Focus => { | ||
self.request_focus(ctx, data); | ||
ctx.set_handled(); | ||
} | ||
_ => (), | ||
} | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
fn lifecycle( | ||
&mut self, | ||
ctx: &mut LifeCycleCtx, | ||
event: &LifeCycle, | ||
data: &LapceTabData, | ||
env: &Env, | ||
) { | ||
} | ||
|
||
fn update( | ||
&mut self, | ||
ctx: &mut UpdateCtx, | ||
old_data: &LapceTabData, | ||
data: &LapceTabData, | ||
env: &Env, | ||
) { | ||
} | ||
|
||
fn layout( | ||
&mut self, | ||
ctx: &mut LayoutCtx, | ||
bc: &BoxConstraints, | ||
data: &LapceTabData, | ||
env: &Env, | ||
) -> Size { | ||
bc.max() | ||
} | ||
|
||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {} | ||
} |
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
Oops, something went wrong.